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.openwms.core.http.AbstractWebController.java
/** * Transforming {@link MethodArgumentNotValidException} {@link ValidationException} into server error {@code 500 Internal Server Error} * responses with according validation error message text. * * @return A response object wraps the server result *//*from w w w .j av a2 s. c o m*/ @ExceptionHandler({ MethodArgumentNotValidException.class, ValidationException.class }) public ResponseEntity<Response> handleValidationException() { return new ResponseEntity<>(new Response(translate(ExceptionCodes.VALIDATION_ERROR), HttpStatus.INTERNAL_SERVER_ERROR.toString()), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.jrb.lots.web.GlobalExceptionHandler.java
/** * Converts any remaining unmatched server-based errors into an HTTP 500 * response with an error body./*from w ww . j a va 2s. com*/ * * @param e * the server exception * @return the error body */ @ExceptionHandler({ Exception.class }) public ResponseEntity<MessageResponse> handleServerError(final Exception e) { if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } return utils.createMessageResponse(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.ow2.proactive.procci.rest.ComputeRest.java
@RequestMapping(value = "{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ResourceRendering> getCompute(@PathVariable("id") String id) { logger.debug("Get Compute "); try {// ww w . j av a2 s .c om Optional<Entity> compute = instanceService.getEntity(id, transformerManager.getTransformerProvider(TransformerType.COMPUTE)); if (!compute.isPresent()) { return new ResponseEntity(HttpStatus.NOT_FOUND); } else { return new ResponseEntity<>(((Compute) compute.get()).getRendering(), 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:com.devoxx.watson.AskDevoxxController.java
/** * Analyse the OGG audio file to determine the sentence and process the inquiry from the detected text * @param file the OGG audio file//from w w w.j av a 2 s . c o m * @return response to the client */ @RequestMapping(value = "/speech", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> speechToResponse(@RequestParam("file") MultipartFile file, @RequestHeader("conversationId") String conversationId) { List<SpeechToTextModel> analysisResults; try { analysisResults = getSpeechToTextModels(file); } catch (FileException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } DevoxxQuestion question = new DevoxxQuestion(); ConversationContext conversationContext = null; question.setText(analysisResults.stream().findFirst().map(SpeechToTextModel::getRecognizedText).get()); if (!conversationId.equalsIgnoreCase("0")) { conversationContext = new ConversationContext(); conversationContext.setConversationId(conversationId); ConversationContextSystem conversationContextSystem = new ConversationContextSystem(); // TODO: Daniel: No Idead what are the following 3 properties for. But seems to be required conversationContextSystem.setDialogRequestCounter("1.0"); conversationContextSystem.setDialogTurnCounter("1.0"); conversationContextSystem.setDialogStack("[node_2_1472838558087]"); conversationContext.setSystem(conversationContextSystem); question.setContext(conversationContext); } log.info("Speech To Question:" + question.toString() + ":"); return processInquiry(question); }
From source file:com.cfitzarl.cfjwed.controller.ApiExceptionHandler.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public void handleGenericException(Exception e, HttpServletResponse response) { respond(e, "errors.generic", response, true); }
From source file:org.hekmatof.activiti.editor.ModelSaveRestResource.java
@RequestMapping(value = "/model/{modelId}/deploy") public @ResponseBody ResponseEntity<String> deploy(@PathVariable String modelId) { logger.info("in deploy module"); Model model = engine.getRepositoryService().getModel(modelId); logger.debug("model id is " + model.getId()); try {/*from w w w . j a v a 2s . c o m*/ repositoryService.createDeployment().addInputStream(model.getName() + ".bpmn", new ByteArrayInputStream(exportModel((getBpmnModel(model))))).deploy(); return new ResponseEntity<>(HttpStatus.OK); } catch (IOException e) { logger.error("failed to export model to BPMN XML", e); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:alfio.controller.api.admin.EventApiController.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public String unhandledException(Exception e) { if (!IllegalArgumentException.class.isInstance(e)) { log.warn("unhandled exception", e); }/*from ww w . j a v a 2 s . co m*/ return e.getMessage(); }
From source file:com.ge.predix.acs.zone.management.ZoneController.java
@RequestMapping(method = DELETE, value = V1 + AcsApiUriTemplates.ZONE_URL) @ApiOperation(value = "Deletes the zone.", hidden = true) public ResponseEntity<?> deleteZone(@PathVariable("zoneName") final String zoneName) { try {/* w w w . ja v a 2s . co m*/ Boolean deleted = this.service.deleteZone(zoneName); if (deleted) { return noContent(); } return notFound(); } catch (Exception e) { String message = String.format("Unexpected Exception while deleting Zone with name %s", zoneName); throw new RestApiException(HttpStatus.INTERNAL_SERVER_ERROR, message, e); } }
From source file:com.couchbase.beersample.breweries.BreweriesController.java
@RequestMapping("/{id}") public ResponseEntity<String> getBrewery(@PathVariable String id) { ViewQuery forBrewery = CouchbaseService.createQueryBeersForBrewery(id); Observable<JsonDocument> brewery = couchbaseService.asyncRead(id); Observable<List<JsonDocument>> beers = couchbaseService.findBeersForBreweryAsync(id) //extract rows from the result .flatMap(new Func1<AsyncViewResult, Observable<AsyncViewRow>>() { @Override//from www . java 2s .com public Observable<AsyncViewRow> call(AsyncViewResult asyncViewResult) { return asyncViewResult.rows(); } }) //extract the actual document (pair of brewery id and beer id) .flatMap(new Func1<AsyncViewRow, Observable<JsonDocument>>() { @Override public Observable<JsonDocument> call(AsyncViewRow asyncViewRow) { return asyncViewRow.document(); } }).toList(); //in the next observable we'll transform list of brewery-beer pairs into an array of beers //then we'll inject it into the associated brewery jsonObject Observable<JsonDocument> fullBeers = couchbaseService.concatBeerInfoToBrewery(brewery, beers) //take care of the case where no corresponding brewery info was found .singleOrDefault(JsonDocument.create("empty", JsonObject.create().put("error", "brewery " + id + " not found"))) //log errors and return a json describing the error if one arises .onErrorReturn(new Func1<Throwable, JsonDocument>() { @Override public JsonDocument call(Throwable throwable) { LOGGER.warn("Couldn't get beers", throwable); return JsonDocument.create("error", JsonObject.create().put("error", throwable.getMessage())); } }); try { return new ResponseEntity<String>(fullBeers.toBlocking().single().content().toString(), HttpStatus.OK); } catch (Exception e) { LOGGER.error("Unable to get brewery " + id, e); return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:io.github.autsia.crowly.controllers.rest.CampaignsController.java
@RequestMapping(value = "/create", method = RequestMethod.GET) public ResponseEntity<String> create(@RequestParam String name, @RequestParam String socialEndpoints, @RequestParam String languages, @RequestParam String keywords, @RequestParam String regionNames, @RequestParam String cronExpression, @RequestParam String sentiment, @RequestParam float threshold, @RequestParam(required = false) String userEmails, HttpServletResponse response) { try {/*from w w w. ja v a2 s.co m*/ Campaign campaign = new Campaign(); campaign.setName(name); campaign.setStatus(Campaign.NOT_ACTIVE); campaign.setSocialEndpoints(new HashSet<>(Arrays.asList(socialEndpoints.split(SEPARATOR)))); campaign.setLanguages(new HashSet<>(Arrays.asList(languages.split(SEPARATOR)))); campaign.setKeywords(new HashSet<>(Arrays.asList(keywords.split(SEPARATOR)))); campaign.setLocations( geoLocationService.getLocationsAsMap(Arrays.asList(regionNames.split(SEPARATOR)))); campaign.setCronExpression(cronExpression); campaign.setSentiment(Sentiment.get(sentiment)); campaign.setThreshold(threshold); if (userEmails == null) { userEmails = authenticationManager.getCurrentUserEmail(); } Set<String> emailsToStore = new HashSet<>(Arrays.asList(userEmails.split(SEPARATOR))); emailsToStore.add(authenticationManager.getCurrentUserEmail()); campaign.setUserEmails(emailsToStore); campaignRepository.save(campaign); return new ResponseEntity<>(HttpStatus.OK); } catch (Exception e) { logger.error(e.getMessage(), e); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }