List of usage examples for java.net HttpURLConnection HTTP_INTERNAL_ERROR
int HTTP_INTERNAL_ERROR
To view the source code for java.net HttpURLConnection HTTP_INTERNAL_ERROR.
Click Source Link
From source file:nz.skytv.example.SwaggerApplication.java
@ApiOperation(value = "Create a book", notes = "Create a book.", response = Book.class, tags = { "book", "updates" }) @ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Book created successfully"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Something really bad happened") }) @RequestMapping(value = { "/rest/book" }, method = RequestMethod.POST, consumes = "application/json") ResponseEntity<Void> createBook( @ApiParam(value = "Book entity", required = true) @RequestBody @Valid final Book book) { LOG.debug("create {}", book); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:i5.las2peer.services.loadStoreGraphService.LoadStoreGraphService.java
/** * // ww w .j a va 2 s . co m * getGraphList * * * @return HttpResponse * */ @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.TEXT_PLAIN) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "internalError"), @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "graphListAsJsonArray"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "noGraphExists") }) @ApiOperation(value = "getGraphList", notes = "") public HttpResponse getGraphList() { String result = ""; String columnName = ""; String selectquery = ""; int columnCount = 0; Connection conn = null; PreparedStatement stmnt = null; ResultSet rs = null; ResultSetMetaData rsmd = null; JSONObject ro = null; JSONArray graphList = new JSONArray(); try { // get connection from connection pool conn = dbm.getConnection(); selectquery = "SELECT graphId, description FROM graphs;"; // prepare statement stmnt = conn.prepareStatement(selectquery); // retrieve result set rs = stmnt.executeQuery(); rsmd = (ResultSetMetaData) rs.getMetaData(); columnCount = rsmd.getColumnCount(); // process result set while (rs.next()) { ro = new JSONObject(); for (int i = 1; i <= columnCount; i++) { result = rs.getString(i); columnName = rsmd.getColumnName(i); // setup resulting JSON Object ro.put(columnName, result); } graphList.add(ro); } if (graphList.isEmpty()) { String er = "No results"; HttpResponse noGraphExists = new HttpResponse(er, HttpURLConnection.HTTP_NOT_FOUND); return noGraphExists; } else { // return HTTP Response on success HttpResponse graphListAsJsonArray = new HttpResponse(graphList.toJSONString(), HttpURLConnection.HTTP_OK); return graphListAsJsonArray; } } catch (Exception e) { String er = "Internal error: " + e.getMessage(); HttpResponse internalError = new HttpResponse(er, HttpURLConnection.HTTP_INTERNAL_ERROR); return internalError; } finally { // free resources if (rs != null) { try { rs.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); String er = "Internal error: " + e.getMessage(); HttpResponse internalError = new HttpResponse(er, HttpURLConnection.HTTP_INTERNAL_ERROR); return internalError; } } if (stmnt != null) { try { stmnt.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); String er = "Internal error: " + e.getMessage(); HttpResponse internalError = new HttpResponse(er, HttpURLConnection.HTTP_INTERNAL_ERROR); return internalError; } } if (conn != null) { try { conn.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); String er = "Internal error: " + e.getMessage(); HttpResponse internalError = new HttpResponse(er, HttpURLConnection.HTTP_INTERNAL_ERROR); return internalError; } } } }
From source file:org.takes.http.FtSecureTest.java
/** * FtSecure can gracefully work with a broken back. * @throws Exception If some problem inside *//*from w w w . j a v a2s . c om*/ @Test public void gracefullyHandlesBrokenBack() throws Exception { FtSecureTest.secure(new TkFailure("Jeffrey Lebowski")).exec(new FtRemote.Script() { @Override public void exec(final URI home) throws IOException { new JdkRequest(home).fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_INTERNAL_ERROR) .assertBody(Matchers.containsString("Lebowski")); } }); }
From source file:rapture.blob.file.FileBlobStore.java
@Override public Boolean storeBlob(CallingContext context, RaptureURI blobUri, Boolean append, InputStream content) { if (createSymLink) { // the display name is either a RaptureURI's docPath or docPathWithElement // if the display name contains an element (starts with #), then that element is the local file path // create a sym link to that local path //// w w w .jav a2 s .c o m // an example blobUri will be like // app/admin/blob.html#/Curtis/CurtisAdmin/FEATURE/content/curtisweb/app/admin/blob.html int index = blobUri.getDocPathWithElement().indexOf("#"); if (index > -1) { String filePath = blobUri.getDocPathWithElement().substring(index + 1); String docPath = blobUri.getDocPathWithElement().substring(0, index); return createSymLink(docPath, filePath); } } try { File f = FileRepoUtils.makeGenericFile(parentDir, blobUri.getDocPathWithElement() + Parser.COLON_CHAR); // Should be impossible if (f.isDirectory()) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, f.getCanonicalPath() + " exists and is a directory"); FileUtils.forceMkdir(f.getParentFile()); try (FileOutputStream fos = new FileOutputStream(f, append)) { IOUtils.copy(content, fos); fos.close(); // this shouldn't be necessary; the try is supposed to close it. } } catch (IOException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error storing blob into file", e); } return true; }
From source file:org.eclipse.hono.client.impl.TenantClientImpl.java
@Override protected final TenantResult<TenantObject> getResult(final int status, final String payload, final CacheDirective cacheDirective) { if (payload == null) { return TenantResult.from(status); } else {// w w w . j a va 2 s .c o m try { return TenantResult.from(status, OBJECT_MAPPER.readValue(payload, TenantObject.class), cacheDirective); } catch (final IOException e) { LOG.warn("received malformed payload from Tenant service", e); return TenantResult.from(HttpURLConnection.HTTP_INTERNAL_ERROR); } } }
From source file:rapture.kernel.schedule.CronParser.java
private static Set<Integer> fillRange(int start, int end) { if (start > end) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Range in reverse"); }//w w w. j a va 2 s . co m Set<Integer> ret = new HashSet<Integer>(); for (int i = start; i <= end; i++) { ret.add(i); } return ret; }
From source file:org.jboss.test.web.test.CustomErrorsUnitTestCase.java
/** Test that the custom 500 error page is seen for an exception * /*from ww w . j a v a2 s . c o m*/ * @throws Exception */ public void testExceptionError() throws Exception { log.info("+++ testExceptionError"); URL url = new URL(baseURLNoAuth + "error-producer/ErrorGeneratorServlet"); HttpMethodBase request = HttpUtils.accessURL(url, "Realm", HttpURLConnection.HTTP_INTERNAL_ERROR); Header page = request.getResponseHeader("X-CustomErrorPage"); log.info("X-CustomErrorPage: " + page); assertTrue("X-CustomErrorPage(" + page + ") is 500.jsp", page.getValue().equals("500.jsp")); Header errors = request.getResponseHeader("X-ExceptionType"); log.info("X-ExceptionType: " + errors); assertTrue("X-ExceptionType(" + errors + ") is 500.jsp", errors.getValue().equals("java.lang.IllegalStateException")); }
From source file:rapture.common.RaptureURI.java
public RaptureURI(String documentURI, Scheme defaultScheme) { if ("//".equals(documentURI) || "/".equals(documentURI) || "".equals(documentURI) || documentURI == null) { this.scheme = defaultScheme; this.authority = ""; } else/*from ww w .j a v a 2s . c o m*/ try { Parser parser = new Parser(documentURI, defaultScheme); parser.parse(); this.scheme = parser.getScheme(); this.authority = parser.getAuthority(); this.docPath = parser.getDocPath(); this.version = parser.getVersion(); this.asOfTime = parser.getAsOfTime(); this.element = parser.getElement(); this.attribute = parser.getAttribute(); } catch (URISyntaxException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format("Unable to parse URI %s: %s", documentURI, e.getMessage()), e); } }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Create a Command configuration./* w w w . ja v a 2s . c o m*/ * * @param command The command configuration to create * @return The command created * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create a command", notes = "Create a command from the supplied information.", response = Command.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Created", response = Command.class), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "A command with the supplied id already exists"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response createCommand( @ApiParam(value = "The command to create.", required = true) final Command command) throws GenieException { LOG.info("called to create new command configuration " + command.toString()); final Command createdCommand = this.commandConfigService.createCommand(command); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdCommand.getId()).build()) .entity(createdCommand).build(); }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Create cluster configuration.//from w w w.jav a2 s . c om * * @param cluster contains the cluster information to create * @return The created cluster * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create a cluster", notes = "Create a cluster from the supplied information.", response = Cluster.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Created", response = Cluster.class), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "A cluster with the supplied id already exists"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response createCluster( @ApiParam(value = "The cluster to create.", required = true) final Cluster cluster) throws GenieException { LOG.info("Called to create new cluster " + cluster); final Cluster createdCluster = this.clusterConfigService.createCluster(cluster); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdCluster.getId()).build()) .entity(createdCluster).build(); }