List of usage examples for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR
int SC_INTERNAL_SERVER_ERROR
To view the source code for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR.
Click Source Link
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendSaveSolutionResult() { try {//from w ww . java 2s .c om boolean completed = Boolean.parseBoolean(request.getParameter("completed")); Project solution = objectMapper.readValue(request.getParameter("solution"), Project.class); solution.args = ""; MySqlConnector.getInstance().saveSolution(sessionInfo.getUserInfo(), solution, completed); } catch (IOException e) { writeResponse("Can't write response", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } }
From source file:controller.MunicipiosRestController.java
/** * * @param id/*from w w w . java2 s. c om*/ * @param request * @param response * @return XML */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/xml") public String getByIdXML(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { MunicipiosDAO tabla = new MunicipiosDAO(); XStream XML; Municipios elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } XML = new XStream(); XML.alias("municipio", Municipios.class); response.setStatus(HttpServletResponse.SC_OK); return XML.toXML(elemento); }
From source file:com.janrain.backplane.provision.ProvisioningController.java
/** * Handle auth SimpleDB errors/* w w w .ja v a 2 s . c om*/ */ @ExceptionHandler @ResponseBody public Map<String, String> handle(final SimpleDBException e, HttpServletResponse response) { logger.error("Provisioning authentication error: " + e.getMessage()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return new HashMap<String, String>() { { put(ERR_MSG_FIELD, e.getMessage()); } }; }
From source file:eu.trentorise.smartcampus.unidataservice.controller.rest.Esse3Controller.java
@RequestMapping(method = RequestMethod.GET, value = "/getcds/{facId}") public @ResponseBody List<CdsData> getCds(HttpServletRequest request, HttpServletResponse response, @PathVariable String facId) throws InvocationException { try {/*from www . ja v a 2 s . c o m*/ Map<String, Object> params = new TreeMap<String, Object>(); params.put("facId", facId); return getCds(params); } catch (Exception e) { e.printStackTrace(); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return null; }
From source file:eu.trentorise.smartcampus.mobility.controller.rest.OTPController.java
@RequestMapping(method = RequestMethod.GET, value = "/getstops/{agencyId}/{routeId}/{latitude}/{longitude}/{radius:.+}") public @ResponseBody void getStops(HttpServletRequest request, HttpServletResponse response, HttpSession session, @PathVariable String agencyId, @PathVariable String routeId, @PathVariable double latitude, @PathVariable double longitude, @PathVariable double radius) throws Exception { try {/* ww w.j av a2 s .co m*/ // String address = otpURL + OTP + "getstops/" + agencyId + "/" + routeId + "/" + latitude + "/" + longitude + "/" + radius; // String stops = HTTPConnector.doGet(address, null, null, MediaType.APPLICATION_JSON, "UTF-8"); logger.info("-" + getUserId() + "~AppConsume~stops=" + agencyId); String stops = smartPlannerHelper.stops(agencyId, routeId, latitude, longitude, radius); response.setContentType("application/json; charset=utf-8"); response.getWriter().write(stops); } catch (ConnectorException e0) { response.setStatus(e0.getCode()); } catch (Exception e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:com.ephesoft.gxt.admin.server.TestExtractionResultDownloadServlet.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) *//*from w w w. j a v a 2 s .c o m*/ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.info("Downloading the result file."); final String identifier = request.getParameter("batchClassIdentifier"); final String zipFileName = EphesoftStringUtil.concatenate(identifier, UNDER_SCORE, "Result"); LOGGER.info("Zip File Name is " + zipFileName); response.setContentType(APPLICATION_ZIP); final String downloadedFile = EphesoftStringUtil.concatenate(zipFileName, ".zip", "\"\r\n"); response.setHeader(CONTENT_DISPOSITION, "attachment; filename=\"" + downloadedFile); final BatchSchemaService batchService = this.getSingleBeanOfType(BatchSchemaService.class); StringBuilder folderPathBuilder = new StringBuilder(batchService.getBaseFolderLocation()); folderPathBuilder.append(File.separator); folderPathBuilder.append(identifier); File batchClassFolder = new File(folderPathBuilder.toString()); if (!batchClassFolder.exists()) { LOGGER.info("Batch Class Folder does not exist."); throw new IOException("Unable to download extraction result. Batch Class Folder does not exist."); } // The path for test classification folder is found....... folderPathBuilder.append(File.separator); folderPathBuilder.append(BatchClassConstants.TEST_EXTRACTION_FOLDER_NAME); folderPathBuilder.append(File.separator); folderPathBuilder.append("test-extraction-result"); System.out.println("The path is : " + folderPathBuilder.toString()); File file = new File(folderPathBuilder.toString()); if (!file.exists()) { throw new IOException("Unable to download the files. The file does not exist."); } LOGGER.info("File path is " + folderPathBuilder.toString()); ServletOutputStream out = null; ZipOutputStream zout = null; try { out = response.getOutputStream(); zout = new ZipOutputStream(out); FileUtils.zipDirectoryWithFullName(folderPathBuilder.toString(), zout); } catch (IOException ioException) { LOGGER.error("Unable to download the files." + ioException, ioException); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Problem occured in downloading."); } finally { IOUtils.closeQuietly(zout); IOUtils.closeQuietly(out); } }
From source file:org.opendatakit.api.users.UserService.java
@ApiOperation(response = UserEntity.class, value = "Return just the current user.") @GET/*from www .jav a 2 s . c om*/ @Path("current") @Produces({ MediaType.APPLICATION_JSON, ApiConstants.MEDIA_TEXT_XML_UTF8, ApiConstants.MEDIA_APPLICATION_XML_UTF8 }) public Response getCurrent(@Context HttpHeaders httpHeaders) throws IOException { TreeSet<GrantedAuthorityName> grants; try { grants = SecurityServiceUtil.getCurrentUserSecurityInfo(callingContext); } catch (ODKDatastoreException e) { logger.error("Retrieving users persistence error: " + e.toString()); throw new WebApplicationException(ErrorConsts.PERSISTENCE_LAYER_PROBLEM + "\n" + e.toString(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } HashMap<String, Object> userInfoMap = internalGetUser(grants); UserEntity userEntity = new UserEntity((String) userInfoMap.get(SecurityConsts.USER_ID), (String) userInfoMap.get(SecurityConsts.FULL_NAME), (String) userInfoMap.get(SecurityConsts.OFFICE_ID), (List<String>) userInfoMap.get(SecurityConsts.ROLES)); // Need to set host header? original has // resp.addHeader(HttpHeaders.HOST, cc.getServerURL()); return Response.ok(userEntity).encoding(BasicConsts.UTF8_ENCODE).type(MediaType.APPLICATION_JSON) .header(ApiConstants.OPEN_DATA_KIT_VERSION_HEADER, ApiConstants.OPEN_DATA_KIT_VERSION) .header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Credentials", "true") .build(); }
From source file:com.ephesoft.gxt.admin.server.TestContentResultDownloadServlet.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) *//* w w w .ja v a 2s .co m*/ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.info("Downloading the result file."); final String identifier = request.getParameter("batchClassIdentifier"); final String zipFileName = EphesoftStringUtil.concatenate(identifier, UNDER_SCORE, "Result"); LOGGER.info("Zip File Name is " + zipFileName); response.setContentType(APPLICATION_ZIP); final String downloadedFile = EphesoftStringUtil.concatenate(zipFileName, ".zip", "\"\r\n"); response.setHeader(CONTENT_DISPOSITION, "attachment; filename=\"" + downloadedFile); final BatchSchemaService batchService = this.getSingleBeanOfType(BatchSchemaService.class); StringBuilder folderPathBuilder = new StringBuilder(batchService.getBaseFolderLocation()); folderPathBuilder.append(File.separator); folderPathBuilder.append(identifier); File batchClassFolder = new File(folderPathBuilder.toString()); if (!batchClassFolder.exists()) { LOGGER.info("Batch Class Folder does not exist."); throw new IOException("Unable to perform Content Classification. Batch Class Folder does not exist."); } // The path for test classification folder is found....... folderPathBuilder.append(File.separator); folderPathBuilder.append(BatchClassConstants.TEST_CLASSIFICATION_FOLDER_NAME); folderPathBuilder.append(File.separator); folderPathBuilder.append("test-classification-result"); System.out.println("The path is : " + folderPathBuilder.toString()); File file = new File(folderPathBuilder.toString()); if (!file.exists()) { throw new IOException("Unable to download the files. The file does not exist."); } LOGGER.info("File path is " + folderPathBuilder.toString()); ServletOutputStream out = null; ZipOutputStream zout = null; try { out = response.getOutputStream(); zout = new ZipOutputStream(out); FileUtils.zipDirectoryWithFullName(folderPathBuilder.toString(), zout); } catch (IOException ioException) { LOGGER.error("Unable to download the files." + ioException, ioException); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Problem occured in downloading."); } finally { IOUtils.closeQuietly(zout); IOUtils.closeQuietly(out); } }
From source file:controller.IndicadoresRestController.java
/** * * @param id/* w w w . j ava 2 s . c o m*/ * @param request * @param response * @return XML */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/xml") public String getByIdXML(@PathVariable("id") String id, HttpServletRequest request, HttpServletResponse response) { IndicadoresDAO tabla = new IndicadoresDAO(); XStream XML; Indicadores elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } XML = new XStream(); XML.alias("indicador", Indicadores.class); response.setStatus(HttpServletResponse.SC_OK); return XML.toXML(elemento); }
From source file:controller.TemasNivel2RestController.java
/** * * @param id// ww w . j a v a 2 s . c o m * @param request * @param response * @return XML */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/xml") public String getByIdXML(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { TemasNivel2DAO tabla = new TemasNivel2DAO(); XStream XML; TemasNivel2 elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); XML = new XStream(); XML.alias("message", Error.class); return XML.toXML(e); } XML = new XStream(); XML.alias("Tema-Nivel-2", TemasNivel2.class); response.setStatus(HttpServletResponse.SC_OK); return XML.toXML(elemento); }