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:eu.trentorise.smartcampus.unidataservice.controller.rest.Esse3Controller.java
@RequestMapping(method = RequestMethod.GET, value = "/getad/{cdsId}/{aaOrd}/{aaOff}") public @ResponseBody List<AdData> getAd(HttpServletRequest request, HttpServletResponse response, @PathVariable String cdsId, @PathVariable String aaOrd, @PathVariable String aaOff) throws InvocationException { try {//w w w . j a v a 2 s . c om Map<String, Object> params = new TreeMap<String, Object>(); params.put("cdsId", cdsId); params.put("aaOrd", aaOrd); params.put("aaOff", aaOff); return getAd(params); } catch (Exception e) { e.printStackTrace(); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return null; }
From source file:com.eureka.v1_0.account.information.api.AccountInformationController.java
@ResponseBody @RequestMapping(method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE, produces = MediaType.TEXT_XML_VALUE, value = "/login") public LoginResponse login(@RequestBody LoginRequest loginRequest, HttpServletRequest request, HttpServletResponse response) {//from ww w . j a va 2s . co m if (loginRequest != null) { try { witLoggerService.debug(JaxbHandler.toXml(loginRequest)); LoginResponse loginResponse = this.accountInformationApiService.login(loginRequest); if (loginResponse != null) { witLoggerService.debug(JaxbHandler.toXml(loginResponse)); response.setStatus(HttpServletResponse.SC_OK); return loginResponse; } else { response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED); } } catch (Exception ex) { witLoggerService.warn(ex); ex.printStackTrace(); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return null; }
From source file:de.codecentric.boot.admin.zuul.filters.route.SimpleHostRoutingFilter.java
@Override public Object run() { RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); MultiValueMap<String, String> headers = this.helper.buildZuulRequestHeaders(request); MultiValueMap<String, String> params = this.helper.buildZuulRequestQueryParams(request); String verb = getVerb(request); InputStream requestEntity = getRequestBody(request); if (request.getContentLength() < 0) { context.setChunkedRequestBody(); }// w w w .j a v a 2s.c o m String uri = this.helper.buildZuulRequestURI(request); this.helper.addIgnoredHeaders(); try { CloseableHttpResponse response = forward(this.httpClient, verb, uri, request, headers, params, requestEntity); setResponse(response); } catch (Exception ex) { context.set(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); context.set("error.exception", ex); } return null; }
From source file:org.jasig.portlet.emailpreview.controller.EmailAccountSummaryController.java
@ResourceMapping(value = "accountSummary") public ModelAndView getAccountSummary(ResourceRequest req, ResourceResponse res, @RequestParam("pageStart") int start, @RequestParam("numberOfMessages") int max, @RequestParam(value = "inboxFolder", required = false) String folder) throws IOException { // Define view and generate model Map<String, Object> model = new HashMap<String, Object>(); String username = req.getRemoteUser(); try {/*w w w . j a v a 2 s . c o m*/ // Force a re-load from the data source if called for by the UI. boolean refresh = Boolean.valueOf(req.getParameter(FORCE_REFRESH_PARAMETER)); // Or because of a change in settings. if (req.getPortletSession().getAttribute(FORCE_REFRESH_PARAMETER) != null) { // Doesn't matter what the value is; this calls for a refresh... refresh = true; req.getPortletSession().removeAttribute(FORCE_REFRESH_PARAMETER); } PortletPreferences prefs = req.getPreferences(); if ((folder == null) || (folder.equals(INBOX_NAME_UNDEFINED))) { folder = prefs.getValue(EmailAccountSummaryController.INBOX_NAME_PREFERENCE, INBOX_NAME_DEFAULT); } String prefFolder = prefs.getValue(EmailAccountSummaryController.INBOX_NAME_PREFERENCE, INBOX_NAME_DEFAULT); if ((!prefs.isReadOnly(INBOX_NAME_PREFERENCE)) && (!folder.equals(prefFolder))) { prefs.setValue(INBOX_NAME_PREFERENCE, folder); prefs.store(); } // Get current user's account information AccountSummary accountSummary = getEmailAccountService(req).getAccountSummary(req, start, max, refresh, folder); // Check for AuthN failure... if (accountSummary.isValid()) { model.put(KEY_ACCOUNT_SUMMARY, accountSummary); model.put(KEY_INBOX_URL, accountSummary.getInboxUrl()); if (accountSummary.getQuota() == null) { model.put(KEY_EMAIL_QUOTA_USAGE, "-1"); } else { model.put(KEY_EMAIL_QUOTA_USAGE, accountSummary.getQuota().getUsageAsPercentage()); model.put(KEY_EMAIL_QUOTA_LIMIT, accountSummary.getQuota().getLimitAsString()); } } else { Throwable cause = accountSummary.getErrorCause(); if (MailAuthenticationException.class.isAssignableFrom(cause.getClass())) { log.info("Authentication Failure (username='" + username + "') : " + cause.getMessage()); res.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_UNAUTHORIZED)); model.put(KEY_ERROR, "Not authorized"); } else { log.error("Unanticipated Error", cause); res.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); model.put(KEY_ERROR, "Unanticipated Error"); } } } catch (MailTimeoutException ex) { log.error("Mail Service Timeout", ex); res.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_GATEWAY_TIMEOUT)); model.put(KEY_ERROR, "Mail Service Timeout"); } catch (Exception ex) { /* ******************************************************** In the case of an unknown error we want to send the exception's message back to the portlet. This will let implementers write specific instructions for their service desks to follow for specific errors. ******************************************************** */ log.error("Unanticipated Error", ex); res.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); model.put(KEY_ERROR, "ex.getMessage()"); } return new ModelAndView("json", model); }
From source file:com.enonic.cms.web.webdav.DavResourceImpl.java
private void createFile(final File localFile, final InputContext in) throws DavException { try {//from ww w . j a v a2 s .com ByteStreams.copy(in.getInputStream(), Files.newOutputStreamSupplier(localFile)); } catch (IOException e) { throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } }
From source file:com.eureka.v1_0.kyc.information.api.KycInformationApiController.java
@ResponseBody @RequestMapping(method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE, produces = MediaType.TEXT_XML_VALUE, value = "/createpersonalinformation") public CreatePersonalInformationResponse createPersonalInformation( @RequestBody CreatePersonalInformationRequest createPersonalInformationRequest, HttpServletRequest request, HttpServletResponse response) { if (createPersonalInformationRequest != null) { try {/*from ww w . j av a 2 s . c o m*/ witLoggerService.debug(JaxbHandler.toXml(createPersonalInformationRequest)); CreatePersonalInformationResponse createPersonalInformationResponse = this.kycInformationApiService .createPersonalInformation(createPersonalInformationRequest); if (createPersonalInformationResponse != null) { witLoggerService.debug(JaxbHandler.toXml(createPersonalInformationResponse)); response.setStatus(HttpServletResponse.SC_OK); return createPersonalInformationResponse; } else { response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED); } } catch (Exception ex) { witLoggerService.warn(ex); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return null; }
From source file:org.ngrinder.script.controller.DavSvnController.java
/** * Request Handler./*w w w . j av a 2 s. com*/ * * @param request * request * @param response * response * @throws ServletException * occurs when servlet has a problem. * @throws IOException * occurs when file system has a problem. */ @Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (LOGGER.isTraceEnabled()) { logRequest(request); } try { final String head = DAVPathUtil.head(request.getPathInfo()); final User currentUser = userContext.getCurrentUser(); // check the security. If the other user tries to the other user's // repo, deny it. if (!StringUtils.equals(currentUser.getUserId(), head)) { SecurityContextHolder.getContext().setAuthentication(null); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, head + " is not accessible by " + currentUser.getUserId()); return; } // To make it understand Asian Language.. request = new MyHttpServletRequestWrapper(request); DAVRepositoryManager repositoryManager = new DAVRepositoryManager(getDAVConfig(), request); ServletDAVHandler handler = DAVHandlerExFactory.createHandler(repositoryManager, request, response); handler.execute(); } catch (DAVException de) { response.setContentType(XML_CONTENT_TYPE); handleError(de, response); } catch (SVNException svne) { StringWriter sw = new StringWriter(); svne.printStackTrace(new PrintWriter(sw)); /** * truncate status line if it is to long */ String msg = sw.getBuffer().toString(); if (msg.length() > 128) { msg = msg.substring(0, 128); } SVNErrorCode errorCode = svne.getErrorMessage().getErrorCode(); if (errorCode == SVNErrorCode.FS_NOT_DIRECTORY || errorCode == SVNErrorCode.FS_NOT_FOUND || errorCode == SVNErrorCode.RA_DAV_PATH_NOT_FOUND) { response.sendError(HttpServletResponse.SC_NOT_FOUND, msg); } else if (errorCode == SVNErrorCode.NO_AUTH_FILE_PATH) { response.sendError(HttpServletResponse.SC_FORBIDDEN, msg); } else if (errorCode == SVNErrorCode.RA_NOT_AUTHORIZED) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, msg); } else { String errorBody = generateStandardizedErrorBody(errorCode.getCode(), null, null, svne.getMessage()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType(XML_CONTENT_TYPE); response.getWriter().print(errorBody); } } catch (Throwable th) { StringWriter sw = new StringWriter(); th.printStackTrace(new PrintWriter(sw)); String msg = sw.getBuffer().toString(); LOGGER.debug("Error in DavSVN Controller", th); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); } finally { response.flushBuffer(); } }
From source file:com.novartis.pcs.ontology.rest.servlet.SynonymsServlet.java
private void serialize(String datasourceAcronym, String vocabRefId, boolean pending, HttpServletResponse response) {//from ww w. jav a 2 s . c o m try { List<SynonymDTO> dtos = new ArrayList<SynonymDTO>(1024); Datasource datasource = datasourceDAO.loadByAcronym(datasourceAcronym); if (datasource != null) { Collection<Synonym> synonyms = vocabRefId != null ? synonymDAO.loadByCtrldVocabRefId(datasource, vocabRefId) : synonymDAO.loadByDatasource(datasource); EnumSet<Status> statusSet = pending ? EnumSet.of(Status.PENDING, Status.APPROVED) : EnumSet.of(Status.APPROVED); for (Synonym synonym : synonyms) { if (statusSet.contains(synonym.getStatus())) { dtos.add(new SynonymDTO(synonym)); } } } if (!dtos.isEmpty()) { response.setStatus(HttpServletResponse.SC_OK); response.setHeader("Access-Control-Allow-Origin", "*"); response.setContentType(MEDIA_TYPE_JSON + ";charset=utf-8"); response.setHeader("Cache-Control", "public, max-age=0"); // As per jackson javadocs - Encoding will be UTF-8 mapper.writeValue(response.getOutputStream(), dtos); } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setContentLength(0); } } catch (Exception e) { log("Failed to serialize synonyms to JSON", e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentLength(0); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendProjectFileContent() { try {//from w ww . j av a2 s . c om ProjectFile file = MySqlConnector.getInstance().getFile(request.getParameter("publicId")); if (file != null) { writeResponse(objectMapper.writeValueAsString(file), HttpServletResponse.SC_OK); } else { writeResponse("", HttpServletResponse.SC_NOT_FOUND); } } catch (IOException e) { writeResponse("Can't write response", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } }