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:at.ac.tuwien.infosys.ArtifactBuilder.java

@RequestMapping(value = "/plan/{componentName}/{componentVersion}", method = RequestMethod.GET)
public ResponseEntity<List<Component>> mockCDM(@PathVariable String componentName,
        @PathVariable String componentVersion) {

    List<Component> components = new ArrayList<Component>();

    try {/*from  w  w w.  java  2  s.c o  m*/
        Component component = componentRepository.get(componentName, new Version(componentVersion));

        for (Dependency dependency : componentRepository.getDependencies(component)) {
            components.add(componentRepository.get(dependency.getName(), dependency.getVersion()));
        }

        components.add(component);
    } catch (NotFoundException e) {
        e.printStackTrace();
        return new ResponseEntity<List<Component>>(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    logger.info("Returning component-list: " + components);

    return new ResponseEntity<List<Component>>(components, HttpStatus.OK);
}

From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java

@RequestMapping(produces = APPLICATION_JSON)
@ExceptionHandler(Exception.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public @ResponseBody Map<String, Object> handleUncaughtException(Exception ex) throws IOException {
    Map<String, Object> map = newHashMap();
    map.put("error", "Unknown Error");
    if (ex.getCause() != null) {
        map.put("cause", ex.getCause().getMessage());
    } else {/*from w  w  w .ja  v  a  2 s . c  om*/
        map.put("cause", ex.getMessage());
    }
    return map;
}

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

/**
 * GET  /account : get the current user.
 *
 * @return the ResponseEntity with status 200 (OK) and the current user in body, or status 500 (Internal Server Error) if the user couldn't be returned
 *///from   ww  w .jav a  2s . co m
@RequestMapping(value = "/account", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<UserDTO> getAccount() {
    return Optional.ofNullable(userService.getUserWithAuthorities())
            .map(user -> new ResponseEntity<>(new UserDTO(user), HttpStatus.OK))
            .orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:net.oneandone.stool.overview.StageController.java

@ExceptionHandler(Exception.class)
public ResponseEntity<ExceptionExport> handleApiException(Throwable e) {
    LOG.error("Exception in stageoverview", e);
    return new ResponseEntity<>(new ExceptionExport(e), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:org.openmrs.module.rheashradapter.web.controller.RHEApatientController.java

@RequestMapping(value = "/identifier", method = RequestMethod.PUT)
@ResponseBody/*from ww  w .  ja  v a 2 s .c  om*/
public ResponseEntity<String> mergePatients(@RequestBody String mergeMessage, HttpServletRequest request,
        HttpServletResponse response) {
    Map<String, String> postUpdateIdentifiers = null;
    Map<String, String> preUpdateIdentifiers = null;

    HttpSession httpSession = request.getSession();
    if (Context.isAuthenticated()) {
        NodeList node = identifyMessageType(mergeMessage);
        String typeName = node.item(0).getTextContent();

        postUpdateIdentifiers = identifyPostUpdateIdentifiers(mergeMessage);
        preUpdateIdentifiers = identifyPreUpdateIdentifiers(mergeMessage);

        if (typeName.equals("JOIN")) {
            Object httpResponse = mergePatient(postUpdateIdentifiers, preUpdateIdentifiers);
            response.setStatus((Integer) httpResponse);

            if (response.equals(HttpServletResponse.SC_OK)) {
                httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.merged");
                validatePostidentifiers(postUpdateIdentifiers);

                return new ResponseEntity<String>(HttpStatus.OK);
            } else {
                return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);

            }
        } else if (typeName.equals("LEAVE")) {
            Object httpResponse = restorePatient(postUpdateIdentifiers, preUpdateIdentifiers);
            response.setStatus((Integer) httpResponse);

            if (response.equals(HttpServletResponse.SC_OK)) {
                httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.restored");
                validatePostidentifiers(postUpdateIdentifiers);

                return new ResponseEntity<String>(HttpStatus.OK);
            } else {
                return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
        }
    }
    return new ResponseEntity<String>(HttpStatus.FORBIDDEN);
}

From source file:edu.sjsu.cmpe275.project.controller.ReservationController.java

/** Update a reservation
 * @param a         Description of a/*from  w w w  .ja va 2s . c om*/
 * @param b         Description of b
 * @return         Description of c
 */

@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public ResponseEntity<?> updateReservation(@PathVariable("id") Long reservationNo,
        @RequestParam(value = "email", required = true) String email,
        @RequestParam(value = "fname", required = true) String fname,
        @RequestParam(value = "midname", required = false) String midname,
        @RequestParam(value = "lname", required = true) String lname,
        @RequestParam(value = "dl_no", required = true) String dlNo,
        @RequestParam(value = "street", required = true) String street,
        @RequestParam(value = "city", required = true) String city,
        @RequestParam(value = "state", required = true) String state,
        @RequestParam(value = "zip", required = true) String zip,
        @RequestParam(value = "discount", required = false) Integer discount,
        @RequestParam(value = "rooms", required = true) List<String> rooms) {

    //TODO

    Reservation reservation = new Reservation();
    reservation = reservationService.update(reservation);
    if (reservation == null) {
        return new ResponseEntity<Object>(null, HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        return new ResponseEntity<Object>(reservation, HttpStatus.OK);
    }
}

From source file:eu.trentorise.smartcampus.permissionprovider.auth.internal.RegistrationController.java

/**
 * Register with the REST call//  w  w  w  . j  av  a  2  s .  c o  m
 * @param model
 * @param reg
 * @param result
 * @param req
 * @return
 */
@RequestMapping(value = "/register/rest", method = RequestMethod.POST)
public @ResponseBody void registerREST(@RequestBody RegistrationBean reg, HttpServletResponse res) {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<RegistrationBean>> errors = validator.validate(reg);

    if (errors.size() > 0) {
        res.setStatus(HttpStatus.BAD_REQUEST.value());
        return;
    }
    try {
        manager.register(reg.getName(), reg.getSurname(), reg.getEmail(), reg.getPassword(), reg.getLang());
    } catch (AlreadyRegisteredException e) {
        res.setStatus(HttpStatus.CONFLICT.value());
    } catch (RegistrationException e) {
        e.printStackTrace();
        res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    } catch (Exception e) {
        e.printStackTrace();
        res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    }
}

From source file:de.steilerdev.myVerein.server.controller.ContentController.java

/**
 * This function gathers the name of the club defined within the properties file. The function is invoked by GETting the URI /content/clubName.
 * @return An HTTP response with a status code. If an error occurred an error message is bundled into the response, otherwise the name of the club.
 *///from  www.  j a va 2  s .  c  o  m
@RequestMapping(value = "clubName", method = RequestMethod.GET)
@ResponseBody
ResponseEntity<String> getClubName() {
    logger.trace("Gathering club name");
    String clubName = Settings.loadSettings(settingsRepository).getClubName();
    if (clubName == null || clubName.isEmpty()) {
        logger.warn("Unable to get club name");
        return new ResponseEntity<>("Unable to get club name", HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        logger.debug("Returning club name " + clubName);
        return new ResponseEntity<>(clubName, HttpStatus.OK);
    }
}

From source file:com.haulmont.restapi.controllers.FileUploadController.java

protected void uploadToMiddleware(InputStream is, FileDescriptor fd) throws FileStorageException {
    try {//www.  j  ava 2  s.c  om
        fileLoader.saveStream(fd, new FileLoader.SingleInputStreamSupplier(is));
    } catch (FileStorageException e) {
        throw new RestAPIException("Unable to upload file to FileStorage",
                "Unable to upload file to FileStorage: " + fd.getId(), HttpStatus.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.devoxx.watson.AskDevoxxController.java

protected ResponseEntity<Object> processInquiry(DevoxxQuestion devoxxQuestion) {
    InquiryResponseNear inquiryResponseNear = callDevoxxWatsonServices(devoxxQuestion);

    return Optional.ofNullable(inquiryResponseNear).map(cr -> new ResponseEntity<>((Object) cr, HttpStatus.OK))
            .orElse(new ResponseEntity<>("AskDevoxx inquiry request unsuccessful",
                    HttpStatus.INTERNAL_SERVER_ERROR));
}