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:com.opensearchserver.hadse.index.IndexCatalog.java

public final static ResponseEntity<?> delete(String indexName) throws IOException {
    File indexFile = new File(Hadse.data_dir, indexName);
    if (!indexFile.exists())
        return new ResponseEntity<String>("Index not found:" + indexName, HttpStatus.NOT_FOUND);
    FileUtils.deleteDirectory(indexFile);
    if (indexFile.exists())
        return new ResponseEntity<String>("Unable to delete the directory", HttpStatus.INTERNAL_SERVER_ERROR);
    IndexItem.remove(indexName);//from w  w w.j a  v  a2s .c o m
    return new ResponseEntity<String>("Index deleted: " + indexName, HttpStatus.OK);
}

From source file:org.osiam.addons.selfadministration.exception.OsiamExceptionHandler.java

@ExceptionHandler(OsiamClientException.class)
protected ModelAndView handleConflict(OsiamClientException ex, HttpServletResponse response) {
    LOGGER.log(Level.WARNING, AN_EXCEPTION_OCCURED, ex);
    response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    modelAndView.addObject(KEY, "registration.form.error");
    setLoggingInformation(ex);//from w  ww  .j  av a  2s  .  c  o  m
    return modelAndView;
}

From source file:com.dbi.jmmerge.MapController.java

@ExceptionHandler
public ResponseEntity<Map> handleException(Exception ex, HttpServletRequest request) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    Map msgs = new HashMap();
    ResponseEntity<Map> ret = new ResponseEntity<Map>(msgs, headers, HttpStatus.INTERNAL_SERVER_ERROR);
    msgs.put("message", "An error occurred . . . contact your administrator for details.");
    msgs.put("error", ex.getMessage());
    LOG.error("An error occurred handling a " + request.getMethod() + " to URL " + request.getRequestURL(), ex);
    return ret;//from w  w w.  j av a 2s .  c  om
}

From source file:com.expedia.seiso.web.controller.ExceptionHandlerAdvice.java

@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/*from   ww  w. ja v a2 s  .c o m*/
public ErrorObject handleRuntimeException(RuntimeException e, WebRequest request) {
    log.error("Internal server error", e);
    val fullMsg = e.getClass().getName() + ": " + e.getMessage();
    return new ErrorObject(C.EC_INTERNAL_ERROR, fullMsg);
}

From source file:com.auditbucket.helper.GlobalControllerExceptionHandler.java

@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleInternal(Exception ex) {
    logger.error("Error 500", ex);
    return new JsonError(ex.getMessage()).asModelAndView();
}

From source file:things.view.rest.ThingRestExceptionHandler.java

@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/*from w  w w . j a v a2s.c om*/
public ErrorInfo exception(final HttpServletRequest req, final Exception ex) {

    myLogger.debug("Exception: " + ex.getLocalizedMessage(), ex);

    return new ErrorInfo(req.getRequestURL().toString(), ex);
}

From source file:com.javafxpert.wikibrowser.WikiLocatorController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> locatorEndpoint(@RequestParam(value = "id", defaultValue = "") String itemId,
        @RequestParam(value = "lang") String lang) {

    String language = wikiBrowserProperties.computeLang(lang);

    ItemInfo itemInfo = null;//from  w  w  w .ja  v a 2 s.co m
    if (!itemId.equals("")) {
        itemInfo = id2Name(itemId, language);
    }

    return Optional.ofNullable(itemInfo).map(cr -> new ResponseEntity<>((Object) cr, HttpStatus.OK))
            .orElse(new ResponseEntity<>("Wikidata query unsuccessful", HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:be.solidx.hot.rest.RestController.java

protected ResponseEntity<byte[]> buildJSONResponse(Object response, HttpHeaders headers,
        HttpStatus httpStatus) {/*from  w w  w .j  a  v  a2 s .c  om*/
    HttpHeaders jsonHeaders = jsonResponseHeaders();
    jsonHeaders.putAll(headers);
    try {
        return new ResponseEntity<byte[]>(objectMapper.writeValueAsBytes(response), jsonHeaders, httpStatus);
    } catch (Exception e) {
        return new ResponseEntity<byte[]>(e.getMessage().getBytes(), HttpStatus.INTERNAL_SERVER_ERROR);
    }
}

From source file:io.lavagna.web.helper.GeneralHandlerExceptionResolver.java

private void handleException(Exception ex, HttpServletResponse response) {
    for (Entry<Class<? extends Throwable>, Integer> entry : statusCodeResolver.entrySet()) {
        if (ex.getClass().equals(entry.getKey())) {
            response.setStatus(entry.getValue());
            LOG.info("Class: {} - Message: {} - Cause: {}", ex.getClass(), ex.getMessage(), ex.getCause());
            LOG.info("Cnt", ex);
            return;
        }//from w  w w  .ja v  a2 s.  com
    }
    /**
     * Non managed exceptions flow Set HTTP status 500 and log the exception with a production visible level
     */
    response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    LOG.warn(ex.getMessage(), ex);
}

From source file:com.opensearchserver.hadse.index.IndexController.java

@RequestMapping(method = RequestMethod.DELETE, value = "/{index_name}")
@ResponseBody//from w w w .  ja  v  a  2s  . c  om
public HttpEntity<?> deleteIndex(@PathVariable String index_name) {
    if (!IndexCatalog.exists(index_name))
        return new ResponseEntity<String>("Index not found: " + index_name, HttpStatus.NOT_FOUND);
    try {
        return IndexCatalog.delete(index_name);
    } catch (IOException e) {
        return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
    }

}