List of usage examples for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR
HttpStatus INTERNAL_SERVER_ERROR
To view the source code for org.springframework.http HttpStatus INTERNAL_SERVER_ERROR.
Click Source Link
From source file:org.ow2.proactive.procci.rest.ComputeRest.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<EntitiesRendering> listAllComputes() { logger.debug("Get all Compute instances"); try {/*from w w w . j av a 2s . c om*/ List<EntityRendering> entityRenderings = instanceService.getInstancesRendering(mixinService); return new ResponseEntity<>(new EntitiesRendering.Builder().addEntities(entityRenderings).build(), HttpStatus.OK); } catch (ClientException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(e.getJsonError(), HttpStatus.BAD_REQUEST); } catch (ServerException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:org.bonitasoft.web.designer.controller.ResourceControllerAdvice.java
@ExceptionHandler(IOException.class) public ResponseEntity<ErrorMessage> handleIOException(IOException exception) { logger.error("Internal Server Error Exception", exception); return new ResponseEntity<>(new ErrorMessage(exception), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.ow2.proactive.procci.rest.MixinRest.java
@RequestMapping(method = RequestMethod.POST) public ResponseEntity<MixinRendering> createMixin(@RequestBody MixinRendering mixinRendering) { logger.debug("Creating Mixin " + mixinRendering.toString()); try {/* ww w .j a va 2s .c o m*/ Mixin mixin = new MixinBuilder(mixinService, instanceService, mixinRendering).build(); mixinService.addMixin(mixin); return new ResponseEntity(mixin.getRendering(), HttpStatus.OK); } catch (ServerException ex) { logger.error(this.getClass().getName(), ex); return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } catch (ClientException ex) { return new ResponseEntity(ex.getJsonError(), HttpStatus.BAD_REQUEST); } }
From source file:fr.gmjgav.controller.BarController.java
@RequestMapping(value = "/beerCountry/{location:.+}/{country}", method = GET) public ResponseEntity<?> getByBeerCountry(@PathVariable String location, @PathVariable String country) { List<Beer> beers = beerRepository.findByCountry(country); if (beers.isEmpty()) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); }// ww w. ja va2 s . co m List<Bar> bars = new ArrayList<>(); for (Beer beer : beers) { List<Bar> tmpBarLst = beer.getBars(); for (Bar tmpBar : tmpBarLst) { if (!bars.contains(tmpBar)) { bars.add(tmpBar); } } } ListAndStatus returnedBars = GooglePlacesManager.intersectBarsAndPlaces(bars, barRepository, new Coordinates(location)); return new ResponseEntity<>(returnedBars.getList(), returnedBars.getResponseCode()); }
From source file:org.dawnsci.marketplace.controllers.ExtendedRestApiController.java
@PreAuthorize("hasRole('UPLOAD')") @RequestMapping(value = "/upload", method = RequestMethod.POST) public ResponseEntity<String> postSolution(Principal principal, @RequestBody String solution) throws Exception { Account account = accountRepository.findOne(principal.getName()); Node node = MarketplaceSerializer.deSerializeSolution(solution); Object result = marketplaceDAO.saveOrUpdateSolution(node, account); if (result instanceof Node) { return new ResponseEntity<String>(MarketplaceSerializer.serialize((Node) result), HttpStatus.OK); } else {/* w w w .j a va 2s . co m*/ if (result instanceof Exception) { ((Exception) result).printStackTrace(); String message = ((Exception) result).getMessage(); return new ResponseEntity<String>(message, HttpStatus.INTERNAL_SERVER_ERROR); } else return new ResponseEntity<String>(result.toString(), HttpStatus.FORBIDDEN); } }
From source file:com.todo.backend.web.rest.exception.ExceptionResolver.java
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(Throwable.class) public @ResponseBody ErrorResponse serverError(HttpServletRequest request, Throwable exception) { if (log.isErrorEnabled()) { log.error(exception.getMessage(), exception); }//from w ww. j a va 2 s . c o m return new ErrorResponse(exception.getClass().getSimpleName(), exception.getMessage()); }
From source file:com.github.vanroy.cloud.dashboard.controller.ApplicationController.java
/** * Proxy call instance with specific management method * @param id id of instance//ww w . j av a 2 s.c om * @param method Management method name * @return Return directly from instance */ @RequestMapping(value = "/api/instance/{id}/{method}", method = RequestMethod.GET) public ResponseEntity<String> proxy(@PathVariable String id, @PathVariable String method) { String managementUrl = repository.getInstanceManagementUrl(id); if (managementUrl == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } try { HttpResponse response = httpClient.execute(new HttpGet(managementUrl + "/" + method)); return ResponseEntity.status(response.getStatusLine().getStatusCode()) .body(EntityUtils.toString(response.getEntity())); } catch (Exception e) { LOGGER.debug("Cannot proxy metrics to instance", e); } return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:com.esri.geoportal.harvester.rest.ProcessController.java
/** * Get access to the given process./*from ww w . java 2s . c o m*/ * @param processId process id * @return process info */ @RequestMapping(value = "/rest/harvester/processes/{processId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ProcessStatisticsResponse> getProcessInfo(@PathVariable UUID processId) { try { LOG.debug(formatForLog("GET /rest/harvester/processes/%s", processId)); ProcessInstance process = engine.getProcessesService().getProcess(processId); Statistics statistics = engine.getProcessesService().getStatistics(processId); return new ResponseEntity<>(process != null ? new ProcessStatisticsResponse(processId, process.getTask().getTaskDefinition(), process.getStatus(), statistics) : null, HttpStatus.OK); } catch (DataProcessorException ex) { LOG.error(formatForLog("Error getting process info: %s", processId), ex); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:eu.impress.impressplatform.IntegrationLayer.ResourcesMgmt.BedAvailabilityServiceBean.java
@Override public String createBedAvailabilityDE() throws DatatypeConfigurationException { String DEmessageenvelope = ""; String DEmessage = ""; EDXLDistribution ed = EDXLlib.createEDXLEnvelope(); try {/*from w w w. j a v a 2 s . c o m*/ JAXBContext jaxbContext = JAXBContext.newInstance(EDXLDistribution.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); StringWriter sw = new StringWriter(); //marshal the envelope jaxbMarshaller.marshal(ed, sw); DEmessageenvelope = sw.toString(); //could not unescape characters no matter what! //encapsulate the edxl have message into DE by avoiding jaxb //DEmessage = EDXLlib.DEEncapsulation(DEmessageenvelope, edxlhave); DEmessage = DEmessageenvelope; } catch (JAXBException e) { e.printStackTrace(); return "Error Marshalling XML Object" + HttpStatus.INTERNAL_SERVER_ERROR; } return DEmessage; }
From source file:de.steilerdev.myVerein.server.controller.user.MessageController.java
/** * This function retrieves all unread messages of a user. The function is invoked bu GETting the URI /api/user/message. * @param currentUser The currently logged in user. * @return An HTTP response with a status code, together with the JSON list-object of all unread messages, or only an error code if an error occurred. *//*from w w w. j a v a 2s. c o m*/ @RequestMapping(produces = "application/json", method = RequestMethod.GET) public ResponseEntity<List<Message>> getMessages(@CurrentUser User currentUser, @RequestParam(required = false) String all) { logger.trace("[{}] Getting unread messages", currentUser); List<Message> messages = messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.PENDING); if (messages == null) { logger.debug("[{}] Unable to find any undelivered messages", currentUser); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { messages.parallelStream().forEach(message -> message.setDelivered(currentUser)); if (all != null && !all.isEmpty()) { logger.debug("[{}] Retrieving all messages", currentUser); messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.DELIVERED)); messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.READ)); } try { messageRepository.save(messages); messages.replaceAll(Message::getSendingObjectOnlyId); logger.info("[{}] Returning messages", currentUser); return new ResponseEntity<>(messages, HttpStatus.OK); } catch (IllegalArgumentException e) { logger.warn("[" + currentUser + "] Unable to save messages for " + currentUser.getEmail() + ": " + e.getMessage()); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } }