public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    System.out.println("Started processing sentiment update");
    List allcardslist = conversationCardDAO.getAllRecords();
    int pos = 0;
    int posplus = 0;
    int neu = 0;
    int neg = 0;
    int negplus = 0;
    List posl = new ArrayList();
    List pospl = new ArrayList();
    List neul = new ArrayList();
    List negl = new ArrayList();
    List negpl = new ArrayList();
    for (int i = 0; i < allcardslist.size(); i++) {
      ConversationCard cc = (ConversationCard) allcardslist.get(i);
      Long cardid = cc.getId();
      List voiceslist = voicesDAO.getAllRecordsbyCardId(cardid);
      /*int pos = 0;
      int posplus = 0;
      int neu = 0;
      int neg = 0;
      int negplus = 0;*/
      for (int j = 0; j < voiceslist.size(); j++) {
        Voices voices = (Voices) voiceslist.get(j);
        Long voicesid = voices.getId();
        List vdlist = voicesDetailsDAO.getAllRecordsbyVoices(voicesid);
        for (int k = 0; k < vdlist.size(); k++) {
          VoicesDetails vd = (VoicesDetails) vdlist.get(k);
          String line = StrUtil.nonNull(vd.getPosttext());
          if (!"".equalsIgnoreCase(line)) {
            String sentimentstr = MahoutCaller.getSentiments(line);
            System.out.println("vd sentimentstr: " + k + " : " + sentimentstr);
            if (POSITIVEPLUS.equalsIgnoreCase(sentimentstr)) {
              posplus = posplus + 1;
              pospl.add("");
            } else if (POSITIVE.equalsIgnoreCase(sentimentstr)) {
              pos = pos + 1;
              posl.add("");
            } else if (NEUTRAL.equalsIgnoreCase(sentimentstr)) {
              neu = neu + 1;
              neul.add("");
            } else if (NEGATIVEPLUS.equalsIgnoreCase(sentimentstr)) {
              negplus = negplus + 1;
              negpl.add("");
            } else if (NEGATIVE.equalsIgnoreCase(sentimentstr)) {
              neg = neg + 1;
              negl.add("");
            }
            int sentimentscore = MahoutCaller.getSentimentScore(sentimentstr);
            vd.setSentimentrating(sentimentstr);
            vd.setSentimentscore(new Long(sentimentscore));
            try {
              voicesDetailsDAO.addOrUpdateRecord(vd);
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
        String line = StrUtil.nonNull(voices.getPosttext());
        if (!"".equalsIgnoreCase(line)) {
          String sentimentstr = MahoutCaller.getSentiments(line);
          System.out.println("voices sentimentstr: " + j + " : " + sentimentstr);
          if (POSITIVEPLUS.equalsIgnoreCase(sentimentstr)) {
            posplus = posplus + 1;
            pospl.add("");
          } else if (POSITIVE.equalsIgnoreCase(sentimentstr)) {
            pos = pos + 1;
            posl.add("");
          } else if (NEUTRAL.equalsIgnoreCase(sentimentstr)) {
            neu = neu + 1;
            neul.add("");
          } else if (NEGATIVEPLUS.equalsIgnoreCase(sentimentstr)) {
            negplus = negplus + 1;
            negpl.add("");
          } else if (NEGATIVE.equalsIgnoreCase(sentimentstr)) {
            neg = neg + 1;
            negl.add("");
          }
          int sentimentscore = MahoutCaller.getSentimentScore(sentimentstr);
          voices.setSentimentrating(sentimentstr);
          voices.setSentimentscore(new Long(sentimentscore));
          try {
            voicesDAO.addOrUpdateRecord(voices);
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }

      double finalpos = 0;
      double finalneg = 0;

      int posnum = posl.size();
      int pospnum = pospl.size();
      int neunum = neul.size();
      int negnum = negl.size();
      int negpnum = negpl.size();

      finalpos = posnum + 1.5 * pospnum;
      finalneg = negnum + 1.5 * negpnum;
      Double finalposd = new Double(finalpos);
      Double finalnegd = new Double(finalneg);
      cc.setPositivevoices(new Long(finalposd.longValue()));
      cc.setNegativevoices(new Long(finalnegd.longValue()));
      cc.setNeutralvoices(new Long(neunum));
      System.out.println(
          "For card id: "
              + cc.getId()
              + " count is pos: "
              + finalposd.longValue()
              + ", neg: "
              + finalnegd.longValue()
              + ", neu: "
              + new Long(neu).toString());

      try {
        conversationCardDAO.addOrUpdateRecord(cc);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      // Reset
      pos = 0;
      posplus = 0;
      neu = 0;
      neg = 0;
      negplus = 0;
      posl.clear();
      pospl.clear();
      neul.clear();
      negl.clear();
      negpl.clear();
    }
    System.out.println("Finished processing sentiment update");
    return null;
  }
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    System.out.println("Inside GetVoicesController ready to spotate");
    HttpSession session = request.getSession(true);
    JsonHeader jsonHeader = (JsonHeader) session.getAttribute("jsonHeader");
    String cardid = jsonHeader.getCardid();
    String cardtype = jsonHeader.getCardtype();
    String carduniqueid = jsonHeader.getCarduniqueid();
    String useridstr = jsonHeader.getUserid();
    Long userid = new Long(useridstr);
    User user = (User) userDAO.getObjectById(userid);

    String jsonbody = (String) session.getAttribute("jsonbody");
    Gson gson = new Gson();
    JsonRequestBody jrb = gson.fromJson(jsonbody, JsonRequestBody.class);

    List voicesList = callQuery(jrb, jsonHeader);

    List listforJson = new ArrayList();
    StringBuffer sbfr = new StringBuffer();
    String temp = "";
    for (int i = 0; i < voicesList.size(); i++) {
      Voices voices = (Voices) voicesList.get(i);
      sbfr.append(temp);
      Long voicesid = voices.getId();

      List commentslist = voiceCommentsDAO.getAllRecordsbyVoiceid(voicesid);

      voices.setCancomment(true);
      Long commentscount = new Long(0);
      if (commentslist != null && commentslist.size() > 0) {
        commentscount = new Long(commentslist.size());
      }
      voices.setCommentscount(commentscount);
      voices.setExtcommentscount(new Long(0));
      voices.setSbuser(false);
      List upvotelist = voiceVoteModelDAO.getAllUpRecordsByVoiceid(voicesid);
      List downvotelist = voiceVoteModelDAO.getAllDownRecordsByVoiceid(voicesid);
      int upsize = 0;
      if (upvotelist != null) {
        upsize = upvotelist.size();
      }
      int downsize = 0;
      if (downvotelist != null) {
        downsize = downvotelist.size();
      }
      //	voices.setDislikecount(new Integer(downsize));
      voices.setLikecount(new Integer(upsize));

      //	voices.setIsdisliked(false);
      voices.setIsliked(false);
      String source = voices.getSource();
      String firstalph = StrUtil.getFirstletter(source);
      voices.setFirstletter(firstalph);

      for (int h = 0; h < upvotelist.size(); h++) {
        VoiceVoteModel cvm = (VoiceVoteModel) upvotelist.get(h);
        Long useridcvmvote = cvm.getUserid();
        int useridcvmvoteint = useridcvmvote.intValue();
        int useridint = userid.intValue();
        if (useridint == useridcvmvoteint) {
          voices.setIsliked(true);
          //	voices.setIsdisliked(false);
          break;
        }
      }

      for (int h = 0; h < downvotelist.size(); h++) {
        VoiceVoteModel cvm = (VoiceVoteModel) downvotelist.get(h);
        Long useridcvmvote = cvm.getUserid();
        int useridcvmvoteint = useridcvmvote.intValue();
        int useridint = userid.intValue();
        if (useridint == useridcvmvoteint) {
          voices.setIsliked(false);
          //	voices.setIsdisliked(true);
          break;
        }
      }

      List sharelist = voiceShareDAO.getAllSharesForVoiceid(voices.getId());
      Long sharecount = new Long(0);
      if (sharecount != null) {
        sharecount = new Long(sharelist.size());
      }
      voices.setSharecount(sharecount);

      // temp = gson.toJson(voices);
      listforJson.add(voices);
      // sbfr.append(temp);
    }
    // String responseString = sbfr.toString();
    String responseString = gson.toJson(listforJson);
    // String responseString = dummy();
    //	System.out.println("responseString: " + responseString);
    response.addHeader("Access-Control-Allow-Origin", "*");
    response.setStatus(200);
    PrintWriter writer = response.getWriter();
    writer.write(responseString);
    writer.close();

    return null;
  }