List of usage examples for org.springframework.http HttpStatus NOT_FOUND
HttpStatus NOT_FOUND
To view the source code for org.springframework.http HttpStatus NOT_FOUND.
Click Source Link
From source file:com.mysample.springbootsample.config.WebConfig.java
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override//from w ww. jav a 2s . com public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error/404.html"); ErrorPage error505Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/505.html"); container.addErrorPages(error404Page, error505Page); } }; }
From source file:web.UsersRESTController.java
/** * Gets a list of events in the Event Log tied to a specific User ID through * REST API// ww w . j a v a2 s. c om * @param id * @return */ @RequestMapping(value = "/api/users/userevents/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<EventLog>> getUserEvents(@PathVariable("id") int id) { List<EventLog> userEL = null; //returns a NOT_FOUND error if no Event Log history for User exists try { userEL = adao.getEventsByUserID(id); } catch (EmptyResultDataAccessException ex) { return new ResponseEntity<List<EventLog>>(HttpStatus.NOT_FOUND); } //otherwise returns Event Log history for that User return new ResponseEntity<List<EventLog>>(userEL, HttpStatus.OK); }
From source file:com.ar.dev.tierra.api.controller.ProductoController.java
@RequestMapping(value = "/advanced", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> advanced( @RequestParam(value = "descripcion", required = false, defaultValue = "") String descripcion, @RequestParam(value = "marca", required = false, defaultValue = "") String marca, @RequestParam(value = "talla", required = false, defaultValue = "") String talla, @RequestParam(value = "codigo", required = false, defaultValue = "") String codigo, @RequestParam(value = "categoria", required = false, defaultValue = "") String categoria, @RequestParam(value = "page", required = false, defaultValue = "") Integer page, @RequestParam(value = "size", required = false, defaultValue = "") Integer size) { Page paged = facadeService.getProductoService().getByParams(descripcion, marca, talla, codigo, categoria, page, size);/*from ww w . ja v a2s . c o m*/ if (paged.getSize() != 0) { return new ResponseEntity<>(paged, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:org.cloudfoundry.maven.Info.java
@Override protected void doExecute() throws MojoExecutionException { final CloudInfo cloudinfo; final List<ServiceConfiguration> serviceConfigurations; final String localTarget = getTarget().toString(); try {//from w w w .j a v a 2 s.c o m cloudinfo = client.getCloudInfo(); serviceConfigurations = client.getServiceConfigurations(); } catch (CloudFoundryException e) { if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) { throw new MojoExecutionException(String.format( "The target host '%s' exists but it does not appear to be a valid Cloud Foundry target url.", localTarget), e); } else { throw e; } } catch (ResourceAccessException e) { throw new MojoExecutionException(String.format("Cannot access host at '%s'.", localTarget), e); } super.getLog().info(getCloudInfoFormattedAsString(cloudinfo, serviceConfigurations, localTarget)); }
From source file:org.n52.tamis.rest.controller.processes.jobs.DeleteRequestController.java
@RequestMapping("") public ResponseEntity delete(@PathVariable(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME) String serviceId, @PathVariable(URL_Constants_TAMIS.PROCESS_ID_VARIABLE_NAME) String processId, @PathVariable(URL_Constants_TAMIS.JOB_ID_VARIABLE_NAME) String jobId, HttpServletRequest request, HttpServletResponse response) {// www. ja v a 2s.c o m logger.info("Received delete request for service id \"{}\", process id \"{}\" and job id \"{}\" !", serviceId, processId, jobId); initializeParameterValueStore(serviceId, processId, jobId); // prepare response entity with HTTP status 404, not found ResponseEntity responseEntity = new ResponseEntity(HttpStatus.NOT_FOUND); try { logger.info("Trying to delete resource at \"{}\"", request.getRequestURL()); responseEntity = deleteRequestForwarder.forwardRequestToWpsProxy(request, null, parameterValueStore); } catch (Exception e) { logger.info("DELETE request for resouce at \"{}\" failed.", request.getRequestURL()); response.setStatus(HttpStatus.NOT_FOUND.value()); return new ResponseEntity(HttpStatus.NOT_FOUND); } return responseEntity; }
From source file:com.crazyacking.learn.spring.actuator.ManagementPortAndPathSampleActuatorApplicationTests.java
@Test public void testMissing() { ResponseEntity<String> entity = new TestRestTemplate("user", getPassword()) .getForEntity("http://localhost:" + this.managementPort + "/admin/missing", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getBody()).contains("\"status\":404"); }
From source file:edu.sjsu.cmpe275.project.controller.UserController.java
/** Update a user * @return Description of c// w w w . j a v a 2s. co m */ @RequestMapping(value = "/{id}", method = RequestMethod.POST) public ResponseEntity<?> updateUser(@PathVariable("id") String name, @RequestParam(value = "password", required = true) String password, @RequestParam(value = "role", required = true) String role) { User user = new User(name, password, role); user = userDao.updateUser(user); if (user == null) { return new ResponseEntity<Object>(null, HttpStatus.NOT_FOUND); } else { return new ResponseEntity<Object>(user, HttpStatus.OK); } }
From source file:demo.service.RemoteVehicleDetailsServiceTest.java
@Test public void getVehicleDetailsWhenResultIsNotFoundShouldThrowException() throws Exception { this.server.expect(requestTo("http://example.com/vehicle/" + VIN + "/details")) .andRespond(withStatus(HttpStatus.NOT_FOUND)); this.thrown.expect(VehicleIdentificationNumberNotFoundException.class); this.service.getVehicleDetails(new VehicleIdentificationNumber(VIN)); }
From source file:ch.heigvd.gamification.api.PointScalesEndpoint.java
@Override @RequestMapping(value = "/{pointScaleId}", method = RequestMethod.DELETE) public ResponseEntity<Void> pointScalesPointScaleIdDelete( @ApiParam(value = "pointScaleIdt", required = true) @RequestHeader(value = "X-Gamification-Token", required = true) String xGamificationToken, @ApiParam(value = "pointScaleId", required = true) @PathVariable("pointScaleId") Long pointScaleId) { AuthenKey apiKey = authenRepository.findByAppKey(xGamificationToken); if (apiKey == null) { return new ResponseEntity("apikey not exist", HttpStatus.UNAUTHORIZED); }/*from www . java 2 s . co m*/ PointScale pointScale = pointscaleRepository.findOne(pointScaleId); if (pointScale != null) { pointscaleRepository.delete(pointScale); return new ResponseEntity(HttpStatus.OK); } else { return new ResponseEntity(HttpStatus.NOT_FOUND); } }
From source file:org.mitre.uma.web.ClaimsAPI.java
@RequestMapping(value = "/{rsid}", method = RequestMethod.GET, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) public String getClaimsForResourceSet(@PathVariable(value = "rsid") Long rsid, Model m, Authentication auth) { ResourceSet rs = resourceSetService.getById(rsid); if (rs == null) { m.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND); return HttpCodeView.VIEWNAME; }/*from w w w . ja v a2 s. c o m*/ if (!rs.getOwner().equals(auth.getName())) { // authenticated user didn't match the owner of the resource set m.addAttribute(HttpCodeView.CODE, HttpStatus.FORBIDDEN); return HttpCodeView.VIEWNAME; } m.addAttribute(JsonEntityView.ENTITY, rs.getClaimsRequired()); return JsonEntityView.VIEWNAME; }