List of usage examples for org.apache.commons.httpclient HttpStatus SC_CONFLICT
int SC_CONFLICT
To view the source code for org.apache.commons.httpclient HttpStatus SC_CONFLICT.
Click Source Link
From source file:com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation.java
/** * Performs the operation/* w w w .j a v a 2 s .c o m*/ * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(WebdavClient client) { RemoteOperationResult result = null; MkColMethod mkcol = null; boolean noInvalidChars = FileUtils.isValidPath(mRemotePath); if (noInvalidChars) { try { mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath)); int status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT); if (!mkcol.succeeded() && mkcol.getStatusCode() == HttpStatus.SC_CONFLICT && mCreateFullPath) { result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT); // second (and last) try } result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders()); Log.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage()); client.exhaustResponse(mkcol.getResponseBodyAsStream()); } catch (Exception e) { result = new RemoteOperationResult(e); Log.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e); } finally { if (mkcol != null) mkcol.releaseConnection(); } } else { result = new RemoteOperationResult(ResultCode.INVALID_CHARACTER_IN_NAME); } return result; }
From source file:com.eviware.soapui.impl.rest.mock.RestMockResponseWriterTest.java
@Test public void shouldSetStatusCode() throws Exception { mockResponse.setResponseHttpStatus(HttpStatus.SC_CONFLICT); mockResponse.writeResponse(result, originalResponseContent); verify(servletResponse).setStatus(HttpStatus.SC_CONFLICT); }
From source file:com.bbva.arq.devops.ae.mirrorgate.jenkins.plugin.service.DefaultMirrorGateService.java
@Override public MirrorGateResponse sendBuildDataToExtraEndpoints(BuildDTO request, String URL) { try {// w w w. ja v a2 s .c om return buildRestCall().makeRestCallPost(URL, MirrorGateUtils.convertObjectToJson(request), null, null); } catch (IOException e) { LOG.log(Level.SEVERE, "MirrorGate: Error posting to" + URL, e); return new MirrorGateResponse(HttpStatus.SC_CONFLICT, ""); } }
From source file:com.owncloud.android.operations.RemoteOperationResult.java
private RemoteOperationResult(boolean success, int httpCode) { mSuccess = success;/*from w ww . ja va 2 s .co m*/ mHttpCode = httpCode; if (success) { mCode = ResultCode.OK; } else if (httpCode > 0) { switch (httpCode) { case HttpStatus.SC_UNAUTHORIZED: mCode = ResultCode.UNAUTHORIZED; break; case HttpStatus.SC_NOT_FOUND: mCode = ResultCode.FILE_NOT_FOUND; break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: mCode = ResultCode.INSTANCE_NOT_CONFIGURED; break; case HttpStatus.SC_CONFLICT: mCode = ResultCode.CONFLICT; break; case HttpStatus.SC_INSUFFICIENT_STORAGE: mCode = ResultCode.QUOTA_EXCEEDED; break; default: mCode = ResultCode.UNHANDLED_HTTP_CODE; Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode); } } }
From source file:com.owncloud.android.oc_framework.operations.RemoteOperationResult.java
private RemoteOperationResult(boolean success, int httpCode) { mSuccess = success;/*from w w w. j a va 2 s .c o m*/ mHttpCode = httpCode; if (success) { mCode = ResultCode.OK; } else if (httpCode > 0) { switch (httpCode) { case HttpStatus.SC_UNAUTHORIZED: mCode = ResultCode.UNAUTHORIZED; break; case HttpStatus.SC_NOT_FOUND: mCode = ResultCode.FILE_NOT_FOUND; break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: mCode = ResultCode.INSTANCE_NOT_CONFIGURED; break; case HttpStatus.SC_CONFLICT: mCode = ResultCode.CONFLICT; break; case HttpStatus.SC_INSUFFICIENT_STORAGE: mCode = ResultCode.QUOTA_EXCEEDED; break; default: mCode = ResultCode.UNHANDLED_HTTP_CODE; Log.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode); } } }
From source file:com.cerema.cloud2.lib.common.operations.RemoteOperationResult.java
private RemoteOperationResult(boolean success, int httpCode) { mSuccess = success;/* w w w. ja va2 s . c o m*/ mHttpCode = httpCode; if (success) { mCode = ResultCode.OK; } else if (httpCode > 0) { switch (httpCode) { case HttpStatus.SC_UNAUTHORIZED: mCode = ResultCode.UNAUTHORIZED; break; case HttpStatus.SC_NOT_FOUND: mCode = ResultCode.FILE_NOT_FOUND; break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: mCode = ResultCode.INSTANCE_NOT_CONFIGURED; break; case HttpStatus.SC_CONFLICT: mCode = ResultCode.CONFLICT; break; case HttpStatus.SC_INSUFFICIENT_STORAGE: mCode = ResultCode.QUOTA_EXCEEDED; break; case HttpStatus.SC_FORBIDDEN: mCode = ResultCode.FORBIDDEN; break; default: mCode = ResultCode.UNHANDLED_HTTP_CODE; Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode); } } }
From source file:com.eucalyptus.blockstorage.StorageReplyQueue.java
public void handle(ExceptionMessage muleMsg) { try {//from w w w. j a va2 s . c o m Object requestMsg = muleMsg.getPayload(); String requestString = requestMsg.toString(); BaseMessage msg = (BaseMessage) BindingManager.getDefaultBinding().fromOM(requestString); Throwable ex = muleMsg.getException().getCause(); StorageErrorMessageType errMsg = null; if (ex instanceof NoSuchVolumeException) { errMsg = new StorageErrorMessageType("NoSuchVolume", "Volume not found", HttpStatus.SC_NOT_FOUND, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeInUseException) { errMsg = new StorageErrorMessageType("VolumeInUse", "Volume in use", HttpStatus.SC_FORBIDDEN, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof NoSuchSnapshotException) { errMsg = new StorageErrorMessageType("NoSuchSnapshot", "Snapshot not found", HttpStatus.SC_NOT_FOUND, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeAlreadyExistsException) { errMsg = new StorageErrorMessageType("VolumeAlreadyExists", "Volume already exists", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeNotReadyException) { errMsg = new StorageErrorMessageType("VolumeNotReady", "Volume not ready yet", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof SnapshotInUseException) { errMsg = new StorageErrorMessageType("SnapshotInUse", "Snapshot in use", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else { replies.putMessage( new EucalyptusErrorMessageType(muleMsg.getComponentName(), msg, ex.getMessage())); } if (errMsg != null) { replies.putMessage(errMsg); } } catch (Exception e) { LOG.error(e); } }
From source file:edu.ucsb.eucalyptus.ic.StorageReplyQueue.java
public void handle(ExceptionMessage muleMsg) { try {/*from w ww . ja v a 2 s. c o m*/ Object requestMsg = muleMsg.getPayload(); String requestString = requestMsg.toString(); BaseMessage msg = (BaseMessage) BindingManager.getBinding("msgs_eucalyptus_com").fromOM(requestString); Throwable ex = muleMsg.getException().getCause(); StorageErrorMessageType errMsg = null; if (ex instanceof NoSuchVolumeException) { errMsg = new StorageErrorMessageType("NoSuchVolume", "Volume not found", HttpStatus.SC_NOT_FOUND, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeInUseException) { errMsg = new StorageErrorMessageType("VolumeInUse", "Volume in use", HttpStatus.SC_FORBIDDEN, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof NoSuchSnapshotException) { errMsg = new StorageErrorMessageType("NoSuchSnapshot", "Snapshot not found", HttpStatus.SC_NOT_FOUND, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeAlreadyExistsException) { errMsg = new StorageErrorMessageType("VolumeAlreadyExists", "Volume already exists", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof VolumeNotReadyException) { errMsg = new StorageErrorMessageType("VolumeNotReady", "Volume not ready yet", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else if (ex instanceof SnapshotInUseException) { errMsg = new StorageErrorMessageType("SnapshotInUse", "Snapshot in use", HttpStatus.SC_CONFLICT, msg.getCorrelationId()); errMsg.setCorrelationId(msg.getCorrelationId()); } else { replies.putMessage( new EucalyptusErrorMessageType(muleMsg.getComponentName(), msg, ex.getMessage())); } if (errMsg != null) { replies.putMessage(errMsg); } } catch (Exception e) { LOG.error(e); } }
From source file:com.sun.faban.harness.util.DeployTask.java
/** * Executes the Faban deployment task./*from w w w . j av a2 s. com*/ * @throws BuildException If there is an */ public void execute() throws BuildException { try { // First check the jar file and name if (jarFile == null) throw new BuildException("jar attribute missing for target deploy."); if (!jarFile.isFile()) throw new BuildException("jar file not found."); String jarName = jarFile.getName(); if (!jarName.endsWith(".jar")) throw new BuildException("Jar file name must end with \".jar\""); jarName = jarName.substring(0, jarName.length() - 4); if (jarName.indexOf('.') > -1) throw new BuildException("Jar file name must not have any " + "dots except ending with \".jar\""); // Prepare the parts for the request. ArrayList<Part> params = new ArrayList<Part>(4); if (user != null) params.add(new StringPart("user", user)); if (password != null) params.add(new StringPart("password", password)); if (clearConfig) params.add(new StringPart("clearconfig", "true")); params.add(new FilePart("jarfile", jarFile)); Part[] parts = new Part[params.size()]; parts = params.toArray(parts); // Prepare the post method. PostMethod post = new PostMethod(target + "/deploy"); // Ensure text/plain is the only accept header. post.removeRequestHeader("Accept"); post.setRequestHeader("Accept", "text/plain"); post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); // Execute the multi-part post method. HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(post); StringBuilder b = new StringBuilder(); InputStream respBody = post.getResponseBodyAsStream(); byte[] readBuffer = new byte[8192]; for (;;) { int size = respBody.read(readBuffer); if (size == -1) break; b.append(new String(readBuffer, 0, size)); } String response = b.toString(); // Check status. if (status == HttpStatus.SC_CONFLICT) { handleErrorFlush(response); throw new BuildException( "Benchmark to deploy is currently " + "run or queued to be run. Please clear run queue " + "of this benchmark before deployment"); } else if (status == HttpStatus.SC_NOT_ACCEPTABLE) { handleErrorFlush(response); throw new BuildException( "Benchmark deploy name or deploy " + "file invalid. Deploy file may contain errors. Name " + "must have no '.' and file must have the " + "'.jar' extensions."); } else if (status != HttpStatus.SC_CREATED) { handleOutput(response); throw new BuildException( "Faban responded with status code " + status + ". Status code 201 (SC_CREATED) expected."); } } catch (FileNotFoundException e) { throw new BuildException(e); } catch (HttpException e) { throw new BuildException(e); } catch (IOException e) { throw new BuildException(e); } }
From source file:com.cloud.network.bigswitch.BigSwitchBcfApi.java
private String checkResponse(final HttpMethodBase m, final String errorMessageBase) throws BigSwitchBcfApiException, IllegalArgumentException { String customErrorMsg = null; if (m.getStatusCode() == HttpStatus.SC_OK) { String hash = ""; if (m.getResponseHeader(HASH_MATCH) != null) { hash = m.getResponseHeader(HASH_MATCH).getValue(); set_hash(hash);//from ww w. j av a2s . co m } return hash; } if (m.getStatusCode() == HttpStatus.SC_CONFLICT) { if (m instanceof GetMethod) { return HASH_CONFLICT; } throw new BigSwitchBcfApiException("BCF topology sync required", true); } if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) { isMaster = false; set_hash(HASH_IGNORE); return HASH_IGNORE; } if (m.getStatusCode() == HttpStatus.SC_NOT_FOUND) { if (m instanceof DeleteMethod) { return ""; } } if (m.getStatusCode() == HttpStatus.SC_BAD_REQUEST) { customErrorMsg = " Invalid data in BCF request"; throw new IllegalArgumentException(customErrorMsg); } String errorMessage = responseToErrorMessage(m); m.releaseConnection(); S_LOGGER.error(errorMessageBase + errorMessage); throw new BigSwitchBcfApiException(errorMessageBase + errorMessage + customErrorMsg); }