Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/mail Emailer.java MailList.java MailListAdminMaint.java MailListAdminMaint.properties MailListArchive.java MailListArchive.properties MailListManager.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/mail Emailer.java MailList.java MailListAdminMaint.java MailListAdminMaint.properties MailListArchive.java MailListArchive.properties MailListManager.java

Author commitlogger at hocus dot collab dot net
Full name commitlogger at hocus dot collab dot net
Date 2000-04-18 09:59:55 PDT
Message User: dlr
  Date: 00/04/18 09:59:55

  Modified: java/org/joist/mail Emailer.java MailList.java
                        MailListAdminMaint.java
                        MailListAdminMaint.properties MailListArchive.java
                        MailListArchive.properties MailListManager.java
  Log:
  sXc merge (nothing to merge), minor refactoring of Emailer.
  
  Revision Changes Path
  1.5 +30 -4 joist/java/org/joist​/mail/Emailer.java
  
  Index: Emailer.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/Emailer.j​ava,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Emailer.java 2000/04/16 09:44:46 1.4
  +++ Emailer.java 2000/04/18 16:59:54 1.5
  @@ -58,7 +58,7 @@
     * underlying java mail facility.
     *
     * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
     * Copyright (c) 1999, 2000 Collab.Net, Inc.
  @@ -69,11 +69,37 @@
       static private Log log = new Log("emailer", "Emailer");
       static private boolean debug = true;
   
  - //FIX: make this configurable
  + /**
  + * The email address under which email is sent.
  + */
       static private String systemSender = "notifier at sourcexchange dot com";
   
   
       /**
  + * Gets the email address under which the system sends email.
  + *
  + * @return The email address under which email is currently sent.
  + */
  + public static String
  + getSystemSender()
  + {
  + return systemSender;
  + }
  +
  +
  + /**
  + * Sets the email address under which the system sends email.
  + *
  + * @param sender The email address under which you'd like email sent.
  + */
  + public static void
  + setSystemSender(String sender)
  + {
  + systemSender = sender;
  + }
  +
  +
  + /**
        * Sends an email message from the system to a single recipient
        *
        * @param recipient the recipient's email address
  @@ -109,7 +135,7 @@
           Message message = new MimeMessage(session);
           message.setFrom(new InternetAddress(sender));
           message.setRecipient​(Message.RecipientTy​pe.TO,
  - new InternetAddress(recipient));
  + new InternetAddress(recipient));
           message.setSubject(subject);
           message.setText(body);
           Transport.send(message);
  @@ -265,7 +291,7 @@
       //FIX: make this configurable through a property, or subclass for sXc, tigris, etc.
       StringBuffer listName = new StringBuffer("project");
       String mailHost = System.getProperty("​org.sourcexchange.ma​ilhost");
  - listName.append(proj​ectID).append("@" + mailHost);
  + listName.append(proj​ectID).append('@' + mailHost);
       recipients.addElemen​t(listName.toString(​));
       }
   }
  
  
  
  1.3 +70 -67 joist/java/org/joist​/mail/MailList.java
  
  Index: MailList.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailList.​java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MailList.java 2000/01/30 13:00:35 1.2
  +++ MailList.java 2000/04/18 16:59:54 1.3
  @@ -9,20 +9,22 @@
     * Interface to the mail list management software. For example, ezmlm.
     *
     * @author C. Ludewig
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
  - * Copyright (c) 1999, 2000 Collab.Net, Inc.
  + * Copyright (c) 1999, 2000 Collab.Net, Inc.
     */
   public class MailList extends Object
   {
       static private Log log = new Log("maillst", "MailList");
       static private boolean debug = true;
   
  - private static final String MAIL_HOST = System.getProperty("​org.joist.mailhost")​;
  - private static final String MAIL_USER = System.getProperty("​org.joist.mailuser")​;
  + private static final String MAIL_HOST =
  + System.getProperty("​org.joist.mailhost")​;
  + private static final String MAIL_USER =
  + System.getProperty("​org.joist.mailuser")​;
   
  - /*
  + /**
        * Creates a new mail list.
        *
        * @param listName name of the new list
  @@ -35,31 +37,28 @@
       {
       try
       {
  - // Execute the mail list command as an ssh command to the mail host.
  - Command command = new Command();
  - StringBuffer buffer = new StringBuffer(1024);
  - String commandString = "ssh -l " + MAIL_USER + " " + MAIL_HOST +
  - " list-create " + listName;
  + // Build list creation command.
  + StringBuffer commandBuf = new StringBuffer("list-create " +
  + listName);
           if (members != null)
           {
               Enumeration e = members.elements();
               while (e.hasMoreElements())
  - commandString += " " + (String)e.nextElement();
  + cmdBuffer.append(' ').append((String)e.​nextElement());
           }
  - if (debug) log.debug("exec: " + commandString);
  - command.exec(commandString, buffer);
  - if (debug) log.debug("result: " + buffer);
  - if (!buffer.toString().​trim().equals(""))
  - throw new MailListException(bu​ffer.toString());
  +
  + String cmdResults = execSSHCommand(cmdBu​ffer.toString());
  + if (!cmdResults.trim().equals(""))
  + throw new MailListException(cmdResults);
       }
       catch (Exception e)
       {
           throw new MailListException("Can't create mail list " +
  - listName + ": " + e.getMessage());
  + listName + ": " + e.getMessage());
       }
       }
   
  - /*
  + /**
        * Adds a member to a list.
        *
        * @param listName name of the mail list
  @@ -72,25 +71,20 @@
       {
       try
       {
  - // Execute the mail list command as an ssh command to the mail host.
  - Command command = new Command();
  - StringBuffer buffer = new StringBuffer(1024);
  - String commandString = "ssh -l " + MAIL_USER + " " + MAIL_HOST +
  - " list-subscribe " + listName + " " + member;
  - if (debug) log.debug("exec: " + commandString);
  - command.exec(commandString, buffer);
  - if (debug) log.debug("result: " + buffer);
  - if (!buffer.toString().​trim().equals(""))
  - throw new MailListException(bu​ffer.toString());
  + String cmdResults =
  + execSSHCommand("list-subscribe " + listName + ' ' + member);
  + if (!cmdResults.trim().equals(""))
  + throw new MailListException(cmdResults);
       }
       catch (Exception e)
       {
           throw new MailListException("Can't add member " + member +
  - " to mail list " + listName + ": " + e.getMessage());
  + " to mail list " + listName + ": " +
  + e.getMessage());
       }
       }
   
  - /*
  + /**
        * Returns a table of the current members.
        *
        * @param listName name of the mail list
  @@ -102,18 +96,10 @@
       {
       try
       {
  - // Execute the mail list command as an ssh command to the mail host.
  - Command command = new Command();
  - StringBuffer buffer = new StringBuffer(1024);
  - String commandString = "ssh -l " + MAIL_USER + " " + MAIL_HOST +
  - " list-list " + listName;
  - if (debug) log.debug("exec: " + commandString);
  - command.exec(commandString, buffer);
  - if (debug) log.debug("result: " + buffer);
  -
           // Parse the output.
  + StringTokenizer tokenizer =
  + new StringTokenizer(exec​SSHCommand("list-lis​t " + listName));
               Hashtable t = new Hashtable();
  - StringTokenizer tokenizer = new StringTokenizer(buff​er.toString());
               while (tokenizer.hasMoreTokens())
               {
           String member = tokenizer.nextToken();
  @@ -124,11 +110,11 @@
       catch (Exception e)
       {
           throw new MailListException("Can't list mail list " +
  - listName + ": " + e.getMessage());
  + listName + ": " + e.getMessage());
       }
       }
   
  - /*
  + /**
        * Returns true if the address specified is in the list.
        *
        * @param listName name of the mail list
  @@ -144,9 +130,15 @@
       // becomes an issue, we will need to cache the list of members.
       Hashtable members = getMembers(listName);
       return (members.get(address) != null);
  +
  + /* TODO: Try out and test this implemention:
  + String cmdResults =
  + execSSHCommand("list-list " + listName + " | grep " + address);
  + return (cmdResults != null && cmdResults.length() > 0);
  + */
       }
   
  - /*
  + /**
        * Returns a list of the current members.
        *
        * @param listName name of the mail list
  @@ -158,18 +150,10 @@
       {
       try
       {
  - // Execute the mail list command as an ssh command to the mail host.
  - Command command = new Command();
  - StringBuffer buffer = new StringBuffer(1024);
  - String commandString = "ssh -l " + MAIL_USER + " " + MAIL_HOST +
  - " list-list " + listName;
  - if (debug) log.debug("exec: " + commandString);
  - command.exec(commandString, buffer);
  - if (debug) log.debug("result: " + buffer);
  -
           // Parse the output.
  + StringTokenizer tokenizer =
  + new StringTokenizer(exec​SSHCommand("list-lis​t " + listName));
               Vector v = new Vector();
  - StringTokenizer tokenizer = new StringTokenizer(buff​er.toString());
               while (tokenizer.hasMoreTokens())
               {
           String member = tokenizer.nextToken();
  @@ -179,12 +163,12 @@
       }
       catch (Exception e)
       {
  - throw new MailListException("Can't list mail list " +
  - listName + ": " + e.getMessage());
  + throw new MailListException("Can't list mail list " + listName +
  + ": " + e.getMessage());
       }
       }
   
  - /*
  + /**
        * Removes a member from the list.
        *
        * @param listName name of the mail list
  @@ -197,21 +181,40 @@
       {
       try
       {
  - // Execute the mail list command as an ssh command to the mail host.
  - Command command = new Command();
  - StringBuffer buffer = new StringBuffer(1024);
  - String commandString = "ssh -l " + MAIL_USER + " " + MAIL_HOST +
  - " list-unsubscribe " + listName + " " + member;
  - if (debug) log.debug("exec: " + commandString);
  - command.exec(commandString, buffer);
  - if (debug) log.debug("result: " + buffer);
  - if (!buffer.toString().​trim().equals(""))
  - throw new MailListException(bu​ffer.toString());
  + String cmdResults =
  + execSSHCommand("list​-unsubscribe " + listName + ' ' + member);
  + if (!cmdResults.trim().equals(""))
  + throw new MailListException(cmdResults);
       }
       catch (Exception e)
       {
           throw new MailListException("Can't remove member " + member +
  - " from mail list " + listName + ": " + e.getMessage());
  + " from mail list " + listName + ": " +
  + e.getMessage());
       }
  + }
  +
  + /**
  + * Executes the specified shell command over ssh to the mail host. Returns
  + * the command output.
  + *
  + * @param cmd The shell command to execute.
  + * @return The shell command output.
  + */
  + protected static String
  + execSSHCommand(String cmd)
  + throws MailListException
  + {
  + // Execute the mail list command as an ssh command to the mail host.
  + String cmdString = "ssh -l " + MAIL_USER + ' ' + MAIL_HOST + ' ' +
  + cmd;
  + if (debug) log.debug("exec: " + cmdString);
  + StringBuffer buffer = new StringBuffer(1024);
  + new Command().exec(cmdString, buffer);
  +
  + // Log and check the results.
  + String cmdResults = buffer.toString();
  + if (debug) log.debug("result: " + cmdResults);
  + return cmdResults;
       }
   }
  
  
  
  1.4 +7 -7 joist/java/org/joist​/mail/MailListAdminM​aint.java
  
  Index: MailListAdminMaint.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailListA​dminMaint.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MailListAdminMaint.java 2000/02/29 01:23:57 1.3
  +++ MailListAdminMaint.java 2000/04/18 16:59:54 1.4
  @@ -63,10 +63,10 @@
     *
     * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
    
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
  - * Copyright (c) 1999, 2000 Collab.Net, Inc.
  + * Copyright (c) 1999, 2000 Collab.Net, Inc.
     */
   
   public class MailListAdminMaint extends MailListMaintenance
  @@ -120,17 +120,17 @@
   
   
       /**
  - * Checks that the Project is one over which the user has authority.
  + * Checks that the MailList is one over which the user has authority.
        * If not, send to UnauthorizedAccess.
        * Authorized Users include:
  - * - Sponsor Contact
  - * - Lead Developer
  - * - Peer Reviewer
  + * - TODO: Add user(s) here, if there are any to add.
  + * - FIX: Otherwise, remove me.
        *
        * @exception RedirectException, SQLException
        */
       protected void
  - checkAuthority (Connection connection, WebContext context, String projectID)
  + checkAuthority (Connection connection, WebContext context,
  + String mailListID)
       throws SQLException, RedirectException, HandlerException
       {
       // Admin can operate on anything ...
  
  
  
  1.3 +1 -0 joist/java/org/joist​/mail/MailListAdminM​aint.properties
  
  Index: MailListAdminMaint.properties
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailListA​dminMaint.properties​,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MailListAdminMaint.properties 2000/01/30 13:00:35 1.2
  +++ MailListAdminMaint.properties 2000/04/18 16:59:54 1.3
  @@ -1,3 +1,4 @@
   permission=Mailing List - Admin
   servletTemplate=mail​/MailListMaint.wm
   servletName=MailListAdminMaint
  +displayName=Mailing List Maintenance for the Administrator
  
  
  
  1.4 +40 -27 joist/java/org/joist​/mail/MailListArchiv​e.java
  
  Index: MailListArchive.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailListA​rchive.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MailListArchive.java 2000/04/16 09:44:46 1.3
  +++ MailListArchive.java 2000/04/18 16:59:54 1.4
  @@ -64,14 +64,14 @@
   import org.joist.util.*;
   
   /**
  - * View the mailing list archive.
  - *
  - * @author C. Ludewig
  -
  - * @version $Revision: 1.3 $
  - *
  - * Copyright (c) 1999 Collab.Net, Inc.
  - */
  + * View the mailing list archive.
  + *
  + * @author C. Ludewig
  + *
  + * @version $Revision: 1.4 $
  + *
  + * Copyright (c) 1999, 2000 Collab.Net, Inc.
  + */
   
   public class MailListArchive extends UnsecureServlet
   {
  @@ -126,7 +126,8 @@
       int messageNumber;
       try
       {
  - messageNumber = Integer.valueOf(cont​ext.getForm("message​Number")).intValue()​;
  + messageNumber =
  + Integer.valueOf(cont​ext.getForm("message​Number")).intValue()​;
       }
       catch (Exception e)
       {
  @@ -170,7 +171,8 @@
           context.put("projectName", projectName);
           
           // Get the list server name.
  - String listServer = System.getProperty("​org.sourcexchange.ma​ilhost");
  + String listServer =
  + System.getProperty("​org.sourcexchange.ma​ilhost");
           context.put("listServer", listServer);
   
           // Handle subscription stuff separately.
  @@ -196,7 +198,8 @@
           if (debug) log.debug("removing " + email);
           mMgr.remove(listName, email);
   
  - context.put("Message", "You are now unsubscribed from " + listName);
  + context.put("Message",
  + "You are now unsubscribed from " + listName);
           context.put("action", "Subscribe");
           action = "View Archive";
           }
  @@ -208,14 +211,18 @@
           checkForViewPermissi​on(userPerms);
   
           if (mMgr.isMember(listName, email))
  - context.put("action", "Unsubscribe");
  + {
  + context.put("action", "Unsubscribe");
  + }
           else
  - context.put("action", "Subscribe");
  + {
  + context.put("action", "Subscribe");
  + }
           }
   
           if (action.equals("Next"))
           {
  - phase = "Viewing next N messages in";
  + phase = "Viewing next " + MESSAGES_PER_PAGE " messages in";
           checkForViewPermissi​on(userPerms);
           
           // Increment the message counter.
  @@ -234,15 +241,15 @@
           if (action.equals("Next") ||
           action.equals("Prev") ||
           action.equals("View Archive") ||
  - ((action.equals("Close") ||
  - action.equals("none")) &&
  - (searchPattern == null || searchPattern.equals(""))))
  + ((action.equals("Close") || action.equals("none")) &&
  + (searchPattern == null || searchPattern.equals(""))))
           {
           // Get the next N message headers.
           // (Actually, get one more than needed, so we can
           // see if there's more to follow...)
           Vector headers = mMgr.getIndex(listName, firstMessage,
  - firstMessage+MESSAGE​S_PER_PAGE);
  + firstMessage +
  + MESSAGES_PER_PAGE);
               
           boolean showPrev = false;
           if (firstMessage > 1)
  @@ -267,8 +274,9 @@
           }
   
           else if (action.equals("Search") ||
  - ((action.equals("Close") ||
  - action.equals("none")) && searchPattern != null)) // occurs when "Enter" hit
  + ((action.equals("Close") ||
  + // occurs when "Enter" hit
  + action.equals("none")) && searchPattern != null))
           {
           phase = "Searching ";
           checkForViewPermissi​on(userPerms);
  @@ -280,7 +288,8 @@
           context.put("showPrev", new Boolean(false));
           context.put("showNext", new Boolean(false));
           context.put("searchPattern", searchPattern);
  - context.put("searchP​atternEncoded", URLEncoder.encode(se​archPattern));
  + context.put("searchP​atternEncoded",
  + URLEncoder.encode(se​archPattern));
           }
   
           else if (action.equals("View"))
  @@ -291,15 +300,16 @@
           try
           {
               // Get message text
  - String messageText = mMgr.getMessage(listName, messageNumber);
  - context.put("messageText", messageText);
  + context.put("messageText",
  + mMgr.getMessage(listName, messageNumber));
               
               context.put("showMessage", new Boolean(true));
               
               // Forward basic message stuff
               context.put("firstMessage", new Integer(firstMessage));
               context.put("searchPattern", searchPattern);
  - context.put("searchP​atternEncoded", URLEncoder.encode(se​archPattern));
  + context.put("searchP​atternEncoded",
  + URLEncoder.encode(se​archPattern));
               context.put("messageNumber", new Integer(messageNumber));
               context.put("subject", context.getForm("subject"));
               context.put("date", context.getForm("date"));
  @@ -307,7 +317,8 @@
           }
           catch (NumberFormatException e)
           {
  - context.put("Message", "No such archive message: " + e.getMessage());
  + context.put("Message", "No such archive message: " +
  + e.getMessage());
           }
           }
       }
  @@ -402,14 +413,16 @@
       {
           if (str == null) return null;
   
  - StringBuffer dec = new StringBuffer(); // decoded string output
  + // decoded string output
  + StringBuffer dec = new StringBuffer();
           int strPos = 0;
           int strLen = str.length();
   
           dec.ensureCapacity(s​tr.length());
           while (strPos < strLen)
       {
  - int laPos; // lookahead position
  + // lookahead position
  + int laPos;
   
               // look ahead to next URLencoded metacharacter, if any
               for (laPos = strPos; laPos < strLen; laPos++)
  
  
  
  1.2 +1 -0 joist/java/org/joist​/mail/MailListArchiv​e.properties
  
  Index: MailListArchive.properties
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailListA​rchive.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MailListArchive.properties 2000/01/30 13:00:35 1.1
  +++ MailListArchive.properties 2000/04/18 16:59:54 1.2
  @@ -1,3 +1,4 @@
   permission=Mailing List - View Archive
   servletTemplate=mail​/MailListArchive.wm
   servletName=MailListArchive
  +displayName=Mailing List Archive
  
  
  
  1.5 +5 -5 joist/java/org/joist​/mail/MailListManage​r.java
  
  Index: MailListManager.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/mail/MailListM​anager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MailListManager.java 2000/04/16 09:44:46 1.4
  +++ MailListManager.java 2000/04/18 16:59:54 1.5
  @@ -61,7 +61,7 @@
     * Interface to the mail list management software. For example, ezmlm.
     *
     * @author C. Ludewig
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
     * Copyright (c) 1999, 2000 Collab.Net, Inc.
  @@ -122,11 +122,11 @@
       {
       try
       {
  - String results = doListCommand("list-subscribe",
  - listName + " " + member);
  + String cmdResults = doListCommand("list-subscribe",
  + listName + ' ' + member);
   
  - if (!results.trim().equals(""))
  - throw new MailListException(results);
  + if (!cmdResults.trim().equals(""))
  + throw new MailListException(cmdResults);
       }
       catch (Exception e)
       {

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/mail Emailer.java MailList.java MailListAdminMaint.java MailListAdminMaint.properties MailListArchive.java MailListArchive.properties MailListManager.java commitlogger at hocus dot collab dot net commitlogger at hocus dot collab dot net 2000-04-18 09:59:55 PDT
Messages per page: