List of usage examples for org.springframework.http HttpStatus BAD_REQUEST
HttpStatus BAD_REQUEST
To view the source code for org.springframework.http HttpStatus BAD_REQUEST.
Click Source Link
From source file:nl.flotsam.calendar.web.CalendarController.java
@ExceptionHandler(URISyntaxException.class) public void handleURISyntaxException(HttpServletResponse response) throws IOException { response.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid URI passed as a parameter."); }
From source file:com.codekul.simpleboot.controller.ControllerRestServices.java
@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Map<String, Object>> loginUser(@RequestBody User user) { ResponseEntity<Map<String, Object>> entity = null; Map<String, Object> mapBody = new HashMap<>(); HttpHeaders headers = new HttpHeaders(); try {/*from w w w . j a v a 2 s. c o m*/ serviceUser.login(user); mapBody.clear(); mapBody.put("status", "success"); mapBody.put("msg", "Logged Successfully .."); entity = new ResponseEntity<>(mapBody, headers, HttpStatus.OK); } catch (Exception ex) { Logger.getLogger(ControllerRestServices.class.getName()).log(Level.SEVERE, null, ex); mapBody.clear(); mapBody.put("status", "fail"); mapBody.put("msg", "Bad Crediantials ..."); entity = new ResponseEntity<>(mapBody, headers, HttpStatus.BAD_REQUEST); } return entity; }
From source file:org.openlmis.fulfillment.service.stockmanagement.StockEventStockManagementService.java
/** * Saves the given stock event to the stockmanagement service. * * @param stockEventDto the physical inventory to be submitted *///from w ww . ja va2 s .c o m @SuppressWarnings("PMD.PreserveStackTrace") public void submit(StockEventDto stockEventDto) { String url = getServiceUrl() + getUrl(); LOGGER.debug("Sending Stock Events to Stock Management: {}", stockEventDto); try { restTemplate.exchange(createUri(url), HttpMethod.POST, createEntity(stockEventDto), UUID.class); } catch (HttpStatusCodeException ex) { if (ex.getStatusCode() == HttpStatus.BAD_REQUEST) { try { LocalizedMessageDto localizedMessage = objectMapper.readValue(ex.getResponseBodyAsString(), LocalizedMessageDto.class); throw new ExternalApiException(ex, localizedMessage); } catch (IOException ex2) { throw new ServerException(ex2, MessageKeys.ERROR_IO, ex2.getMessage()); } } else { throw buildDataRetrievalException(ex); } } }
From source file:com.ar.dev.tierra.api.controller.UsuariosController.java
@PreAuthorize("hasAuthority('ROLE_ADMIN')") @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAllUsuarios() { List<Usuarios> listUsuarios = facadeService.getUsuariosDAO().allUsuarios(); ResponseEntity responseEntity;// w w w . j ava 2 s .c om if (listUsuarios.isEmpty()) { responseEntity = new ResponseEntity(HttpStatus.BAD_REQUEST); } else { responseEntity = new ResponseEntity(listUsuarios, HttpStatus.OK); } return responseEntity; }
From source file:de.sainth.recipe.backend.rest.controller.FoodController.java
@Secured("ROLE_ADMIN") @RequestMapping(value = "{id}", method = RequestMethod.PUT) HttpEntity<Food> update(@PathVariable("id") Long id, @Valid @RequestBody Food food) { if (id.equals(food.getId())) { if (repository.findOne(food.getId()) != null) { repository.save(food);//from w ww . ja va2 s .com return new ResponseEntity<>(food, HttpStatus.OK); } } return new ResponseEntity<>(HttpStatus.BAD_REQUEST); }
From source file:es.ucm.fdi.dalgs.web.MainController.java
@ExceptionHandler @ResponseBody/*from ww w .j ava 2 s. c o m*/ @ResponseStatus(value = HttpStatus.BAD_REQUEST) public ModelAndView handleException(Exception exception) { ModelAndView model = new ModelAndView("error"); System.out.println("por aqui"); model.addObject("reason", exception.getMessage()); return model; }
From source file:com.intel.databackend.handlers.ErrorHandler.java
@ExceptionHandler(MissingDataSubmissionArgumentException.class) public ResponseEntity handleError(MissingDataSubmissionArgumentException ex) { logger.error("Bad request: ", ex); return new ResponseEntity(HttpStatus.BAD_REQUEST); }
From source file:org.syncope.core.rest.data.ConnInstanceDataBinder.java
public ConnInstance getConnInstance(final ConnInstanceTO connectorInstanceTO) throws SyncopeClientCompositeErrorException { SyncopeClientCompositeErrorException compositeErrorException = new SyncopeClientCompositeErrorException( HttpStatus.BAD_REQUEST); SyncopeClientException requiredValuesMissing = new SyncopeClientException( SyncopeClientExceptionType.RequiredValuesMissing); if (connectorInstanceTO.getBundleName() == null) { requiredValuesMissing.addElement("bundlename"); }//from w ww. ja va 2 s. c o m if (connectorInstanceTO.getVersion() == null) { requiredValuesMissing.addElement("bundleversion"); } if (connectorInstanceTO.getConnectorName() == null) { requiredValuesMissing.addElement("connectorname"); } if (connectorInstanceTO.getConfiguration() == null || connectorInstanceTO.getConfiguration().isEmpty()) { requiredValuesMissing.addElement("configuration"); } ConnInstance connectorInstance = new ConnInstance(); BeanUtils.copyProperties(connectorInstanceTO, connectorInstance, IGNORE_PROPERTIES); // Throw composite exception if there is at least one element set // in the composing exceptions if (!requiredValuesMissing.isEmpty()) { compositeErrorException.addException(requiredValuesMissing); } if (compositeErrorException.hasExceptions()) { throw compositeErrorException; } return connectorInstance; }
From source file:com.github.iexel.fontus.web.rest.GlobalControllerAdviceRest.java
@ResponseBody @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(Throwable.class) public AjaxError handle(Throwable ex) { logger.error(null, ex);/*www .j av a 2 s. com*/ AjaxError ajaxError = new AjaxError(); ajaxError.setGlobalErrorCode("error_unexpected"); return ajaxError; }
From source file:org.syncope.core.rest.data.VirtualSchemaDataBinder.java
public <K extends AbstractSchema> AbstractVirSchema update(final VirtualSchemaTO virtualSchemaTO, AbstractVirSchema virtualSchema, final Class<K> reference) { return populate(virtualSchema, virtualSchemaTO, reference, new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST)); }