List of usage examples for javax.servlet ServletException printStackTrace
public void printStackTrace()
From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java
/** * //from w w w. j a v a 2 s . c om * @param groupName * @return */ public NodeRef getNodeRefForGroup(AlfrescoTransaction transaction, String groupName) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("serviceName", "AuthorityDAO"); parameters.put("methodName", "getAuthorityNodeRefOrNull"); Vector<Object> paramList = new Vector<Object>(); // add parameters to the method in paramList String patchedGroupName = PermissionService.GROUP_PREFIX + groupName; if (groupName.startsWith(PermissionService.GROUP_PREFIX)) { patchedGroupName = groupName; } paramList.add(patchedGroupName); parameters.put("methodParams", xstream.toXML(paramList)); NodeRef result; try { String resultStr = controller.requestString(transaction, parameters, MsgId.INT_WEBSCRIPT_OPCODE_SERVICE); result = (NodeRef) xstream.fromXML(resultStr); } catch (ServletException e) { e.printStackTrace(); return null; } return result; }
From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java
/** * // w ww . j av a 2 s. c om * @param asGroups * @return */ @SuppressWarnings("unchecked") public Set<String> getAllAuthoritiesAsGroupsOrUsers(AlfrescoTransaction transaction, boolean asGroups) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("serviceName", "AuthorityDAO"); parameters.put("methodName", "getAllAuthorities"); Vector<Object> paramList = new Vector<Object>(); // add parameters to the method in paramList if (asGroups) { paramList.add(AuthorityType.GROUP); } else { paramList.add(AuthorityType.USER); } parameters.put("methodParams", xstream.toXML(paramList)); Set<String> result; try { String resultStr = controller.requestString(transaction, parameters, MsgId.INT_WEBSCRIPT_OPCODE_SERVICE); result = (Set<String>) xstream.fromXML(resultStr); } catch (ServletException e) { e.printStackTrace(); return null; } return result; }
From source file:org.jenkinsci.plugins.configfiles.ConfigFilesManagement.java
public HttpResponse doSaveConfig(StaplerRequest req) { try {/*from ww w . j a v a 2s . c om*/ JSONObject json = req.getSubmittedForm().getJSONObject("config"); Config config = req.bindJSON(Config.class, json); for (ConfigProvider provider : ConfigProvider.all()) { if (provider.isResponsibleFor(config.id)) { provider.save(config); } } } catch (ServletException e) { e.printStackTrace(); } return new HttpRedirect("index"); }
From source file:org.rti.zcore.dar.report.DefaultersRegister.java
public void getPatientRegister(Date beginDate, Date endDate, int siteId) { ResultSet rs = null;//from ww w . j a va2 s . c o m Connection conn = null; try { conn = ZEPRSUtils.getZEPRSConnection(); } catch (ServletException e) { e.printStackTrace(); } try { // get a list of patients with appointments for the past week // use beginDate = one week ago, endDate = today, preset in ChooseReportAction. /* String DATE_FORMAT = "yyyy-MM-dd"; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT); java.util.Calendar c2 = java.util.Calendar.getInstance(); c2.add(java.util.Calendar.WEEK_OF_YEAR, -1); java.util.Date date1weekpast = c2.getTime(); sdf.setTimeZone(TimeZone.getDefault()); String date1weekpastStr = sdf.format(date1weekpast); java.sql.Date date1weekpastSql = java.sql.Date.valueOf(date1weekpastStr); java.sql.Date dateNow = DateUtils.getNow();*/ rs = ZEPRSUtils.getScheduledVisits(beginDate, endDate, siteId, conn); // For each patient, load the report class and add this patient to the list while (rs.next()) { Long patientId = rs.getLong("patient_id"); Date appointmentDate = rs.getDate("appointment_date"); ScheduledPatient scheduledPatient = new ScheduledPatient(); scheduledPatient.setAppointmentDate(appointmentDate); scheduledPatient.setPatientId(patientId); // Get the demo info try { Long encounterId = DemographicsDAO.getDemographicsId(conn, patientId, Long.valueOf(1)); PatientRegistrationReport encounter = (PatientRegistrationReport) EncountersDAO .getOneReportById(conn, encounterId, new Long("1"), PatientRegistrationReport.class); scheduledPatient.setPatientRegistration(encounter); } catch (ServletException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (ObjectNotFoundException e) { log.error(e); e.printStackTrace(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block log.error(e); e.printStackTrace(); } // now check if they had any visits during this time range. ResultSet encounterRS = ZEPRSUtils.getPatientEncounters(patientId, beginDate, endDate, conn); int count = 0; while (encounterRS.next()) { Long encounterId = encounterRS.getLong("id"); count++; } if (count == 0) { this.addPatient(scheduledPatient); } } rs.close(); } catch (ServletException e) { log.error(e); e.printStackTrace(); } catch (SQLException e) { log.error(e); e.printStackTrace(); } try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } }
From source file:org.opencastproject.feed.impl.FeedServlet.java
/** * Sets the http service./*from ww w .ja va2 s.co m*/ * * @param httpService * the http service */ public void setHttpService(HttpService httpService) { try { HttpContext httpContext = httpService.createDefaultHttpContext(); httpService.registerServlet("/feeds", FeedServlet.this, null, httpContext); logger.debug("Feed servlet registered"); } catch (ServletException e) { e.printStackTrace(); } catch (NamespaceException e) { e.printStackTrace(); } }
From source file:com.mondospider.spiderlocationapi.SetSpiderStatus.java
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (!req.isSecure()) { resp.getWriter()/* w w w . ja va2s .co m*/ .println("{\"result:error\", \"reason\":\"SSL secured connection required for updates.\"}"); return; } if (req.getParameter("status") == null) { //Display Error&Help try { req.getRequestDispatcher("/index.html").forward(req, resp); } catch (ServletException e) { resp.getWriter().println("{\"result:error\", \"reason\":\"Forward failed\"}"); e.printStackTrace(); return; } } // Permission Check String key = req.getParameter("pwd"); if (!isSecretKeyTrue(key)) { // accessDenied resp.getWriter().println("{\"result:error\", \"reason\":\"Wrong Key\"}"); return; } try { String status = req.getParameter("status"); // Update Position updateStatus(status); responseResp.put("result", "success"); responseResp.put("updated_on", new Date()); resp.setContentType("text/plain"); resp.getWriter().println(responseResp.toString(2)); return; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } resp.sendRedirect("/index.html"); }
From source file:com.paladin.mvc.RequestContext.java
public void forward(String uri) { RequestDispatcher rd = context.getRequestDispatcher(uri); try {/* w ww . j a v a2 s . c o m*/ rd.forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:uk.ac.manchester.cs.diff.WebDiff.java
/** * Load both ontologies//w w w . ja va 2 s. c o m * @param pw Print writer * @param request Http request * @param response Http response * @param runner Ecco diff runner * @throws IOException * @throws FileUploadException * @throws OWLOntologyCreationException */ private void parseRequest(PrintWriter pw, HttpServletRequest request, HttpServletResponse response, EccoRunner runner) throws IOException, FileUploadException, OWLOntologyCreationException { FileItemFactory factory = new DiskFileItemFactory(); // Create a factory for disk-based file items ServletFileUpload upload = new ServletFileUpload(factory); // Create a new file upload handler List<FileItem> items = null; try { items = upload.parseRequest(request); // Parse the request } catch (Exception e) { RequestDispatcher view = getServletContext().getRequestDispatcher("/index.jsp"); try { view.forward(request, response); } catch (ServletException e1) { e1.printStackTrace(); } } String ont1uri = "", ont2uri = ""; if (items != null) { // Process the uploaded items Iterator<FileItem> iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); String name = item.getFieldName(); // Load from text area content if (item.isFormField()) { if (name.equals("o1")) { ont1uri = item.getString(); if (!ont1uri.equals("")) ont1 = runner.loadOntology(1, ont1uri.trim(), false); } else if (name.equals("o2")) { ont2uri = item.getString(); if (!ont2uri.equals("")) ont2 = runner.loadOntology(2, ont2uri.trim(), false); } else if (name.equals("cdiff")) cdiff = item.getString(); else if (name.equals("processImports")) runner.setProcessImports(Boolean.parseBoolean(item.getString())); } // Load from uploaded file else { if (name.equals("o1file")) { InputStream file1Stream = item.getInputStream(); if (file1Stream != null && file1Stream.available() != 0) ont1 = runner.loadOntology(1, file1Stream, false); } else if (name.equals("o2file")) { InputStream file2Stream = item.getInputStream(); if (file2Stream != null && file2Stream.available() != 0) ont2 = runner.loadOntology(2, file2Stream, false); } } } } }
From source file:com.mondospider.spiderlocationapi.SetSpiderLocation.java
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (!req.isSecure()) { resp.getWriter()/*from w w w.j av a 2 s . co m*/ .println("{\"result:error\", \"reason\":\"SSL secured connection required for updates.\"}"); return; } if (req.getParameter("lat") == null || req.getParameter("lng") == null || req.getParameter("pwd") == null) { //Display Error&Help try { req.getRequestDispatcher("/index.html").forward(req, resp); } catch (ServletException e) { resp.getWriter().println("{\"result:error\", \"reason\":\"Forward failed\"}"); e.printStackTrace(); return; } } // Permission Check String key = req.getParameter("pwd"); if (!isSecretKeyTrue(key)) { // accessDenied resp.getWriter().println("{\"result:error\", \"reason\":\"Wrong Key\"}"); return; } try { // Get lat/lng Parameters and validate double lat = 0; double lng = 0; try { lat = Double.parseDouble(req.getParameter("lat")); lng = Double.parseDouble(req.getParameter("lng")); } catch (NumberFormatException e) { responseResp.put("result", "error"); responseResp.put("reason", "Parameter lat or log missing or invalid"); resp.getWriter().println(responseResp.toString(2)); return; } String status = req.getParameter("status"); // Update Position updatePosition("spider", lat, lng, status); responseResp.put("result", "success"); responseResp.put("updated_on", new Date()); resp.setContentType("text/plain"); resp.getWriter().println(responseResp.toString(2)); return; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } resp.sendRedirect("/index.html"); }
From source file:fr.ybonnel.simpleweb4j.MultipartIntegrationTest.java
@Before public void startServer() { resetDefaultValues();/*from w w w . j av a2 s. c o m*/ port = Integer.getInteger("test.http.port", random.nextInt(10000) + 10000); setPort(port); resource(new RestResource<TestUploadImage>("multipart", TestUploadImage.class) { @Override public TestUploadImage getById(String id) throws HttpErrorException { return null; } @Override public List<TestUploadImage> getAll() throws HttpErrorException { return Collections.emptyList(); } @Override public void update(String id, TestUploadImage resource) throws HttpErrorException { resource.id = id; lastCall = resource; } @Override public TestUploadImage create(TestUploadImage resource) throws HttpErrorException { lastCall = resource; return resource; } @Override public Route<TestUploadImage, TestUploadImage> routeCreate() { return new Route<TestUploadImage, TestUploadImage>("multipart", TestUploadImage.class) { @Override public Response<TestUploadImage> handle(TestUploadImage param, RouteParameters routeParams) throws HttpErrorException { return new Response<>(create(param), HttpServletResponse.SC_CREATED); } @Override protected TestUploadImage getRouteParam(HttpServletRequest request) throws IOException { try { Part dataPart = request.getPart("data"); TestUploadImage data = ContentType.GSON .fromJson(new InputStreamReader(dataPart.getInputStream()), getParamType()); Part imagePart = request.getPart("image"); if (null != imagePart) { data.imageName = ((MultiPartInputStreamParser.MultiPart) imagePart) .getContentDispositionFilename(); data.image = IOUtils.toByteArray(imagePart.getInputStream()); } return data; } catch (ServletException e) { e.printStackTrace(); return null; } } }; } @Override public Route<TestUploadImage, Void> routeUpdate() { return new Route<TestUploadImage, Void>("multipart/:id", TestUploadImage.class) { @Override public Response<Void> handle(TestUploadImage param, RouteParameters routeParams) throws HttpErrorException { update(routeParams.getParam("id"), param); return new Response<>(null); } @Override protected TestUploadImage getRouteParam(HttpServletRequest request) throws IOException { try { Part dataPart = request.getPart("data"); InputStreamReader dataReader = new InputStreamReader(dataPart.getInputStream()); TestUploadImage data = ContentType.GSON.fromJson(dataReader, getParamType()); dataReader.close(); Part imagePart = request.getPart("image"); if (null != imagePart) { data.imageName = ((MultiPartInputStreamParser.MultiPart) imagePart) .getContentDispositionFilename(); data.image = IOUtils.toByteArray(imagePart.getInputStream()); } return data; } catch (ServletException e) { e.printStackTrace(); return null; } } }; } @Override public void delete(String id) throws HttpErrorException { } }); start(false); }