List of usage examples for java.net HttpURLConnection HTTP_BAD_REQUEST
int HTTP_BAD_REQUEST
To view the source code for java.net HttpURLConnection HTTP_BAD_REQUEST.
Click Source Link
From source file:org.eclipse.orion.server.tests.servlets.git.GitCheckoutTest.java
@Test public void testCheckoutEmptyPaths() throws Exception { // clone a repo URI workspaceLocation = createWorkspace(getMethodName()); String workspaceId = workspaceIdFromLocation(workspaceLocation); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null); IPath clonePath = getClonePath(workspaceId, project); clone(clonePath);// ww w. ja v a2 s .c o m // get project metadata WebRequest request = getGetRequest(project.getString(ProtocolConstants.KEY_CONTENT_LOCATION)); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); project = new JSONObject(response.getText()); JSONObject gitSection = project.optJSONObject(GitConstants.KEY_GIT); assertNotNull(gitSection); String gitCloneUri = gitSection.getString(GitConstants.KEY_CLONE); request = getCheckoutRequest(gitCloneUri, new String[] {}); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, response.getResponseCode()); }
From source file:co.cask.cdap.client.rest.RestStreamClientTest.java
@Test public void testBadRequestSetTTL() throws IOException { try {/*from w w w. ja v a 2 s . com*/ streamClient.setTTL(TestUtils.BAD_REQUEST_STREAM_NAME, STREAM_TTL); Assert.fail("Expected HttpFailureException"); } catch (HttpFailureException e) { Assert.assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, e.getStatusCode()); } }
From source file:rapture.kernel.DecisionApiImpl.java
/** * Returns a workflow, or throws a {@link RaptureException} if no workflow exists at the given URI. This should only be used internally by methods that are * intended to modify an existing {@link Workflow} and require it to already be defined *//*from www . j a va2s . co m*/ private Workflow getWorkflowNotNull(CallingContext context, String workflowURI) { Workflow workflow = getWorkflow(context, workflowURI); if (workflow == null) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, String.format("Workflow does not exist: '%s'", workflowURI)); } else { return workflow; } }
From source file:edu.umass.cs.gnsclient.client.http.GNSHTTPProxy.java
private static int translateToHTTPStatusCode(ResponseCode code) { // FIXME: systematically distinguish between client and server errors return HttpURLConnection.HTTP_BAD_REQUEST; }
From source file:org.betaconceptframework.astroboa.resourceapi.resource.TopicResource.java
@PUT @Path("/{topicIdOrName: " + CmsConstants.UUID_OR_SYSTEM_NAME_REG_EXP_FOR_RESTEASY + "}") public Response putTopicByIdOrName(@PathParam("topicIdOrName") String topicIdOrName, String requestContent) { if (StringUtils.isBlank(topicIdOrName)) { logger.warn("Use HTTP PUT to save topic {} but no id or name was provided ", requestContent); throw new WebApplicationException(HttpURLConnection.HTTP_BAD_REQUEST); }//w w w .j av a 2s. c o m return saveTopicByIdOrName(topicIdOrName, requestContent, HttpMethod.PUT); }
From source file:rapture.kernel.DocApiImpl.java
@Override public void archiveRepoDocs(CallingContext context, String docRepoUri, int versionLimit, long timeLimit, Boolean ensureVersionLimit) { RaptureURI internalUri = new RaptureURI(docRepoUri, Scheme.DOCUMENT); checkParameter(NAME, internalUri.getAuthority()); log.info("Archive versions " + internalUri.getFullPath()); Repository repository = getRepoFromCache(internalUri.getAuthority()); if (repository == null) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, apiMessageCatalog.getMessage("NoSuchRepo", internalUri.toAuthString())); //$NON-NLS-1$ } else if (repository instanceof VersionedRepo) { archiveVersionedRepo(context, repository, internalUri, versionLimit, timeLimit, ensureVersionLimit); } else if (repository instanceof NVersionedRepo) { archiveNVersionedRepo(context, repository, internalUri, versionLimit, timeLimit, ensureVersionLimit); } else {/*w w w. j a v a 2 s. c o m*/ throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, apiMessageCatalog.getMessage("ArchiveUnsupported", repository.getClass().getSimpleName())); //$NON-NLS-1$ } }
From source file:org.intermine.webservice.client.util.HttpConnection.java
/** * Handles an error response received while executing a service request. * Throws a {@link ServiceException} or one of its subclasses, depending on * the failure conditions.//from w w w .j a v a2 s .c o m * * @throws ServiceException exception describing the failure. * @throws IOException error reading the error response from the * service. */ protected void handleErrorResponse() throws IOException { String message = executedMethod.getResponseBodyAsString(); try { JSONObject jo = new JSONObject(message); message = jo.getString("error"); } catch (JSONException e) { // Pass } switch (executedMethod.getStatusCode()) { case HttpURLConnection.HTTP_NOT_FOUND: throw new ResourceNotFoundException(this); case HttpURLConnection.HTTP_BAD_REQUEST: if (message != null) { throw new BadRequestException(message); } else { throw new BadRequestException(this); } case HttpURLConnection.HTTP_FORBIDDEN: if (message != null) { throw new ServiceForbiddenException(message); } else { throw new ServiceForbiddenException(this); } case HttpURLConnection.HTTP_NOT_IMPLEMENTED: throw new NotImplementedException(this); case HttpURLConnection.HTTP_INTERNAL_ERROR: if (message != null) { throw new InternalErrorException(message); } else { throw new InternalErrorException(this); } case HttpURLConnection.HTTP_UNAVAILABLE: throw new ServiceUnavailableException(this); default: if (message != null) { throw new ServiceException(message); } else { throw new ServiceException(this); } } }
From source file:rapture.repo.file.FileDataStore.java
@Override public RaptureQueryResult runNativeQuery(String repoType, List<String> queryParams) { if (repoType.toUpperCase().equals("FILE")) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Not yet implemented"); } else {/*from ww w . ja v a 2 s .c om*/ throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, "RepoType mismatch. Repo is of type FILE, asked for " + repoType); } }
From source file:rapture.kernel.DecisionApiImpl.java
private Workflow getWorkflowNotNull(CallingContext context, RaptureURI uri) { Workflow workflow = getWorkflow(uri); if (workflow == null) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, String.format("Workflow does not exist: '%s'", uri.toString())); } else {/*from w w w .ja v a2s . co m*/ return workflow; } }
From source file:org.eclipse.hono.service.registration.BaseRegistrationService.java
private Future<EventBusMessage> processAssertRequest(final EventBusMessage request) { final String tenantId = request.getTenant(); final String deviceId = request.getDeviceId(); final String gatewayId = request.getGatewayId(); if (tenantId == null || deviceId == null) { return Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST)); } else if (gatewayId == null) { log.debug("asserting registration of device [{}] with tenant [{}]", deviceId, tenantId); final Future<RegistrationResult> result = Future.future(); assertRegistration(tenantId, deviceId, result.completer()); return result.map(res -> { return request.getResponse(res.getStatus()).setDeviceId(deviceId).setJsonPayload(res.getPayload()) .setCacheDirective(res.getCacheDirective()); });/*from w ww .j a v a 2s . c o m*/ } else { log.debug("asserting registration of device [{}] with tenant [{}] for gateway [{}]", deviceId, tenantId, gatewayId); final Future<RegistrationResult> result = Future.future(); assertRegistration(tenantId, deviceId, gatewayId, result.completer()); return result.map(res -> { return request.getResponse(res.getStatus()).setDeviceId(deviceId).setJsonPayload(res.getPayload()) .setCacheDirective(res.getCacheDirective()); }); } }