Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.UniformInterfaceException


                } catch (InterruptedException ignore) {
                } catch (CancellationException ignore){
                } catch (ExecutionException e) {
                  if (e.getCause() != null){
                    if (e.getCause().getClass() == UniformInterfaceException.class){
                        UniformInterfaceException ue = (UniformInterfaceException)e.getCause();
                        ClientResponse cr = ue.getResponse();
                        thoughtLoadable.completeLoadingThoughts(
                            cr.getClientResponseStatus(),
                            null,
                            cr.getEntity(String.class));
                    } else if (e.getCause().getClass() == NotRegisteredException.class){
View Full Code Here


                } catch (InterruptedException ignore) {
                } catch (CancellationException ignore){
                } catch (ExecutionException e) {
                  if (e.getCause() != null){
                    if (e.getCause().getClass() == UniformInterfaceException.class){
                        UniformInterfaceException ue = (UniformInterfaceException)e.getCause();
                        ClientResponse cr = ue.getResponse();
                        thoughtLoadable.completeLoadingThoughts(
                            cr.getClientResponseStatus(),
                            null,
                            cr.getEntity(String.class));
                    } else if (e.getCause().getClass() == ClientHandlerException.class)  {
View Full Code Here

                } catch (InterruptedException ignore) {
                } catch (CancellationException ignore){
                } catch (ExecutionException e) {
                  if (e.getCause()!=null){
                    if (e.getCause().getClass() == UniformInterfaceException.class){
                      UniformInterfaceException ue = (UniformInterfaceException)e.getCause();
                      ClientResponse cr = ue.getResponse();  
                      finishRegistration(cr.getEntity(String.class),
                          registrationInstance,
                          cr.getClientResponseStatus(),
                          cr.getEntity(String.class));
                      } else if(e.getCause().getClass() == ClientHandlerException.class){
View Full Code Here

            }
        }

        // next filter in chain
        ClientResponse response;
        UniformInterfaceException uie = null;
        try {
            response = getNext().handle(request);
        } catch (UniformInterfaceException e) {
            response = e.getResponse();
            uie = e;
View Full Code Here

    String exType = headers.getFirst(EXCEPTION_TYPE);
    String exMsg = headers.getFirst(EXCEPTION_MESSAGE);
    if (exMsg == null) {
      exMsg = headers.getFirst(EXCEPTION_POINT);
    }
    UniformInterfaceException uiex;
    if (response.getStatus() == 404) {
      uiex = new UniformInterfaceException404NotFound(response, true);
    } else if (response.getStatus() == 204) {
      uiex = new UniformInterfaceException204NoContent(response, true);
    } else {
      uiex = new UniformInterfaceException(response, true);
    }
    if (exType == null) {
      throw uiex;  // standard UniformInterfaceException as we have nothing to add
    }
    RuntimeException exception;
View Full Code Here

        List<DataSource> parts = parseParts(response.getEntityInputStream(),
                response.getHeaders().getFirst("Content-Type"));

        if (parts.size() == 0 || parts.size() > entityBatchOperations.size()) {
            throw new UniformInterfaceException(String.format(
                    "Batch response from server does not contain the correct amount "
                            + "of parts (expecting %d, received %d instead)",
                    parts.size(), entityBatchOperations.size()), response);
        }

        for (int i = 0; i < parts.size(); i++) {
            DataSource ds = parts.get(i);
            EntityBatchOperation entityBatchOperation = entityBatchOperations
                    .get(i);

            StatusLine status = StatusLine.create(ds);
            InternetHeaders headers = parseHeaders(ds);
            InputStream content = parseEntity(ds);

            if (status.getStatus() >= HTTP_ERROR) {

                InBoundHeaders inBoundHeaders = new InBoundHeaders();
                @SuppressWarnings("unchecked")
                Enumeration<Header> e = headers.getAllHeaders();
                while (e.hasMoreElements()) {
                    Header header = e.nextElement();
                    inBoundHeaders.putSingle(header.getName(),
                            header.getValue());
                }

                ClientResponse clientResponse = new ClientResponse(
                        status.getStatus(), inBoundHeaders, content, null);

                UniformInterfaceException uniformInterfaceException = new UniformInterfaceException(
                        clientResponse);
                throw uniformInterfaceException;
            } else if (entityBatchOperation instanceof Job.CreateBatchOperation) {

                try {
View Full Code Here

    public static void throwIfNotSuccess(ClientResponse clientResponse) {
        int statusCode = clientResponse.getStatus();

        if ((statusCode < 200) || (statusCode >= 300)) {
            String errorMessage = createErrorMessage(clientResponse);
            throw new UniformInterfaceException(errorMessage, clientResponse);
        }
    }
View Full Code Here

    }

    public static void throwIfError(ClientResponse clientResponse) {
        if (clientResponse.getStatus() >= 400) {
            String errorMessage = createErrorMessage(clientResponse);
            throw new UniformInterfaceException(errorMessage, clientResponse);
        }
    }
View Full Code Here

    @Test
    public void serviceNameAndMessageAndCauseAppearInException() {
        // Arrange
        ClientResponse response = new ClientResponse(404, null,
                new ByteArrayInputStream(new byte[0]), null);
        UniformInterfaceException cause = new UniformInterfaceException(
                response);

        // Act
        ServiceException exception = ServiceExceptionFactory.process("testing",
                new ServiceException("this is a test", cause));
View Full Code Here

    @Test
    public void httpStatusCodeAndReasonPhraseAppearInException() {
        // Arrange
        ClientResponse response = new ClientResponse(404, null,
                new ByteArrayInputStream(new byte[0]), null);
        UniformInterfaceException cause = new UniformInterfaceException(
                response);

        // Act
        ServiceException exception = ServiceExceptionFactory.process("testing",
                new ServiceException("this is a test", cause));
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.client.UniformInterfaceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.