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:access.test.PiazzaEnvironmentTests.java
@Test public void testResourceCreationServerError() { Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces"), Mockito.eq(HttpMethod.POST), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<>("{\"result\": \"all good\"}", HttpStatus.OK)) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)) .thenThrow(new RuntimeException()); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces/piazza.xml"), Mockito.eq(HttpMethod.PUT), Mockito.any(), Mockito.eq(String.class))) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/datastores/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/datastores"), Mockito.eq(HttpMethod.POST), Mockito.any(), Mockito.eq(String.class))) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)) .thenThrow(new RuntimeException()); this.piazzaEnvironment.initializeEnvironment(); this.piazzaEnvironment.initializeEnvironment(); this.piazzaEnvironment.initializeEnvironment(); }
From source file:org.venice.piazza.servicecontroller.controller.ServiceController.java
/** * Registers a service with the piazza service controller. * //from w w w . j a va2 s . c om * This service is meant for internal Piazza use, Swiss-Army-Knife (SAK) administration and for testing of the * serviceController. * * @param serviceMetadata * metadata about the service * @return A Json message with the resourceId {resourceId="<the id>"} */ @RequestMapping(value = "/registerService", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<PiazzaResponse> registerService(@RequestBody PiazzaJobRequest jobRequest) { try { RegisterServiceJob serviceJob = (RegisterServiceJob) jobRequest.jobType; // For Task-Managed Services, URL is not required. For all other // services, it is. Validate that here. if ((serviceJob.data.getIsTaskManaged() == null) || (serviceJob.data.getIsTaskManaged() == false)) { if ((serviceJob.data.getUrl() == null) || (serviceJob.data.getUrl().isEmpty())) { // Throw validation error throw new InvalidInputException("`url` property is required."); } } String serviceId = rsHandler.handle(serviceJob.data); return new ResponseEntity<PiazzaResponse>(new ServiceIdResponse(serviceId), HttpStatus.OK); } catch (InvalidInputException exception) { LOGGER.error("Error Registering Service", exception); logger.log(String.format("Error Registering Service: %s", exception.getMessage()), Severity.ERROR, new AuditElement("serviceController", "registeringService", "jobRequest")); return new ResponseEntity<PiazzaResponse>( new ErrorResponse(String.format("Error Registering Service: %s", exception.getMessage()), "Service Controller"), HttpStatus.BAD_REQUEST); } catch (Exception exception) { LOGGER.error("Error Registering Service", exception); logger.log(String.format("Error Registering Service: %s", exception.getMessage()), Severity.ERROR, new AuditElement("serviceController", "registeringService", "jobRequest")); return new ResponseEntity<PiazzaResponse>( new ErrorResponse(String.format("Error Registering Service: %s", exception.getMessage()), "Service Controller"), HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:org.echocat.marquardt.authority.spring.SpringAuthorityController.java
@ExceptionHandler(IOException.class) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) public void handleIOException(final IOException ex) { LOGGER.error("Caught unhandled IOException.", ex); }
From source file:org.apereo.openlrs.controllers.xapi.XAPIExceptionHandlerAdvice.java
@ExceptionHandler(Exception.class) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody//from w w w .java 2s .c o m public XAPIErrorInfo exception(final HttpServletRequest request, Exception e) throws Exception { final String logMessageReferenceId = RandomStringUtils.randomAlphanumeric(8); final XAPIErrorInfo result = new XAPIErrorInfo(HttpStatus.INTERNAL_SERVER_ERROR, request, "Unexpected error [reference ID: " + logMessageReferenceId + "]."); logger.debug("Unexpected XAPI exception [refId: {}]: {}", logMessageReferenceId, e); this.logError(result); return result; }
From source file:com.esri.geoportal.harvester.rest.BrokerController.java
/** * Adds a new task.// ww w.j a v a2s .c om * @param brokerDefinition broker definition * @return broker info of the newly created broker */ @RequestMapping(value = "/rest/harvester/brokers", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<BrokerResponse> createBroker(@RequestBody EntityDefinition brokerDefinition) { try { LOG.debug(String.format("POST /rest/harvester/brokers <-- %s", brokerDefinition)); return new ResponseEntity<>(BrokerResponse.createFrom( engine.getBrokersService().createBroker(brokerDefinition, LocaleContextHolder.getLocale())), HttpStatus.OK); } catch (DataProcessorException ex) { LOG.error(String.format("Error creating broker: %s", brokerDefinition), ex); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:cn.org.once.cstack.config.RestHandlerException.java
@ExceptionHandler(value = { NoSuchElementException.class }) protected ResponseEntity<Object> handleNoSuchElementException(Exception ex, WebRequest request) { ex.printStackTrace();/*from w w w . j a va 2 s.c om*/ HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return handleExceptionInternal(ex, new HttpErrorServer("An unkown error has occured! Server response : NoSuchElementException"), headers, HttpStatus.INTERNAL_SERVER_ERROR, request); }
From source file:com.haulmont.restapi.ldap.LdapAuthController.java
@ExceptionHandler(Exception.class) public ResponseEntity<OAuth2Exception> handleException(Exception e) throws Exception { log.error("Exception in LDAP auth controller", e); return new ResponseEntity<>(new OAuth2Exception("Server error", e), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.openlmis.fulfillment.web.errorhandler.ServiceErrorHandling.java
/** * Handles the {@link JRException} which may be thrown during Jasper report generation. * * @param err exception that caused the issue * @return error response/* ww w. j av a2 s . com*/ */ @ExceptionHandler(JRException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public Message.LocalizedMessage handleJrRuntimeException(JRException err) { return logErrorAndRespond("Error during Jasper Report generation", ERROR_JASPER_REPORT_CREATION_WITH_MESSAGE, err.getMessage()); }
From source file:com.hypersocket.auth.json.AuthenticatedController.java
@ExceptionHandler(Throwable.class) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) public void handleException(Throwable ex) { // Log this?//from w ww .jav a2 s.c o m if (log.isErrorEnabled()) { log.error("Caught internal error", ex); } }