gt:             String userid = sessionHandlerImpl.getUserid(request);
context: /*
   * Copyright (C) 2012  Krawler Information Systems Pvt Ltd
   * All rights reserved.
   * 
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   * 
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
  package com.krawler.spring.crm.productModule; 
  import com.krawler.common.comet.CometConstants;
  import com.krawler.common.comet.CrmPublisherHandler;
  import com.krawler.common.cometModule.bizservice.CometManagementService;
  import com.krawler.common.service.ServiceException;
  import com.krawler.common.session.SessionExpiredException;
  import com.krawler.crm.utils.AuditAction;
  import com.krawler.common.util.StringUtil;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletResponse;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
  import java.util.Iterator;
  import javax.servlet.http.HttpServletRequest;
  import com.krawler.crm.database.tables.CrmProduct;
  import com.krawler.crm.dbhandler.crmManagerCommon;
  import com.krawler.spring.crm.common.CrmCommonService;
  import com.krawler.spring.crm.common.crmManagerDAO;
  import com.krawler.spring.auditTrailModule.auditTrailDAO;
  import com.krawler.spring.common.KwlReturnObject;
  import com.krawler.spring.comments.commentDAO;
  import com.krawler.spring.common.kwlCommonTablesDAO;
  import com.krawler.spring.exportFunctionality.exportDAOImpl;
  import com.krawler.spring.sessionHandler.sessionHandlerImpl;
  import com.krawler.utils.json.JSONException;
  import com.krawler.utils.json.base.JSONArray;
  import com.krawler.utils.json.base.JSONObject;
  import java.util.Date;
  import java.util.HashMap;
  import org.springframework.orm.hibernate3.HibernateTransactionManager;
  import org.springframework.transaction.TransactionDefinition;
  import org.springframework.transaction.TransactionStatus;
  import org.springframework.transaction.support.DefaultTransactionDefinition;
  import com.krawler.common.util.Constants;
  import com.krawler.crm.product.bizservice.ProductManagementService;
  import com.krawler.customFieldMaster.fieldDataManager;
  import com.krawler.customFieldMaster.fieldManagerDAO;
  import com.krawler.spring.authHandler.authHandler;
  import java.text.DateFormat;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  public class crmProductController extends MultiActionController {
      private crmProductDAO crmProductDAOObj;
      private crmManagerDAO crmManagerDAOObj;
      private exportDAOImpl exportDAOImplObj;
      private auditTrailDAO auditTrailDAOObj;
      private commentDAO crmCommentDAOObj;
      private sessionHandlerImpl sessionHandlerImplObj;
      private kwlCommonTablesDAO kwlCommonTablesDAOObj;
      private String successView;
      private HibernateTransactionManager txnManager;
      private fieldDataManager fieldDataManagercntrl;
      private ProductManagementService productManagementService;
      private CometManagementService CometManagementService;
      private CrmCommonService crmCommonService;
      private fieldManagerDAO fieldManagerDAOobj;
  
      public void setFieldManagerDAO(fieldManagerDAO fieldManagerDAOobj) {
          this.fieldManagerDAOobj = fieldManagerDAOobj;
      }
  
      public void setCrmCommonService(CrmCommonService crmCommonService) {
  		this.crmCommonService = crmCommonService;
  	}
      
  	public void setCometManagementService(CometManagementService CometManagementService) {
          this.CometManagementService = CometManagementService;
      }
      /**
       * @return the activityManagementService
       */
      public ProductManagementService getProductManagementService()
      {
          return productManagementService;
      }
  
      /**
       * @param leadManagementService the leadManagementService to set
       */
      public void setProductManagementService(ProductManagementService productManagementService)
      {
          this.productManagementService = productManagementService;
      }
  
      public void setFieldDataManager(fieldDataManager fieldDataManagercntrl) {
          this.fieldDataManagercntrl = fieldDataManagercntrl;
      }
  
      public crmProductDAO getcrmProductDAO(){
          return crmProductDAOObj;
      }
      public void setTxnManager(HibernateTransactionManager txManager) {
          this.txnManager = txManager;
      }
  
      public void setcrmProductDAO(crmProductDAO crmProductDAOObj1) {
          this.crmProductDAOObj = crmProductDAOObj1;
      }
  
      public void setkwlCommonTablesDAO(kwlCommonTablesDAO kwlCommonTablesDAOObj1) {
          this.kwlCommonTablesDAOObj = kwlCommonTablesDAOObj1;
      }
  
      public void setcrmManagerDAO(crmManagerDAO crmManagerDAOObj1) {
          this.crmManagerDAOObj = crmManagerDAOObj1;
      }
  
      public void setAuditTrailDAO(auditTrailDAO auditTrailDAOObj1) {
          this.auditTrailDAOObj = auditTrailDAOObj1;
      }
  
      public String getSuccessView() {
  		return successView;
  	}
  
  	public void setSuccessView(String successView) {
  		this.successView = successView;
      }
  
      public void setexportDAOImpl(exportDAOImpl exportDAOImplObj) {
          this.exportDAOImplObj = exportDAOImplObj;
      }
  
      public void setcrmCommentDAO(commentDAO crmCommentDAOObj1) {
          this.crmCommentDAOObj = crmCommentDAOObj1;
      }
  
      public void setsessionHandlerImpl(sessionHandlerImpl sessionHandlerImplObj1) {
          this.sessionHandlerImplObj = sessionHandlerImplObj1;
      }
      /**
       *
       * @param request
       * @param response
       * @return org.springframework.web.servlet.ModelAndView : JSonObject of all products which contains nodes -
       * 1.Success 2. totalCount 3.Data - which contains nodes -
       * 1.id 2.name 3.unitprice
       * @throws javax.servlet.ServletException
       */
      public ModelAndView getProductname(HttpServletRequest request, HttpServletResponse response)
              throws ServletException {
         JSONObject jobj = new JSONObject();
         KwlReturnObject kmsg = null;
         try{
              String userid = sessionHandlerImpl.getUserid(request);
              String companyid = sessionHandlerImpl.getCompanyid(request);
              StringBuffer usersList = sessionHandlerImpl.getRecursiveUsersList(request);
              JSONArray jarr = new JSONArray();
              int dl = 0;
  
              ArrayList filter_names = new ArrayList();ArrayList filter_values = new ArrayList();
              filter_names.add("c.deleteflag");filter_values.add(0);
              filter_names.add("c.company.companyID");filter_values.add(companyid);
              filter_names.add("c.validflag");filter_values.add(1);
  
              ArrayList order_by = new ArrayList();ArrayList order_type = new ArrayList();
              order_by.add("c.productname");
              order_type.add("asc");
  
              HashMap<String, Object> requestParams = new HashMap<String, Object>();
              requestParams.put("order_by", order_by);
              requestParams.put("order_type", order_type);
              String hierarchy= request.getParameter("hierarchy");
              boolean heirarchyPerm = crmManagerCommon.chkHeirarchyPerm(request, "Product");
              if(!StringUtil.isNullOrEmpty(hierarchy) && Boolean.parseBoolean(hierarchy)){
                  if(!heirarchyPerm){
                      filter_names.add("INc.usersByUserid.userID");filter_values.add(usersList);
                  }
              }
              requestParams.put("filter_names", filter_names);
              requestParams.put("filter_values", filter_values);
             
              kmsg = crmProductDAOObj.getAllProducts(requestParams);
              dl = kmsg.getRecordTotalCount();
              Iterator ite = kmsg.getEntityList().iterator();
              while (ite.hasNext()) {
                  boolean hasAccess =true;
                  CrmProduct obj = (CrmProduct) ite.next();
                  JSONObject tmpObj = new JSONObject();
                  tmpObj.put("id", obj.getProductid());
                  tmpObj.put("productid", obj.getProductid());
                  tmpObj.put("name", obj.getProductname());
                  tmpObj.put("productname", obj.getProductname());
                  tmpObj.put("unitprice", StringUtil.isNullOrEmpty(obj.getUnitprice())?"":obj.getUnitprice());
                  tmpObj.put("salespricedatewise", StringUtil.isNullOrEmpty(obj.getUnitprice())?"":obj.getUnitprice());
                  tmpObj.put("desc", StringUtil.isNullOrEmpty(obj.getDescription())?"":obj.getDescription());
                  if(StringUtil.isNullOrEmpty(hierarchy) ){
                      if(!heirarchyPerm) {
                          hasAccess = false;
                          if(usersList.indexOf(obj.getUsersByUserid().getUserID()) != -1 ){
                              hasAccess = true;
                          }
                      }else{
                          hasAccess = !obj.getIsarchive();
                      }
                  }else{
                      hasAccess = !obj.getIsarchive();
                  }
                  tmpObj.put(ProductConstants.Crm_hasAccess,hasAccess);
                  jarr.put(tmpObj);
              }
              jobj.put("success", true);
              jobj.put("data", jarr);
              jobj.put("totalCount", dl);
         } catch(Exception e) {
            logger.warn(e.getMessage(), e);
         }
         return new ModelAndView("jsonView", "model", jobj.toString());
      }
      
      /**
       *
       * @param request
       * @param response
       * @return org.springframework.web.servlet.ModelAndView : JSONObject - It contains all the fields of CrmProduct class
       * including total comments and unread comments count
       * @throws javax.servlet.ServletException
       */
      public ModelAndView getProducts(HttpServletRequest request, HttpServletResponse response)
              throws ServletException {
         JSONObject jobj = new JSONObject();
         try{
  