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:com.jaspersoft.jasperserver.rest.services.RESTPermission.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { String res = restUtils.extractRepositoryUri(req.getPathInfo()); try {/*from w w w . ja va 2s . c o m*/ List<ObjectPermission> permissions = permissionsService.getPermissions(res); restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, generatePermissionUsingJaxb(permissions)); } catch (RemoteException e) { throw new ServiceException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getClass().getName() + (e.getMessage() != null ? ": " + e.getMessage() : "")); } }
From source file:com.esri.gpt.control.rest.search.DistributedSearchServlet.java
/** * Processes the HTTP request./*from www .j a v a 2 s. c o m*/ * * @param request * the HTTP request. * @param response * HTTP response. * @param context * request context * @throws Exception * if an exception occurs */ @Override public void execute(HttpServletRequest request, HttpServletResponse response, RequestContext context) throws Exception { LOG.finer("Handling rest query string=" + request.getQueryString()); MessageBroker msgBroker = new FacesContextBroker(request, response).extractMessageBroker(); // parse the query RestQuery query = null; PrintWriter printWriter = null; try { query = parseRequest(request, context); if (query == null) query = new RestQuery(); this.executeQuery(request, response, context, msgBroker, query); } catch (Exception e) { LOG.log(Level.SEVERE, "Error executing query.", e); String msg = Val.chkStr(e.getMessage()); if (msg.length() == 0) msg = e.toString(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); } finally { printWriter = response.getWriter(); if (printWriter != null) { try { try { printWriter.flush(); } catch (Throwable e) { LOG.log(Level.FINE, "Error while flushing printwriter", e); } } catch (Throwable t) { LOG.log(Level.FINE, "Error while closing printwriter", t); } } } }
From source file:com.cognifide.cq.cqsm.core.servlets.ScriptReplicationServlet.java
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ResourceResolver resolver = request.getResourceResolver(); final String searchPath = request.getParameter("fileName"); final String run = request.getParameter("run"); if (StringUtils.isEmpty(searchPath)) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); ServletUtils.writeMessage(response, "error", "File name parameter is required"); return;/*from w ww .ja va2 s. c om*/ } final Script script = scriptFinder.find(searchPath, resolver); if (script == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); ServletUtils.writeMessage(response, "error", String.format("Script cannot be found: %s", searchPath)); return; } final String scriptPath = script.getPath(); try { final ModifiableScript modifiableScript = new ModifiableScriptWrapper(resolver, script); if (PUBLISH_RUN.equals(run)) { modifiableScript.setPublishRun(true); } scriptReplicator.replicate(script, resolver); ServletUtils.writeMessage(response, "success", String.format("Script '%s' replicated successfully", scriptPath)); } catch (PersistenceException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ServletUtils.writeMessage(response, "error", String.format("Script '%s' cannot be processed because of" + " repository error: %s", scriptPath, e.getMessage())); } catch (ExecutionException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ServletUtils.writeMessage(response, "error", String.format("Script '%s' cannot be processed: %s", scriptPath, e.getMessage())); } catch (ReplicationException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ServletUtils.writeMessage(response, "error", String.format("Script '%s' cannot be replicated: %s", scriptPath, e.getMessage())); } }
From source file:eu.trentorise.smartcampus.unidataservice.controller.rest.StudentInfoController.java
@RequestMapping(method = RequestMethod.GET, value = "/getstudentdata") public @ResponseBody StudentInfoData getStudentInfo(HttpServletRequest request, HttpServletResponse response) throws InvocationException { try {/*ww w . j av a 2 s. co m*/ User user = getCurrentUser(); String userId = getUserId(user); if (userId == null) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return null; } String token = getToken(request); String idAda = getIdAda(token); StudentInfoData sd = getStudentInfo(idAda); if (sd != null) { return sd; } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } return null; } catch (Exception e) { e.printStackTrace(); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return null; }
From source file:com.jaspersoft.jasperserver.rest.services.RESTAttribute.java
@Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { try {//from www. ja v a 2 s . c om String userName = restUtils.getFullUserName(restUtils.extractResourceName(req.getPathInfo())); @SuppressWarnings("unchecked") JAXBList<ProfileAttribute> atts = (JAXBList<ProfileAttribute>) restUtils.unmarshal(req.getInputStream(), JAXBList.class, ProfileAttributeImpl.class); for (int i = 0; i < atts.size(); i++) { attributesRemoteService.putAttribute(userName, atts.get(i)); } restUtils.setStatusAndBody(HttpServletResponse.SC_CREATED, resp, ""); } catch (IOException e) { throw new ServiceException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (JAXBException e) { throw new ServiceException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } }
From source file:cz.muni.fi.pa165.deliverysystemweb.CourierActionBean.java
public Resolution update() { courierDTO.setFirstName(escapeHTML(courierDTO.getFirstName())); courierDTO.setLastName(escapeHTML(courierDTO.getLastName())); courierDTO.setEmail(escapeHTML(courierDTO.getEmail())); try {/* www . j a v a 2 s .co m*/ courierService.updateCourier(courierDTO); } catch (DataAccessException ex) { return new ErrorResolution(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return new RedirectResolution(this.getClass(), "list"); }
From source file:net.triptech.buildulator.web.AdminController.java
/** * Update the user.//w w w . jav a2s . co m * * @param id the id * @param colId the col id * @param value the value * @param request the request * @param response the response * @return the string */ @RequestMapping(value = "/users/update", method = RequestMethod.POST) @PreAuthorize("hasRole('ROLE_ADMIN')") public @ResponseBody String updateUser(@RequestParam(value = "id", required = true) final String id, @RequestParam(value = "columnPosition", required = true) final Integer colId, @RequestParam(value = "value", required = true) final String value, final HttpServletRequest request, final HttpServletResponse response) { String returnMessage = ""; Person person = Person.findByEmailAddress(id); if (person != null) { try { returnMessage = person.set(colId, value, this.getContext()); person.merge(); person.flush(); } catch (Exception e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); returnMessage = this.getMessage("users_update_error"); } } else { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); returnMessage = this.getMessage("users_update_notfounderror"); } return returnMessage; }
From source file:com.cognifide.cq.cqsm.core.servlets.ScriptRemoveServlet.java
private void removeAllFiles(ResourceResolver resolver, SlingHttpServletResponse response, String all) throws IOException { if (!Boolean.parseBoolean(all)) { ServletUtils.writeMessage(response, "error", "Remove all scripts is not confirmed"); } else {/*from ww w .j a v a 2 s . c o m*/ final List<String> paths = new LinkedList<>(); final List<Script> scripts = scriptFinder.findAll(resolver); try { for (Script script : scripts) { final String path = script.getPath(); scriptStorage.remove(script, resolver); paths.add(path); } final Map<String, Object> context = new HashMap<>(); context.put("paths", paths); ServletUtils.writeMessage(response, "success", String.format("Scripts removed successfully, total: %d", scripts.size()), context); } catch (RepositoryException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ServletUtils.writeJson(response, "Cannot save remove all scripts. Repository error: " + e.getMessage()); } } }
From source file:org.opendatakit.api.users.UserService.java
@ApiOperation(response = UserEntity.class, responseContainer = "List", value = "This endpoint is backwards-compatible with ODK Aggregate/Survey sync. With admin privileges, this call retrieves user information for all users. Without admin privileges, this retrieves user information for the current user.") @GET// w w w . j a v a2 s . c o m @Path("list") @Produces({ MediaType.APPLICATION_JSON, ApiConstants.MEDIA_TEXT_XML_UTF8, ApiConstants.MEDIA_APPLICATION_XML_UTF8 }) public Response getList(@Context HttpHeaders httpHeaders) throws IOException { TreeSet<GrantedAuthorityName> grants; try { grants = SecurityServiceUtil.getCurrentUserSecurityInfo(callingContext); } catch (ODKDatastoreException e) { logger.error("Retrieving users persistence error: " + e.toString()); e.printStackTrace(); throw new WebApplicationException(ErrorConsts.PERSISTENCE_LAYER_PROBLEM + "\n" + e.toString(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } boolean returnFullList = false; for (GrantedAuthorityName grant : grants) { if (grant.equals(GrantedAuthorityName.ROLE_SITE_ACCESS_ADMIN) || grant.equals(GrantedAuthorityName.ROLE_ADMINISTER_TABLES) || grant.equals(GrantedAuthorityName.ROLE_SUPER_USER_TABLES)) { returnFullList = true; break; } } if (!returnFullList) { ArrayList<HashMap<String, Object>> listOfUsers = new ArrayList<HashMap<String, Object>>(); listOfUsers.add(internalGetUser(grants)); return Response.ok(mapper.writeValueAsString(listOfUsers)).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(); } else { // we have privileges to see all users -- return the full mapping return UserAdminService.internalGetList(callingContext); } }
From source file:com.devicehive.websockets.WebSocketResponseBuilder.java
public JsonObject buildResponse(JsonObject request, WebSocketSession session) { JsonObject response;/*from w w w.ja v a 2 s . c o m*/ try { response = requestProcessor.process(request, session).getResponseAsJson(); } catch (BadCredentialsException ex) { logger.error("Unauthorized access", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_UNAUTHORIZED, "Invalid credentials").build(); } catch (AccessDeniedException ex) { logger.error("Access to action is denied", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized").build(); } catch (HiveException ex) { logger.error("Error executing the request", ex); response = JsonMessageBuilder.createError(ex).build(); } catch (ConstraintViolationException ex) { logger.error("Error executing the request", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage()).build(); } catch (org.hibernate.exception.ConstraintViolationException ex) { logger.error("Error executing the request", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_CONFLICT, ex.getMessage()).build(); } catch (JsonParseException ex) { logger.error("Error executing the request", ex); response = JsonMessageBuilder.createErrorResponseBuilder(HttpServletResponse.SC_BAD_REQUEST, Messages.INVALID_REQUEST_PARAMETERS).build(); } catch (OptimisticLockException ex) { logger.error("Error executing the request", ex); logger.error("Data conflict", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_CONFLICT, Messages.CONFLICT_MESSAGE).build(); } catch (PersistenceException ex) { if (ex.getCause() instanceof org.hibernate.exception.ConstraintViolationException) { response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_CONFLICT, ex.getMessage()).build(); } else { response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()) .build(); } } catch (Exception ex) { logger.error("Error executing the request", ex); response = JsonMessageBuilder .createErrorResponseBuilder(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()) .build(); } return new JsonMessageBuilder().addAction(request.get(JsonMessageBuilder.ACTION)) .addRequestId(request.get(JsonMessageBuilder.REQUEST_ID)).include(response).build(); }