Package com.dotmarketing.portlets.campaigns.model

Examples of com.dotmarketing.portlets.campaigns.model.Recipient


    List<HashMap<String, Object>> campaigns = new ArrayList<HashMap<String, Object>>();
   
    List communications = new ArrayList();

    Iterator itRecipient = recipients.iterator();
    Recipient r;
    while(itRecipient.hasNext()){
      r = (Recipient) itRecipient.next();
      Campaign campaign = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
      if (InodeUtils.isSet(campaign.getInode())) {
        if (UtilMethods.isSet(campaign.getExpirationDate()) && now.after(campaign.getExpirationDate())) {
View Full Code Here


    List<Campaign> campaigns = new ArrayList<Campaign>();
    List communications = new ArrayList();

    Iterator itRecipient = recipients.iterator();
    while(itRecipient.hasNext()){
      Recipient r = (Recipient) itRecipient.next();
      Campaign campaign = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
      if (InodeUtils.isSet(campaign.getInode())) {
        if (UtilMethods.isSet(campaign.getExpirationDate()) && now.after(campaign.getExpirationDate())) {
          break;
        }
View Full Code Here

    List<Recipient> recipients = RecipientFactory.getRecipientsByUserId(userId, condition);
    Iterator itRecipient = recipients.iterator();
    Date now = new Date();
    while(itRecipient.hasNext()){
      Recipient r = (Recipient) itRecipient.next();

      Campaign campaign = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
      if (InodeUtils.isSet(campaign.getInode())) {
        if (UtilMethods.isSet(campaign.getExpirationDate()) && now.after(campaign.getExpirationDate())) {
          break;
        }
        Communication communication = (Communication) InodeFactory.getChildOfClass(campaign, Communication.class);
        if (InodeUtils.isSet(communication.getInode()) && (communication.getCommunicationType().equalsIgnoreCase("alert"))) {
          r.setOpened(now);
          r.setLastMessage("Alert Displayed");
         
          HibernateUtil.saveOrUpdate(r);
        }
      }
    }
View Full Code Here

      }

      catch (Exception e) {
      }

      Recipient r = RecipientFactory.getRecipient(request.getParameter("r"));
      if(r== null || !InodeUtils.isSet(r.getInode())){
        response.sendError(401);
        return;
      }
      Campaign c = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
      if (InodeUtils.isSet(r.getInode())) {

        //update recipient click through-links
        try {
          Click click = ClickFactory.getClickByLinkAndRecipient(redir, r);
          click.setClickCount((click.getClickCount() + 1));
          click.setLink(redir);
          HibernateUtil.saveOrUpdate(click);
          r.addChild(click);
          HibernateUtil.saveOrUpdate(r);

          //update queue clickthrough links
          click = ClickFactory.getClickByLinkAndCampaign(redir, c);
          click.setClickCount((click.getClickCount() + 1));
          click.setLink(redir);
          HibernateUtil.saveOrUpdate(click);
          c.addChild(click);
          HibernateUtil.saveOrUpdate(c);
        } catch (DotHibernateException e1) {
          Logger.error(this, e1.getMessage(), e1);
        }
        if(Config.getBooleanProperty("ENABLE_CLICKSTREAM_TRACKING", false)){
          try{
            User user = APILocator.getUserAPI().loadByUserByEmail(r.getEmail(), APILocator.getUserAPI().getSystemUser(), false);
            ClickstreamFactory.setClickStreamUser(user.getUserId(), request);
          }catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
          }
        }
View Full Code Here

  //~ Methods ....................................................................................

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


    Recipient r = RecipientFactory.getRecipient(request.getParameter("r"));

    if (InodeUtils.isSet(r.getInode())) {
      r.setOpened(new java.util.Date());
      r.setLastResult(200);
      r.setLastMessage("Opened Email");
      boolean wasError = false;
      try {
        HibernateUtil.startTransaction();
        HibernateUtil.saveOrUpdate(r);
      } catch (DotHibernateException e1) {
        wasError = true;
        try {
          HibernateUtil.rollbackTransaction();
        } catch (DotHibernateException e) {
          Logger.error(CampaignReportingServlet.class,e.getMessage(),e);
        }
        Logger.error(CampaignReportingServlet.class,e1.getMessage(),e1);
      }
      try {
        HibernateUtil.commitTransaction();
      } catch (DotHibernateException e1) {
        wasError = true;
        Logger.error(CampaignReportingServlet.class,e1.getMessage(),e1);
      }
      if(wasError) return;
     
      User user;
      UserProxy sub;
      try {
        user = APILocator.getUserAPI().loadByUserByEmail(r.getEmail(), APILocator.getUserAPI().getSystemUser(), false);
        sub = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);
      } catch (Exception e) {
        Logger.error(CampaignReportingServlet.class,e.getMessage(), e);
        return;
      }
View Full Code Here

    } catch (Exception e1) {
      Logger.error(AlertMessagesWebAPI.class,e1.getMessage(), e1);
    }
   
    while(itRecipient.hasNext()){
      Recipient r = (Recipient) itRecipient.next();
      Campaign campaign = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
      if (InodeUtils.isSet(campaign.getInode())) {
        Communication communication = (Communication) InodeFactory.getChildOfClass(campaign, Communication.class);
        if (InodeUtils.isSet(communication.getInode()) && (communication.getCommunicationType().equalsIgnoreCase("alert"))) {
          String[] comm = new String[3];
          if(UtilMethods.isSet(user)){
            comm[0] = DeliverCampaignThread.replaceTextVar(communication.getTitle(), r, user, communication);
            comm[1] = DeliverCampaignThread.replaceTextVar(communication.getTextMessage(), r, user, communication);
          }
          comm[2] = UtilMethods.dateToPrettyHTMLDate2(r.getOpened());
          communications.add(comm);
        }
      }
    }
View Full Code Here

            } catch (Exception e) {
              Logger.error(DeliverCampaignThread.class, "deliverCampaigns Failed - getting subscriber: " + userProxy.getUserId() + " " + e.getMessage());
             
            }
 
            Recipient recipient = RecipientFactory.getRecipientByCampaignAndSubscriber(c, member);
            recipient.setUserId(member.getUserId());
            if (EmailFactory.isSubscribed(unSubscribers,member))
            {
              recipient.setLastMessage("On "+MailingListFactory.getUnsubscribersMailingList().getTitle());
              recipient.setLastResult(500);
              userProxy.setLastMessage("On "+MailingListFactory.getUnsubscribersMailingList().getTitle());
              userProxy.setLastResult(500);
              c.addChild(recipient);
              continue;
            }
 
            //if this recipient already got the email
            List<UserComment> l = UserCommentsFactory.getUserCommentsByComm(userProxy.getInode(), comm.getInode());
 
            if (InodeUtils.isSet(recipient.getInode()) || l.size() > 0)
            {
              Logger.debug(EmailFactory.class,"Already got this email:" + recipient.getEmail());
              if (!c.isSendEmail()) {
                continue;
              }
            }
 
            recipient.setEmail(member.getEmailAddress());
            recipient.setName(member.getFirstName());
            recipient.setLastname(member.getLastName());
 
            recipient.setSent(new java.util.Date());
            HibernateUtil.saveOrUpdate(recipient);
 
            setRecipient(recipient);
            setCampaign(c);
            setSubscriber(member);
            setAlternateTextMessage(alternateTextMessage);
            setMessage(message);
            setHtml(true);
            c.addChild(recipient);
           
            if (!comm.getCommunicationType().equalsIgnoreCase("alert")) {
              if(!sendEmail()) {
                //If got errors sending the email then we mark it as a bounce
                //from the mailing list
                MailingListFactory.markAsBounceFromMailingList(ml, userProxy);
              }
            }
            else {
              //for alert communications only
              recipient.setLastResult(200);
              recipient.setLastMessage("Alert created");
            }
            HibernateUtil.saveOrUpdate(recipient);
 
            long sleepTime = 10;
            if(UtilMethods.isSet(send_per_hour) && !send_per_hour.equals("unlimited"))
View Full Code Here

        {
            List recipients = RecipientFactory.getAllRecipientsByCampaign(c);
            Iterator i = recipients.iterator();

            while (i.hasNext()) {
                Recipient r = (Recipient) i.next();
                List clicks = ClickFactory.getClicksByParent(r);
                Iterator i2 = clicks.iterator();

                while (i2.hasNext()) {
                    Click click = (Click) i2.next();
View Full Code Here

    Logger.debug(this, "RETR: after:" +i);

        boolean removeEmail = false;

    Recipient r = new Recipient();
       
    while (((s = in.readLine()) != null) && (!(s.equals(".")))) {
      //t += s + "\n";
      //get error message
     
      if (s.startsWith("<<< ")) {
        errorMessage = s.substring(4).trim();

      }

      //get recipient id
      if (s.startsWith("X-RecipientId:")) {
        java.util.StringTokenizer st = new java.util.StringTokenizer(s, ": ");
        st.nextToken();

        Logger.debug(this, "Found a X-Recipient ID=" + s);

        try {
          r = (Recipient) InodeFactory.getInode(st.nextToken(), Recipient.class);
        } catch (Exception e) {
          Logger.debug(this, "Recipient=" + r.getInode() + ", not found might be that the campaign was deleted.");
        }
        removeEmail = true;

        Logger.debug(this, "Found recipient=" + r.getInode());
      }

    }

    //if we have a recipient
        if (InodeUtils.isSet(r.getInode())) {
            r.setLastResult(500);

          if(errorMessage == null){
              r.setLastMessage("Email Bounced");
          }
          else {
              r.setLastMessage(errorMessage);
          }
           
            HibernateUtil.saveOrUpdate(r);

            Logger.debug(this, "Saved recipient with 500 last result" + r.getEmail());
           
            User user = APILocator.getUserAPI().loadByUserByEmail(r.getEmail(), APILocator.getUserAPI().getSystemUser(), false);
            UserProxy sub = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

            Logger.debug(this, "Subscriber =" + sub.getInode());

            if(InodeUtils.isSet(sub.getInode())){

                Logger.debug(this, "errorMessage: " +errorMessage);

              if(errorMessage == null){
                  sub.setLastMessage("Email Bounced");
              }
              else{
                  sub.setLastMessage(errorMessage.replaceAll("<","&lt;").replaceAll(">", "&gt;"));

              }
                sub.setLastResult(500);

                HibernateUtil.saveOrUpdate(sub);

                Campaign c = (Campaign) InodeFactory.getParentOfClass(r, Campaign.class);
                if(c != null && InodeUtils.isSet(c.getInode())) {
          MailingList ml = (MailingList) InodeFactory.getChildOfClass(c,MailingList.class);
                  if(ml != null && InodeUtils.isSet(ml.getInode()))
            MailingListFactory.markAsBounceFromMailingList(ml, sub);
                }
               
            }
            Logger.info(this, "Found a bounce for recipient: " + r.getInode());
        }

        if(removeEmail) {
            Logger.debug(this, "Before deleting message");
            send(out, "DELE " + i);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.campaigns.model.Recipient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.