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:org.appverse.web.framework.backend.frontfacade.rest.remotelog.services.presentation.RemoteLogServiceFacadeImpl.java
/** * Writes a remote log//w w w . j av a 2 s .c o m * @param remoteLogRequestVO * @return */ @RequestMapping(value = "${appverse.frontfacade.rest.remoteLogEndpoint.path:/remotelog/log}", method = RequestMethod.POST) public ResponseEntity<Void> writeRemoteLog(@RequestBody RemoteLogRequestVO remoteLogRequestVO) { RemoteLogResponseVO remoteLogResponseVO = null; try { remoteLogResponseVO = remoteLogManager.writeLog(remoteLogRequestVO); if (!(remoteLogResponseVO.getErrorVO().getCode() == 0)) { // Error related to client call return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST); //return Response.status(Response.Status.BAD_REQUEST).build(); } } catch (Exception e) { // Server error // return Response.serverError().build(); return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); } // return Response.ok().build(); return new ResponseEntity<Void>(HttpStatus.OK); }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.UpdateServiceHandlerTest.java
@Test /**/* w ww . ja v a 2s . c o m*/ * Test that the handle method returns null */ public void testHandleJobRequestNull() { PiazzaJobType jobRequest = null; ResponseEntity<String> result = usHandler.handle(jobRequest); assertEquals("The response to a null JobRequest update should be null", result.getStatusCode(), HttpStatus.BAD_REQUEST); }
From source file:de.steilerdev.myVerein.server.controller.user.EventController.java
/** * This function gathers all events for the currently logged in user. If lastChanged is stated only events that * changed after that moment are returned. * * @param lastChanged The date of the last changed action, correctly formatted (YYYY-MM-DDTHH:mm:ss) * @param currentUser The currently logged in user * @return A list of all events for the user that changed since the last changed moment in time (only containing * id's)/*ww w. j a va 2 s .co m*/ */ @RequestMapping(produces = "application/json", method = RequestMethod.GET) public ResponseEntity<List<Event>> getAllEventsForUser(@RequestParam(required = false) String lastChanged, @CurrentUser User currentUser) { List<Event> events; if (lastChanged != null && !lastChanged.isEmpty()) { logger.debug("[{}] Gathering all user events changed after {}", currentUser, lastChanged); LocalDateTime lastChangedTime; try { lastChangedTime = LocalDateTime.parse(lastChanged, DateTimeFormatter.ISO_LOCAL_DATE_TIME); } catch (DateTimeParseException e) { logger.warn("[{}] Unable to get all events for user, because the last changed format is wrong: {}", currentUser, e.getLocalizedMessage()); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } events = eventRepository.findAllByPrefixedInvitedUserAndLastChangedAfter( Event.prefixedUserIDForUser(currentUser), lastChangedTime); } else { logger.debug("[{}] Gathering all user events", currentUser); events = eventRepository.findAllByPrefixedInvitedUser(Event.prefixedUserIDForUser(currentUser)); } if (events == null || events.isEmpty()) { logger.warn("[{}] No events to return", currentUser); return new ResponseEntity<>(HttpStatus.OK); } else { logger.info("[{}] Returning {} events", currentUser, events.size()); events.replaceAll(Event::getSendingObjectOnlyId); return new ResponseEntity<>(events, HttpStatus.OK); } }
From source file:edu.chalmers.dat076.moviefinder.controller.AdminController.java
@RequestMapping(value = "/addPath", method = RequestMethod.POST) public ResponseEntity<ListeningPath> addPath(@RequestBody ListeningPath path) { File f = new File(path.getListeningPath().toLowerCase()); if (f.exists() && f.isDirectory()) { try {//from w w w .j av a 2 s. c o m ListeningPath savedPath = databaseHelper.addPath(f.toPath()); fileThreadService.addListeningPath(f.toPath()); return new ResponseEntity<>(savedPath, HttpStatus.OK); } catch (DataIntegrityViolationException e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } } else { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:org.mifosplatform.mpesa.controller.MifosMpesaController.java
@RequestMapping(value = "/transactiondetails", method = RequestMethod.POST) public @ResponseBody ResponseEntity<String> storeTransactionDetails(@QueryParam("id") final Long id, @QueryParam("orig") final String orig, @QueryParam("dest") final String dest, @QueryParam("tstamp") final String tstamp, @QueryParam("text") final String text, @QueryParam("user") final String user, @QueryParam("pass") final String pass, @QueryParam("mpesa_code") final String mpesa_code, @QueryParam("mpesa_acc") final String mpesa_acc, @QueryParam("mpesa_msisdn") final String mpesa_msisdn, @QueryParam("mpesa_trx_date") final Date mpesa_trx_date, @QueryParam("mpesa_trx_time") final String mpesa_trx_time, @QueryParam("mpesa_amt") final BigDecimal mpesa_amt, @QueryParam("mpesa_sender") final String mpesa_sender) { String responseMessage = ""; try {//from w w w.j a v a 2s . c om if (user.equalsIgnoreCase("caritas") && pass.equalsIgnoreCase("nairobi")) { responseMessage = this.mpesaBridgeService.storeTransactionDetails(id, orig, dest, tstamp, text, user, pass, mpesa_code, mpesa_acc, mpesa_msisdn, mpesa_trx_date, mpesa_trx_time, mpesa_amt, mpesa_sender); } } catch (Exception e) { logger.error("Exception " + e); return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST); } return new ResponseEntity<String>(responseMessage, HttpStatus.OK); }
From source file:com.envision.envservice.rest.UserCaseCommentResource.java
@POST @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)// w ww .j a va 2s . c o m @Produces(MediaType.APPLICATION_JSON) public Response add(@PathParam("id") int id, UserCaseCommentBo userCaseComment) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(userCaseComment)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { userCaseCommentService.add(id, userCaseComment); } return Response.status(status.value()).entity(response).build(); }
From source file:org.cloudfoundry.identity.uaa.codestore.CodeStoreEndpoints.java
@RequestMapping(value = "/Codes/{code}", method = RequestMethod.GET) @ResponseBody/*from w w w . ja va 2 s . c om*/ public ExpiringCode retrieveCode(@PathVariable String code) { ExpiringCode result = null; try { result = expiringCodeStore.retrieveCode(code); } catch (NullPointerException e) { throw new CodeStoreException("code is required.", HttpStatus.BAD_REQUEST); } if (result == null) { throw new CodeStoreException("Code not found: " + code, HttpStatus.NOT_FOUND); } return result; }
From source file:se.sawano.scala.examples.scalaspringmvc.ValidationTestIT.java
@Test public void scalaJavaPostWithMissingName() { try {/*from ww w . ja v a2 s.c o m*/ JavaIndata indata = new JavaIndata(null, 1); restTemplate.postForObject(baseUrl + "scalajava/indata", indata, Void.class, (Object) null); fail("Expected JSR-303 validation to fail"); } catch (HttpClientErrorException e) { assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); } }
From source file:com.wisemapping.rest.BaseController.java
@ExceptionHandler(java.lang.reflect.UndeclaredThrowableException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public RestErrors handleSecurityErrors(@NotNull UndeclaredThrowableException ex) { final Throwable cause = ex.getCause(); RestErrors result;//from w w w.j a va 2 s . co m if (cause instanceof ClientException) { result = handleClientErrors((ClientException) cause); } else { result = new RestErrors(ex.getMessage(), Severity.INFO); } return result; }
From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java
@RequestMapping(produces = APPLICATION_JSON) @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(value = HttpStatus.BAD_REQUEST) public @ResponseBody Map<String, Object> handleValidationException(MethodArgumentNotValidException ex) throws IOException { Map<String, Object> map = newHashMap(); map.put("error", "Validation Failure"); map.put("violations", convertConstraintViolation(ex)); return map;//from w w w.j av a2s . co m }