List of usage examples for org.springframework.http HttpStatus PRECONDITION_FAILED
HttpStatus PRECONDITION_FAILED
To view the source code for org.springframework.http HttpStatus PRECONDITION_FAILED.
Click Source Link
From source file:org.cloudfoundry.identity.uaa.scim.exception.ScimResourceConstraintFailedException.java
/** * @param message a message for the caller */ public ScimResourceConstraintFailedException(String message) { super(message, HttpStatus.PRECONDITION_FAILED); }
From source file:com.redblackit.web.test.RestTemplateTestHelperTest.java
/** * Method returning parameters, which also sets up the servlets to use *///from www. j a va 2 s.c om @Parameters public static List<Object[]> getParameters() throws Exception { final String[] methods = { "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS" }; final HttpStatus[][] codes = { { HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR }, { HttpStatus.NOT_FOUND, HttpStatus.FORBIDDEN, HttpStatus.CONFLICT, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.METHOD_NOT_ALLOWED, HttpStatus.PRECONDITION_FAILED }, { HttpStatus.NOT_FOUND, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND } }; ServletContextHandler jettyContext = new ServletContextHandler(ServletContextHandler.SESSIONS); jettyContext.setContextPath("/"); server.setHandler(jettyContext); List<Object[]> parameters = new ArrayList<Object[]>(); for (int i = 0; i < codes.length; ++i) { String url = "/test" + i; Map<String, HttpStatus> mcmap = new HashMap<String, HttpStatus>(); for (int j = 0; j < methods.length; ++j) { mcmap.put(methods[j], codes[i][j]); } jettyContext.addServlet(new ServletHolder(new StatusCodeServlet(mcmap)), url); parameters.add(new Object[] { BASE_URL + url, mcmap }); } server.start(); int i = 0; while (!server.isStarted() && i < 20) { Thread.sleep(200); ++i; } if (!server.isStarted()) { Assert.fail("server not started"); } return parameters; }
From source file:com.headstartech.iam.web.controllers.ExceptionMapper.java
/** * Handle constraint violation exceptions. * * @param response The HTTP response//from w ww.jav a2 s .c om * @param cve The exception to handle * @throws IOException on error in sending error */ @ExceptionHandler(ConstraintViolationException.class) public void handleConstraintViolation(final HttpServletResponse response, final ConstraintViolationException cve) throws IOException { final StringBuilder builder = new StringBuilder(); for (final ConstraintViolation<?> cv : cve.getConstraintViolations()) { if (builder.length() != 0) { builder.append(NEW_LINE); } builder.append(cv.getMessage()); } response.sendError(HttpStatus.PRECONDITION_FAILED.value(), builder.toString()); }
From source file:com.netflix.genie.web.controllers.GenieExceptionMapper.java
/** * Handle constraint violation exceptions. * * @param response The HTTP response/*from ww w . j a v a 2s . c om*/ * @param cve The exception to handle * @throws IOException on error in sending error */ @ExceptionHandler(ConstraintViolationException.class) public void handleConstraintViolation(final HttpServletResponse response, final ConstraintViolationException cve) throws IOException { final StringBuilder builder = new StringBuilder(); if (cve.getConstraintViolations() != null) { for (final ConstraintViolation<?> cv : cve.getConstraintViolations()) { if (builder.length() != 0) { builder.append(NEW_LINE); } builder.append(cv.getMessage()); } } this.countException(cve); log.error(cve.getLocalizedMessage(), cve); response.sendError(HttpStatus.PRECONDITION_FAILED.value(), builder.toString()); }
From source file:fr.olympicinsa.riocognized.exception.MyExceptionHandler.java
@ExceptionHandler(NoFaceDetectedException.class) @ResponseBody//from w w w .j a v a 2 s . co m @ResponseStatus(HttpStatus.PRECONDITION_FAILED) public ErrorMessage handleNoFaceDetectedException(NoFaceDetectedException e, HttpServletRequest req) { return new ErrorMessage("NO_FACE_DETECTED"); }
From source file:de.thm.arsnova.controller.SecurityExceptionControllerAdvice.java
@ResponseStatus(HttpStatus.PRECONDITION_FAILED) @ExceptionHandler(PreconditionFailedException.class) public void handlePreconditionFailedException(final Exception e, final HttpServletRequest request) { }
From source file:com.netflix.genie.web.controllers.GenieExceptionMapper.java
/** * Handle MethodArgumentNotValid exceptions. * * @param response The HTTP response/*w w w .j a v a 2 s. c om*/ * @param e The exception to handle * @throws IOException on error in sending error */ @ExceptionHandler(MethodArgumentNotValidException.class) public void handleMethodArgumentNotValidException(final HttpServletResponse response, final MethodArgumentNotValidException e) throws IOException { this.countException(e); log.error(e.getMessage(), e); response.sendError(HttpStatus.PRECONDITION_FAILED.value(), e.getMessage()); }
From source file:com.searchbox.framework.web.admin.SearchElementDefinitionController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView update(@Valid SearchElementEntity elementDefinition, BindingResult bindingResult, HttpServletRequest httpServletRequest, ServerHttpResponse response) { LOGGER.info("Creating an filed element: " + elementDefinition.getClazz().getSimpleName() + " for preset: " + elementDefinition.getPreset().getSlug()); ModelAndView model = new ModelAndView("admin/SearchElementDefinition/updateForm"); if (bindingResult.hasErrors()) { LOGGER.error("Bindding has error..."); for (ObjectError error : bindingResult.getAllErrors()) { LOGGER.error("Error: " + error.getDefaultMessage()); }/*from w w w .j av a2s.c o m*/ response.setStatusCode(HttpStatus.PRECONDITION_FAILED); return model; } try { elementDefinition = repository.save(elementDefinition); } catch (Exception e) { LOGGER.error("Could not save elementDefinition", e); } model.addObject("searchElementDefinition", elementDefinition); return model; }
From source file:com.netflix.genie.web.controllers.GenieExceptionMapperUnitTests.java
/** * Test constraint violation exceptions. * * @throws IOException on error// w w w . ja v a 2 s. com */ @Test public void canHandleConstraintViolationExceptions() throws IOException { final ConstraintViolationException exception = new ConstraintViolationException("cve", null); this.mapper.handleConstraintViolation(this.response, exception); Mockito.verify(this.response, Mockito.times(1)) .sendError(Mockito.eq(HttpStatus.PRECONDITION_FAILED.value()), Mockito.anyString()); Mockito.verify(counterId, Mockito.times(1)).withTag(MetricsConstants.TagKeys.EXCEPTION_CLASS, exception.getClass().getCanonicalName()); Mockito.verify(counter, Mockito.times(1)).increment(); }
From source file:org.echocat.marquardt.authority.spring.SpringAuthorityController.java
@ExceptionHandler(AlreadyLoggedInException.class) @ResponseStatus(value = HttpStatus.PRECONDITION_FAILED, reason = "Already logged in.") public void handleAlreadyLoggedInException(final AlreadyLoggedInException ex) { LOGGER.info(ex.getMessage());/*from www . jav a2 s . c o m*/ }