channelName
.
- *
- * @param channelName
- * - name of the required channel.
- * @return {@link Channel} with name channelName
or null
- * @throws ChannelFinderException - channelfinder exception
- */
- public Channel getChannel(String channelName) throws ChannelFinderException;
-
- /**
- * Destructively set a single channel channel
, if the channel
- * already exists it will be replaced with the given channel.
- *
- * @param channel
- * the channel to be added
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Channel.Builder channel) throws ChannelFinderException;
-
-
- /**
- * Destructively set a Tag tag
with no associated channels to the
- * database.
- *
- * @param tag
- * - the tag to be set.
- */
- public void set(Tag.Builder tag);
-
- /**
- * Destructively set tag tag
to channel channelName
and
- * remove the tag from all other channels.
- *
- * @param tag
- * - the tag to be set.
- * @param channelName
- * - the channel to which the tag should be set on.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Tag.Builder tag, String channelName)
- throws ChannelFinderException;
-
- /**
- * Set tag tag
on the set of channels {channels} and remove it from
- * all others.
- *
- * @param tag
- * - the tag to be set.
- * @param channelNames
- * - the list of channels to which this tag will be added and
- * removed from all others.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Tag.Builder tag, Collectionproperty
.
- *
- * @param prop
- * - the property to be set.
- */
- public void set(Property.Builder prop) throws ChannelFinderException;
-
- /**
- * Destructively set property prop
and add it to the channel
- * channelName
and remove it from all others.
- *
- * @param prop
- * - property to be set.
- * @param channelName
- * - the channel to which this property must be added.
- */
- public void set(Property.Builder prop, String channelName);
-
- /**
- * Destructively set property prop
and add it to the channels
- * channelNames
removing it from all other channels. By default all
- * channels will contain the property with the same value specified in the
- * prop
.prop
and add it to the channels
- * specified in the channelPropertyMap
, where the map key is the
- * channel name and the associated value is the property value to be used
- * for that channel.
- *
- * @param prop
- * - the property to be set.
- * @param channelPropertyMap
- * - map with channel names and property values
- */
- public void set(Property.Builder prop,
- Mapchannel
.
- *
- * @param channel - channel builder
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Channel.Builder channel) throws ChannelFinderException;
-
- /**
- * Update Tag tag
by adding it to Channel with name
- * channelName
, without affecting the other instances of this tag.
- *
- * @param tag
- * the tag to be added
- * @param channelName
- * Name of the channel to which the tag is to be added
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Tag.Builder tag, String channelName)
- throws ChannelFinderException;
-
- /**
- *
- * Update the Tag tag
by adding it to the set of the channels with
- * names channelNames
, without affecting the other instances of
- * this tag.
- *
- * @param tag
- * - the tag that needs to be updated.
- * @param channelNames
- * - list of channels to which this tag should be added.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Tag.Builder tag, Collectionproperty
by adding it to the channel
- * channelName
, without affecting the other channels.
- *
- * @param property
- * - the property to be updated
- * @param channelName
- * - the channel to which this property should be added or
- * updated.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Property.Builder property, String channelName)
- throws ChannelFinderException;
-
- /**
- * Update the channels identified with channelNames
with the
- * property property
- *
- * @param property - property builder
- * @param channelNames - list of channel names
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Property.Builder property,
- Collectionproperty
on all channels specified in the
- * channelPropValueMap, where the key in the map is the channel name and the
- * value is the value for that property
- *
- * @param property - property builder
- * @param channelPropValueMap - property value map
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Property.Builder property,
- Mappattern
.pattern
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionpattern
.pattern
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionpattern
.propertyName
who's value matches the pattern
- * pattern
.
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionquery
example:
- * find("SR* Cell=1,2 Tags=GolderOrbit,myTag)channel
- *
- * @param channelName
- * channel to be removed
- * @throws ChannelFinderException - channelfinder exception
- */
- public void deleteChannel(String channelName) throws ChannelFinderException;
-
- /**
- * Delete the set of channels identified by channels
- *
- * @param channels - list of channel builders
- * @throws ChannelFinderException - channelfinder exception
- */
- @Deprecated
- public void delete(Collectiontag
from the channel with the name
- * channelName
- *
- * @param tag
- * - the tag to be deleted.
- * @param channelName
- * - the channel from which to delete the tag tag
- * @throws ChannelFinderException - channelfinder exception
- */
- public void delete(Tag.Builder tag, String channelName)
- throws ChannelFinderException;
-
- /**
- * Remove the tag tag
from all the channels channelNames
- *
- * @param tag
- * - the tag to be deleted.
- * @param channelNames
- * - the channels from which to delete the tag tag
- * @throws ChannelFinderException - channelfinder exception
- */
- public void delete(Tag.Builder tag, Collectionproperty
from the channel with name
- * channelName
- *
- * @param property
- * - the property to be deleted.
- * @param channelName
- * - the channel from which to delete the property
- * property
- * @throws ChannelFinderException - channelfinder exception
- */
- public void delete(Property.Builder property, String channelName)
- throws ChannelFinderException;
-
- /**
- * Remove the property property
from the set of channels
- * channelNames
- *
- * @param property
- * - the property to be deleted.
- * @param channelNames
- * - the channels from which to delete the property
- * property
- * @throws ChannelFinderException - channelfinder exception
- */
- public void delete(Property.Builder property,
- Collection
+ * Query for channels based on the Query string query
example:
+ * find("SR* Cell=1,2 Tags=GolderOrbit,myTag)
+ *
+ * this will return all channels with names starting with SR AND have
+ * property Cell=1 OR 2 AND have tags goldenOrbit AND myTag.
+ *
+ * IMP: each criteria is logically AND'ed while multiple values for
+ * Properties are OR'ed.
+ * this will return all channels with name=any name AND tag=tag1 AND
+ * property Cell = 1 OR 2 OR 3.
+ *
+ * @param map - search map
+ * @return Collection of channels which satisfy the search map.
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ Collection
* this will return all channels with names starting with SR AND have
* property Cell=1 OR 2 AND have tags goldenOrbit AND myTag.
- * this will return all channels with name=any name AND tag=tag1 AND
- * property Cell = 1 OR 2 OR 3.
- *
- * @param map - multivalued map of all search criteria
- * @return Collection of channels which satisfy the search map.
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collection
+ *
+ * @param query - channelfinder query
+ * @return Collection of channels which satisfy the search criteria.
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ Collection
+ * Map.put("~tag", "tag1")
+ * Map.put("Cell", "1,2,3")
+ * tag
from the channel with the name
+ * channelName
+ *
+ * @param tag - the tag to be deleted.
+ * @param channelName - the channel from which to delete the tag tag
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void delete(Tag.Builder tag, String channelName)
+ throws ChannelFinderException;
+
+ /**
+ * Remove the tag tag
from all the channels channelNames
+ *
+ * @param tag - the tag to be deleted.
+ * @param channelNames - the channels from which to delete the tag tag
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void delete(Tag.Builder tag, Collectionproperty
from the channel with name
+ * channelName
+ *
+ * @param property - the property to be deleted.
+ * @param channelName - the channel from which to delete the property
+ * property
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void delete(Property.Builder property, String channelName)
+ throws ChannelFinderException;
+
+ /**
+ * Remove the property property
from the set of channels
+ * channelNames
+ *
+ * @param property - the property to be deleted.
+ * @param channelNames - the channels from which to delete the property
+ * property
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void delete(Property.Builder property,
+ Collectiontag
by adding it to the set of the channels with
+ * names channelNames
, without affecting the other instances of
+ * this tag.
+ *
+ * @param tag
+ * - the tag that needs to be updated.
+ * @param channelNames
+ * - list of channels to which this tag should be added.
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void update(Tag.Builder tag, CollectionchannelNames
with the
+ * property property
+ *
+ * @param property - property builder
+ * @param channelNames - list of channel names
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ void update(Property.Builder property,
+ Collectionuri
.
- *
- * @param uri - service uri
- * @return {@link CFCBuilder}
- */
- public static CFCBuilder serviceURL(String uri)
- {
- return new CFCBuilder(URI.create(uri));
- }
-
- /**
- * Creates a {@link CFCBuilder} for a CF client to {@link URI}
- * uri
.
- *
- * @param uri - service uri
- * @return {@link CFCBuilder}
- */
- public static CFCBuilder serviceURL(URI uri) {
- return new CFCBuilder(uri);
- }
-
- /**
- * Enable of Disable the HTTP authentication on the client connection.
*
- * @param withHTTPAuthentication -
* @return {@link CFCBuilder}
*/
- public CFCBuilder withHTTPAuthentication(boolean withHTTPAuthentication) {
- this.withHTTPAuthentication = withHTTPAuthentication;
- return this;
- }
-
- /**
- * Set the username to be used for HTTP Authentication.
- *
- * @param username - username
- * @return {@link CFCBuilder}
- */
- public CFCBuilder username(String username) {
- this.username = username;
- return this;
- }
-
- /**
- * Set the password to be used for the HTTP Authentication.
- *
- * @param password - password
- * @return {@link CFCBuilder}
- */
- public CFCBuilder password(String password) {
- this.password = password;
- return this;
- }
-
- /**
- * set the {@link ClientConfig} to be used while creating the
- * channelfinder client connection.
- *
- * @param clientConfig - client config
- * @return {@link CFCBuilder}
- */
- public CFCBuilder withClientConfig(ClientConfig clientConfig) {
- this.clientConfig = clientConfig;
- return this;
+ public static CFCBuilder serviceURL() {
+ return new CFCBuilder();
}
@SuppressWarnings("unused")
@@ -199,118 +96,75 @@ private CFCBuilder withSSLContext(SSLContext sslContext) {
return this;
}
- /**
- * Set the trustManager that should be used for authentication.
- *
- * @param trustManager - trust manager
- * @return {@link CFCBuilder}
- */
- public CFCBuilder withTrustManager(TrustManager[] trustManager) {
- this.trustManager = trustManager;
- return this;
- }
-
- /**
- * Provide your own executor on which the queries are to be made.
- * By default a single threaded executor is used.
- *
- * @param executor - executor
- * @return {@link CFCBuilder}
- */
- public CFCBuilder withExecutor(ExecutorService executor) {
- this.executor = executor;
- return this;
- }
-
/**
* Will actually create a {@link ChannelFinderClientImpl} object using
* the configuration informoation in this builder.
- *
+ *
* @return {@link ChannelFinderClientImpl}
*/
public ChannelFinderClient create() throws ChannelFinderException {
- if(this.uri == null || this.uri.toString().isEmpty()){
+ if (this.uri == null || this.uri.toString().isEmpty()) {
log.warning("Cannot create a channel finder client as URL is null or empty");
return null;
}
log.info("Creating a channelfinder client to : " + this.uri);
- if (this.protocol.equalsIgnoreCase("http")) { //$NON-NLS-1$
- this.clientConfig = new DefaultClientConfig();
- } else if (this.protocol.equalsIgnoreCase("https")) { //$NON-NLS-1$
- if (this.clientConfig == null) {
- SSLContext sslContext = null;
- try {
- sslContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$
- sslContext.init(null, this.trustManager, null);
- } catch (NoSuchAlgorithmException e) {
- throw new ChannelFinderException(e.getMessage());
- } catch (KeyManagementException e) {
- throw new ChannelFinderException(e.getMessage());
- }
- this.clientConfig = new DefaultClientConfig();
- this.clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties(new HostnameVerifier() {
-
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- }, sslContext));
- }
- }
- if (this.withHTTPAuthentication) {
- this.httpBasicAuthFilter = new HTTPBasicAuthFilter(
- properties.getPreferenceValue("username"),
- properties.getPreferenceValue("password"));
- }
- return new ChannelFinderClientImpl(this.uri, this.clientConfig, this.httpBasicAuthFilter, this.executor);
+ return new ChannelFinderClientImpl(this.uri, this.executor);
}
}
- ChannelFinderClientImpl(URI uri, ClientConfig config, HTTPBasicAuthFilter httpBasicAuthFilter,
- ExecutorService executor) {
- Client client = Client.create(config);
- client.setFollowRedirects(true);
- cfResource = client.resource(uri.toString());
- cfAuthenticatedResource = client.resource(uri.toString());
- if (httpBasicAuthFilter != null) {
- cfAuthenticatedResource.addFilter(httpBasicAuthFilter);
- }
- // TODO add a preference to add logging
- if(Boolean.parseBoolean(properties.getPreferenceValue("rawFiltering"))) {
- client.addFilter(new RawLoggingFilter(Logger.getLogger(RawLoggingFilter.class.getName())));
- }
- this.executor = executor;
- }
+ ChannelFinderClientImpl(URI uri, ExecutorService executor) {
- /**
- * Get a list of names of all the properties currently present on the
- * channelfinder service.
- *
- * @return list of names of all existing {@link Property}s.
- */
- public Collection>() {
- });
- } catch (JsonParseException e) {
- log.log(Level.WARNING, "Failed to retrieve channelfinder properties", e);
- }
- for (XmlProperty xmlproperty : xmlproperties) {
- allProperties.add(xmlproperty.getName());
- }
- return allProperties;
+ basicAuthenticationHeader = "Basic " + Base64.getEncoder().encodeToString((org.phoebus.channelfinder.Preferences.username + ":" +
+ org.phoebus.channelfinder.Preferences.password).getBytes());
+
+ if (uri.getScheme().equalsIgnoreCase("http")) { //$NON-NLS-1$
+ httpClient = HttpClient.newBuilder().build();
+ } else if (uri.getScheme().equalsIgnoreCase("https")) {
+ try {
+ TrustManager PROMISCUOUS_TRUST_MANAGER = new X509ExtendedTrustManager() {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return new java.security.cert.X509Certificate[0];
+ }
+
+ @Override
+ public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType) {
+ }
+ };
+
+ SSLContext sslContext = SSLContext.getInstance("SSL"); // OR TLS
+ sslContext.init(null, new TrustManager[]{PROMISCUOUS_TRUST_MANAGER}, new SecureRandom());
+ httpClient = HttpClient.newBuilder().sslContext(sslContext).build();
+ } catch (Exception e) {
+ log.log(Level.WARNING,
+ "Failed to properly create the elastic rest client to: " + org.phoebus.channelfinder.Preferences.serviceURL
+ , e);
+ return;
}
- });
+ }
+
+ this.executor = executor;
}
/**
@@ -319,21 +173,37 @@ public Collection
>() {
private final ObjectMapper mapper = new ObjectMapper();
+
@Override
- public List
>() {
+ HttpRequest httpRequest = HttpRequest.newBuilder()
+ .uri(URI.create(org.phoebus.channelfinder.Preferences.serviceURL + "/" + resourceProperties))
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .GET()
+ .build();
+
+ HttpResponse
>() { });
- } catch ( JsonParseException | JsonMappingException e) {
- log.log(Level.WARNING, "Failed to parse the list of tags", e);
- } catch ( IOException e) {
- log.log(Level.WARNING, "Failed to parse the list of tags", e);
- } catch (UniformInterfaceException e) {
- throw new ChannelFinderException(e);
- } catch (ClientHandlerException e) {
- throw new ChannelFinderException(e);
- }
- for (XmlTag xmltag : xmltags) {
- allTags.add(xmltag.getName());
- }
- return allTags;
- }
- });
- }
-
- private final ObjectMapper mapper = new ObjectMapper();
- /**
- * Get a list of names of all the tags currently present on the
- * channelfinder service.
- *
- * @return a list of names of all the existing {@link Tag}s.
- */
- public Collection
>() {
-
- @Override
- public List
>() { });
- } catch ( JsonParseException | JsonMappingException e) {
- log.log(Level.WARNING, "Failed to parse the list of tags", e);
- } catch ( IOException e) {
- log.log(Level.WARNING, "Failed to parse the list of tags", e);
- } catch (UniformInterfaceException e) {
- throw new ChannelFinderException(e);
- } catch (ClientHandlerException e) {
- throw new ChannelFinderException(e);
- }
- for (XmlTag xmltag : xmltags) {
- allTags.add(xmltag.getName());
- }
- return xmltags.stream().map(xmlTag -> new Tag(xmlTag)).collect(Collectors.toList());
-
- }
- });
- }
-
- @Deprecated
- public static void resetPreferences() {
- try {
- Preferences.userNodeForPackage(ChannelFinderClientImpl.class).clear();
- } catch (BackingStoreException e) {
- log.log(Level.WARNING, "Failed to retrieve channelfinder preferences", e);
- }
- }
-
- /**
- * Returns a channel that exactly matches the channelName
- *
channelName
.
- *
- * @param channelName - name of the required channel.
- * @return {@link Channel} with name channelName
or null
- * @throws ChannelFinderException - channelfinder exception
- */
- public Channel getChannel(String channelName) throws ChannelFinderException {
- try {
- return wrappedSubmit(new FindByChannelName(channelName));
- } catch (ChannelFinderException e) {
- if (e.getStatus().equals(ClientResponse.Status.NOT_FOUND)) {
- return null;
- } else {
- throw e;
- }
- }
-
- }
-
- private class FindByChannelName implements Callablechannel
, if the channel
- * already exists it will be replaced with the given channel.
- *
- * @param channel the channel to be added
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Channel.Builder channel) throws ChannelFinderException {
- wrappedSubmit(new SetChannel(channel.toXml()));
- }
-
- private class SetChannel implements Runnable {
- private XmlChannel pxmlChannel = new XmlChannel();
-
- public SetChannel(XmlChannel xmlChannel) {
- super();
- this.pxmlChannel = xmlChannel;
- }
-
- @Override
- public void run() {
- ObjectMapper mapper = new ObjectMapper();
- try {
- cfAuthenticatedResource
- .path(resourceChannels).path(this.pxmlChannel.getName())
- .type(MediaType.APPLICATION_JSON)
- .put(mapper.writeValueAsString(this.pxmlChannel));
- } catch (JsonProcessingException e) {
- log.log(Level.WARNING, "Failed to process the list of channel ", e);
- }
- }
- }
-
- /**
- * Destructively set a set of channels, if any channels already exists it is
- * replaced.
- *
- * @param channels set of channels to be added
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Collectiontag
with no associated channels to the
- * database.
- *
- * @param tag - the tag to be set.
- */
- public void set(Tag.Builder tag) {
- wrappedSubmit(new SetTag(tag.toXml()));
- }
-
- /**
- * Destructively set tag tag
to channel channelName
and
- * remove the tag from all other channels.
- *
- * @param tag - the tag to be set.
- * @param channelName - the channel to which the tag should be set on.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Tag.Builder tag, String channelName) throws ChannelFinderException {
- Collectiontag
on the set of channels {channels} and remove it from
- * all others.
- *
- * @param tag - the tag to be set.
- * @param channelNames - the list of channels to which this tag will be added and
- * removed from all others.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void set(Tag.Builder tag, Collectionproperty
.
- *
- * @param prop - the property to be set.
- */
- public void set(Property.Builder prop) throws ChannelFinderException {
- wrappedSubmit(new SetProperty(prop.toXml()));
- }
-
- /**
- * Destructively set property prop
and add it to the channel
- * channelName
and remove it from all others.
- *
- * @param prop - property to be set.
- * @param channelName - the channel to which this property must be added.
- */
- public void set(Property.Builder prop, String channelName) {
- Collectionprop
and add it to the channels
- * channelNames
removing it from all other channels. By default all
- * channels will contain the property with the same value specified in the
- * prop
.
- * to individually set the value for each channel use channelPropertyMap.
- *
- * @param prop - the property to be set.
- * @param channelNames - the channels to which this property should be added and
- * removed from all others.
- */
- public void set(Property.Builder prop, Collectionprop
and add it to the channels
- * specified in the channelPropertyMap
, where the map key is the
- * channel name and the associated value is the property value to be used
- * for that channel.
- *
- * @param prop - the property to be set.
- * @param channelPropertyMap - map with channel names and property values
- */
- public void set(Property.Builder prop, Mapchannel
.
- *
- * @param channel - channel builder
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Channel.Builder channel) throws ChannelFinderException {
- wrappedSubmit(new UpdateChannel(channel.toXml()));
- }
-
- private class UpdateChannel implements Runnable {
- private XmlChannel channel;
- private final ObjectMapper mapper = new ObjectMapper();
-
- UpdateChannel(XmlChannel channel) {
- super();
- this.channel = channel;
- }
-
- @Override
- public void run() {
- try {
- cfAuthenticatedResource.path(resourceChannels)
- .path(this.channel.getName())
- .type(MediaType.APPLICATION_JSON)
- .post(mapper.writeValueAsString(this.channel));
- } catch (UniformInterfaceException e) {
- throw new ChannelFinderException(e);
- } catch (JsonProcessingException e) {
- log.log(Level.WARNING, "Failed to process the list of channel ", e);
- }
- }
-
- }
-
- /**
- * Update Tag tag
by adding it to Channel with name
- * channelName
, without affecting the other instances of this tag.
- *
- * @param tag the tag to be added
- * @param channelName Name of the channel to which the tag is to be added
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Tag.Builder tag, String channelName) throws ChannelFinderException {
- wrappedSubmit(new UpdateTag(tag.toXml(), channelName));
- }
-
- /**
- * Update the Tag tag
by adding it to the set of the channels with
- * names channelNames
, without affecting the other instances of
- * this tag.
- *
- * @param tag - the tag that needs to be updated.
- * @param channelNames - list of channels to which this tag should be added.
- * @throws ChannelFinderException - channelfinder exception
- */
- public void update(Tag.Builder tag, Collectionproperty
by adding it to the channel
- * channelName
, without affecting the other channels.
+ * Get a list of names of all the tags currently present on the
+ * channelfinder service.
*
- * @param property - the property to be updated
- * @param channelName - the channel to which this property should be added or
- * updated.
- * @throws ChannelFinderException - channelfinder exception
+ * @return a list of names of all the existing {@link Tag}s.
*/
- public void update(Property.Builder property, String channelName) throws ChannelFinderException {
- wrappedSubmit(new UpdateChannelProperty(property.toXml(), channelName));
- }
+ @Override
+ public Collectionpattern
.
- * The pattern can contain wildcard char * or ?.
- *
- * @param pattern - the search pattern for the channel names
- * @return A Collection of channels who's name match the pattern
- * pattern
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionpattern
.
- * The pattern can contain wildcard char * or ?.
- *
- * @param pattern - the search pattern for the tag names
- * @return A Collection of channels which contain tags who's name match the
- * pattern pattern
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionpattern
.
- * The pattern can contain wildcard char * or ?.
- *
- * @param property - the name of the property.
- * @param pattern - the seatch pattern for the property value.
- * @return A collection of channels containing the property with name
- * propertyName
who's value matches the pattern
- * pattern
.
- * @throws ChannelFinderException - channelfinder exception
- */
- public Collectionquery
example:
- * find("SR* Cell=1,2 Tags=GolderOrbit,myTag)
+ * find("""SR* Cell=1,2 Tags=GolderOrbit,myTag")
*
@@ -1022,6 +364,7 @@ public Collection
- * Map.put("~tag", "tag1")
- * Map.put("Cell", "1")
- * Map.put("Cell", "2")
- * Map.put("Cell", "3")
- * >() {
- });
+ HttpRequest request = HttpRequest.newBuilder()
+ .uri(URI.create(org.phoebus.channelfinder.Preferences.serviceURL + "/" + resourceChannels + "?" + QueryParamsHelper.mapToQueryParams(multivaluedMap)))
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .GET()
+ .build();
+ HttpResponse
channel
- *
- * @param channelName - channel to be removed
- * @throws ChannelFinderException - channelfinder exception
- */
- public void deleteChannel(String channelName) throws ChannelFinderException
- {
- wrappedSubmit(new DeleteElement(resourceChannels, channelName)); // $NON-NLS-1$
- }
-
- private class DeleteElement implements Runnable
- {
- private final String elementType;
- private final String elementName;
-
- DeleteElement(String elementType, String elementName) {
- super();
- this.elementType = elementType;
- this.elementName = elementName;
- }
-
- @Override
- public void run() {
- cfAuthenticatedResource.path(elementType).path(elementName).delete();
- }
-
- }
-
- /**
- * Delete the set of channels identified by channels
- *
- * @param channels - channels to be deleted
- * @throws ChannelFinderException - throws exception
- */
- @Deprecated
- public void delete(Collectiontag
from the channel with the name
* channelName
@@ -1224,8 +489,8 @@ public void delete(Collectiontag
* @throws ChannelFinderException - throws exception
*/
- public void delete(Tag.Builder tag, String channelName) throws ChannelFinderException
- {
+ @Override
+ public void delete(Tag.Builder tag, String channelName) throws ChannelFinderException {
wrappedSubmit(new DeleteElementfromChannel(resourceTags, tag // $NON-NLS-1$
.toXml().getName(), channelName));
}
@@ -1237,8 +502,8 @@ public void delete(Tag.Builder tag, String channelName) throws ChannelFinderExce
* @param channelNames - the channels from which to delete the tag tag
* @throws ChannelFinderException - throws exception
*/
- public void delete(Tag.Builder tag, Collectionproperty
* @throws ChannelFinderException - throws exception
*/
- public void delete(Property.Builder property, String channelName) throws ChannelFinderException
- {
+ @Override
+ public void delete(Property.Builder property, String channelName) throws ChannelFinderException {
wrappedSubmit(new DeleteElementfromChannel(resourceProperties, property.build().getName(), channelName));
}
@@ -1268,21 +533,19 @@ public void delete(Property.Builder property, String channelName) throws Channel
* property
* @throws ChannelFinderException - throws exception
*/
- public void delete(Property.Builder property, Collection>() {
- });
- } catch (JsonParseException | JsonMappingException e) {
- log.log(Level.WARNING, "Failed to parse the list of channels ", e);
- } catch ( IOException e) {
- log.log(Level.WARNING, "Failed to parse the list of channels", e);
- } catch (UniformInterfaceException e) {
- throw new ChannelFinderException(e);
+ /**
+ * Update the Tag
tag
by adding it to the set of the channels with
+ * names channelNames
, without affecting the other instances of
+ * this tag.
+ *
+ * @param tag - the tag that needs to be updated.
+ * @param channelNames - list of channels to which this tag should be added.
+ * @throws ChannelFinderException - channelfinder exception
+ */
+ public void update(Tag.Builder tag, Collection