Search in sources :

Example 1 with ResponseException

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);
}
Also used : InternalClientErrorResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalClientErrorResponseException) InternalClientErrorResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalClientErrorResponseException) ClientErrorResponseException(nl.teslanet.mule.connectors.coap.api.error.ClientErrorResponseException) NoResponseException(nl.teslanet.mule.connectors.coap.api.error.NoResponseException) ResponseException(nl.teslanet.mule.connectors.coap.api.error.ResponseException) ServerErrorResponseException(nl.teslanet.mule.connectors.coap.api.error.ServerErrorResponseException) InternalNoResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalNoResponseException) InternalUnexpectedResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalUnexpectedResponseException) InternalResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalResponseException) InternalServerErrorResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalServerErrorResponseException) InternalInvalidRequestCodeException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidRequestCodeException) InternalServerErrorResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalServerErrorResponseException) RequestException(nl.teslanet.mule.connectors.coap.api.error.RequestException) InternalRequestException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalRequestException) ServerErrorResponseException(nl.teslanet.mule.connectors.coap.api.error.ServerErrorResponseException) InternalServerErrorResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalServerErrorResponseException) DiscoveredResource(nl.teslanet.mule.connectors.coap.api.DiscoveredResource) InternalInvalidResponseCodeException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidResponseCodeException) InternalUnexpectedResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalUnexpectedResponseException) TreeSet(java.util.TreeSet) UriException(nl.teslanet.mule.connectors.coap.api.error.UriException) InternalUriException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalUriException) InternalRequestException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalRequestException) IOException(java.io.IOException) InternalResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalResponseException) InternalNoResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalNoResponseException) WebLink(org.eclipse.californium.core.WebLink) InternalEndpointException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalEndpointException) EndpointException(nl.teslanet.mule.connectors.coap.api.error.EndpointException) ConnectorException(org.eclipse.californium.elements.exception.ConnectorException) NoResponseException(nl.teslanet.mule.connectors.coap.api.error.NoResponseException) InternalNoResponseException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalNoResponseException) InternalUriException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalUriException) InternalInvalidRequestCodeException(nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidRequestCodeException) InvalidRequestCodeException(nl.teslanet.mule.connectors.coap.api.error.InvalidRequestCodeException) Throws(org.mule.runtime.extension.api.annotation.error.Throws)

Aggregations

IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 DiscoveredResource (nl.teslanet.mule.connectors.coap.api.DiscoveredResource)1 ClientErrorResponseException (nl.teslanet.mule.connectors.coap.api.error.ClientErrorResponseException)1 EndpointException (nl.teslanet.mule.connectors.coap.api.error.EndpointException)1 InvalidRequestCodeException (nl.teslanet.mule.connectors.coap.api.error.InvalidRequestCodeException)1 NoResponseException (nl.teslanet.mule.connectors.coap.api.error.NoResponseException)1 RequestException (nl.teslanet.mule.connectors.coap.api.error.RequestException)1 ResponseException (nl.teslanet.mule.connectors.coap.api.error.ResponseException)1 ServerErrorResponseException (nl.teslanet.mule.connectors.coap.api.error.ServerErrorResponseException)1 UriException (nl.teslanet.mule.connectors.coap.api.error.UriException)1 InternalClientErrorResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalClientErrorResponseException)1 InternalEndpointException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalEndpointException)1 InternalInvalidRequestCodeException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidRequestCodeException)1 InternalInvalidResponseCodeException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalInvalidResponseCodeException)1 InternalNoResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalNoResponseException)1 InternalRequestException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalRequestException)1 InternalResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalResponseException)1 InternalServerErrorResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalServerErrorResponseException)1 InternalUnexpectedResponseException (nl.teslanet.mule.connectors.coap.internal.exceptions.InternalUnexpectedResponseException)1