List of usage examples for java.net HttpURLConnection HTTP_CONFLICT
int HTTP_CONFLICT
To view the source code for java.net HttpURLConnection HTTP_CONFLICT.
Click Source Link
From source file:org.eclipse.mylyn.internal.gerrit.core.client.GerritClient.java
private ChangeDetail submitRest(PatchSet.Id id, IProgressMonitor monitor) throws GerritException { final String uri = "/a/changes/" + id.getParentKey().get() + "/revisions/" + id.get() + "/submit"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ executePostRestRequest(uri, new SubmitInput(true), SubmitInfo.class, new ErrorHandler() { @Override//w ww .j a v a 2 s . com public void handleError(HttpMethodBase method) throws GerritException { String errorMsg = getResponseBodyAsString(method); if (isNotPermitted(method, errorMsg) || isConflict(method)) { throw new GerritException(NLS.bind("Cannot submit change: {0}", errorMsg)); //$NON-NLS-1$ } } private String getResponseBodyAsString(HttpMethodBase method) { try { return method.getResponseBodyAsString(); } catch (IOException e) { return null; } } private boolean isNotPermitted(HttpMethodBase method, String msg) { return method.getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN && "submit not permitted\n".equals(msg); //$NON-NLS-1$ } private boolean isConflict(HttpMethodBase method) { return method.getStatusCode() == HttpURLConnection.HTTP_CONFLICT; } }, monitor); return getChangeDetail(id.getParentKey().get(), monitor); }