List of usage examples for java.net HttpURLConnection HTTP_NOT_FOUND
int HTTP_NOT_FOUND
To view the source code for java.net HttpURLConnection HTTP_NOT_FOUND.
Click Source Link
From source file:org.betaconceptframework.astroboa.resourceapi.resource.TaxonomyResource.java
private String retrieveTaxonomyXMLorJSONByIdOrSystemName(String taxonomyIdOrName, Output output, String prettyPrint, FetchLevel fetchLevel) { if (StringUtils.isBlank(taxonomyIdOrName)) { logger.warn("The provided Taxonomy IdOrName {} is Blank ", taxonomyIdOrName); throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); }/* w w w. j a va 2 s. com*/ //Default output is XML if (output == null) { output = Output.XML; } //Default fetch level is ENTITY_CHILDREN if (fetchLevel == null) { fetchLevel = FetchLevel.ENTITY_AND_CHILDREN; } boolean prettyPrintEnabled = ContentApiUtils.isPrettyPrintEnabled(prettyPrint); switch (output) { case XML: { String taxonomyXML = astroboaClient.getTaxonomyService().getTaxonomy(taxonomyIdOrName, ResourceRepresentationType.XML, fetchLevel, prettyPrintEnabled); if (StringUtils.isBlank(taxonomyXML)) { throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); } return taxonomyXML; } case JSON: { String taxonomyJSON = astroboaClient.getTaxonomyService().getTaxonomy(taxonomyIdOrName, ResourceRepresentationType.JSON, fetchLevel, prettyPrintEnabled); if (StringUtils.isBlank(taxonomyJSON)) { throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); } return taxonomyJSON; } default: { String taxonomyXML = astroboaClient.getTaxonomyService().getTaxonomy(taxonomyIdOrName, ResourceRepresentationType.XML, fetchLevel, prettyPrintEnabled); if (StringUtils.isBlank(taxonomyXML)) { throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); } return taxonomyXML; } } }
From source file:com.google.wave.api.AbstractRobot.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { this.request = req; String path = req.getRequestURI(); if (path.equals(PROFILE_PATH)) { processProfile(req, resp);//from w w w.j a v a 2 s .c om } else if (path.equals(CAPABILITIES_PATH)) { processCapabilities(req, resp); } else if (path.equals(VERIFY_TOKEN_PATH)) { processVerifyToken(req, resp); } else { resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND); } }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Get all the clusters this command is associated with. * * @param id The id of the command to get the clusters for. Not * NULL/empty/blank./*from w w w .ja va2 s . c om*/ * @param statuses The statuses of the clusters to get * @return The list of clusters. * @throws GenieException For any error */ @GET @Path("/{id}/clusters") @ApiOperation(value = "Get the clusters this command is associated with", notes = "Get the clusters which this command exists on supports.", response = Cluster.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 List<Cluster> getClustersForCommand( @ApiParam(value = "Id of the command to get the clusters for.", required = true) @PathParam("id") final String id, @ApiParam(value = "Status of the cluster.", allowableValues = "UP, OUT_OF_SERVICE, TERMINATED") @QueryParam("status") final Set<String> statuses) throws GenieException { LOG.info("Called with id " + id + " and statuses " + statuses); Set<ClusterStatus> enumStatuses = null; if (!statuses.isEmpty()) { enumStatuses = EnumSet.noneOf(ClusterStatus.class); for (final String status : statuses) { if (StringUtils.isNotBlank(status)) { enumStatuses.add(ClusterStatus.parse(status)); } } } return this.commandConfigService.getClustersForCommand(id, enumStatuses); }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Update the tags for a given cluster.//from w ww .j ava 2 s .c o m * * @param id The id of the cluster to update the tags for. * Not null/empty/blank. * @param tags The tags to replace existing configuration * files with. Not null/empty/blank. * @return The new set of cluster tags. * @throws GenieException For any error */ @PUT @Path("/{id}/tags") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Update tags for a cluster", notes = "Replace the existing tags for cluster with given id.", response = String.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 Set<String> updateTagsForCluster( @ApiParam(value = "Id of the cluster to update tags for.", required = true) @PathParam("id") final String id, @ApiParam(value = "The tags to replace existing with.", required = true) final Set<String> tags) throws GenieException { LOG.info("Called with id " + id + " and tags " + tags); return this.clusterConfigService.updateTagsForCluster(id, tags); }
From source file:ORG.oclc.os.SRW.SRWServlet.java
/** * respond to the ?list command.// ww w . java 2 s . c o m * if enableList is set, we list the engine config. If it isnt, then an * error is written out * @param response * @throws AxisFault, IOException */ protected void processListRequest(HttpServletResponse response) throws AxisFault, IOException { AxisEngine engine = getEngine(); if (enableList) { Document doc = Admin.listConfig(engine); if (doc != null) { response.setContentType("text/xml"); PrintWriter writer = response.getWriter(); XMLUtils.DocumentToWriter(doc, writer); writer.close(); } else { //error code is 404 response.setStatus(HttpURLConnection.HTTP_NOT_FOUND); response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.println("<h2>" + Messages.getMessage("error00") + "</h2>"); writer.println("<p>" + Messages.getMessage("noDeploy00") + "</p>"); writer.close(); } } else { // list not enable, return error //error code is, what, 401 response.setStatus(HttpURLConnection.HTTP_FORBIDDEN); response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.println("<h2>" + Messages.getMessage("error00") + "</h2>"); writer.println("<p><i>?list</i> " + Messages.getMessage("disabled00") + "</p>"); writer.close(); } }
From source file:org.eclipse.orion.server.tests.servlets.git.GitConfigTest.java
@Test public void testGetConfigEntryForNonExistingRepository() throws Exception { URI workspaceLocation = createWorkspace(getMethodName()); String workspaceId = getWorkspaceId(workspaceLocation); JSONArray clonesArray = listClones(workspaceId, null); String dummyId = "dummyId"; GitCloneTest.ensureCloneIdDoesntExist(clonesArray, dummyId); String entryLocation = SERVER_LOCATION + GIT_SERVLET_LOCATION + ConfigOption.RESOURCE + "/dummyKey/" + Clone.RESOURCE + "/file/" + dummyId; // get value of config entry WebRequest request = getGetGitConfigRequest(entryLocation); WebResponse response = webConversation.getResponse(request); assertEquals(response.getResponseMessage(), HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode()); }
From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java
/** * Delete the all tags from a given application. * * @param id The id of the application to delete the tags from. * Not null/empty/blank./*from w ww . j av a2 s . c om*/ * @return Empty set if successful * @throws GenieException For any error */ @DELETE @Path("/{id}/tags") @ApiOperation(value = "Remove all tags from a application", notes = "Remove all the tags from the application with given id. Note that the genie name space tags" + "prefixed with genie.id and genie.name cannot be deleted.", 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> removeAllTagsForApplication( @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.removeAllTagsForApplication(id); }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Delete the all tags from a given cluster. * * @param id The id of the cluster to delete the tags from. * Not null/empty/blank./*from w ww .j a v a 2s .c o m*/ * @return Empty set if successful * @throws GenieException For any error */ @DELETE @Path("/{id}/tags") @ApiOperation(value = "Remove all tags from a cluster", notes = "Remove all the tags from the cluster with given id. Note that the genie name space tags" + "prefixed with genie.id and genie.name cannot be deleted.", response = String.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 Set<String> removeAllTagsForCluster( @ApiParam(value = "Id of the cluster to delete from.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("Called with id " + id); return this.clusterConfigService.removeAllTagsForCluster(id); }
From source file:ORG.oclc.os.SRW.SRWServlet.java
/** * report that we have no WSDL/*from ww w. j av a2 s .c om*/ * @param res * @param moreDetailCode optional name of a message to provide more detail * @param axisFault optional fault string, for extra info at debug time only */ protected void reportNoWSDL(HttpServletResponse res, String moreDetailCode, AxisFault axisFault) throws IOException { res.setStatus(HttpURLConnection.HTTP_NOT_FOUND); res.setContentType("text/html"); PrintWriter writer = res.getWriter(); writer.println("<h2>" + Messages.getMessage("error00") + "</h2>"); writer.println("<p>" + Messages.getMessage("noWSDL00") + "</p>"); if (moreDetailCode != null) { writer.println("<p>" + Messages.getMessage(moreDetailCode) + "</p>"); } if (axisFault != null && isDevelopment()) { //dev systems only give fault dumps writeFault(writer, axisFault); } writer.close(); }
From source file:org.betaconceptframework.astroboa.resourceapi.resource.ContentObjectResource.java
private Response getContentObjectByIdOrName(String contentObjectIdOrSystemName, String commaDelimitedProjectionPaths, Output output, String callback, boolean prettyPrint) { if (StringUtils.isBlank(contentObjectIdOrSystemName)) { logger.warn("No contentObjectId provided"); throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); }/*from w ww . j a v a 2 s. c o m*/ Date lastModified = null; String contentObjectXmlorJson = retrieveContentObjectXMLorJSONByIdOrSystemName(contentObjectIdOrSystemName, commaDelimitedProjectionPaths, output, lastModified, prettyPrint); if (StringUtils.isBlank(contentObjectXmlorJson)) { throw new WebApplicationException(HttpURLConnection.HTTP_NOT_FOUND); } try { StringBuilder resourceRepresentation = new StringBuilder(); if (StringUtils.isBlank(callback)) { resourceRepresentation.append(contentObjectXmlorJson); } else { switch (output) { case XML: { ContentApiUtils.generateXMLP(resourceRepresentation, contentObjectXmlorJson, callback); break; } case JSON: ContentApiUtils.generateJSONP(resourceRepresentation, contentObjectXmlorJson, callback); break; } } return ContentApiUtils.createResponse(resourceRepresentation, output, callback, lastModified); } catch (Exception e) { logger.error("ContentObejct id/name " + contentObjectIdOrSystemName, e); throw new WebApplicationException(HttpURLConnection.HTTP_BAD_REQUEST); } }