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:reconf.server.services.property.RealAllPropertiesService.java
@RequestMapping(value = "/product/{prod}/component/{comp}/property", method = RequestMethod.GET) @Transactional(readOnly = true)//from ww w . java 2 s. c o m public ResponseEntity<AllPropertiesResult> global(@PathVariable("prod") String product, @PathVariable("comp") String component, HttpServletRequest request, Authentication auth) { ComponentKey key = new ComponentKey(product, component); if (!products.exists(key.getProduct())) { return new ResponseEntity<AllPropertiesResult>(new AllPropertiesResult(key, Product.NOT_FOUND), HttpStatus.NOT_FOUND); } if (!components.exists(new ComponentKey(key.getProduct(), key.getName()))) { return new ResponseEntity<AllPropertiesResult>(new AllPropertiesResult(key, Component.NOT_FOUND), HttpStatus.NOT_FOUND); } List<PropertyRuleResult> result = new ArrayList<>(); for (Property dbProperty : properties.findByKeyProductAndKeyComponent(key.getProduct(), key.getName())) { PropertyRuleResult toAdd = new PropertyRuleResult(dbProperty, CrudServiceUtils.getBaseUrl(request)); if (StringUtils.equalsIgnoreCase(dbProperty.getKey().getRuleName(), Property.DEFAULT_RULE_NAME)) { toAdd.clearRule(); } toAdd.addSelfUri(CrudServiceUtils.getBaseUrl(request)); result.add(toAdd); } return new ResponseEntity<AllPropertiesResult>( new AllPropertiesResult(key, result, CrudServiceUtils.getBaseUrl(request)), HttpStatus.OK); }
From source file:org.syncope.core.rest.ConfigurationTestITCase.java
@Test public void delete() throws UnsupportedEncodingException { try {//from w ww . jav a 2 s . c om restTemplate.delete(BASE_URL + "configuration/delete/{key}.json", "nonExistent"); } catch (HttpStatusCodeException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode()); } ConfigurationTO tokenLengthTO = restTemplate.getForObject(BASE_URL + "configuration/read/{key}.json", ConfigurationTO.class, "token.length"); restTemplate.delete(BASE_URL + "configuration/delete/{key}.json", "token.length"); try { restTemplate.getForObject(BASE_URL + "configuration/read/{key}.json", ConfigurationTO.class, "token.length"); } catch (HttpStatusCodeException e) { assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND); } ConfigurationTO newConfigurationTO = restTemplate.postForObject(BASE_URL + "configuration/create", tokenLengthTO, ConfigurationTO.class); assertEquals(tokenLengthTO, newConfigurationTO); }
From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java
/** * Handles "Not Found" scenario and renders a 404 page. * * @param request http request used for getting the URL and wiring config into model * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPNotFoundException} * @return logical name of a view to render *///from ww w . j av a 2s . co m @ResponseStatus(HttpStatus.NOT_FOUND) // 404 @ExceptionHandler(HTTPNotFoundException.class) public String handleNotFound(HttpServletRequest request, Exception exception) { logger.error("[404] Request: " + request.getRequestURL() + " raised " + exception, exception); request.setAttribute("configApp", this.config); if (Utilities.getAuthUserId() == 0) return "guest/errors/404"; return "errors/404"; }
From source file:co.agileventure.jwtauth.web.controller.UserProcessorImpl.java
public ResponseEntity processUser(final HttpServletRequest request, final User.Provider provider, final String id, final String displayName, final String email, final String picture, final String name, final String givenName, final String familyName) throws JOSEException, ParseException { User user = null;/*from w ww .j ava2 s . c o m*/ switch (provider) { case FACEBOOK: user = userService.findByFacebook(id); break; case GOOGLE: user = userService.findByGoogle(id); break; default: return new ResponseEntity<String>("Unknown OAUTH2.0 Provider", HttpStatus.NOT_FOUND); } //If not found by provider try to find it by email if (user == null && StringUtils.isNotEmpty(email)) { user = userService.findByEmail(email); } // Step 3a. If user is already signed in then link accounts. User userToSave; final String authHeader = request.getHeader(AuthUtils.AUTH_HEADER_KEY); if (StringUtils.isNotBlank(authHeader)) { if (user == null) { return new ResponseEntity<String>(String.format(CONFLICT_MSG, provider.capitalize()), HttpStatus.CONFLICT); } final String subject = AuthUtils.getSubject(authHeader); final User foundUser = userService.findOne(subject); if (foundUser == null) { return new ResponseEntity<String>(NOT_FOUND_MSG, HttpStatus.NOT_FOUND); } userToSave = foundUser; boolean updated = setUserProvider(provider, userToSave, id); if (userToSave.getDisplayName() == null) { userToSave.setDisplayName(displayName); updated = true; } if (userToSave.getPicture() == null) { userToSave.setPicture(picture); updated = true; } if (updated) { userToSave = userService.save(userToSave); } } else { // Step 3b. Create a new user account or return an existing one. if (user != null) { userToSave = user; if (setUserProvider(provider, userToSave, id)) { if (userToSave.getPicture() == null) { userToSave.setPicture(picture); } userToSave = userService.save(userToSave); } } else { userToSave = new User(); userToSave.setId(UUID.randomUUID().toString()); userToSave.setDisplayName(displayName); userToSave.setEmail(email); userToSave.setName(name); userToSave.setGivenName(givenName); userToSave.setPicture(picture); userToSave.setFamilyName(familyName); setUserProvider(provider, userToSave, id); userToSave = userService.save(userToSave); } } Token token = AuthUtils.createToken(request.getRemoteHost(), userToSave.getId()); return new ResponseEntity<Token>(token, HttpStatus.OK); }
From source file:org.openlmis.fulfillment.web.errorhandler.WebErrorHandling.java
@ExceptionHandler(NotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody/*from www . j a v a 2 s . com*/ public Message.LocalizedMessage handleOrderNotFoundException(NotFoundException ex) { return logErrorAndRespond("Cannot find an resource", ex); }
From source file:com.opensearchserver.hadse.index.IndexTest.java
@Test public void t01_deleteIndex() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.DELETE, null, String.class); assertNotNull(entity);/*from ww w .ja v a 2 s .c om*/ HttpStatus res = entity.getStatusCode(); assertNotNull(res); switch (res) { case OK: assertEquals(HttpStatus.OK, res); break; case NOT_FOUND: assertEquals(HttpStatus.NOT_FOUND, res); break; default: fail("Unexpected result: " + res); break; } }
From source file:io.fourfinanceit.homework.controller.ClientController.java
@RequestMapping(value = "/client/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Client> getClient(@PathVariable("id") Long id) { Client client = clientRepository.findOne(id); if (client == null) { return new ResponseEntity<Client>(HttpStatus.NOT_FOUND); }//from w w w. ja v a2 s . c om return new ResponseEntity<Client>(client, HttpStatus.OK); }
From source file:bg.vitkinov.edu.services.JokeCategoryService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?> getCategory(@PathVariable Long id) { Category category = repository.findOne(id); return category == null ? new ResponseEntity<>(HttpStatus.NOT_FOUND) : new ResponseEntity<>(category, HttpStatus.OK); }
From source file:org.cloudfoundry.maven.Logs.java
@Override protected void doExecute() throws MojoExecutionException { try {//from w w w . ja v a 2 s .c o m getLog().info(String.format("Getting logs for '%s'", getAppname())); LoggingListener listener = new LoggingListener(); getClient().streamLogs(getAppname(), listener); synchronized (listener) { try { listener.wait(); } catch (InterruptedException e) { throw new MojoExecutionException("Interrupted while streaming logs", e); } } } catch (CloudFoundryException e) { if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) { throw new MojoExecutionException(String.format("Application '%s' does not exist", getAppname()), e); } else { throw new MojoExecutionException(String.format( "Error getting logs for application '%s'. Error message: '%s'. Description: '%s'", getAppname(), e.getMessage(), e.getDescription()), e); } } }
From source file:org.nekorp.workflow.backend.controller.imp.ReporteGlobalControllerImp.java
/**{@inheritDoc}*/ @Override/* w w w.j a va 2s . c om*/ @RequestMapping(value = "/{idServicio}", method = RequestMethod.GET) @ResponseBody public RenglonRG getRenglon(@PathVariable final Long idServicio, final HttpServletResponse response) { Servicio servicio = servicioDAO.consultar(idServicio); if (servicio == null) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; } RenglonRG r = renglonFactoryRG.build(servicio); response.setHeader("Content-Type", "application/json;charset=UTF-8"); return r; }