Package org.sonatype.nexus.client.internal.msg

Examples of org.sonatype.nexus.client.internal.msg.ErrorResponse


          .serviceResource("repositories")
          .post(RepositoryResourceResponse.class, request)
          .getData();
    }
    catch (UniformInterfaceException e) {
      final ErrorResponse response = e.getResponse().getEntity(ErrorResponse.class);
      for (ErrorMessage message : response.getErrors()) {
        System.err.println(message.getId() + ": " + message.getMsg());
      }
      throw e;
    }
  }
View Full Code Here


  private void throwIf400WithErrorMessage(final ClientResponse response) {
    if (ClientResponse.Status.BAD_REQUEST.equals(response.getClientResponseStatus())) {
      final String body = getResponseBody(response);
      response.bufferEntity();
      ErrorResponse errorResponse = null;
      try {
        errorResponse = response.getEntity(ErrorResponse.class);
      }
      catch (Exception ignore) {
        // most probably we do not have an error response
      }
      if (errorResponse != null) {
        // convert them to hide stupid "old" REST model, and not have it leak out
        final List<ErrorMessage> errors = Lists.newArrayList();
        for (org.sonatype.nexus.client.internal.msg.ErrorMessage message : errorResponse.getErrors()) {
          errors.add(new NexusClientErrorResponseException.ErrorMessage(message.getId(), message.getMsg()));
        }
        throw new NexusClientErrorResponseException(
            response.getClientResponseStatus().getReasonPhrase(),
            body,
View Full Code Here

  public NexusClientErrorResponseException convertIf400WithErrorMessage(final UniformInterfaceException e) {
    final ClientResponse response = e.getResponse();
    if (ClientResponse.Status.BAD_REQUEST.equals(response.getClientResponseStatus())) {
      final String body = getResponseBody(response);
      ErrorResponse errorResponse = null;
      try {
        errorResponse = (ErrorResponse) getXStream().fromXML(body, new ErrorResponse());
      }
      catch (Exception e1) {
        // ignore
        // XStreamException if body is not ErrorResponse
      }
      if (errorResponse != null) {
        // convert them to hide stupid "old" REST model, and not have it leak out
        final ArrayList<NexusClientErrorResponseException.ErrorMessage> errors =
            new ArrayList<NexusClientErrorResponseException.ErrorMessage>(errorResponse.getErrors().size());
        for (ErrorMessage message : errorResponse.getErrors()) {
          errors.add(
              new NexusClientErrorResponseException.ErrorMessage(message.getId(), message.getMsg()));
        }
        return new NexusClientErrorResponseException(
            response.getClientResponseStatus().getReasonPhrase(),
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.client.internal.msg.ErrorResponse

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.