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.envision.envservice.rest.UserCaseResource.java
@GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON)//from www .ja v a2 s.c om public Response queryOther(@PathParam("id") int id) throws Exception { HttpStatus status = HttpStatus.OK; String response = StringUtils.EMPTY; UserCaseInfoBo userCaseInfo = userCaseService.queryUserCase(id); if (userCaseInfo != null) { response = JSONObject.toJSONString(userCaseInfo, JSONFilter.UNDERLINEFILTER); } else { status = HttpStatus.NOT_FOUND; response = FailResult.toJson(Code.CASE_NOT_EXSIT, "?"); } return Response.status(status.value()).entity(response).build(); }
From source file:com.orange.clara.tool.controllers.RssController.java
@RequestMapping(method = RequestMethod.GET, value = "/{id:[0-9]+}*") public @ResponseBody ResponseEntity<String> getFeed(@PathVariable("id") Integer id) throws FeedException { User user = this.getCurrentUser(); WatchedResource watchedResource = this.watchedResourceRepo.findOne(id); if (watchedResource == null) { return generateEntityFromStatus(HttpStatus.NOT_FOUND); }/*from w w w. j a va2 s . com*/ if (!watchedResource.hasUser(user) && !this.isCurrentUserAdmin()) { return generateEntityFromStatus(HttpStatus.UNAUTHORIZED); } SyndFeed feed = rssService.generateFeed(watchedResource); return ResponseEntity.ok(rssService.getOutput(feed)); }
From source file:minium.developer.web.rest.js.SelectorGadgetResource.java
@RequestMapping(value = "/deactivate", method = { POST, GET }) public ResponseEntity<Void> deactivate() throws Exception { SelectorGadgetWebElements elems = getSelectorGadgetWebElements(); if (elems == null) { return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); }//from w w w . j a v a 2 s . c o m elems.deactivateSelectorGadget(); activated = false; return new ResponseEntity<Void>(HttpStatus.OK); }
From source file:com.example.api.UrlShortener.java
@RequestMapping(value = "{hash}", method = RequestMethod.GET) ResponseEntity<?> get(@PathVariable String hash) { String url = urlMap.get(hash); if (url != null) { return new ResponseEntity<>(url, HttpStatus.OK); } else {//from w w w . ja v a2 s . c o m return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:com.ar.dev.tierra.api.controller.ChartController.java
@RequestMapping(value = "/medio/ventas", method = RequestMethod.GET) public ResponseEntity<?> getMedioMonto(@RequestParam("idMedioPago") int idMedioPago) { List<Chart> chart = impl.getMontoMedioPago(idMedioPago); if (!chart.isEmpty()) { return new ResponseEntity<>(chart, HttpStatus.OK); } else {// w w w.j a va 2s . c o m return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:web.ClientsRESTController.java
/** * Gets a specific client's info based on a Client ID * @param id// ww w.j av a 2s . co m * @return */ @RequestMapping(value = "/api/clients/clientinfo/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Clients> getClientInfo(@PathVariable("id") int id) { Clients client = null; //returns a NOT_FOUND error if no Client is tied to specific ClientID try { client = dao.getClientByID(id); } catch (EmptyResultDataAccessException ex) { return new ResponseEntity<Clients>(HttpStatus.NOT_FOUND); } //otherwise returns specific Client's info return new ResponseEntity<Clients>(client, HttpStatus.OK); }
From source file:com.wujiabo.opensource.feather.rest.controller.RbacRestController.java
@RequestMapping(value = "/group/{userId}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8) public List<Map<String, Object>> get(@PathVariable("userId") Integer userId) { List<Map<String, Object>> list = userMgmtService.getGroupByUserId(userId); if (list == null) { String message = "?(id:" + userId + ")"; logger.warn(message);/*w w w. jav a2 s.co m*/ throw new RestException(HttpStatus.NOT_FOUND, message); } List<Map<String, Object>> jsonList = new ArrayList<Map<String, Object>>(); for (Map<String, Object> map : list) { Map<String, Object> jsonMap = new HashMap<String, Object>(); jsonMap.put("id", map.get("group_id")); jsonMap.put("pId", map.get("group_pid")); jsonMap.put("name", map.get("group_name")); if ("0".equals(map.get("flag").toString())) { jsonMap.put("checked", true); } jsonList.add(jsonMap); } return jsonList; }
From source file:eu.cloudwave.wp5.feedbackhandler.metricsources.AbstractMetricSourceClient.java
/** * This method can be used by subclass for error handling. It directly handles 404 Errors and general errors that are * not treated specially and calls the hook {@link #handleHttpServerException(HttpServerErrorException)} for errors * that have to be treated specially by subclasses. By implementing the hook methods subclasses can handles those * errors individually.// w ww . j a va 2s . c om * * @param throwable * the exception * @throws MetricSourceClientException * for errors that do not have to be treated specially by subclasses */ protected final void handleException(final Throwable throwable) throws MetricSourceClientException { if (throwable instanceof HttpStatusCodeException) { final HttpStatusCodeException httpError = (HttpStatusCodeException) throwable; // handle errors individually by subclasses try { handleHttpServerException(httpError); } catch (final IOException e) { /** * This error can occur while trying to identify the cause for the original error. It is ignored and the * original error is thrown instead. */ } // handle 404 NOT FOUND errors if (httpError.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new MetricSourceClientException(ErrorType.METRIC_SOURCE_NOT_AVAILABLE, httpError); } } // if no precise cause could be identified, throw the original exception throw new MetricSourceClientException(ErrorType.NEW_RELIC__GENERAL, throwable); }
From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java
@Override @RequestMapping(method = RequestMethod.GET) public @ResponseBody Page<Evento, Long> getEventos(@PathVariable final Long idServicio, @Valid @ModelAttribute final PaginationDataLong pagination, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; }/* w ww . ja va 2s. c o m*/ List<Evento> datos = eventoDAO.consultarTodos(idServicio, null, pagination); Page<Evento, Long> r = pagFactory.getPage(); r.setTipoItems("evento"); r.setLinkPaginaActual(armaUrl(idServicio, pagination.getSinceId(), pagination.getMaxResults())); if (pagination.hasNext()) { r.setLinkSiguientePagina(armaUrl(idServicio, pagination.getNextId(), pagination.getMaxResults())); r.setSiguienteItem(pagination.getNextId()); } r.setItems(datos); response.setHeader("Content-Type", "application/json;charset=UTF-8"); return r; }