public static Column getObject(HttpServletRequest request) { Column column = CCManager.getColumnInstance(); try { column.setCreator(AuthHandler.getUserid(request)); column.setType(Integer.parseInt(request.getParameter("typeid"))); column.setHeader(request.getParameter("header")); column.setModule(request.getParameter("module")); if (!StringUtil.isNullOrEmpty("masterdata")) { column.setMasterString(request.getParameter("masterdata")); } if (!StringUtil.isNullOrEmpty(request.getParameter("enabled"))) { column.setEnabled(request.getParameter("enabled").equals("on") ? true : false); } if (!StringUtil.isNullOrEmpty(request.getParameter("visible"))) { column.setVisible(request.getParameter("visible").equals("on") ? true : false); } if (!StringUtil.isNullOrEmpty(request.getParameter("isMandatory"))) { column.setMandatory(request.getParameter("isMandatory").equals("on") ? true : false); } if (!StringUtil.isNullOrEmpty("defaultValue")) { column.setDefaultValue(request.getParameter("defaultValue")); } } catch (SessionExpiredException ex) { Logger.getLogger(CcUtil.class.getName()).log(Level.SEVERE, null, ex); } return column; }
public static void getCompanyDetails(HttpServletRequest request) { String res1 = null; String res2 = null; String res3 = null; PreparedStatement pstmt = null; ResultSet rs = null; com.krawler.database.DbPool.Connection conn = null; String GET_COMPNY_IMGPATH = "SELECT companyname,subdomain,image FROM company WHERE companyid = ?"; try { conn = DbPool.getConnection(); pstmt = conn.prepareStatement(GET_COMPNY_IMGPATH); pstmt.setString(1, AuthHandler.getCompanyid(request)); rs = pstmt.executeQuery(); if (rs.next()) { res1 = rs.getString("image").trim(); String tmp[] = res1.split("/"); res1 = tmp[tmp.length - 1].toString().trim(); res3 = rs.getString("subdomain"); res2 = rs.getString("companyname"); } else { res1 = ""; res2 = ""; res3 = ""; } // conn.close(); } catch (SessionExpiredException ex) { KrawlerLog.op.warn("Problem While Creating PDF :" + ex.toString()); DbPool.quietRollback(conn); res1 = ""; res2 = ""; res3 = ""; } catch (SQLException ex) { KrawlerLog.op.warn("Problem While Creating PDF :" + ex.toString()); DbPool.quietRollback(conn); res1 = ""; res2 = ""; res3 = ""; } catch (ServiceException ex) { KrawlerLog.op.warn("Problem While Creating PDF :" + ex.toString()); DbPool.quietRollback(conn); res1 = ""; res2 = ""; res3 = ""; } finally { imgPath = res1; companyName = res2; companySubDomain = res3; DbPool.quietClose(conn); } }
public ModelAndView getDocs(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); KwlReturnObject kmsg = null; KwlReturnObject result = null; try { HashMap<String, Object> requestParams = new HashMap<String, Object>(); ArrayList filter_names = new ArrayList(), filter_values = new ArrayList(); JSONArray jarr = new JSONArray(); String userid = ""; int start, limit; userid = request.getParameter("userid"); String currentuser = AuthHandler.getUserid(request); String ss = request.getParameter("ss"); if (request.getParameter("start") == null) { start = 0; limit = 15; } else { start = Integer.parseInt(request.getParameter("start")); limit = Integer.parseInt(request.getParameter("limit")); } if (request.getParameter("applicant").equalsIgnoreCase("applicant")) { filter_names.add("recid"); filter_values.add(userid); filter_names.add("docid.deleted"); filter_values.add(false); filter_names.add("docid.referenceid"); filter_values.add(userid); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); requestParams.put("ss", ss); requestParams.put("searchcol", new String[] {"docid.docname", "docid.docdesc"}); requestParams.put("start", start); requestParams.put("limit", limit); requestParams.put("allflag", false); result = hrmsExtApplDocsDAOObj.getDocs(requestParams); Iterator ite = result.getEntityList().iterator(); while (ite.hasNext()) { HrmsDocmap docs = (HrmsDocmap) ite.next(); JSONObject tmpObj = new JSONObject(); tmpObj.put("docid", docs.getDocid().getDocid()); tmpObj.put("docname", docs.getDocid().getDocname()); tmpObj.put("docdesc", docs.getDocid().getDocdesc()); tmpObj.put("uploadedby", docs.getDocid().getUploadedby()); Float dsize = Math.max(0, Float.parseFloat(docs.getDocid().getDocsize()) / 1024); tmpObj.put("docsize", String.valueOf(dsize)); tmpObj.put( "uploaddate", AuthHandler.getDateFormatter(request).format(docs.getDocid().getUploadedon())); jarr.put(tmpObj); } } else { filter_names.add("recid"); filter_values.add(userid); filter_names.add("docid.deleteflag"); filter_values.add(0); requestParams.put("filter_names", filter_names); requestParams.put("filter_values", filter_values); requestParams.put("ss", ss); requestParams.put("searchcol", new String[] {"docid.docname", "docid.docdesc"}); requestParams.put("start", start); requestParams.put("limit", limit); requestParams.put("allflag", false); result = documentDAOObj.getDocs(requestParams); Iterator ite = result.getEntityList().iterator(); while (ite.hasNext()) { Docmap docs = (Docmap) ite.next(); JSONObject tmpObj = new JSONObject(); tmpObj.put("docid", docs.getDocid().getDocid()); tmpObj.put("docname", docs.getDocid().getDocname()); tmpObj.put("docdesc", docs.getDocid().getDocdesc()); tmpObj.put( "uploadedby", docs.getDocid().getUserid().getFirstName() + " " + docs.getDocid().getUserid().getLastName()); Float dsize = Math.max(0, Float.parseFloat(docs.getDocid().getDocsize()) / 1024); tmpObj.put("docsize", String.valueOf(dsize)); tmpObj.put( "uploaddate", AuthHandler.getDateFormatter(request).format(docs.getDocid().getUploadedon())); jarr.put(tmpObj); } } jobj.put("data", jarr); jobj.put("count", result.getRecordTotalCount()); jobj1.put("data", jobj.toString()); jobj1.put("valid", true); } catch (Exception e) { System.out.println(e.getMessage()); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SessionExpiredException { JSONObject j = null; Connection conn = null; clearAll(); String projectId = request.getParameter("projectid"); ProjectName = request.getParameter("projname"); ReportName = request.getParameter("reportname"); String loginid = AuthHandler.getUserid(request); String userName = AuthHandler.getUserName(request); String companyid = AuthHandler.getCompanyid(request); String ipAddress = AuthHandler.getIPAddress(request); String exportType = request.getParameter("exporttype"); String filename = filename = ProjectName + "_" + ReportName + "." + exportType; ByteArrayOutputStream baos = null; try { conn = DbPool.getConnection(); String cmpcurr = ProfileHandler.getCmpCurrFromProj(conn, projectId); try { char a1 = (char) Integer.parseInt(cmpcurr, 16); currSymbol = Character.toString(a1); } catch (Exception e) { currSymbol = cmpcurr; } String baseid = request.getParameter("baselineid"); String jbase = projdb.getBaselineDetails(conn, baseid); JSONObject temp = new JSONObject(jbase); baseName = temp.getJSONArray("data").getJSONObject(0).getString("baselinename"); String reportJson = projdb.getProjectSummaryData(conn, projectId, baseid, loginid); j = projdb.getAllProjectSummaryData(reportJson); JSONArray store = j.getJSONArray("data"); JSONArray rstore = j.getJSONArray("resources"); if (StringUtil.equal(exportType, "pdf")) { baos = getPdfData(store, rstore, request); } else if (StringUtil.equal(exportType, "csv")) { JSONObject jtemp = new JSONObject(reportJson); rstore = jtemp.getJSONArray("resources"); baos = getCsvData(rstore, store, request); } String params = AuthHandler.getAuthor(conn, loginid) + " (" + userName + "), " + ReportName + ", " + exportType + " , " + ProjectName; AuditTrail.insertLog( conn, "1111", loginid, projectId, projectId, companyid, params, ipAddress, 0); } catch (ServiceException ex) { filename = "Problem_in_exporting_file." + exportType; DbPool.quietRollback(conn); } catch (JSONException e) { filename = "Problem_in_exporting_file." + exportType; DbPool.quietRollback(conn); } finally { DbPool.quietClose(conn); try { if (baos != null) { baos.close(); } } catch (IOException e) { } writeDataToFile(filename, baos, response); } }