@Override protected String getResponseMessage() throws IOException { return postMethod.getStatusText(); }
@Override protected String getResponseMessage() throws IOException { return postMethod.getStatusText(); }
@Override protected String getResponseMessage() throws IOException { return postMethod.getStatusText(); }
@Override protected String getResponseMessage() throws IOException { return postMethod.getStatusText(); }
protected void checkStatusCode(PostMethod method) throws IOException { if (method.getStatusCode() != 200) { throw new IOException("Wrong status code: 200 expected but got " + method.getStatusCode() + " (" + method.getStatusText() + ")"); } }
throw new RuntimeException(method.getStatusText()); throw new RuntimeException(method.getStatusText()); throw new RuntimeException(method.getStatusText());
public BintrayPackage createPackage(String owner, String repository, CreatePackageRequest request){ String url = String.format("https://api.bintray.com/packages/%s/%s/", owner, repository); PostMethod post = new PostMethod(url); assertAuthorized(); post.addRequestHeader("Authorization", "Basic "+ new String(Base64.encodeBase64((username+":"+password).getBytes()))); ObjectMapper mapper = new ObjectMapper(); try{ post.setRequestEntity(new ByteArrayRequestEntity(mapper.writeValueAsBytes(request))); new HttpClient().executeMethod(post); if(post.getStatusLine() == null || post.getStatusCode()==401){ throw new IOException("Unauthorized, this user have no rights to publish packages as "+owner+", or API key is invalid"); } JsonParser parser = new JsonFactory().createParser(post.getResponseBodyAsStream()); parser.setCodec(new ObjectMapper()); BintrayPackage bintrayPackage = parser.readValueAs(BintrayPackage.class); //there is response body so mapper will return empty object, not null if(bintrayPackage.getName() != null){ return bintrayPackage; } else { throw new RuntimeException("Failed to create package, cause : "+(post.getStatusCode()+" - "+ post.getStatusText())); } } catch (IOException e) { throw new RuntimeException("Failed to create package", e); } }
+ " text : " + post.getStatusText()); if (isDebugEnabled) { log.debug("Error response : " + readResponse(post));
throw new RuntimeException(method.getStatusText());
msg.append( method.getStatusLine().getReasonPhrase() ); msg.append( "\n\n" ); msg.append( method.getStatusText() ); msg.append( "\n\n" ); msg.append( "request: "+method.getURI() );
+ post.getStatusText());
throw new IOException("HTTP status code " + method.getStatusCode() + ": " + method.getStatusText());
TransmitterException ex = new TransmitterException(method.getStatusText()); throw ex;
+ " text : " + patch.getStatusText()); if (isDebugEnabled) { log.debug("Error response : " + readResponse(patch));
throw new LDAPException(LDAPException.resultCodeToString(LDAPException.INVALID_CREDENTIALS),LDAPException.INVALID_CREDENTIALS,LDAPException.resultCodeToString(LDAPException.INVALID_CREDENTIALS)); } else { throw new LDAPException(LDAPException.resultCodeToString(LDAPException.UNAVAILABLE),LDAPException.UNAVAILABLE,post.getStatusText());
if (rc != HttpServletResponse.SC_NO_CONTENT) { String errorMessage = "Unexpected response code received from hub: " + hub + " - " + rc + " " + method.getStatusText(); log.warn(errorMessage); blog.warn(errorMessage);
@Override protected Either<? extends Exception, Boolean> checkServiceAvailability(final boolean checkTimeout, final long timeoutRemaining) { final PostMethod request = getResponseBuilder().forPackId(NO_SUCH_PACK_ID).withParam(KEY_CMD, CMD_DELETE).getJsonUrlRequest(); final int oldTimeout = getClient().getHttpConnectionManager().getParams().getConnectionTimeout(); if (checkTimeout) { getClient().getHttpConnectionManager().getParams().setConnectionTimeout((int) timeoutRemaining); request.getParams().setSoTimeout((int) timeoutRemaining); } try { int status = getClient().executeMethod(request); SimpleResponse response = parseSimpleResponse(status, request.getStatusText(), request.getResponseBodyAsStream(), request.getResponseCharSet(), true); return right(Exception.class, response != null); } catch (IOException e) { return left(e, Boolean.class); } finally { getClient().getHttpConnectionManager().getParams().setConnectionTimeout(oldTimeout); request.releaseConnection(); } }