List of usage examples for java.lang StringBuffer substring
@Override public synchronized String substring(int start, int end)
From source file:org.apache.hadoop.mapred.HappyJobClient.java
private String getJobPriorityNames() { StringBuffer sb = new StringBuffer(); for (JobPriority p : JobPriority.values()) { sb.append(p.name()).append(" "); }//from w w w .j a v a 2 s. c o m return sb.substring(0, sb.length() - 1); }
From source file:org.wso2.carbon.identity.core.persistence.IdentityDBInitializer.java
private void executeSQLScript() { String databaseType = null;/* ww w . j a va 2s . c om*/ try { databaseType = IdentityDBInitializer.getDatabaseType(dataSource.getConnection()); } catch (Exception e) { throw new IdentityRuntimeException("Error occurred while getting database type"); } boolean keepFormat = false; if ("oracle".equals(databaseType)) { delimiter = "/"; } else if ("db2".equals(databaseType)) { delimiter = "/"; } else if ("openedge".equals(databaseType)) { delimiter = "/"; keepFormat = true; } String dbScriptLocation = getDbScriptLocation(databaseType); StringBuffer sql = new StringBuffer(); BufferedReader reader = null; try { InputStream is = new FileInputStream(dbScriptLocation); reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (!keepFormat) { if (line.startsWith("//")) { continue; } if (line.startsWith("--")) { continue; } StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String token = st.nextToken(); if ("REM".equalsIgnoreCase(token)) { continue; } } } sql.append(keepFormat ? "\n" : " ").append(line); // SQL defines "--" as a comment to EOL // and in Oracle it may contain a hint // so we cannot just remove it, instead we must end it if (!keepFormat && line.contains("--")) { sql.append("\n"); } if ((checkStringBufferEndsWith(sql, delimiter))) { executeSQL(sql.substring(0, sql.length() - delimiter.length())); sql.replace(0, sql.length(), ""); } } // Catch any statements not followed by ; if (sql.length() > 0) { executeSQL(sql.toString()); } } catch (IOException e) { throw new IdentityRuntimeException( "Error occurred while executing SQL script for creating identity database", e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { log.error("Error occurred while closing stream for Identity SQL script", e); } } } }
From source file:org.etudes.component.app.melete.SectionDB.java
private String getAllDeleteSectionIds(List<Integer> delSections) { StringBuffer allIds = new StringBuffer("( "); String a = null;//from w w w. j a v a 2s .co m for (Integer s : delSections) { allIds.append(Integer.toString(s) + ","); } if (allIds.lastIndexOf(",") != -1) a = allIds.substring(0, allIds.lastIndexOf(",")) + " )"; return a; }
From source file:org.wso2.carbon.utils.dbcreator.DatabaseCreator.java
/** * executes content in SQL script//from ww w . j a v a 2 s . c o m * * @return StringBuffer * @throws Exception */ private void executeSQLScript() throws Exception { String databaseType = DatabaseCreator.getDatabaseType(this.conn); boolean keepFormat = false; if ("oracle".equals(databaseType)) { delimiter = "/"; } else if ("db2".equals(databaseType)) { delimiter = "/"; } else if ("openedge".equals(databaseType)) { delimiter = "/"; keepFormat = true; } String dbscriptName = getDbScriptLocation(databaseType); StringBuffer sql = new StringBuffer(); BufferedReader reader = null; try { InputStream is = new FileInputStream(dbscriptName); reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (!keepFormat) { if (line.startsWith("//")) { continue; } if (line.startsWith("--")) { continue; } StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String token = st.nextToken(); if ("REM".equalsIgnoreCase(token)) { continue; } } } sql.append(keepFormat ? "\n" : " ").append(line); // SQL defines "--" as a comment to EOL // and in Oracle it may contain a hint // so we cannot just remove it, instead we must end it if (!keepFormat && line.indexOf("--") >= 0) { sql.append("\n"); } if ((checkStringBufferEndsWith(sql, delimiter))) { executeSQL(sql.substring(0, sql.length() - delimiter.length())); sql.replace(0, sql.length(), ""); } } // Catch any statements not followed by ; if (sql.length() > 0) { executeSQL(sql.toString()); } } catch (IOException e) { log.error("Error occurred while executing SQL script for creating registry database", e); throw new Exception("Error occurred while executing SQL script for creating registry database", e); } finally { if (reader != null) { reader.close(); } } }
From source file:com.konakartadmin.modules.payment.authorizenet.AdminPayment.java
/** * This method executes the transaction with the payment gateway. The action attribute of the * options object instructs the method as to what transaction should be executed. E.g. It could * be a payment or a payment confirmation for a transaction that has already been authorized * etc./*w w w . j a v a 2s.co m*/ * * @param options * @return Returns an array of NameValue objects that may contain any return information * considered useful by the caller. * @throws Exception */ public NameValue[] execute(PaymentOptions options) throws Exception { checkRequired(options, "PaymentOptions", "options"); // Read the configuration variables ConfigVariables configs = getConfigVariables(); /* * Decide what to do based on the action. We could be using this class to manage * subscriptions */ if (options.getAction() == KKConstants.ACTION_CREATE_SUBSCRIPTION) { return createSubscription(options); } else if (options.getAction() == KKConstants.ACTION_UPDATE_SUBSCRIPTION) { return updateSubscription(options); } else if (options.getAction() == KKConstants.ACTION_CANCEL_SUBSCRIPTION) { return cancelSubscription(options); } else if (options.getAction() == KKConstants.ACTION_GET_SUBSCRIPTION_STATUS) { return getSubscriptionStatus(options); } String errorDesc = null; String gatewayResult = null; String transactionId = null; AdminIpnHistory ipnHistory = new AdminIpnHistory(); ipnHistory.setModuleCode(code); AdminOrder order = getAdminOrderMgr().getOrderForOrderId(options.getOrderId()); if (order == null) { throw new KKAdminException("An order does not exist for id = " + options.getOrderId()); } // Get the scale for currency calculations AdminCurrency currency = getAdminCurrMgr().getCurrency(order.getCurrencyCode()); if (currency == null) { throw new KKAdminException("A currency does not exist for code = " + order.getCurrencyCode()); } int scale = new Integer(currency.getDecimalPlaces()).intValue(); List<NameValue> parmList = new ArrayList<NameValue>(); parmList.add(new NameValue("x_delim_data", "True")); parmList.add(new NameValue("x_relay_response", "False")); parmList.add(new NameValue("x_login", configs.getAuthorizeNetLoginId())); parmList.add(new NameValue("x_tran_key", configs.getAuthorizeNetTxnKey())); parmList.add(new NameValue("x_delim_char", ",")); parmList.add(new NameValue("x_encap_char", "")); parmList.add(new NameValue("x_method", "CC")); // AuthorizeNet requires details of the final price - inclusive of tax. BigDecimal total = null; for (int i = 0; i < order.getOrderTotals().length; i++) { AdminOrderTotal ot = order.getOrderTotals()[i]; if (ot.getClassName().equals(OrderTotalMgr.ot_total)) { total = ot.getValue().setScale(scale, BigDecimal.ROUND_HALF_UP); } } if (total == null) { throw new KKAdminException("An Order Total was not found"); } parmList.add(new NameValue("x_amount", total.toString())); parmList.add(new NameValue("x_currency_code", currency.getCode())); parmList.add(new NameValue("x_invoice_num", order.getId())); // TODO parmList.add(new NameValue("x_test_request", (configs.isTestMode() ? "TRUE" : "FALSE"))); // Set the billing address // Set the billing name. If the name field consists of more than two strings, we take the // last one as being the surname. String bName = order.getBillingName(); if (bName != null) { String[] names = bName.split(" "); int len = names.length; if (len >= 2) { StringBuffer firstName = new StringBuffer(); for (int i = 0; i < len - 1; i++) { if (firstName.length() == 0) { firstName.append(names[i]); } else { firstName.append(" "); firstName.append(names[i]); } } parmList.add(new NameValue("x_first_name", firstName.toString())); parmList.add(new NameValue("x_last_name", names[len - 1])); } } parmList.add(new NameValue("x_company", order.getBillingCompany())); parmList.add(new NameValue("x_city", order.getBillingCity())); parmList.add(new NameValue("x_state", order.getBillingState())); parmList.add(new NameValue("x_zip", order.getBillingPostcode())); parmList.add(new NameValue("x_phone", order.getCustomerTelephone())); parmList.add(new NameValue("x_cust_id", order.getCustomerId())); parmList.add(new NameValue("x_email", order.getCustomerEmail())); StringBuffer addrSB = new StringBuffer(); addrSB.append(order.getBillingStreetAddress()); if (order.getBillingSuburb() != null && order.getBillingSuburb().length() > 0) { addrSB.append(", "); addrSB.append(order.getBillingSuburb()); } if (addrSB.length() > 60) { parmList.add(new NameValue("x_address", addrSB.substring(0, 56) + "...")); } else { parmList.add(new NameValue("x_address", addrSB.toString())); } // Country requires the two letter country code AdminCountry country = getAdminTaxMgr().getCountryByName(order.getBillingCountry()); if (country != null) { parmList.add(new NameValue("x_country", country.getIsoCode2())); } /* * The following code may be customized depending on the process which could be any of the * following: */ int mode = 1; if (mode == 1 && options.getCreditCard() != null) { /* * 1 . Credit card details have been passed into the method and so we use those for the * payment. */ parmList.add(new NameValue("x_card_num", options.getCreditCard().getCcNumber())); parmList.add(new NameValue("x_card_code", options.getCreditCard().getCcCVV())); parmList.add(new NameValue("x_exp_date", options.getCreditCard().getCcExpires())); parmList.add(new NameValue("x_type", "AUTH_CAPTURE")); } else if (mode == 2) { /* * 2 . We get the Credit card details from the order since they were encrypted and saved * on the order. */ parmList.add(new NameValue("x_card_num", order.getCcNumber())); parmList.add(new NameValue("x_card_code", order.getCcCVV())); parmList.add(new NameValue("x_exp_date", order.getCcExpires())); parmList.add(new NameValue("x_type", "AUTH_CAPTURE")); } else if (mode == 3) { /* * 3.If when the products were ordered through the store front application, an AUTH_ONLY * transaction was done instead of an AUTH_CAPTURE transaction and so now we need to do * a PRIOR_AUTH_CAPTURE transaction using the transaction id that was saved on the order * when the status was set. */ /* * Get the transaction id from the status trail of the order. This bit of code will have * to be customized because it depends which state was used to capture the transaction * id and whether the transaction id is the only string in the comments field or whether * it has to be parsed out. The transaction id may also have been stored in an Order * custom field in which case it can be retrieved directly from there. */ String authTransId = null; if (order.getStatusTrail() != null) { for (int i = 0; i < order.getStatusTrail().length; i++) { AdminOrderStatusHistory sh = order.getStatusTrail()[i]; if (sh.getOrderStatus().equals("ENTER_THE_STATUS_WHERE_THE_AUTH_TRANS_ID_WAS SAVED")) { authTransId = sh.getComments(); } } } if (authTransId == null) { throw new KKAdminException( "The authorized transaction cannot be confirmed since a transaction id cannot be found on the order"); } parmList.add(new NameValue("x_type", "PRIOR_AUTH_CAPTURE")); parmList.add(new NameValue("x_trans_id", authTransId)); } AdminPaymentDetails pDetails = new AdminPaymentDetails(); pDetails.setParmList(parmList); pDetails.setRequestUrl(configs.getAuthorizeNetRequestUrl()); // Do the post String gatewayResp = postData(pDetails); gatewayResp = URLDecoder.decode(gatewayResp, "UTF-8"); if (log.isDebugEnabled()) { log.debug("Unformatted GatewayResp = \n" + gatewayResp); } // Process the parameters sent in the callback StringBuffer sb = new StringBuffer(); String[] parms = gatewayResp.split(","); if (parms != null) { for (int i = 0; i < parms.length; i++) { String parm = parms[i]; sb.append(getRespDesc(i + 1)); sb.append("="); sb.append(parm); sb.append("\n"); if (i + 1 == respTextPosition) { errorDesc = parm; } else if (i + 1 == respCodePosition) { gatewayResult = parm; ipnHistory.setGatewayResult(parm); } else if (i + 1 == txnIdPosition) { ipnHistory.setGatewayTransactionId(parm); transactionId = parm; } } } // Put the response in the ipnHistory record ipnHistory.setGatewayFullResponse(sb.toString()); if (log.isDebugEnabled()) { log.debug("Formatted Authorize.net response data:"); log.debug(sb.toString()); } AdminOrderUpdate updateOrder = new AdminOrderUpdate(); updateOrder.setUpdatedById(order.getCustomerId()); // Determine whether the request was successful or not. if (gatewayResult != null && gatewayResult.equals(approved)) { String comment = ORDER_HISTORY_COMMENT_OK + transactionId; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET0_DESC); ipnHistory.setKonakartResultId(RET0); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } else if (gatewayResult != null && (gatewayResult.equals(declined) || gatewayResult.equals(error))) { String comment = ORDER_HISTORY_COMMENT_KO + errorDesc; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET0_DESC); ipnHistory.setKonakartResultId(RET0); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } else { /* * We only get to here if there was an unknown response from the gateway */ String comment = RET1_DESC + gatewayResult; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET1_DESC + gatewayResult); ipnHistory.setKonakartResultId(RET1); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } return new NameValue[] { new NameValue("ret", "0") }; }
From source file:org.pentaho.platform.web.http.api.resources.RepositoryResource.java
/** * Takes a pathId to a file and generates a URI that represents the URL to call to generate content from that file. * * <p><b>Example Request:</b><br /> * GET pentaho/api/repos/public:steel%20wheels:Invoice%20(report).prpt/default * </p>/* www . j a v a2 s . com*/ * * @param pathId @param pathId * * @return URI that represents a forwarding URL to execute to generate content from the file {pathId}. * * <p><b>Example Response:</b></p> * <pre function="syntax.xml"> * This response does not contain data. * </pre> */ @GET @Path("{pathId : .+}/default") @Produces({ WILDCARD }) @StatusCodes({ @ResponseCode(code = 303, condition = "Successfully get the resource."), @ResponseCode(code = 404, condition = "Failed to find the resource.") }) public Response doExecuteDefault(@PathParam("pathId") String pathId) throws FileNotFoundException, MalformedURLException, URISyntaxException { String perspective = null; StringBuffer buffer = null; String url = null; String path = FileResource.idToPath(pathId); String extension = path.substring(path.lastIndexOf('.') + 1); IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession()); IContentInfo info = pluginManager.getContentTypeInfo(extension); for (IPluginOperation operation : info.getOperations()) { if (operation.getId().equalsIgnoreCase("RUN")) { //$NON-NLS-1$ perspective = operation.getPerspective(); break; } } if (perspective == null) { perspective = GENERATED_CONTENT_PERSPECTIVE; } buffer = httpServletRequest.getRequestURL(); String queryString = httpServletRequest.getQueryString(); url = buffer.substring(0, buffer.lastIndexOf("/") + 1) + perspective + //$NON-NLS-1$ ((queryString != null && queryString.length() > 0) ? "?" + httpServletRequest.getQueryString() : ""); return Response.seeOther((new URL(url)).toURI()).build(); }
From source file:tasly.greathealth.oms.inventory.services.impl.DefaultItemInfoService.java
private boolean batchUpdateItemLocationSub(final Map<String, String> oldChannelMap) throws Exception { // ?ItemLocation? final List<TaslyItemLocationData> taslyItemLocationDatas = taslyItemLocationService.getAll(); int num = 0;/*from w w w . j av a 2s.c o m*/ final StringBuffer failList = new StringBuffer(); // ? if (taslyItemLocationDatas != null && taslyItemLocationDatas.size() > 0) { final Set<String> oldKeySet = oldChannelMap.keySet(); for (final TaslyItemLocationData taslyItemLocationData : taslyItemLocationDatas) { if (oldKeySet.contains(taslyItemLocationData.getStockroomLocation().getStoreName())) { final String percent = oldChannelMap .get(taslyItemLocationData.getStockroomLocation().getStoreName()); taslyItemLocationData.setAllocationPercent(Integer.valueOf(percent)); num++; } else { failList.append(taslyItemLocationData.getItemId()).append(","); } } } else { omsInventoryLog.info("taslyItemLocation??."); } omsInventoryLog.info("ItemLocation" + num + "."); if ((taslyItemLocationDatas.size() - num) > 0) { omsInventoryLog .info("ItemLocation" + (taslyItemLocationDatas.size() - num) + "."); omsInventoryLog .info("ItemLocationSKU" + failList.substring(0, failList.length() - 1)); } return true; }
From source file:org.nuclos.client.wizard.steps.NuclosEntityNameStep.java
private boolean dropEntityAllowed(EntityMetaDataVO voEntity, StringBuffer sb) { boolean blnAllowed = true; StringBuffer sbEntities = new StringBuffer(); for (EntityMetaDataVO vo : MetaDataClientProvider.getInstance().getAllEntities()) { if (vo.getEntity().equals(voEntity.getEntity())) continue; for (EntityFieldMetaDataVO voField : MetaDataClientProvider.getInstance() .getAllEntityFieldsByEntity(vo.getEntity()).values()) { if (voField.getForeignEntity() != null && voField.getForeignEntity().equals(voEntity.getEntity())) { sbEntities.append(SpringLocaleDelegate.getInstance() .getTextFallback(vo.getLocaleResourceIdForLabel(), vo.getEntity())); sbEntities.append(" "); blnAllowed = false;// w ww . j a v a2 s . c o m } } } if (!blnAllowed) { sb.append(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.7", "Die Entitt wird referenziert von " + sbEntities.substring(0, sbEntities.length() - 1) + ". Bitte entfernen Sie die Referenz vorher dort!", sbEntities)); } return blnAllowed; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * When CTRL+Z is pressed invokes the <code>ChatWritePanel.undo()</code> * method, when CTRL+R is pressed invokes the * <code>ChatWritePanel.redo()</code> method. * * @param e the <tt>KeyEvent</tt> that notified us *//*from www .j a v a 2 s. c om*/ public void keyPressed(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_Z) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canUndo()) undo(); } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_R) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canRedo()) redo(); } else if (e.getKeyCode() == KeyEvent.VK_TAB) { if (!(chatPanel.getChatSession() instanceof ConferenceChatSession)) return; e.consume(); int index = ((JEditorPane) e.getSource()).getCaretPosition(); StringBuffer message = new StringBuffer(chatPanel.getMessage()); int position = index - 1; while (position > 0 && (message.charAt(position) != ' ')) { position--; } if (position != 0) position++; String sequence = message.substring(position, index); if (sequence.length() <= 0) { // Do not look for matching contacts if the matching pattern is // 0 chars long, since all contacts will match. return; } Iterator<ChatContact<?>> iter = chatPanel.getChatSession().getParticipants(); ArrayList<String> contacts = new ArrayList<String>(); while (iter.hasNext()) { ChatContact<?> c = iter.next(); if (c.getName().length() >= (index - position) && c.getName().substring(0, index - position).equals(sequence)) { message.replace(position, index, c.getName().substring(0, index - position)); contacts.add(c.getName()); } } if (contacts.size() > 1) { char key = contacts.get(0).charAt(index - position - 1); int pos = index - position - 1; boolean flag = true; while (flag) { try { for (String name : contacts) { if (key != name.charAt(pos)) { flag = false; } } if (flag) { pos++; key = contacts.get(0).charAt(pos); } } catch (IndexOutOfBoundsException exp) { flag = false; } } message.replace(position, index, contacts.get(0).substring(0, pos)); Iterator<String> contactIter = contacts.iterator(); String contactList = "<DIV align='left'><h5>"; while (contactIter.hasNext()) { contactList += contactIter.next() + " "; } contactList += "</h5></DIV>"; chatPanel.getChatConversationPanel().appendMessageToEnd(contactList, ChatHtmlUtils.HTML_CONTENT_TYPE); } else if (contacts.size() == 1) { String limiter = (position == 0) ? ": " : ""; message.replace(position, index, contacts.get(0) + limiter); } try { ((JEditorPane) e.getSource()).getDocument().remove(0, ((JEditorPane) e.getSource()).getDocument().getLength()); ((JEditorPane) e.getSource()).getDocument().insertString(0, message.toString(), null); } catch (BadLocationException ex) { ex.printStackTrace(); } } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Only enters editing mode if the write panel is empty in // order not to lose the current message contents, if any. if (this.chatPanel.getLastSentMessageUID() != null && this.chatPanel.isWriteAreaEmpty()) { this.chatPanel.startLastMessageCorrection(); e.consume(); } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { if (chatPanel.isMessageCorrectionActive()) { Document doc = editorPane.getDocument(); if (editorPane.getCaretPosition() == doc.getLength()) { chatPanel.stopMessageCorrection(); } } } }
From source file:com.krawler.spring.importFunctionality.ImportController.java
public ModelAndView getImportLog(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); boolean issuccess = false; String msg = ""; try {/* ww w . j av a 2 s .c o m*/ DateFormat sdf = new SimpleDateFormat(Constants.yyyyMMddHHmmss); String tzDiff = authHandler.getTimeZoneDifference(request); TimeZone zone = TimeZone.getTimeZone("GMT" + tzDiff); sdf.setTimeZone(zone); HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("start", request.getParameter("start")); requestParams.put("limit", request.getParameter("limit")); requestParams.put("startdate", sdf.parse(request.getParameter("startdate")).getTime()); requestParams.put("enddate", sdf.parse(request.getParameter("enddate")).getTime()); requestParams.put("companyid", sessionHandlerImpl.getCompanyid(request)); StringBuffer moduleid = new StringBuffer(); if ((sessionHandlerImpl.getPerms(request, ProjectFeature.leadFName) & 64) == 64) { moduleid.append("'" + Constants.MODULEID_LEAD + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.productFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_PRODUCT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.accountFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_ACCOUNT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.contactFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_CONTACT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.targetFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_TARGET + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.opportunityFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_OPPORTUNITY + "',"); } // fetch calibration report log entry (For sunrise client) moduleid.append("'" + Constants.MODULEID_CALIBRATION + "',"); String moduleids = moduleid.substring(0, (moduleid.length() - 1)); requestParams.put("moduleid", moduleids); KwlReturnObject result = importDao.getImportLog(requestParams); List list = result.getEntityList(); DateFormat df = authHandler.getDateFormatter(request); df.setTimeZone(zone); JSONArray jArr = new JSONArray(); Iterator itr = list.iterator(); while (itr.hasNext()) { ImportLog ilog = (ImportLog) itr.next(); JSONObject jtemp = new JSONObject(); jtemp.put("id", ilog.getId()); jtemp.put("filename", ilog.getFileName()); jtemp.put("storename", ilog.getStorageName()); jtemp.put("failurename", ilog.getFailureFileName()); jtemp.put("log", ilog.getLog()); jtemp.put("imported", ilog.getImported()); jtemp.put("total", ilog.getTotalRecs()); jtemp.put("rejected", ilog.getRejected()); jtemp.put("type", ilog.getType()); jtemp.put("importon", df.format(ilog.getImportDate())); jtemp.put("module", ilog.getModule().getModuleName()); jtemp.put("importedby", (ilog.getUser().getFirstName() == null ? "" : ilog.getUser().getFirstName()) + " " + (ilog.getUser().getLastName() == null ? "" : ilog.getUser().getLastName())); jtemp.put("company", ilog.getCompany().getCompanyName()); jArr.put(jtemp); } jobj.put("data", jArr); jobj.put("count", result.getRecordTotalCount()); issuccess = true; } catch (Exception ex) { msg = "" + ex.getMessage(); Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, ex); } finally { try { jobj.put("success", issuccess); jobj.put("msg", msg); } catch (JSONException ex) { Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, ex); } } return new ModelAndView("jsonView", "model", jobj.toString()); }