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:com.netflix.genie.server.resources.JobResource.java
/** * Get job information for given job id. * * @param id id for job to look up//from w w w . j a v a 2 s. c om * @return the Job * @throws GenieException For any error */ @GET @Path("/{id}") @ApiOperation(value = "Find a job by id", notes = "Get the job by id if it exists", response = Job.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Job 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 Job getJob(@ApiParam(value = "Id of the job to get.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("called for job with id: " + id); return this.jobService.getJob(id); }
From source file:com.scvngr.levelup.core.net.LevelUpResponseTest.java
/** * Tests {@link com.scvngr.levelup.core.net.LevelUpResponse#mapStatus(int, String)}. */// w w w.j a v a 2 s . c o m @SmallTest public void testMapStatusHttp_errorCodeNotFound() { assertEquals(LevelUpStatus.ERROR_NOT_FOUND, LevelUpResponse.mapStatus(HttpURLConnection.HTTP_NOT_FOUND, SERVER_LEVELUP_PLATFORM)); }
From source file:com.datos.vfs.provider.http.HttpFileObject.java
/** * Determines the type of this file. Must not return null. The return * value of this method is cached, so the implementation can be expensive. *//* w w w . ja v a 2 s . c o m*/ @Override protected FileType doGetType() throws Exception { // Use the HEAD method to probe the file. final int status = this.getHeadMethod().getStatusCode(); if (status == HttpURLConnection.HTTP_OK || status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) { return FileType.FILE; } else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) { return FileType.IMAGINARY; } else { throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status)); } }
From source file:nl.ru.cmbi.vase.web.rest.JobRestResource.java
@MethodMapping(value = "/status/{jobid}", httpMethod = HttpMethod.GET, produces = RestMimeTypes.TEXT_PLAIN) public String status(String jobid) { if (Config.isXmlOnly() || !Config.hsspPdbCacheEnabled()) { log.warn("rest/status was requested, but not enabled"); // hssp job submission is not allowed if hssp is turned off throw new AbortWithHttpErrorCodeException(HttpURLConnection.HTTP_NOT_FOUND); }//from w ww . ja va 2 s . co m try { URL url = new URL(hsspRestURL + "/status/pdb_file/hssp_stockholm/" + jobid + "/"); StringWriter writer = new StringWriter(); IOUtils.copy(url.openStream(), writer); writer.close(); JSONObject output = new JSONObject(writer.toString()); return output.getString("status"); } catch (Exception e) { log.error(e.getMessage(), e); throw new AbortWithHttpErrorCodeException(HttpURLConnection.HTTP_INTERNAL_ERROR); } }
From source file:i5.las2peer.services.userManagement.UserManagement.java
/** * /*w w w . ja va2s .co m*/ * updateUser * * * @return HttpResponse * */ @PUT @Path("/update") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.TEXT_PLAIN) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "userNotFound"), @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "updated"), @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "malformedUpdate") }) @ApiOperation(value = "updateUser", notes = "") public HttpResponse updateUser() { // userNotFound boolean userNotFound_condition = true; if (userNotFound_condition) { String error = "Some String"; HttpResponse userNotFound = new HttpResponse(error, HttpURLConnection.HTTP_NOT_FOUND); return userNotFound; } // updated boolean updated_condition = true; if (updated_condition) { JSONObject updatedUser = new JSONObject(); HttpResponse updated = new HttpResponse(updatedUser.toJSONString(), HttpURLConnection.HTTP_OK); return updated; } // malformedUpdate boolean malformedUpdate_condition = true; if (malformedUpdate_condition) { String error = "Some String"; HttpResponse malformedUpdate = new HttpResponse(error, HttpURLConnection.HTTP_BAD_REQUEST); return malformedUpdate; } return null; }
From source file:org.apache.hadoop.yarn.server.webproxy.TestWebAppProxyServlet.java
@Test(timeout = 5000) public void testWebAppProxyServlet() throws Exception { Configuration configuration = new Configuration(); configuration.set(YarnConfiguration.PROXY_ADDRESS, "localhost:9090"); // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS configuration.setInt("hadoop.http.max.threads", 5); WebAppProxyServerForTest proxy = new WebAppProxyServerForTest(); proxy.init(configuration);/*w w w .j a v a 2 s . c om*/ proxy.start(); int proxyPort = proxy.proxy.proxyServer.getConnectorAddress(0).getPort(); AppReportFetcherForTest appReportFetcher = proxy.proxy.appReportFetcher; // wrong url try { // wrong url. Set wrong app ID URL wrongUrl = new URL("http://localhost:" + proxyPort + "/proxy/app"); HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl.openConnection(); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, proxyConn.getResponseCode()); // set true Application ID in url URL url = new URL("http://localhost:" + proxyPort + "/proxy/application_00_0"); proxyConn = (HttpURLConnection) url.openConnection(); // set cookie proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); assertTrue(isResponseCookiePresent(proxyConn, "checked_application_0_0000", "true")); // cannot found application 1: null appReportFetcher.answer = 1; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, proxyConn.getResponseCode()); assertFalse(isResponseCookiePresent(proxyConn, "checked_application_0_0000", "true")); // cannot found application 2: ApplicationNotFoundException appReportFetcher.answer = 4; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, proxyConn.getResponseCode()); assertFalse(isResponseCookiePresent(proxyConn, "checked_application_0_0000", "true")); // wrong user appReportFetcher.answer = 2; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); String s = readInputStream(proxyConn.getInputStream()); assertTrue(s.contains("to continue to an Application Master web interface owned by")); assertTrue(s.contains("WARNING: The following page may not be safe!")); //case if task has a not running status appReportFetcher.answer = 3; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); } finally { proxy.close(); } }
From source file:com.scvngr.levelup.core.net.LevelUpResponseTest.java
/** * Tests {@link com.scvngr.levelup.core.net.LevelUpResponse#mapStatus(int, String)}. 404s should * be treated as generic server failures if the response is coming from a server other than * LevelUp Platform.//from w w w . ja v a2s .c o m */ @SmallTest public void testMapStatusHttp_errorCodeNotFound_notFromPlatform() { assertEquals(LevelUpStatus.ERROR_SERVER, LevelUpResponse.mapStatus(HttpURLConnection.HTTP_NOT_FOUND, SERVER_NOT_LEVELUP_PLATFORM)); }
From source file:org.eclipse.osee.framework.core.util.HttpProcessor.java
public static boolean isAlive(URL url) { boolean isAlive = false; boolean recheck = true; String key = toIsAliveKey(url); Pair<Integer, Long> lastChecked = isAliveMap.get(key); if (lastChecked != null) { long checkedOffset = System.currentTimeMillis() - lastChecked.getSecond().longValue(); if (checkedOffset < CHECK_WINDOW) { recheck = false;/*w w w. j av a 2 s . c o m*/ isAlive = lastChecked.getFirst() != -1; } } if (recheck) { try { GetMethod method = new GetMethod(url.toString()); try { HttpMethodParams params = new HttpMethodParams(); params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false)); params.setSoTimeout(1000); method.setParams(params); int responseCode = executeMethod(url, method); if (responseCode == HttpURLConnection.HTTP_NOT_FOUND || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_OK) { isAlive = true; } } finally { method.releaseConnection(); } } catch (Exception ex) { // Do Nothing } } return isAlive; }
From source file:com.mobile.godot.core.controller.CoreController.java
public synchronized void addCoOwner(String carName, String coOwnerUsername, LoginBean login) { String servlet = "AddCoOwner"; List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("carName", carName)); params.add(new BasicNameValuePair("coOwnerUsername", coOwnerUsername)); params.add(new BasicNameValuePair("username", login.getUsername())); params.add(new BasicNameValuePair("password", login.getPassword())); SparseIntArray mMessageMap = new SparseIntArray(); mMessageMap.append(HttpURLConnection.HTTP_OK, GodotMessage.Entity.COOWNER_ADDED); mMessageMap.append(HttpURLConnection.HTTP_UNAUTHORIZED, GodotMessage.Error.UNAUTHORIZED); mMessageMap.append(HttpURLConnection.HTTP_NOT_FOUND, GodotMessage.Error.NOT_FOUND); GodotAction action = new GodotAction(servlet, params, mMessageMap, mHandler); Thread tAction = new Thread(action); tAction.start();//from w w w .j a v a 2 s .c o m }