Examples of JaxbExceptionResponse


Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

        this.responses = responses;
    }

    public void addException(Exception exception, int i, Command<?> cmd, JaxbRequestStatus status) {
        lazyInitResponseList();
        this.responses.add(new JaxbExceptionResponse(exception, i, cmd, status));
    }
View Full Code Here

Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

        this.responses = responses;
    }

    public void addException(Exception exception, int i, Command<?> cmd, JaxbRequestStatus status) {
        lazyInitResponseList();
        this.responses.add(new JaxbExceptionResponse(exception, i, cmd, status));
    }
View Full Code Here

Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

        ProcessInstance oompaProcInst = null;
        List<TaskSummary> charliesTasks = null;
        for (JaxbCommandResponse<?> response : cmdResponse.getResponses()) {
            if (response instanceof JaxbExceptionResponse) {
                // something went wrong on the server side
                JaxbExceptionResponse exceptionResponse = (JaxbExceptionResponse) response;
                throw new RuntimeException(exceptionResponse.getMessage());
            }

            if (response.getIndex() == oompaProcessingResultIndex) {
                oompaProcInst = (ProcessInstance) response.getResult();
            } else if (response.getIndex() == loompaMonitoringResultIndex) {
View Full Code Here

Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

    @Test
    public void exceptionTest() throws Exception {
        Assume.assumeFalse(getType().equals(TestType.YAML));
       
        JaxbExceptionResponse resp = new JaxbExceptionResponse();
        resp.setMessage("error");
        resp.setStatus(JaxbRequestStatus.SUCCESS);
        resp.setUrl("http://here");
      
        RuntimeException re = new RuntimeException();
        resp.setCause(re);

        testRoundTrip(resp);
    }
View Full Code Here

Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

        }
        List<JaxbCommandResponse<?>> responses = cmdResponse.getResponses();
        if( responses.size() > 0 ) {
            JaxbCommandResponse<?> response = responses.get(0);
            if( response instanceof JaxbExceptionResponse ) {
                JaxbExceptionResponse exceptionResponse = (JaxbExceptionResponse) response;
                throw new RemoteApiException(exceptionResponse.getMessage());
            } else {
                return response.getResult();
            }
        } else {
            assert responses.size() == 0: "There should only be 1 response, " + "not " + responses.size()
View Full Code Here

Examples of org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse

            httpRequest.disconnect();
            throw new RemoteCommunicationException("Unable to post request: " + e.getMessage(), e);
        }

        // Get response
        JaxbExceptionResponse exceptionResponse = null;
        JaxbCommandsResponse commandResponse = null;
        int responseStatus = httpResponse.code();
        try {
            String content = httpResponse.body();
            if( responseStatus < 300 ) {
                commandResponse = deserializeResponseContent(content, JaxbCommandsResponse.class);
            } else {
                String contentType = httpResponse.contentType();
                if( contentType.equals(MediaType.APPLICATION_XML) ) {
                    exceptionResponse = deserializeResponseContent(content, JaxbExceptionResponse.class);
                } else if( contentType.startsWith(MediaType.TEXT_HTML) ) {
                    exceptionResponse = new JaxbExceptionResponse();
                    Document doc = Jsoup.parse(content);
                    String body = doc.body().text();
                    exceptionResponse.setMessage(body);
                    exceptionResponse.setUrl(httpRequest.getUri().toString());
                    exceptionResponse.setStackTrace("");
                }
                else {
                    throw new RemoteCommunicationException("Unable to deserialize response with content type '" + contentType + "'");
                }
            }
        } catch( Exception e ) {
            logger.error("Unable to retrieve response content from request with status {}: {}", e.getMessage(), e);
            throw new RemoteCommunicationException("Unable to retrieve content from response!", e);
        } finally {
            httpRequest.disconnect();
        }
       
        if( commandResponse != null ) {
            List<JaxbCommandResponse<?>> responses = commandResponse.getResponses();
            if( responses.size() == 0 ) {
                return null;
            } else if( responses.size() == 1 ) {
                JaxbCommandResponse<?> responseObject = responses.get(0);
                if( responseObject instanceof JaxbExceptionResponse ) {
                    exceptionResponse = (JaxbExceptionResponse) responseObject;
                } else {
                    return (T) responseObject.getResult();
                }
            } else {
                throw new RemoteCommunicationException("Unexpected number of results from " + command.getClass().getSimpleName()
                        + ":" + responses.size() + " results instead of only 1");
            }
        }

        logger.error("Response with status {} returned.", responseStatus);
        // Process exception response
        switch ( responseStatus ) {
        case 409:
            throw new RemoteTaskException(exceptionResponse.getMessage() + ":\n" + exceptionResponse.getStackTrace());
        default:
            if( exceptionResponse != null ) {
                throw new RemoteApiException(exceptionResponse.getMessage() + ":\n" + exceptionResponse.getStackTrace());
            } else {
                throw new RemoteCommunicationException("Unable to communicate with remote API via URL "
                        + "'" + httpRequest.getUri().toString() + "'");
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.