Example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

List of usage examples for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Prototype

HttpStatus INTERNAL_SERVER_ERROR

To view the source code for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.

Click Source Link

Document

500 Internal Server Error .

Usage

From source file:edu.pitt.dbmi.ccd.anno.error.ErrorHandler.java

@ExceptionHandler(JpaSystemException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody//  w ww .  j  a  va  2s  . c  o m
public ErrorMessage handleJpaSystemException(JpaSystemException ex, HttpServletRequest req) {
    LOGGER.error(ex.getMessage(), ex);
    return new ErrorMessage(HttpStatus.INTERNAL_SERVER_ERROR, REQUEST_FAILED, req);
}

From source file:com.github.vanroy.cloud.dashboard.controller.ApplicationController.java

/**
 * Proxy call instance with specific management method  (with Http POST method)
 * @param id id of instance/*ww w.j  a  va 2  s . c o  m*/
 * @param method Management method name
 * @return Return directly from instance
 */
@RequestMapping(value = "/api/instance/{id}/{method}", method = RequestMethod.POST)
public ResponseEntity<String> proxyPost(@PathVariable String id, @PathVariable String method,
        @RequestBody String body) {

    String managementUrl = repository.getInstanceManagementUrl(id);
    if (managementUrl == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    try {
        HttpPost post = new HttpPost(managementUrl + "/" + method);
        post.setEntity(new StringEntity(body));
        HttpResponse response = httpClient.execute(post);
        return ResponseEntity.status(response.getStatusLine().getStatusCode())
                .body(EntityUtils.toString(response.getEntity()));
    } catch (IOException e) {
        LOGGER.debug("Cannot proxy metrics to instance", e);
    }
    return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:com.github.bpark.BlogPostController.java

/**
 * Handles SpamExceptions./*from  w w  w  .ja  va2s  .  c o  m*/
 *
 * @param request the request.
 * @param response the response.
 * @param session the session.
 * @param e the SpamException.
 * @return the error page.
 */
@ExceptionHandler(SpamException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleSpamException(HttpServletRequest request, HttpServletResponse response,
        HttpSession session, SpamException e) {
    ModelMap model = new ModelMap();
    return new ModelAndView("/spam", model);
}

From source file:io.kamax.mxisd.controller.DefaultExceptionHandler.java

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(RuntimeException.class)
public String handle(HttpServletRequest req, RuntimeException e) {
    log.error("Unknown error when handling {}", req.getRequestURL(), e);
    return handle(req, "M_UNKNOWN", StringUtils.defaultIfBlank(e.getMessage(),
            "An internal server error occurred. If this error persists, please contact support with reference #"
                    + Instant.now().toEpochMilli()));
}

From source file:com.esri.geoportal.harvester.rest.ProcessController.java

/**
 * Aborts (deletes) an existing process.
 * @param processId process id//from  w ww . j  av  a 2  s.  c  om
 * @return process info
 */
@RequestMapping(value = "/rest/harvester/processes/{processId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProcessResponse> abortProcess(@PathVariable UUID processId) {
    try {
        LOG.debug(formatForLog("DELETE /rest/harvester/processes/%s", processId));
        ProcessInstance process = engine.getProcessesService().getProcess(processId);
        if (process != null) {
            try {
                process.abort();
            } catch (IllegalStateException ex) {
                LOG.warn("Unable to abort the process.", ex);
            }
        }
        return new ResponseEntity<>(process != null
                ? new ProcessResponse(processId, process.getTask().getTaskDefinition(), process.getStatus())
                : null, HttpStatus.OK);
    } catch (DataProcessorException ex) {
        LOG.error(formatForLog("Error aborting process: %s", processId), ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}

From source file:fr.xebia.xke.metrics.web.WineController.java

/**
 * TODO Exercise 8 - Add a meter to monitor error rate ('wine.controller.exception')
 * @param e//from  www  .  j  ava  2s . co  m
 * @return
 */
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception e) {

    return new ResponseEntity<ErrorResponse>(new ErrorResponse(e), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:com.boyuanitsm.fort.web.rest.AccountResource.java

/**
 * GET  /activate : activate the registered user.
 *
 * @param key the activation key/*from www.  j  a v  a2  s .  co  m*/
 * @return the ResponseEntity with status 200 (OK) and the activated user in body, or status 500 (Internal Server Error) if the user couldn't be activated
 */
@RequestMapping(value = "/activate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<String> activateAccount(@RequestParam(value = "key") String key) {
    return userService.activateRegistration(key).map(user -> new ResponseEntity<String>(HttpStatus.OK))
            .orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:edu.mit.oidc.web.StatusEndpoint.java

@RequestMapping(value = "/" + URL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getStatus(Model m) {

    Map<String, Map<String, Object>> e = new HashMap<>();

    ExecutorService executor = Executors.newFixedThreadPool(3);

    try {/*from  w  w w.j av  a 2 s . c om*/
        List<Future<Map<String, Map<String, Object>>>> results = executor
                .invokeAll(Arrays.asList(new Callable<Map<String, Map<String, Object>>>() {
                    // get database status
                    @Override
                    public Map<String, Map<String, Object>> call() throws Exception {
                        return getDbStatus();
                    }
                }, new Callable<Map<String, Map<String, Object>>>() {
                    // get kerberos status
                    @Override
                    public Map<String, Map<String, Object>> call() throws Exception {
                        return getKerbStatus();
                    }
                }, new Callable<Map<String, Map<String, Object>>>() {
                    // get LDAP status
                    @Override
                    public Map<String, Map<String, Object>> call() throws Exception {
                        return getLdapStatus();
                    }
                }), getTimeoutSeconds(), TimeUnit.SECONDS);

        // collect all the results and return them
        for (Future<Map<String, Map<String, Object>>> result : results) {
            e.putAll(result.get());
        }

        m.addAttribute(JsonEntityView.ENTITY, e);
        return JsonEntityView.VIEWNAME;
    } catch (InterruptedException | ExecutionException ex) {

        m.addAttribute(HttpCodeView.CODE, HttpStatus.INTERNAL_SERVER_ERROR);
        m.addAttribute(JsonErrorView.ERROR_MESSAGE, ex.getMessage());

        return JsonErrorView.VIEWNAME;
    }

}

From source file:cn.org.once.cstack.config.RestHandlerException.java

@ExceptionHandler(value = { OutOfMemoryError.class })
protected ResponseEntity<Object> handleOutOfMemoryError(Exception ex, WebRequest request) {
    ex.printStackTrace();/*from   w w  w.  j  a va 2  s .  c  o  m*/
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    return handleExceptionInternal(ex,
            new HttpErrorServer("An unkown error has occured! Server response : OutOfMemoryError"), headers,
            HttpStatus.INTERNAL_SERVER_ERROR, request);
}

From source file:eu.scidipes.toolkits.pawebapp.web.RegistryAuthController.java

@ExceptionHandler(IllegalArgumentException.class)
@ResponseBody/* w w w.  ja  va2 s  .co m*/
public ResponseEntity<String> handleExceptions(final IllegalArgumentException ex) {
    final String err = ex.getMessage();
    LOG.error(err, ex);
    return new ResponseEntity<String>(err, HttpStatus.INTERNAL_SERVER_ERROR);
}