use of nl.teslanet.mule.connectors.coap.api.error.ResponseException in project mule-coap-connector by teslanet-nl.
the class ClientOperations method discover.
/**
* The Discover processor retrieves information about CoAP resources of a
* server.
*
* @param client The client to use to issue the request.
* @param discoverParams The attributes of the discover request
* @return The description of resources on the server that have been discovered.
*/
@Throws({ DiscoverErrorProvider.class })
public Set<DiscoveredResource> discover(@Config Client client, @ParameterGroup(name = "Discover address") DiscoverParams discoverParams) {
Set<WebLink> links = null;
try {
links = client.discover(discoverParams);
} catch (IOException | ConnectorException e) {
throw new EndpointException(client + discoverErrorMsg, e);
} catch (InternalUriException e) {
throw new UriException(client + discoverErrorMsg, e);
} catch (InternalUnexpectedResponseException | InternalInvalidResponseCodeException | InternalResponseException e) {
throw new ResponseException(client + discoverErrorMsg, e);
} catch (InternalNoResponseException e) {
throw new NoResponseException(client + discoverErrorMsg, e);
} catch (InternalClientErrorResponseException e) {
throw new ResponseException(client + discoverErrorMsg, e);
} catch (InternalServerErrorResponseException e) {
throw new ServerErrorResponseException(client + discoverErrorMsg, e);
} catch (InternalInvalidRequestCodeException e) {
throw new InvalidRequestCodeException(client + discoverErrorMsg, e);
} catch (InternalRequestException e) {
throw new RequestException(client + discoverErrorMsg, e);
}
TreeSet<DiscoveredResource> resultSet = new TreeSet<DiscoveredResource>();
for (WebLink link : links) {
resultSet.add(new DiscoveredResource(link.getURI(), link.getAttributes().hasObservable(), link.getAttributes().getTitle(), link.getAttributes().getInterfaceDescriptions(), link.getAttributes().getResourceTypes(), link.getAttributes().getMaximumSizeEstimate(), link.getAttributes().getContentTypes()));
}
return Collections.unmodifiableSortedSet(resultSet);
}
Aggregations