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:com.temetra.vroomapi.RouteController.java
@ResponseStatus(HttpStatus.BAD_REQUEST) @RequestMapping(value = "/error", produces = MimeTypeUtils.APPLICATION_JSON_VALUE) public RequestError badRequest() { return new RequestError("Bad request"); }
From source file:org.esbtools.gateway.resync.controller.ResyncGateway.java
@ExceptionHandler(IncompleteRequestException.class) private ResponseEntity<ResyncResponse> incompleteRequestExceptionHandler(IncompleteRequestException e) { ResyncResponse resyncResponse = new ResyncResponse(ResyncResponse.Status.Error, e.getMessage()); return new ResponseEntity<>(resyncResponse, HttpStatus.BAD_REQUEST); }
From source file:org.ameba.http.AbstractTenantAwareFilter.java
/** * {@inheritDoc}//from w w w. j a va 2s . c o m */ @Override protected final void doFilterInternal(HttpServletRequest r, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String fromSC = (String) r.getServletContext().getAttribute(Constants.PARAM_MULTI_TENANCY_ENABLED); boolean multiTenancyEnabled = Boolean .valueOf(fromSC == null ? getFilterConfig().getInitParameter(Constants.PARAM_MULTI_TENANCY_ENABLED) : fromSC); String tenant = null; if (multiTenancyEnabled && !"OPTIONS".equalsIgnoreCase(r.getMethod())) { tenant = r.getHeader(Constants.HEADER_VALUE_TENANT) == null || r.getHeader(Constants.HEADER_VALUE_TENANT).isEmpty() ? r.getHeader(Constants.HEADER_VALUE_X_TENANT) : r.getHeader(Constants.HEADER_VALUE_TENANT); if (null == tenant || tenant.isEmpty()) { String throwParam = (String) r.getServletContext() .getAttribute(Constants.PARAM_MULTI_TENANCY_THROW_IF_NOT_PRESENT); boolean throwIfNotPresent = Boolean.valueOf(throwParam == null ? getFilterConfig().getInitParameter(Constants.PARAM_MULTI_TENANCY_THROW_IF_NOT_PRESENT) : throwParam); if (throwIfNotPresent) { response.setStatus(HttpStatus.BAD_REQUEST.value()); throw new IllegalArgumentException(String.format( "No tenant information available in http header. Expected header [%s/%s] attribute not present.", Constants.HEADER_VALUE_TENANT, Constants.HEADER_VALUE_X_TENANT)); } } else { doBefore(r, response, filterChain, tenant); } } try { filterChain.doFilter(r, response); } finally { doAfter(r, response, filterChain, tenant); } }
From source file:com.envision.envservice.rest.UserCaseResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/* www . j a v a2s. c om*/ @Produces(MediaType.APPLICATION_JSON) public Response addNew(UserCaseBo userCase) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(userCase)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { response = userCaseService.addUserCase(userCase).toJSONString(); } return Response.status(status.value()).entity(response).build(); }
From source file:com.ar.dev.tierra.api.controller.ClienteController.java
@RequestMapping(value = "/searchId", method = RequestMethod.POST) public ResponseEntity<?> searchById(@RequestParam("idCliente") int idCliente) { Cliente cliente = facadeService.getClienteDAO().searchById(idCliente); if (cliente != null) { return new ResponseEntity<>(cliente, HttpStatus.OK); } else {// w ww. j a v a 2 s . co m return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:org.openlmis.fulfillment.service.stockmanagement.StockEventStockManagementServiceTest.java
@Test(expected = ExternalApiException.class) public void shouldThrowExceptionOnBadRequest() throws IOException { when(objectMapper.readValue(anyString(), eq(LocalizedMessageDto.class))) .thenReturn(new LocalizedMessageDto()); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.POST), any(HttpEntity.class), eq(UUID.class))) .thenThrow(new HttpClientErrorException(HttpStatus.BAD_REQUEST)); service.submit(new StockEventDto()); }
From source file:com.wisemapping.rest.BaseController.java
@ExceptionHandler(ClientException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public RestErrors handleClientErrors(@NotNull ClientException ex) { final Locale locale = LocaleContextHolder.getLocale(); return new RestErrors(ex.getMessage(messageSource, locale), ex.getSeverity(), ex.getTechInfo()); }
From source file:dk.skogemann.airline.project.ApiController.java
@ExceptionHandler(HttpClientErrorException.class) public ResponseEntity<JsonError> handleHttpClientException(HttpClientErrorException e) { e.printStackTrace();//from w w w . j ava 2s. c om JsonError msg = new JsonError(); msg.setMessage(e.getResponseBodyAsString()); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); }
From source file:com.ar.dev.tierra.api.controller.ProveedorController.java
@RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<?> searchById(@RequestParam("id") int id) { Proveedor proveedor = facadeService.getProveedorDAO().searchById(id); if (proveedor != null) { return new ResponseEntity<>(proveedor, HttpStatus.OK); } else {//from w w w . j av a 2 s .c om return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:com.ar.dev.tierra.api.controller.MarcasController.java
@RequestMapping(value = "/searchText", method = RequestMethod.POST) public ResponseEntity<?> findByText(@RequestParam("text") String text) { List<Marcas> list = facadeService.getMarcasDAO().searchByText(text); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {/*from w w w . ja va 2 s.c om*/ return new ResponseEntity<>(list, HttpStatus.BAD_REQUEST); } }