List of usage examples for org.springframework.http HttpStatus SERVICE_UNAVAILABLE
HttpStatus SERVICE_UNAVAILABLE
To view the source code for org.springframework.http HttpStatus SERVICE_UNAVAILABLE.
Click Source Link
From source file:org.zalando.zmon.actuator.RestControllerAdvice.java
@ExceptionHandler(Exception.class) public ResponseEntity<String> handleException(final Exception e) { return new ResponseEntity<String>("TEST-ERROR", HttpStatus.SERVICE_UNAVAILABLE); }
From source file:com.nec.harvest.servlet.interceptor.async.TimeoutCallableProcessingInterceptor.java
@Override public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) throws Exception { final HttpServletResponse servletResponse = request.getNativeResponse(HttpServletResponse.class); if (!servletResponse.isCommitted()) { servletResponse.sendError(HttpStatus.SERVICE_UNAVAILABLE.value()); }/*from w ww .j av a 2s .c om*/ return CallableProcessingInterceptor.RESPONSE_HANDLED; }
From source file:com.xyxy.platform.examples.showcase.demos.hystrix.web.HystrixExceptionHandler.java
/** * ?Hystrix Runtime, :/* w w w . j a va2s. c o m*/ * Command(500). * Hystrix??(503). */ @ExceptionHandler(value = { HystrixRuntimeException.class }) public final ResponseEntity<?> handleException(HystrixRuntimeException e, WebRequest request) { HttpStatus status = HttpStatus.SERVICE_UNAVAILABLE; String message = e.getMessage(); FailureType type = e.getFailureType(); // ? if (type.equals(FailureType.COMMAND_EXCEPTION)) { status = HttpStatus.INTERNAL_SERVER_ERROR; message = Exceptions.getErrorMessageWithNestedException(e); } logger.error(message, e); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.parseMediaType(MediaTypes.TEXT_PLAIN_UTF_8)); return handleExceptionInternal(e, message, headers, status, request); }
From source file:com.basicservice.controller.GeneralController.java
@RequestMapping(method = RequestMethod.GET) @ResponseBody// w ww . j ava 2 s . c om public ResponseEntity<String> runTest(HttpServletResponse response) { LOG.debug("Starting test write to db"); boolean success = service.initReadWriteTest(); LOG.debug("DB test write results: " + success); return new ResponseEntity<String>(success ? HttpStatus.OK : HttpStatus.SERVICE_UNAVAILABLE); }
From source file:com.basicservice.controller.ApiController.java
@ExceptionHandler(Exception.class) public ResponseEntity handleGenericException(Exception error) { try {/*from ww w . jav a2s . com*/ new AppSensorException("ACE1", "Invalid request", "Generic exception occured"); } catch (Exception e) { // AppSensor might throw an exception, but we want to catch it here and stop propagation } return new ResponseEntity<String>(HttpStatus.SERVICE_UNAVAILABLE); }
From source file:io.github.microcks.web.HealthController.java
@RequestMapping(value = "/health", method = RequestMethod.GET) public ResponseEntity<String> health() { log.trace("Health check endpoint invoked"); try {//from ww w . jav a 2s . co m // Using a single selection query to ensure connection to MongoDB is ok. List<ImportJob> jobs = jobRepository .findAll(new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "name"))).getContent(); } catch (Exception e) { log.error("Health check caught an exception: " + e.getMessage(), e); return new ResponseEntity<String>(HttpStatus.SERVICE_UNAVAILABLE); } log.trace("Health check is OK"); return new ResponseEntity<String>(HttpStatus.OK); }
From source file:com.netflix.spinnaker.igor.scm.AbstractCommitController.java
@ExceptionHandler(RuntimeException.class) @ResponseStatus(value = HttpStatus.SERVICE_UNAVAILABLE, reason = "Could not contact the server") public void handleRuntimeException(RuntimeException ex) { log.error("Could not contact the server", ex); }
From source file:org.osiam.resources.exception.OsiamExceptionHandler.java
@ExceptionHandler(ConnectionInitializationException.class) @ResponseStatus(HttpStatus.SERVICE_UNAVAILABLE) @ResponseBody/* w w w.j a va 2 s . c o m*/ public ErrorResponse handleBackendUnavailable(ConnectionInitializationException e) { return produceErrorResponse("Service temporarily unavailable.", HttpStatus.SERVICE_UNAVAILABLE); }
From source file:de.thm.arsnova.controller.SessionController.java
@RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)//from www.j ava 2 s . c o m public Session postNewSession(@RequestBody final Session session, final HttpServletResponse response) { if (session != null && session.isCourseSession()) { final List<Course> courses = new ArrayList<Course>(); final Course course = new Course(); course.setId(session.getCourseId()); courses.add(course); final int sessionCount = sessionService.countSessions(courses); if (sessionCount > 0) { final String appendix = " (" + (sessionCount + 1) + ")"; session.setName(session.getName() + appendix); session.setShortName(session.getShortName() + appendix); } } final Session newSession = sessionService.saveSession(session); if (newSession == null) { response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value()); return null; } return newSession; }
From source file:org.bonitasoft.web.designer.studio.workspace.StudioWorkspaceResourceHandler.java
protected ResponseEntity<String> doGet(final Path filePath, String action) { if (restClient.isConfigured()) { final String url = createGetURL(filePath, action); RestTemplate restTemplate = restClient.getRestTemplate(); return restTemplate.getForEntity(URI.create(url), String.class); }//from w w w . j a v a 2 s.co m return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE); }