Package com.knowgate.hipermail

Examples of com.knowgate.hipermail.DBStore


        bPersonalized = false;
      else
        bPersonalized = getParameter("personalized").equals("true") ? true : false;
      if (DebugFile.trace) DebugFile.writeln("personalized="+getParameter("personalized"));

      DBStore oStor = null;
      DBFolder oOutBox = null;
      JDCConnection oConn = null;
      PreparedStatement oUpdt = null;
      MailAccount oMacc = new MailAccount();

      if (DebugFile.trace) DebugFile.writeln("workarea="+getStringNull(DB.gu_workarea,"null"));
      String sWrkA = getString(DB.gu_workarea);
      try {
        if (DebugFile.trace) DebugFile.writeln("DBBind="+getDataBaseBind());
        // Get User, Account and Domain objects
        oConn = getDataBaseBind().getConnection("MimeSender.init.1");
        iDomainId = ACLDomain.forWorkArea(oConn, sWrkA);
        if (!oUser.load(oConn, new Object[]{getStringNull(DB.gu_writer,null)})) oUser=null;
        if (!oMacc.load(oConn, new Object[]{getParameter("account")})) oMacc=null;
        // If message is personalized then fill data for each mail address
        oConn.setAutoCommit(true);
        if (bPersonalized) resolveAtomsEMails(oConn);
        oConn.close("MimeSender.init.1");
        oConn=null;
      } catch (SQLException sqle) {
        if (DebugFile.trace) DebugFile.writeln("MimeSender.init("+getStringNull(DB.gu_job,"null")+") " + sqle.getClass().getName() + " " + sqle.getMessage());
        if (oConn!=null) { try { if (!oConn.isClosed()) oConn.close("MimeSender.init.1"); } catch (Exception ignore) {} }
        throw sqle;
      }
        catch (NullPointerException npe) {
        if (DebugFile.trace) DebugFile.writeln("MimeSender.init("+getStringNull(DB.gu_job,"null")+") " + npe.getClass().getName());
        if (oConn!=null) { try { if (!oConn.isClosed()) oConn.close("MimeSender.init.1"); } catch (Exception ignore) {} }
        throw npe;
      }
      if (null==oUser) {
        if (DebugFile.trace) {
          DebugFile.decIdent();
          DebugFile.writeln("End MimeSender.init("+oAtm.getString(DB.gu_job)+") : abnormal process termination");
        }
        throw new NullPointerException("User "+getStringNull(DB.gu_writer,"null")+" not found");
      }
      if (null==oMacc) {
        if (DebugFile.trace) {
          DebugFile.decIdent();
          DebugFile.writeln("End MimeSender.init("+oAtm.getString(DB.gu_job)+") : abnormal process termination");
        }
        throw new NullPointerException("Mail Account "+getParameter("account")+" not found");
      }
      try {

        // Create mail session
        if (DebugFile.trace) DebugFile.writeln("new SessionHandler("+oMacc.getStringNull(DB.gu_account,"null")+")");
        oHndlr = new SessionHandler(oMacc);

        // Retrieve profile name to be used from a Job parameter
        // Profile is needed because it contains the path to /storage directory
        // which is used for composing the path to outbox mbox file containing
        // source of message to be sent
        sProfile = getParameter("profile");
        sMBoxDir = DBStore.MBoxDirectory(sProfile,iDomainId,sWrkA);

        oStor = new DBStore(oHndlr.getSession(), new URLName("jdbc://", sProfile, -1, sMBoxDir, oUser.getString(DB.gu_user), oUser.getStringNull(DB.tx_pwd,"")));
        oStor.connect(sProfile, oUser.getString(DB.gu_user), oUser.getStringNull(DB.tx_pwd,""));
        oOutBox = (DBFolder) oStor.getFolder("outbox");
        oOutBox.open(Folder.READ_WRITE);
        String sMsgId = getParameter("message");

        oDraft = oOutBox.getMessageByGuid(sMsgId);
        if (null==oDraft) throw new MessagingException("DBFolder.getMessageByGuid() Message "+sMsgId+" not found");

        oHeaders = oOutBox.getMessageHeaders(sMsgId);
        if (null==oHeaders) throw new MessagingException("DBFolder.getMessageHeaders() Message "+sMsgId+" not found");
        if (null==oHeaders.get(DB.nm_from))
          aFrom = new InternetAddress[]{new InternetAddress(oHeaders.getProperty(DB.tx_email_from))};
        else
          aFrom = new InternetAddress[]{new InternetAddress(oHeaders.getProperty(DB.tx_email_from),
                                                            oHeaders.getProperty(DB.nm_from))};

        if (DebugFile.trace) DebugFile.writeln("tx_email_reply="+oHeaders.getProperty(DB.tx_email_reply));

        aReply = new InternetAddress[]{new InternetAddress(oHeaders.getProperty(DB.tx_email_reply, oHeaders.getProperty(DB.tx_email_from)))};

        sBody = oDraft.getText();
        if (DebugFile.trace) {
          if (null==sBody)
            DebugFile.writeln("Message body: null");
          else
            DebugFile.writeln("Message body: " + Gadgets.left(sBody.replace('\n',' '), 100));
        }

    oOutBox.close(false);
    oOutBox=null;
    oStor.close();
    oStor=null;

        oConn = getDataBaseBind().getConnection("MimeSender.init.2");
        oConn.setAutoCommit(true);

        oUpdt = oConn.prepareStatement("UPDATE "+DB.k_mime_msgs+" SET "+DB.dt_sent+"=? WHERE "+DB.gu_mimemsg+"=?");
        oUpdt.setTimestamp(1, new Timestamp(new Date().getTime()));
      oUpdt.setString(2, sMsgId);
        oUpdt.executeUpdate();
        oUpdt.close();

    DBSubset oBlck = new DBSubset(DB.k_global_black_list, DBBind.Functions.LOWER+"("+DB.tx_email+")",
                                  DB.id_domain+"=? AND "+DB.gu_workarea+" IN (?,'00000000000000000000000000000000')", 1000);
    int nBlacklisted = oBlck.load(oConn, new Object[]{new Integer(iDomainId), getString(DB.gu_workarea)});

    if (nBlacklisted==0) {
      if (getDataBaseBind().exists(oConn, DB.k_grey_list, "U")) {
        DBSubset oGrey = new DBSubset(DB.k_grey_list+" g", DBBind.Functions.LOWER+"("+DB.tx_email+")", null, 1000);
        int nGreylisted = oGrey.load(oConn);
      if (nGreylisted>0) {
          aBlackList = new String[nGreylisted];
          for (int g=0; g<nGreylisted; g++)
            aBlackList[g] = oGrey.getString(0,g);
      } else {
          aBlackList = null;
      }
      } else {
        aBlackList = null;
      }      
    } else {
      aBlackList = new String[nBlacklisted];
      for (int b=0; b<nBlacklisted; b++)
        aBlackList[b] = oBlck.getString(0,b);
      if (getDataBaseBind().exists(oConn, DB.k_grey_list, "U")) {
        DBSubset oGrey = new DBSubset(DB.k_grey_list+" g", DBBind.Functions.LOWER+"("+DB.tx_email+")",
                                      "NOT EXISTS (SELECT "+DB.tx_email+" FROM "+DB.k_global_black_list+" b WHERE b."+DB.tx_email+"=g."+DB.tx_email+" AND b."+DB.id_domain+"=? AND b."+DB.gu_workarea+" IN (?,'00000000000000000000000000000000'))", 1000);
       
        int nGreylisted = oGrey.load(oConn, new Object[]{new Integer(iDomainId), getString(DB.gu_workarea)});
      if (nGreylisted>0) {
          String[] aBlackGrey = new String[nBlacklisted+nGreylisted];
          for (int b=0; b<nBlacklisted; b++)
            aBlackGrey[b] = oBlck.getString(0,b);
          for (int g=0; g<nGreylisted; g++)
            aBlackGrey[g+nBlacklisted] = oGrey.getString(0,g);
          aBlackList = aBlackGrey;
      }
      }
      Arrays.sort(aBlackList);
    } // fi

        Event.trigger(oConn, iDomainId, "initjob", this, getProperties());
                              
        oConn.close("MimeSender.init.2");
        oConn=null;

      } catch (Exception e) {
        if (DebugFile.trace) {
          DebugFile.writeStackTrace(e);
          DebugFile.write("\n");
          DebugFile.decIdent();
          DebugFile.writeln("End MimeSender.init(" + oAtm.getString(DB.gu_job) + ":" + String.valueOf(oAtm.getInt(DB.pg_atom)) + ") : abnormal process termination");
        }
        try { if (oUpdt!=null) oUpdt.close(); } catch (Exception ignore) {}
        try { if (oConn!=null) if (!oConn.isClosed()) oConn.close("MimeSender.init.2"); } catch (Exception ignore) {}
        if (null!=oOutBox) { try { oOutBox.close(false); oOutBox=null; } catch (Exception ignore) {} }
        if (null!=oStor) { try { oStor.close(); oStor=null; } catch (Exception ignore) {} }
        if (null!=oHndlr) { try { oHndlr.close(); oHndlr=null; } catch (Exception ignore) {} }
        throw new MessagingException(e.getMessage(),e);
      }
      if (DebugFile.trace) {
        DebugFile.decIdent();
View Full Code Here


      DebugFile.writeln("Begin MimeSender.free()");
      DebugFile.incIdent();
      DebugFile.writeln("gu_job="+getStringNull(DB.gu_job,"null"));
    }

  DBStore oStor = null;
  DBFolder oSent = null;
  int iStillExecutable = 0;
 
    if (0==iPendingAtoms) {

      try {
        if (getDataBaseBind()!=null) {
          JDCConnection oConn = getDataBaseBind().getConnection("MimeSender.free", true);
          if (oConn!=null) {
            iStillExecutable = DBCommand.queryCount(oConn, "*", DB.k_job_atoms, DB.id_status+" IN ("+
                       String.valueOf(Atom.STATUS_INTERRUPTED)+","+String.valueOf(Atom.STATUS_SUSPENDED)+
                       String.valueOf(Atom.STATUS_RUNNING)+","+String.valueOf(Atom.STATUS_PENDING)+")");
            if (0==iStillExecutable) {
              try {
                Event.trigger(oConn, iDomainId, "freejob", this, getProperties());
              } catch (Exception ignore) { }
            }
            oConn.close("MimeSender.free");
          } // fi (oConn!=null)
        } // fi getDataBaseBind()
      } catch (SQLException sqle) {
        if (DebugFile.trace) {
          DebugFile.writeln("SQLException "+sqle.getMessage());
        }
      }

      if (0==iStillExecutable) {
        try {
          if (oHndlr==null) {
            throw new MessagingException("Session lost. SessionHandler is null");
          } else if (oHndlr.getSession()==null) {
            throw new MessagingException("Session lost. SessionHandler.getSession() is null");
          } else {
            oStor = new DBStore(oHndlr.getSession(), new URLName("jdbc://", sProfile, -1, sMBoxDir, oUser.getString(DB.gu_user), oUser.getStringNull(DB.tx_pwd,"")));
            oStor.connect(sProfile, oUser.getString(DB.gu_user), oUser.getStringNull(DB.tx_pwd,""));
            oSent = (DBFolder) oStor.getFolder("sent");
            oSent.open(Folder.READ_WRITE);
            oSent.moveMessage(oDraft);
          oSent.close(false);
          oStor.close();
          }
        } catch (StoreClosedException sce) {
          if (DebugFile.trace) {
            DebugFile.writeln("MimeSender.free() StoreClosedException "+sce.getMessage());
            try  {
              DebugFile.writeln(StackTraceUtil.getStackTrace(sce));
            } catch (IOException ignore) {}
          }       
        } catch (MessagingException mse) {
          if (DebugFile.trace) {
            DebugFile.writeln("MimeSender.free() MessagingException "+mse.getMessage());
            try  {
              DebugFile.writeln(StackTraceUtil.getStackTrace(mse));
            } catch (IOException ignore) {}
          }
        } catch (NullPointerException npe) {
          if (DebugFile.trace) {
            DebugFile.writeln("MimeSender.free() NullPointerException "+npe.getMessage());
            try  {
              DebugFile.writeln(StackTraceUtil.getStackTrace(npe));
            } catch (IOException ignore) {}
          }
        }
      } // fi (0==iStillExecutable) 
    } // fi

    oDraft=null;
    if (null!=oSent)   { try { oSent.close(false); oSent=null; } catch (Exception ignore) {} }
    if (null!=oStor)   { try { oStor.close(); oStor=null; } catch (Exception ignore) {} }
    if (null!=oHndlr)  { try { oHndlr.close(); oHndlr=null; } catch (Exception ignore) {} }

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End MimeSender.free()");
View Full Code Here

   JDCConnection oCon = null;
   PreparedStatement oStm = null;
   ResultSet oRst = null;
   MimeSender oSnd = null;
   SessionHandler oHnl = null;
   DBStore  oSto = null;
   DBFolder oFld = null;
   DBSubset oLists = new DBSubset(DB.k_lists,DB.gu_list,DB.gu_list+"=? OR "+DB.de_list+"=?",1);
   DBSubset oMaccs = new DBSubset(DB.k_user_mail,DB.gu_account,DB.gu_account+"=? OR "+DB.tl_account+"=?",1);
     
   if (args==null) {
     System.out.println("Mail batch descriptor is required");
   } else if (args.length==0) {
     System.out.println("Mail batch descriptor is required")
   } else {
      try {
        System.out.println("Connecting to database...");
        oDbb = new DBBind(args[0]);
        System.out.println("Database connection was successfull");
        if (oDbb.getProperty("storage")==null) {
         System.out.println("storage property is required but not found at "+args[0]+".cnf file");
         nErrs++;       
        } else {

        if (oDbb.getProperty("mail.list")==null) {
         System.out.println("mail.list property is required but not found at "+args[0]+".cnf file");  
         nErrs++;       
        } else {
           String sMailingDir = Gadgets.chomp(oDbb.getProperty("storage"), File.separator)+"mailing"+File.separator+oDbb.getProperty("mail.list");
     String sBody = null;
     String sType = null;
     String sBodyFile = sMailingDir+File.separator+"body.htm";
    
     if (new File(sMailingDir+File.separator+"body.htm").exists()) {
           System.out.println("Trying to read file "+sMailingDir+File.separator+"body.htm");
       sBody = oFs.readfilestr("file://"+sMailingDir+File.separator+"body.htm","UTF-8");
       sType = "html";      
     } else if (new File("file://"+sMailingDir+File.separator+"body.txt").exists()) {
           System.out.println("Trying to read file "+sMailingDir+File.separator+"body.txt");
       sBody = oFs.readfilestr("file://"+sMailingDir+File.separator+"body.txt","UTF-8");
       sType = "plain";      
     }
     if (null==sBody) {
           System.out.println("Could not find body.htm nor body.txt files at directory "+sMailingDir);
           nErrs++;
     } else {

           oCon = oDbb.getConnection("MimeSender.main()");
           oCon.setAutoCommit(false);
           int nLists = oLists.load(oCon, new Object[]{oDbb.getProperty("mail.list").trim(),oDbb.getProperty("mail.list").trim()});
           if (nLists==0) {
             System.out.println("Mailing list "+oDbb.getProperty("mail.list")+" not found at k_lists table");
             nErrs++;
           } else if (nLists>1) {      
             System.out.println("Ambiguous name for mailing list "+oDbb.getProperty("mail.list"));
             nErrs++;
           } else {
             Date dtNow = new Date();

             if (oDbb.getProperty("mail.account")==null) {
               System.out.println("mail.account property is required but not found at "+args[0]+".cnf file");  
               nErrs++;
             } else {          
               int nMaccs = oMaccs.load(oCon, new Object[]{oDbb.getProperty("mail.account").trim(),oDbb.getProperty("mail.account").trim()});
               if (nMaccs==0) {
                 System.out.println("Mailing account "+oDbb.getProperty("mail.account")+" not found at k_user_mail table");
                 nErrs++;
               } else if (nMaccs>1) {      
                 System.out.println("Ambiguous name for mailing account "+oDbb.getProperty("mail.account"));
                 nErrs++;
               } else {
                 System.out.println("Composing message...");
                 DistributionList oLst = new DistributionList(oCon, oLists.getString(0,0));
                 oLists = null;
                 System.out.println("Getting mail account...");
                 MailAccount oAcc = new MailAccount(oCon, oMaccs.getString(0,0));
                 ACLUser oUsr = new ACLUser(oCon, oAcc.getString(DB.gu_user));
                 System.out.println("Got mail");
                 String sMBoxDir = DBStore.MBoxDirectory(oDbb.getProfileName(),
                                                       oUsr.getInt(DB.id_domain),
                                                       oUsr.getString(DB.gu_workarea));
                 System.out.println("mbox directory is "+sMBoxDir);
                 System.out.println("Opening mail session... ");
                 oHnl = new SessionHandler(oAcc);
        
                 oSto = DBStore.open (oHnl.getSession(), oDbb.getProfileName(), sMBoxDir,
                                      oUsr.getString(DB.gu_user), oUsr.getString(DB.tx_pwd));
                 oFld = oSto.openDBFolder("outbox", DBFolder.READ_WRITE);
                 System.out.println("Creating message template...");
        
                 DBMimeMessage oMsg = DraftsHelper.draftMessage(oFld, oDbb.getProperty("mail.host","127.0.0.1"),
                                                                oUsr.getString(DB.gu_workarea),
                                                                oUsr.getString(DB.gu_user), sType);
                 DraftsHelper.draftUpdate (oCon, oUsr.getInt(DB.id_domain),
                                           oUsr.getString(DB.gu_workarea),
                                           oMsg.getMessageGuid(),
                                           DBCommand.queryStr(oCon, "SELECT "+DB.id_message+" FROM "+DB.k_mime_msgs+
                                             " WHERE "+DB.gu_mimemsg+"='"+oMsg.getMessageGuid()+"'"),
                                           oLst.getString(DB.tx_from),
                                           oLst.getStringNull(DB.tx_reply,oLst.getString(DB.tx_from)),
                                           oLst.getStringNull(DB.tx_sender,oLst.getString(DB.tx_from)),
                                           oLst.getStringNull(DB.tx_subject,""),
                                           "text/"+sType+"; charset=utf-8",
                                           sBody, null, null, null);

                 System.out.println("Message template successfully composed");
                 String sGuJob = null;
                 if (null!=oDbb.getProperty("mail.job.title")) {
                   oStm = oCon.prepareStatement("SELECT "+DB.gu_job+" FROM "+DB.k_jobs+" WHERE "+
                                                DB.tl_job+"=? AND "+DB.gu_workarea+"=?");
                   oStm.setString(1, oDbb.getProperty("mail.job.title"));
                   oStm.setString(2, oLst.getString(DB.gu_workarea));
                   oRst = oStm.executeQuery();
                   if (oRst.next()) sGuJob = oRst.getString(1);
                   oRst.close();
                   oRst=null;
                   oStm.close();
                   oStm=null;
                 } // fi
        
                 if (null==sGuJob) {
                   oSnd = newInstance(oCon, oLst.getString(DB.gu_list),
                                      oLst.getString(DB.gu_workarea),
                                      oUsr.getString(DB.gu_user), dtNow,
                                      Job.STATUS_RUNNING,
                                      oDbb.getProperty("mail.job.title",oLst.getStringNull(DB.de_list,"")+" "+dtNow.toString()),
                                      "profile:"+oDbb.getProfileName()+
                                      ",id:"+oMsg.getMessageID()+
                                      ",message:"+oMsg.getMessageGuid()+
                                      ",account:"+oAcc.getString(DB.gu_account)+
                                      ",gu_list:"+oLst.getString(DB.gu_list)+
                                      ",personalized:"+String.valueOf(true)+
                                      ",bo_attachimages:1");
                 } else {
                   oSnd = new MimeSender();
                   oSnd.load(oCon, sGuJob);
                   oSnd.setStatus(oCon, Job.STATUS_RUNNING);
                 }
                 oSnd.setDataBaseBind(oDbb);

                 oFld.close(false);
                 oFld=null;
                 oSto.close();
                 oSto=null;
                 oHnl.close();
                 oHnl=null;

                 System.out.println("Loading queue...");

                 if (null==sGuJob) {
                   AtomFeeder oAfd = new AtomFeeder();
                   oAfd.loadAtoms (oCon, oSnd.getString(DB.gu_job), Atom.STATUS_RUNNING);        
                 }

                 oCon.commit();
        
                 oSnd.setPending(DBCommand.queryInt(oCon,"SELECT COUNT(*) FROM "+DB.k_job_atoms+" WHERE "+DB.gu_job+"='"+oSnd.getString(DB.gu_job)+"' AND "+DB.id_status+"="+String.valueOf(Atom.STATUS_RUNNING)));

                 System.out.println("Queue loaded with "+String.valueOf(oSnd.pending())+" mails to be sent");

                 oStm = oCon.prepareStatement("SELECT a.*, j." + DB.tx_parameters + " FROM " + DB.k_job_atoms + " a, " + DB.k_jobs + " j WHERE a." + DB.id_status + "=" + String.valueOf(Atom.STATUS_RUNNING) + " AND j." + DB.gu_job + "=a." + DB.gu_job + " AND j." + DB.gu_job + "=? ORDER BY "+DB.pg_atom,
                                              ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

                 oStm.setString(1, oSnd.getString(DB.gu_job));
                 oRst = oStm.executeQuery();
                 ResultSetMetaData oMdt = oRst.getMetaData();
                 boolean bHasNext = oRst.next();
                 while (bHasNext) {
                   Atom oAtm = new Atom(oRst, oMdt);
                   oAtm.replace(DB.id_format,sType);
                   try {                    
                     oSnd.process(oAtm);
                     oAtm.archive(oCon);                    
                     oCon.commit();
                     nSent++;
                     System.out.println("Mail number "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+oAtm.getString(DB.tx_email)+" sent OK");
                   } catch (SQLException sqle) {
                     nErrs++;
                     System.out.println("Mail number "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+oAtm.getString(DB.tx_email)+" failed with SQLException "+sqle.getMessage());
                     if (DebugFile.trace) DebugFile.writeln("SQLException at atom "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+sqle.getMessage()+" "+StackTraceUtil.getStackTrace(sqle));
                     try { oCon.rollback(); oAtm.setStatus(oCon, Atom.STATUS_INTERRUPTED, "SQLException "+sqle.getMessage()); oCon.commit(); } catch (SQLException ignore) { }
                     oRst.close(); oRst=null;
                    oStm.close(); oStm=null;
                     break;
                   } catch (NullPointerException npe) {
                     nErrs++;
                     System.out.println("Mail number "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+oAtm.getString(DB.tx_email)+" failed with NullPointerException "+npe.getMessage());
                     if (DebugFile.trace) DebugFile.writeln("NullPointerException at atom "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+npe.getMessage()+" "+StackTraceUtil.getStackTrace(npe));
                     try { oCon.rollback(); oAtm.setStatus(oCon, Atom.STATUS_INTERRUPTED, "NullPointerException "+npe.getMessage()); oCon.commit(); } catch (SQLException ignore) { }
                     oRst.close(); oRst=null;
                    oStm.close(); oStm=null;
                     break;
                   } catch (MessagingException msge) {
                     nErrs++;
                     System.out.println("Mail number "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+oAtm.getString(DB.tx_email)+" failed with MessagingException "+msge.getMessage());
                     if (DebugFile.trace) DebugFile.writeln(msge.getClass().getName()+" at atom "+String.valueOf(oAtm.getInt(DB.pg_atom))+" "+msge.getMessage()+" "+StackTraceUtil.getStackTrace(msge));
                     try { oCon.rollback(); oAtm.setStatus(oCon, Atom.STATUS_INTERRUPTED, "MessagingException "+msge.getMessage()); oCon.commit(); } catch (SQLException ignore) { }
                   } finally {
                     bHasNext = oRst.next();
                   }
                 } //wend
                 if (null!=oRst) oRst.close();
                 oRst=null;
                 if (null!=oStm) oStm.close();
                 oStm=null;
                 if (oSnd.getStatus()==Job.STATUS_RUNNING) {
                   System.out.println("Finishing job...");
                   oSnd.setStatus(oCon, Job.STATUS_FINISHED);
                 } else {
                   System.out.println("Job finished abnormaly.");
                 }
                 oSnd=null;    
               } // fi
             }
           } // fi
           oCon.close("MimeSender.main()");
           oCon=null;
       }
       } // fi          
     }

      System.out.println("Disconnecting from database...");

      oDbb.close();
      oDbb=null;
      if (nErrs==0)
        System.out.println("Bulk mailing sucessfully finished, "+String.valueOf(nSent)+" messages sent");
      else
        System.out.println("Bulk mailing finished with errors, "+String.valueOf(nSent)+" message"+(nSent==1 ? "s" : "")+" sent and "+String.valueOf(nErrs)+" error"+(nErrs==1 ? "s" : ""));
      } catch (Exception xcpt) {
        System.out.println(xcpt.getClass().getName()+" "+xcpt.getMessage());
        System.out.println(StackTraceUtil.getStackTrace(xcpt));
        if (oFld!=null) try { oFld.close(false); } catch (MessagingException ignore) { }
        if (oSto!=null) try { oSto.close(); } catch (MessagingException ignore) { }
        if (oHnl!=null) try { oHnl.close(); } catch (MessagingException ignore) { }
        if (oSnd!=null) {
           try {
             if (null!=oCon) if (!oCon.isClosed()) oSnd.setStatus(oCon, Job.STATUS_INTERRUPTED);
             oSnd.free();
View Full Code Here

TOP

Related Classes of com.knowgate.hipermail.DBStore

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.