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.ar.dev.tierra.api.controller.PlanPagoController.java
@RequestMapping(value = "/tarjeta", method = RequestMethod.GET) public ResponseEntity<?> searchByTarjeta(@RequestParam("idTarjeta") int idTarjeta) { List<PlanPago> list = facadeService.getPlanPagoDAO().searchPlanByTarjeta(idTarjeta); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {/*from ww w .j av a 2s . c o m*/ return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:com.sap.csc.poc.ems.service.admin.entitlement.EntitlementServiceImpl.java
@Override @RequestMapping(value = "entitlement/{id}", method = RequestMethod.GET) public ResponseEntity<EntitlementInfo> findOne(@PathVariable("id") Long id) { EntitlementHeader entitlementHeader = entitlementHeaderRepository.findOne(id); if (entitlementHeader != null) { return new ResponseEntity<>(new EntitlementInfo(entitlementHeader), HttpStatus.OK); } else {//w w w .j a v a2 s . c o m return new ResponseEntity<>((EntitlementInfo) null, HttpStatus.NOT_FOUND); } }
From source file:it.polimi.diceH2020.launcher.controller.rest.RestLaunchAnalysisController.java
@RequestMapping(value = "/submit/{id}", method = RequestMethod.GET) public ResponseEntity<PendingSubmissionRepresentation> getPendingSubmission(@PathVariable Long id) { ResponseEntity<PendingSubmissionRepresentation> response; PendingSubmission submission = submissionRepository.findOne(id); if (submission == null) { response = new ResponseEntity<>(HttpStatus.NOT_FOUND); } else {// w w w.j ava 2 s .c o m PendingSubmissionRepresentation representation = prepareRepresentation(submission); response = new ResponseEntity<>(representation, HttpStatus.OK); } return response; }
From source file:net.maritimecloud.identityregistry.controllers.RoleController.java
@RequestMapping(value = "/api/org/{orgMrn}/role", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody//from ww w . ja va2 s . c om @PreAuthorize("(hasRole('ORG_ADMIN') and @accessControlUtil.hasAccessToOrg(#orgMrn) and #input.roleName != 'ROLE_SITE_ADMIN') or hasRole('SITE_ADMIN')") public ResponseEntity<Role> createRole(HttpServletRequest request, @PathVariable String orgMrn, @Valid @RequestBody Role input, BindingResult bindingResult) throws McBasicRestException { Organization org = this.organizationService.getOrganizationByMrn(orgMrn); if (org != null) { input.setIdOrganization(org.getId()); Role newRole = this.roleService.save(input); return new ResponseEntity<>(newRole, HttpStatus.OK); } else { throw new McBasicRestException(HttpStatus.NOT_FOUND, MCIdRegConstants.ORG_NOT_FOUND, request.getServletPath()); } }
From source file:net.maritimecloud.identityregistry.controllers.EntityController.java
/** * Creates a new Entity//w w w .j a v a 2s .co m * * @return a reply... * @throws McBasicRestException */ protected ResponseEntity<T> createEntity(HttpServletRequest request, String orgMrn, T input) throws McBasicRestException { Organization org = this.organizationService.getOrganizationByMrn(orgMrn); if (org != null) { // Check that the entity being created belongs to the organization if (!MrnUtil.getOrgShortNameFromOrgMrn(orgMrn) .equals(MrnUtil.getOrgShortNameFromEntityMrn(input.getMrn()))) { throw new McBasicRestException(HttpStatus.BAD_REQUEST, MCIdRegConstants.MISSING_RIGHTS, request.getServletPath()); } input.setIdOrganization(org.getId()); try { T newEntity = this.entityService.save(input); return new ResponseEntity<>(newEntity, HttpStatus.OK); } catch (DataIntegrityViolationException e) { throw new McBasicRestException(HttpStatus.CONFLICT, e.getRootCause().getMessage(), request.getServletPath()); } } else { throw new McBasicRestException(HttpStatus.NOT_FOUND, MCIdRegConstants.ORG_NOT_FOUND, request.getServletPath()); } }
From source file:org.jrb.docasm.web.GlobalExceptionHandler.java
/** * Converts one of several client-based not found exceptions into an HTTP * 404 response with an error body. The mapped exceptions are as follows: * <ul>/*from w ww . ja v a 2s . c om*/ * <li>{@link UnknownDocumentException}</li> * </ul> * * @param e * the client exception * @return the error body */ @ExceptionHandler({ UnknownDocumentException.class }) public ResponseEntity<MessageResponse> handleNotFoundError(final Exception e) { if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } return utils.createMessageResponse(e.getMessage(), HttpStatus.NOT_FOUND); }
From source file:plbtw.klmpk.barang.hilang.controller.BarangController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public CustomResponseMessage /*Collection<Barang>*/ getAllBarang(@RequestHeader String apiKey) { try {//from ww w. j av a 2s .c om if (!authApiKey(apiKey)) { return new CustomResponseMessage(HttpStatus.FORBIDDEN, "Please use your api key to authentication"); } LogRequest temp = DependencyFactory.createLog(apiKey, "Get"); if (checkRateLimit(RATE_LIMIT, apiKey)) { return new CustomResponseMessage(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED, "Please wait a while, you have reached your rate limit"); } Log log = new Log(); log.setApiKey(temp.getApiKey()); log.setStatus(temp.getStatus()); log.setTimeRequest(temp.getTime_request()); logService.addLog(log); List<Barang> allBarang = (List<Barang>) barangService.getAllBarang(); for (Barang barang : allBarang) { Link selfLink = linkTo(BarangController.class).withSelfRel(); barang.add(selfLink); } CustomResponseMessage result = new CustomResponseMessage(); result.add(linkTo(BarangController.class).withSelfRel()); result.setHttpStatus(HttpStatus.FOUND); result.setMessage("Success"); result.setResult(allBarang); return result; } catch (NullPointerException ex) { return new CustomResponseMessage(HttpStatus.NOT_FOUND, "Data not found"); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.FORBIDDEN, ex.getMessage()); } }
From source file:org.cloudfoundry.caldecott.server.controller.TunnelController.java
@ExceptionHandler @ResponseStatus(value = HttpStatus.NOT_FOUND) public void onTunnelNotFound(TunnelNotFoundException exception) { }
From source file:com.ar.dev.tierra.api.controller.ReservaController.java
@RequestMapping(value = "/month", method = RequestMethod.GET) public ResponseEntity<?> getMonth() { List<Factura> list = facadeService.getFacturaDAO().getMonthReserva(); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {/* w w w .jav a2s . c o m*/ return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:com.javiermoreno.springboot.rest.App.java
@Bean public EmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(); //factory.setPort(7777); (est definido en el application.properties factory.setSessionTimeout(10, TimeUnit.MINUTES); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/errores/error404.html"), new ErrorPage(HttpStatus.UNAUTHORIZED, "/errores/error401.html"), new ErrorPage(HttpStatus.FORBIDDEN, "/errores/error403.html")); // Activacin gzip sobre http (*NO* activar sobre ssl, induce ataques.) // http://stackoverflow.com/questions/21410317/using-gzip-compression-with-spring-boot-mvc-javaconfig-with-restful factory.addConnectorCustomizers((TomcatConnectorCustomizer) (Connector connector) -> { AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressionMinSize(256); String mimeTypes = httpProtocol.getCompressableMimeTypes(); String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE; httpProtocol.setCompressableMimeTypes(mimeTypesWithJson); });//from www . j a v a 2 s .c o m factory.addAdditionalTomcatConnectors(createSslConnector()); /* En el caso de que se desee sustitur http por https: ************************ // keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650 final String keystoreFilePath = "keystore.p12"; final String keystoreType = "PKCS12"; final String keystoreProvider = "SunJSSE"; final String keystoreAlias = "tomcat"; factory.addConnectorCustomizers((TomcatConnectorCustomizer) (Connector con) -> { con.setScheme("https"); con.setSecure(true); Http11NioProtocol proto = (Http11NioProtocol) con.getProtocolHandler(); proto.setSSLEnabled(true); // @todo: Descarga el fichero con el certificado actual File keystoreFile = new File(keystoreFilePath); proto.setKeystoreFile(keystoreFile.getAbsolutePath()); proto.setKeystorePass(remoteProps.getKeystorePass()); proto.setKeystoreType(keystoreType); proto.setProperty("keystoreProvider", keystoreProvider); proto.setKeyAlias(keystoreAlias); }); ***************************************************************************** */ return factory; }