public void addCommitComment(Repository repository, Commit commit, String comment) { try { String path = String.format(COMMENT_PATH, repository.getOwner().getName(), repository.getName(), commit.getSha()); WebResource resource = client.resource(GITHUB_URL).path(path); ClientResponse response = resource.type(MediaType.APPLICATION_JSON_TYPE) .accept(MediaType.APPLICATION_JSON) .header("Authorization", authorizationHeader) .entity(new CommitComment(comment)) .post(ClientResponse.class); if (response.getStatus() < 200 || response.getStatus() >=300) { logger.warn("Commit comment failed: " + response.getClientResponseStatus().getReasonPhrase()); } } catch (UniformInterfaceException | ClientHandlerException e) { logger.warn("Comment failed", e); } }
private void printStandardHttpErrorDetails(AtlasServiceException e) { System.err.println("Error details: "); System.err.println("HTTP Status: " + e.getStatus().getStatusCode() + "," + e.getStatus().getReasonPhrase()); System.err.println("Exception message: " + e.getMessage()); }
private void printStandardHttpErrorDetails(AtlasServiceException e) { System.err.println("Error details: "); System.err.println("HTTP Status: " + e.getStatus().getStatusCode() + "," + e.getStatus().getReasonPhrase()); System.err.println("Exception message: " + e.getMessage()); }
throw new OpenStackResponseException(e.getResponse().getClientResponseStatus().getReasonPhrase(), e.getResponse().getStatus());
throw new OpenStackResponseException(e.getResponse().getClientResponseStatus().getReasonPhrase(), e.getResponse().getStatus());
} else { exception.setHttpStatusCode(status.getStatusCode()); exception.setHttpReasonPhrase(status.getReasonPhrase());
} else if (status.getReasonPhrase() == "Not Found") { message += " [status: " + status.getFamily() + " reason: " + status.getReasonPhrase() + "]"; log.warning(message); } else { message += " [status: " + status.getFamily() + " reason: " + status.getReasonPhrase() + "]"; log.severe(message); throw new ContainerException(message);
} else { exception.setHttpStatusCode(status.getStatusCode()); exception.setHttpReasonPhrase(status.getReasonPhrase());
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { WebResource resource = getResource(listener); if (resource != null) { try { ClientResponse response = resource.post(ClientResponse.class); if (Response.Status.Family.SUCCESSFUL.equals(response.getClientResponseStatus().getFamily())) { listener.getLogger().printf("Successfully triggered JIRA to update builds of this job\n"); } else { listener.error("Unable to trigger JIRA to update builds of this job, JIRA responded with [%d] %s", response.getClientResponseStatus().getStatusCode(), response.getClientResponseStatus().getReasonPhrase()); } } catch (Exception e) { listener.error("Failed to triggered JIRA to update builds of this job -> %s", e.getMessage()); } } return true; }
private void checkStatus(ClientResponse response, ClientResponse.Status status, String operation, String entityType, String path, ResponseStatus expected) { if (!expected.isExpected(status)) { if (status == ClientResponse.Status.NOT_FOUND) { throw new ResourceNotFoundException("Could not " + operation + " " + entityType + " at " + path, extractErrorFields(response)); } if (status == ClientResponse.Status.FORBIDDEN) { throw new ForbiddenUserException("User is not allowed to " + operation + " " + entityType + " at " + path, extractErrorFields(response)); } throw new FailedRequestException("failed to " + operation + " " + entityType + " at " + path + ": " + status.getReasonPhrase(), extractErrorFields(response)); } }
/** * @see com.woorea.openstack.base.client.OpenStackResponse#getEntity(java.lang.Class) */ @Override public <T> T getEntity(Class<T> returnType) throws OpenStackResponseException { if(response.getStatus() >= 400) { throw new OpenStackResponseException(response.getClientResponseStatus().getReasonPhrase(), response.getStatus(), this); } if(response.hasEntity() && returnType != null && Void.class != returnType) { return response.getEntity(returnType); } return null; }
public NexusClientException convert( final UniformInterfaceException e ) { NexusClientException exception = convertIfKnown( e ); if ( exception != null ) { return exception; } return new NexusClientResponseException( getMessageIfPresent( e.getResponse().getClientResponseStatus().getStatusCode(), e ), e.getResponse().getClientResponseStatus().getStatusCode(), e.getResponse().getClientResponseStatus().getReasonPhrase(), getResponseBody( e.getResponse() ) ); }
public NexusClientNotFoundException convertIf404( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.NOT_FOUND.equals( response.getClientResponseStatus() ) ) { return new NexusClientNotFoundException( getMessageIfPresent( ClientResponse.Status.NOT_FOUND.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
public NexusClientAccessForbiddenException convertIf403( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.FORBIDDEN.equals( response.getClientResponseStatus() ) ) { return new NexusClientAccessForbiddenException( getMessageIfPresent( ClientResponse.Status.FORBIDDEN.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
public NexusClientBadRequestException convertIf400( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.BAD_REQUEST.equals( response.getClientResponseStatus() ) ) { return new NexusClientBadRequestException( getMessageIfPresent( ClientResponse.Status.BAD_REQUEST.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
private void printStandardHttpErrorDetails(AtlasServiceException e) { System.err.println("Error details: "); System.err.println("HTTP Status: " + e.getStatus().getStatusCode() + "," + e.getStatus().getReasonPhrase()); System.err.println("Exception message: " + e.getMessage()); }
@Override public <T> T getEntity(Class<T> returnType) { if(response.getStatus() >= 400) { throw new OpenStackResponseException(response.getClientResponseStatus().getReasonPhrase(), response.getStatus()); } if(response.hasEntity() && returnType != null && Void.class != returnType) { return response.getEntity(returnType); } else { return null; } }
private void checkStatus(ClientResponse response) { if (response.getStatus() > 299) { String reasonPhrase = ""; if (response.getClientResponseStatus() != null) { reasonPhrase = response.getClientResponseStatus().getReasonPhrase(); } throw new WebException(response.getStatus(), reasonPhrase); } }
@Override public <T> T getEntity(Class<T> returnType) { if(response.getStatus() >= 400) { throw new OpenStackResponseException(response.getClientResponseStatus().getReasonPhrase(), response.getStatus()); } if(response.hasEntity() && returnType != null && Void.class != returnType) { return response.getEntity(returnType); } else { return null; } }
private String negotiate(UniformInterfaceException u) { return negotiateHandler.negotiate(supportedContentType, u.getResponse().getHeaders(), u.getResponse().getStatus(), u.getResponse().getClientResponseStatus().getReasonPhrase()); }