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:com.netflix.genie.server.resources.ApplicationConfigResource.java
/** * Delete the all configuration files from a given application. * * @param id The id of the application to delete the configuration files * from. Not null/empty/blank. * @return Empty set if successful// ww w.j a v a 2 s . co m * @throws GenieException For any error */ @DELETE @Path("/{id}/configs") @ApiOperation(value = "Remove all configuration files from an application", notes = "Remove all the configuration files from the application with given id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Set<String> removeAllConfigsForApplication( @ApiParam(value = "Id of the application to delete from.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("Called with id " + id); return this.applicationConfigService.removeAllConfigsForApplication(id); }
From source file:co.cask.cdap.client.rest.RestStreamClientTest.java
@Test public void testServerErrorTruncate() throws IOException { try {/*from w w w .j a va 2s.c o m*/ streamClient.truncate(StringUtils.EMPTY); Assert.fail("Expected HttpFailureException"); } catch (HttpFailureException e) { Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, e.getStatusCode()); } }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Add new commands to the given cluster. * * @param id The id of the cluster to add the commands to. Not * null/empty/blank./* www. j a v a 2s . c om*/ * @param commands The commands to add. Not null. * @return The active commands for this cluster. * @throws GenieException For any error */ @POST @Path("/{id}/commands") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Add new commands to a cluster", notes = "Add the supplied commands to the cluster with the supplied id." + " commands should already have been created.", response = Command.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "cluster not found"), @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 List<Command> addCommandsForCluster( @ApiParam(value = "Id of the cluster to add commands to.", required = true) @PathParam("id") final String id, @ApiParam(value = "The commands to add.", required = true) final List<Command> commands) throws GenieException { LOG.info("Called with id " + id + " and commands " + commands); return this.clusterConfigService.addCommandsForCluster(id, commands); }
From source file:com.offbynull.portmapper.upnpigd.UpnpIgdController.java
private Map<String, String> performRequest(String action, ImmutablePair<String, String>... params) { byte[] outgoingData = createRequestXml(action, params); HttpURLConnection conn = null; try {/*from w w w. j ava 2s . c o m*/ URL url = controlUrl.toURL(); conn = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY); conn.setRequestMethod("POST"); conn.setReadTimeout(3000); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "text/xml"); conn.setRequestProperty("SOAPAction", serviceType + "#" + action); conn.setRequestProperty("Connection", "Close"); } catch (IOException ex) { throw new IllegalStateException(ex); // should never happen } try (OutputStream os = conn.getOutputStream()) { os.write(outgoingData); } catch (IOException ex) { IOUtils.close(conn); throw new ResponseException(ex); } byte[] incomingData; int respCode; try { respCode = conn.getResponseCode(); } catch (IOException ioe) { IOUtils.close(conn); throw new ResponseException(ioe); } if (respCode == HttpURLConnection.HTTP_INTERNAL_ERROR) { try (InputStream is = conn.getErrorStream()) { incomingData = IOUtils.toByteArray(is); } catch (IOException ex) { IOUtils.close(conn); throw new ResponseException(ex); } } else { try (InputStream is = conn.getInputStream()) { incomingData = IOUtils.toByteArray(is); } catch (IOException ex) { IOUtils.close(conn); throw new ResponseException(ex); } } return parseResponseXml(action + "Response", incomingData); }
From source file:com.netflix.genie.server.resources.JobResource.java
/** * Delete the all tags from a given job. * * @param id The id of the job to delete the tags from. * Not null/empty/blank./*from w ww. ja v a2 s . co m*/ * @return Empty set if successful * @throws GenieException For any error */ @DELETE @Path("/{id}/tags") @ApiOperation(value = "Remove all tags from a job", notes = "Remove all the tags from the job with given id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Job for id does not exist."), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid id supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Set<String> removeAllTagsForJob( @ApiParam(value = "Id of the job to delete from.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("Called with id " + id); return this.jobService.removeAllTagsForJob(id); }
From source file:rapture.kernel.BlobApiImpl.java
@Override public void putContent(CallingContext context, RaptureURI raptureUri, Object content, String comment) { // Why not just put attribute in BlobContainer headers map? if (raptureUri.hasAttribute()) { throw new UnsupportedOperationException("not yet implemented"); } else if (raptureUri.hasDocPath()) { // TODO: Ben - if (content instanceof BlobContainer && ((BlobContainer) content).getHeaders() != null) { BlobContainer blobContainer = ((BlobContainer) content); putBlob(context, raptureUri.toString(), blobContainer.getContent(), blobContainer.getHeaders().get(ContentEnvelope.CONTENT_TYPE_HEADER)); } else {//from w ww. jav a 2 s . c o m throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, apiMessageCatalog .getMessage("ErrorGettingBlobType", content.getClass().getCanonicalName())); } } else { if (content instanceof BlobRepoConfig) { BlobRepoConfig rbc = (BlobRepoConfig) content; createBlobRepo(context, raptureUri.toString(), rbc.getConfig(), rbc.getMetaConfig()); } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, apiMessageCatalog .getMessage("ErrorGettingBlobType", content.getClass().getCanonicalName())); } } }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Add new tags to a given command./*www. j a v a2s .com*/ * * @param id The id of the command to add the tags to. Not * null/empty/blank. * @param tags The tags to add. Not null/empty/blank. * @return The active tags for this command. * @throws GenieException For any error */ @POST @Path("/{id}/tags") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Add new tags to a command", notes = "Add the supplied tags to the command with the supplied id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"), @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 Set<String> addTagsForCommand( @ApiParam(value = "Id of the command to add configuration to.", required = true) @PathParam("id") final String id, @ApiParam(value = "The tags to add.", required = true) final Set<String> tags) throws GenieException { LOG.info("Called with id " + id + " and tags " + tags); return this.commandConfigService.addTagsForCommand(id, tags); }
From source file:org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.java
private GzipGetMethod connectInternal(String requestURL, boolean gzip, IProgressMonitor monitor, String eTagValue) throws IOException, CoreException { monitor = Policy.monitorFor(monitor); hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); for (int attempt = 0; attempt < 2; attempt++) { // force authentication authenticate(monitor);/* ww w. j ava 2 s. c om*/ GzipGetMethod getMethod = new GzipGetMethod(WebUtil.getRequestPath(requestURL), gzip); if (requestURL.contains(QUERY_DELIMITER)) { getMethod.setQueryString(requestURL.substring(requestURL.indexOf(QUERY_DELIMITER))); } getMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" //$NON-NLS-1$ //$NON-NLS-2$ + getCharacterEncoding()); if (eTagValue != null && eTagValue.compareTo("") != 0) { //$NON-NLS-1$ getMethod.setRequestHeader("If-None-Match", eTagValue); //$NON-NLS-1$ } // Resolves bug#195113 httpClient.getParams().setParameter("http.protocol.single-cookie-header", true); //$NON-NLS-1$ // WARNING!! Setting browser compatibility breaks Bugzilla // authentication // getMethod.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); // getMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2109); getMethod.setDoAuthentication(true); int code; try { code = WebUtil.execute(httpClient, hostConfiguration, getMethod, monitor); } catch (IOException e) { WebUtil.releaseConnection(getMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_IO, repositoryUrl.toString(), e)); } switch (code) { case HttpURLConnection.HTTP_OK: return getMethod; case HttpURLConnection.HTTP_NOT_MODIFIED: WebUtil.releaseConnection(getMethod, monitor); throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, "Not changed")); //$NON-NLS-1$ case HttpURLConnection.HTTP_UNAUTHORIZED: case HttpURLConnection.HTTP_FORBIDDEN: // login or reauthenticate due to an expired session loggedIn = false; WebUtil.releaseConnection(getMethod, monitor); authenticate(monitor); break; case HttpURLConnection.HTTP_PROXY_AUTH: loggedIn = false; WebUtil.releaseConnection(getMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), "Proxy authentication required")); //$NON-NLS-1$ case HttpURLConnection.HTTP_INTERNAL_ERROR: loggedIn = false; InputStream stream = getResponseStream(getMethod, monitor); ByteArrayOutputStream ou = new ByteArrayOutputStream(1024); transferData(stream, ou); WebUtil.releaseConnection(getMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_NETWORK, repositoryUrl.toString(), "Error = 500")); //$NON-NLS-1$ default: WebUtil.releaseConnection(getMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_NETWORK, "Http error: " + HttpStatus.getStatusText(code))); //$NON-NLS-1$ } } throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, "All connection attempts to " + repositoryUrl.toString() //$NON-NLS-1$ + " failed. Please verify connection and authentication information.")); //$NON-NLS-1$ }
From source file:i5.las2peer.services.servicePackage.TemplateService.java
@GET @Path("/graphs/termmatrix") @Produces(MediaType.APPLICATION_JSON)/*from www. j av a 2 s . c o m*/ public HttpResponse getTermMatrix() { Connection conn = null; PreparedStatement stmnt = null; ResultSet rs = null; JSONArray json = new JSONArray(); EntityManagement em = new EntityManagement(); WordConverter wordConv = new WordConverter(); Array2DRowRealMatrix matrix = new Array2DRowRealMatrix(); ToJSON converter = new ToJSON(); Algorithms alg = new Algorithms(); try { // get connection from connection pool conn = dbm.getConnection(); // prepare statement stmnt = conn.prepareStatement("SELECT id,content,author FROM urch order by author;"); // retrieve result set rs = stmnt.executeQuery(); //LinkedList<Node> nodes = em.listNodes(rs); // listing nodes and textpreprocessing of content em.createNodeTable(conn); em.createGraphTable(conn); //persist graph built form dataset Graph graph = em.persistNewGraph(rs, conn); Termmatrix termMat = wordConv.convertTFIDF(graph.getNodes()); //matrix = wordConv.convertTFIDF(nodes); // creating term matrix, computing tf- idf, converting to json array for visualization Clustering clust = alg.optCosts(termMat, 2); em.createCommunityTables(conn); em.createCoverTable(conn); em.persistCover(clust, conn); //json = converter.termmatrixToJson(termMat); //json = converter.termmatrixToJson(matrix); return new HttpResponse("New Cover created from dataset urch and persisted", HttpURLConnection.HTTP_OK); } catch (Exception e) { return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } finally { // free resources if exception or not if (rs != null) { try { rs.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } if (stmnt != null) { try { stmnt.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } if (conn != null) { try { conn.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } } }
From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java
/** * Add new jar files for a given application. * * @param id The id of the application to add the jar file to. Not * null/empty/blank./*w w w .j av a 2 s . c om*/ * @param jars The jar files to add. Not null. * @return The active set of application jars. * @throws GenieException For any error */ @POST @Path("/{id}/jars") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Add new jar files to an application", notes = "Add the supplied jar files to the applicaiton with the supplied id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Set<String> addJarsForApplication( @ApiParam(value = "Id of the application to add jar to.", required = true) @PathParam("id") final String id, @ApiParam(value = "The jar files to add.", required = true) final Set<String> jars) throws GenieException { LOG.info("Called with id " + id + " and jars " + jars); return this.applicationConfigService.addJarsForApplication(id, jars); }