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:org.jboss.test.web.test.CustomErrorsUnitTestCase.java
/** Test that the custom 500 error page is seen * /* w w w .jav a2s . c o m*/ * @throws Exception */ public void test500Error() throws Exception { log.info("+++ test500Error"); int errorCode = HttpURLConnection.HTTP_INTERNAL_ERROR; URL url = new URL(baseURLNoAuth + "error-producer/ErrorGeneratorServlet?errorCode=" + errorCode); HttpMethodBase request = HttpUtils.accessURL(url, "Realm", HttpURLConnection.HTTP_INTERNAL_ERROR); Header errors = request.getResponseHeader("X-CustomErrorPage"); log.info("X-CustomErrorPage: " + errors); assertTrue("X-CustomErrorPage(" + errors + ") is 500.jsp", errors.getValue().equals("500.jsp")); }
From source file:nz.skytv.example.SwaggerApplication.java
@RequestMapping(value = { "/rest/books" }, method = RequestMethod.GET) @ApiOperation(value = "Retrieve the list of books", notes = "Retrieve books.", response = Book.class, tags = { "book", "searches" }) @ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Books retrieved successfully"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Something really bad happened") }) List<Book> findBooksByIsbn(final String isbn) { LOG.debug("findBy {}", isbn); return Arrays.asList(new Book()); }
From source file:rapture.table.file.FileIndexHandler.java
private void initUpdatesStream() { try {//from w ww. j a v a 2s. c o m if (updatesStream != null) { updatesStream.close(); } Boolean append = true; updatesStream = new FileOutputStream(persistenceFile, append); } catch (IOException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error (re)initializing index file stream", e); } }
From source file:i5.las2peer.services.videoListService.VideoListService.java
/** * // www . j a va2 s . c o m * getVideoList * * * @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 = "videoListAsJSONArray"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "noVideosExist") }) @ApiOperation(value = "getVideoList", notes = "") public HttpResponse getVideoList() { 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 array = new JSONArray(); try { // get connection from connection pool conn = dbm.getConnection(); selectquery = "SELECT * FROM videodetails;"; // 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); } array.add(ro); } if (array.isEmpty()) { String er = "No results"; HttpResponse noVideosExist = new HttpResponse(er, HttpURLConnection.HTTP_NOT_FOUND); return noVideosExist; } else { // return HTTP Response on success HttpResponse videoListAsJSONArray = new HttpResponse(array.toJSONString(), HttpURLConnection.HTTP_OK); return videoListAsJSONArray; } } 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:rapture.kernel.plugin.SeriesEncoder.java
@Override public PluginTransportItem encode(CallingContext ctx, String uri) { try {//ww w. ja va 2 s. co m PluginTransportItem item = new PluginTransportItem(); MessageDigest md = MessageDigest.getInstance("MD5"); if (isRepository(uri)) { SeriesRepoConfig config = Kernel.getSeries().getSeriesRepoConfig(ctx, uri); byte[] content = JacksonUtil.bytesJsonFromObject(config); item.setContent(content); } else { StringBuilder buf = new StringBuilder(); SeriesApi api = Kernel.getSeries(); for (SeriesPoint val : api.getPoints(ctx, uri)) { // TODO MEL encapsulate newlines in data value buf.append(val.getColumn()); buf.append(","); buf.append(val.getValue()); buf.append("\n"); } item.setContent(buf.toString().getBytes(Charsets.UTF_8)); } md.update(item.getContent()); item.setHash(Hex.encodeHexString(md.digest())); item.setUri(uri); return item; } catch (NoSuchAlgorithmException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error encoding series", e); } }
From source file:org.takes.http.FtBasicTest.java
/** * FtBasic can work with a broken back.//from w w w .ja va2s. c o m * @throws Exception If some problem inside */ @Test public void gracefullyHandlesBrokenBack() throws Exception { new FtRemote(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:com.adaptris.http.legacy.HttpResponseProducer.java
/** * @see Object#Object()//from w ww .j a v a 2 s . com * */ public HttpResponseProducer() { super(); httpResponseCode = HttpURLConnection.HTTP_INTERNAL_ERROR; httpResponseText = "Internal Error"; setAdditionalHeaders(new KeyValuePairSet()); setContentTypeKey(null); }
From source file:org.opendaylight.plugin2oc.neutron.SubnetHandler.java
/** * Invoked when a subnet creation is requested to check if the specified * subnet can be created./*from w w w . ja va2 s .c o m*/ * * @param subnet * An instance of proposed new Neutron Subnet object. * * @return A HTTP status code to the creation request. **/ @Override public int canCreateSubnet(NeutronSubnet subnet) { VirtualNetwork virtualnetwork = new VirtualNetwork(); apiConnector = Activator.apiConnector; if (subnet == null) { LOGGER.error("Neutron Subnet can't be null.."); return HttpURLConnection.HTTP_BAD_REQUEST; } if (subnet.getCidr() == null || ("").equals(subnet.getCidr())) { LOGGER.info("Subnet Cidr can not be empty or null..."); return HttpURLConnection.HTTP_BAD_REQUEST; } boolean isvalidGateway = validGatewayIP(subnet, subnet.getGatewayIP()); if (!isvalidGateway) { LOGGER.error("Incorrect gateway IP...."); return HttpURLConnection.HTTP_BAD_REQUEST; } try { virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID()); } catch (IOException e) { e.printStackTrace(); LOGGER.error("Exception : " + e); return HttpURLConnection.HTTP_INTERNAL_ERROR; } if (virtualnetwork == null) { LOGGER.error("No network exists for the specified UUID..."); return HttpURLConnection.HTTP_FORBIDDEN; } else { try { boolean ifSubnetExist = isSubnetPresent(subnet, virtualnetwork); if (ifSubnetExist) { LOGGER.error("The subnet already exists.."); return HttpURLConnection.HTTP_FORBIDDEN; } } catch (Exception e) { e.printStackTrace(); LOGGER.error("Exception: " + e); return HttpURLConnection.HTTP_INTERNAL_ERROR; } } return HttpURLConnection.HTTP_OK; }
From source file:rapture.table.file.FileIndexHandler.java
protected void finalize() { try {/*from w ww . j a va 2 s . c o m*/ if (updatesStream != null) { updatesStream.close(); } } catch (IOException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error closing index file stream", e); } }
From source file:rapture.structured.StructuredFactory.java
private static StructuredStore getStructuredStore(String className, String instance, Map<String, String> config, String authority) {/*ww w. jav a 2s .c o m*/ try { Class<?> repoClass = Class.forName(className); Object fStore; fStore = repoClass.newInstance(); if (fStore instanceof StructuredStore) { StructuredStore ret = (StructuredStore) fStore; ret.setInstance(instance); ret.setConfig(config, authority); return ret; } else { String message = (className + " is not a repo, cannot instantiate"); throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, message); } } catch (InstantiationException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "InstantiationException. Error creating structured store of type " + className, e); } catch (IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "IllegalAccessException. Error creating structured store of type " + className, e); } catch (ClassNotFoundException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "ClassNotFoundException. Error creating structured store of type " + className + ": " + e.toString()); } }