head	1.19;
access;
symbols
	TIGRIS_0_9_2_4:1.13
	TIGRIS_0_9_2_3:1.13
	HELM_PEER_PORT_BRANCH:1.18.0.2
	TURBINE_PEER:1.18
	TIGRIS_0_9_2_1:1.18
	TIGRIS_0_9_2:1.13.0.2
	TIGRIS_0_9_0:1.11.0.2
	TIGRIS_0_8_4:1.5.0.2;
locks; strict;
comment	@# @;


1.19
date	2001.02.21.03.23.57;	author edk;	state dead;
branches;
next	1.18;

1.18
date	2001.01.26.18.29.09;	author edk;	state Exp;
branches
	1.18.2.1;
next	1.17;

1.17
date	2001.01.26.05.24.08;	author edk;	state dead;
branches;
next	1.16;

1.16
date	2001.01.25.02.42.47;	author edk;	state Exp;
branches;
next	1.15;

1.15
date	2001.01.25.00.26.08;	author edk;	state Exp;
branches;
next	1.14;

1.14
date	2001.01.24.20.42.49;	author dlr;	state Exp;
branches;
next	1.13;

1.13
date	2000.12.23.00.48.19;	author dlr;	state Exp;
branches;
next	1.12;

1.12
date	2000.12.22.03.03.00;	author dlr;	state Exp;
branches;
next	1.11;

1.11
date	2000.12.14.23.32.46;	author edk;	state Exp;
branches;
next	1.10;

1.10
date	2000.12.14.04.03.04;	author edk;	state Exp;
branches;
next	1.9;

1.9
date	2000.12.14.02.28.47;	author edk;	state Exp;
branches;
next	1.8;

1.8
date	2000.12.09.07.40.47;	author edk;	state Exp;
branches;
next	1.7;

1.7
date	2000.12.09.03.16.54;	author edk;	state Exp;
branches;
next	1.6;

1.6
date	2000.12.09.02.55.11;	author edk;	state Exp;
branches;
next	1.5;

1.5
date	2000.12.01.19.36.59;	author edk;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	2000.12.01.19.05.21;	author leonardr;	state Exp;
branches;
next	1.3;

1.3
date	2000.12.01.18.46.46;	author edk;	state Exp;
branches;
next	1.2;

1.2
date	2000.12.01.18.14.51;	author edk;	state Exp;
branches;
next	1.1;

1.1
date	2000.12.01.18.01.49;	author edk;	state Exp;
branches;
next	;

1.5.2.1
date	2000.12.09.06.46.38;	author edk;	state Exp;
branches;
next	1.5.2.2;

1.5.2.2
date	2000.12.14.23.33.30;	author edk;	state Exp;
branches;
next	;

1.18.2.1
date	2001.01.28.01.02.19;	author dlr;	state dead;
branches;
next	;


desc
@@


1.19
log
@delete stuff from the head which is obsolete in the branch (more changes
are still needed for a clean compile)
@
text
@/* ================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.tool;

import java.sql.*;
import java.util.*;

import org.webmacro.util.Log;

import org.tigris.helm.tool.mail.MailingList;
import org.tigris.helm.project.Project;
import org.tigris.helm.domain.User;
import org.tigris.helm.domain.Domain;
import org.tigris.helm.database.DomainManager;

import com.workingdogs.village.*;
import org.joist.database.*;
import org.joist.util.JoistProperties;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.database.TaskManager;
import org.tigris.helm.domain.BusinessObject;
import org.tigris.anzu.client.MailingAliasSpec;
import org.tigris.anzu.client.AddressManagerSpec;

public class AnzuTigrisTask extends TigrisTask
{
    public static String COMPONENT_NAME="Anzu";

    protected AnzuTigrisTask (Connection conn, DataManager dMgr,
            String onBehalfOf, String affectedObjectID, String command,
            String arguments)
        throws SQLException, DataSetException
    {
        super(conn, dMgr, onBehalfOf, COMPONENT_NAME,
                affectedObjectID, command, arguments);
    }

    public static void addMailingList(Connection conn, DataManager dMgr,
            String onBehalfOfID, String list, String projectID, String type,
            String description)
        throws SQLException, DataSetException
    {
        ArrayList args = new ArrayList();
        args.add(list);
        args.add(type);
        args.add(description);
        String arguments = null;
        try {
             arguments = writeArgsArray(args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("unable to store args in a string: " +
                    e.getMessage());
            arguments = list + " " + type + " " + description;
        }
        // this creates the entry and stores it in the db
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID,
                projectID, "addlist", arguments);
    }

    public static void deleteMailingList(Connection conn, DataManager dMgr,
            String onBehalfOfID, String list, String projectID)
        throws SQLException, DataSetException, JoistDatabaseException,
                DoesNotExist
    {
        ArrayList args = new ArrayList();
        Project p = new Project(conn, dMgr, projectID);
        String projectName = p.getName();
        String domainName = p.getDomainName();
        args.add(domainName);
        args.add(projectName);
        args.add(list);
        String arguments = null;
        try {
             arguments = writeArgsArray(args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("unable to store args in a string: " +
                    e.getMessage());
            arguments = domainName + " " + projectName + " " + list;
        }
        // this creates the entry and stores it in the db
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID,
                projectID, "deletelist", arguments);
    }

    public static void addProject(Connection conn, DataManager dMgr,
            String onBehalfOfID, String domainID, String projectName)
        throws SQLException, DataSetException
    {
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, domainID,
                "addproject", projectName);
    }

    public static void deleteProject(Connection conn, DataManager dMgr,
            String onBehalfOfID, String domainID, String project)
        throws SQLException, DataSetException
    {
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, domainID,
                "deleteproject", project);
    }

    public static void setOwnerAlias(Connection conn, DataManager dMgr,
            String onBehalfOfID, String projectID, boolean exists)
        throws SQLException, DataSetException
    {
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, projectID,
                "owneralias", (exists ? "true" : "false"));
    }

    public AnzuTigrisTask(Connection conn, DataManager dMgr, Record r)
        throws SQLException, DataSetException
    {
        super(conn, dMgr, r);
    }

    public void runTask()
        throws UpdateException
    {
        String command = null;
        String objectID = null;
        String userID = null;
        try {
            command = getCommand();
            objectID = getAffectedObjectID();
            userID = getOnBehalfOf();
        } catch (Exception e) {
            log.exception(e);
        }

        if (debug)
            log.info("AnzuTigrisTask called : " + command + " / " +
                    objectID + " / " + userID);

        User user = null;
        if (userID != null && !userID.equals("0")) {
            try {
                user = User.getInstance(conn, dMgr, userID);
            } catch (Exception e) {
                throw new UpdateException("invalid userID : " + userID);
            }
        }
        UpdateException ue = null;
        try {
            if (command != null && objectID != null && userID != null)
            {
                if (command.equals("addlist")) {
                    addList(objectID, user);
                } else if (command.equals("deletelist")) {
                    deleteList(objectID);
                } else if (command.equals("addproject")) {
                    addProject(objectID);
                } else if (command.equals("deleteproject")) {
                    deleteProject(objectID);
                } else if (command.equals("owneralias")) {
                    setOwnerAlias(objectID);
                }
            }
        } catch (UpdateException e) {
            ue = e;
        }
        try 
        { 
            setAsDone();
        } catch (Exception e) {
            log.exception(e);
        }
        if (ue != null) { throw ue; }
    }

    private void deleteList(String projectID) throws UpdateException
    {
        UpdateException ue = null;
        try {
            String argsArray[] = readArgs();
            if (debug) {
                for (int i = 0 ; i < argsArray.length ; ++i) {
                    log.info("argsArray["+i+"] = " + argsArray[i]);
                }
            }
            String domain = argsArray[0];
            String project = argsArray[1];
            String list = argsArray[2];

            MailingList ml = new MailingList(conn, dMgr, projectID, list);
            ml.delete();
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("exception in AnzuTigrisTask deletelist: " +
                    e.getMessage());
            ue = new UpdateException("exception in AnzuTigrisTask deletelist: "+
                    e.getMessage());
        }
        if (ue != null) {
            throw ue;
        }
    }

    private void setOwnerAlias(String projectID) throws UpdateException
    {
        try {
            Project project = new Project(conn, dMgr, projectID);
            String domain = project.getDomainName();
            boolean exists = getArguments().equals("true");

            List owners = project.getOwners();
            StringBuffer address = new StringBuffer();
            Iterator i = owners.iterator();
            while (i.hasNext()) {
                if (address.length() > 0)
                    address.append("\n");
                String ownerEmail = ((User)i.next()).getDomainEmail();
                address.append(ownerEmail);
            }
            // TODO : handle error case where address.length() == 0 ?
            if (debug) log.info("set owner alias: " + address.toString());

            MailingAliasSpec ma = new MailingAliasSpec(domain,
                    project.getName(), "owner");
            ma.setDestination(address.toString());
            if (exists) 
                ma.update();
            else
                ma.create();
        } catch (Exception e) {
            if (debug) log.info("unable to set owner email alias: " + 
                    e.getMessage());
            log.exception(e);
            throw new UpdateException("unable to set owner email alias: " +
                    e.getMessage());
        }
    }

    private void addProject(String domainID) throws UpdateException
    {
        try {
            String projectName = getArguments();
            Domain domain = new Domain(conn, dMgr, domainID);
            String domainName = domain.getName();
            // TODO : we should do this through a different class
            // (AddressManager client library) -- once it exists
            AddressManagerSpec mgr = new AddressManagerSpec();
            mgr.addProject(domainName, projectName);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("unable to add anzu project: " +
                    e.getMessage());
            throw new UpdateException("unable to add anzu project: " + 
                    e.getMessage());
        }
    }
    
    private void deleteProject(String domainID) throws UpdateException
    {
        try {
            String projectName = getArguments();
            Domain domain = new Domain(conn, dMgr, domainID);
            String domainName = domain.getName();
            // TODO : we should do this through a different class
            // (AddressManager client library) -- once it exists
            AddressManagerSpec mgr = new AddressManagerSpec();
            mgr.deleteProject(domainName, projectName);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("unable to delete anzu project: " +
                    e.getMessage());
            throw new UpdateException("unable to delete anzu project: " +
                    e.getMessage());
        }
    }

    private void addList(String projectID, User user) throws UpdateException {
        UpdateException ue = null;
        try {
            String argsArray[] = readArgs();
            if (debug) {
                for (int i = 0 ; i < argsArray.length ; ++i) {
                    log.info("argsArray["+i+"] = " + argsArray[i]);
                }
            }
            String list = argsArray[0];
            String type = argsArray[1];
            String description = argsArray[2];

            // TODO : should we validate the projectID?  it
            // got in the database, it should be valid ...
            MailingList ml =
                new MailingList(conn, dMgr, list, description,
                        projectID, type);
            ml.setOwner(user);
            ml.create();
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("exception in AnzuTigrisTask addlist: " +
                    e.getMessage());
            ue = new UpdateException("exception in AnzuTigrisTask addlist: " +
                    e.getMessage());
        }
        if (ue != null) {
            throw ue;
        }
    }
}

@


1.18
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@@


1.18.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@@


1.17
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@a63 1
import org.tigris.helm.database.DBException;
d73 1
a73 1
    protected AnzuTigrisTask (DataManager dMgr,
d76 1
a76 1
        throws DBException
d78 1
a78 1
        super(dMgr, onBehalfOf, COMPONENT_NAME,
d82 1
a82 1
    public static void addMailingList(DataManager dMgr,
d85 1
a85 1
        throws DBException
d101 1
a101 1
        new AnzuTigrisTask(dMgr, onBehalfOfID,
d105 1
a105 1
    public static void deleteMailingList(DataManager dMgr,
d107 2
a108 1
        throws DoesNotExist, DBException
d111 1
a111 1
        Project p = new Project(dMgr, projectID);
d127 1
a127 1
        new AnzuTigrisTask(dMgr, onBehalfOfID,
d131 1
a131 1
    public static void addProject(DataManager dMgr,
d133 1
a133 1
        throws DBException
d135 1
a135 1
        new AnzuTigrisTask(dMgr, onBehalfOfID, domainID,
d139 1
a139 1
    public static void deleteProject(DataManager dMgr,
d141 1
a141 1
        throws DBException
d143 1
a143 1
        new AnzuTigrisTask(dMgr, onBehalfOfID, domainID,
d147 1
a147 1
    public static void setOwnerAlias(DataManager dMgr,
d149 1
a149 1
        throws DBException
d151 1
a151 1
        new AnzuTigrisTask(dMgr, onBehalfOfID, projectID,
d155 2
a156 2
    public AnzuTigrisTask(DataManager dMgr, Record r)
        throws DBException
d158 1
a158 1
        super(dMgr, r);
d182 1
a182 1
                user = User.getInstance(dMgr, userID);
d229 1
a229 1
            MailingList ml = new MailingList(dMgr, projectID, list);
d246 1
a246 1
            Project project = new Project(dMgr, projectID);
d282 1
a282 1
            Domain domain = new Domain(dMgr, domainID);
d301 1
a301 1
            Domain domain = new Domain(dMgr, domainID);
d332 1
a332 1
                new MailingList(dMgr, list, description,
d348 1
@


1.16
log
@more changes to match the new pattern
@
text
@@


1.15
log
@MailingList changes to more closely resemble other business objects (I
don't like certain parts of the pattern, but consistency is more important)
including changes to avoid keeping reference to Connections.
@
text
@d74 1
a74 1
    protected AnzuTigrisTask (Connection conn, DataManager dMgr,
d79 1
a79 1
        super(conn, dMgr, onBehalfOf, COMPONENT_NAME,
d83 1
a83 1
    public static void addMailingList(Connection conn, DataManager dMgr,
d102 1
a102 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID,
d106 1
a106 1
    public static void deleteMailingList(Connection conn, DataManager dMgr,
d111 1
a111 1
        Project p = new Project(conn, dMgr, projectID);
d127 1
a127 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID,
d131 1
a131 1
    public static void addProject(Connection conn, DataManager dMgr,
d135 1
a135 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, domainID,
d139 1
a139 1
    public static void deleteProject(Connection conn, DataManager dMgr,
d143 1
a143 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, domainID,
d147 1
a147 1
    public static void setOwnerAlias(Connection conn, DataManager dMgr,
d151 1
a151 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, projectID,
d155 1
a155 1
    public AnzuTigrisTask(Connection conn, DataManager dMgr, Record r)
d158 1
a158 1
        super(conn, dMgr, r);
d182 1
a182 1
                user = User.getInstance(conn, dMgr, userID);
d246 1
a246 1
            Project project = new Project(conn, dMgr, projectID);
d282 1
a282 1
            Domain domain = new Domain(conn, dMgr, domainID);
d301 1
a301 1
            Domain domain = new Domain(conn, dMgr, domainID);
@


1.14
log
@Making use of DBException.
@
text
@d229 1
a229 1
            MailingList ml = new MailingList(conn, dMgr, projectID, list);
d332 1
a332 1
                new MailingList(conn, dMgr, list, description,
@


1.13
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d64 1
d77 1
a77 1
        throws SQLException, DataSetException
d86 1
a86 1
        throws SQLException, DataSetException
d108 1
a108 2
        throws SQLException, DataSetException, JoistDatabaseException,
                DoesNotExist
d133 1
a133 1
        throws SQLException, DataSetException
d141 1
a141 1
        throws SQLException, DataSetException
d149 1
a149 1
        throws SQLException, DataSetException
d156 1
a156 1
        throws SQLException, DataSetException
a347 1

@


1.12
log
@Propogated object cache interface.
@
text
@a81 5
    protected Dictionary getCache ()
    {
        return null;
    }

d182 1
a182 1
                user = new User(conn, dMgr, userID);
@


1.11
log
@correct typo
@
text
@d82 5
@


1.10
log
@* handle deleting EB lists when it's time (unfortunately, this doesn't yet
  delete the archives themselves)
* minor argument changes (User to String userID)
@
text
@d273 1
a273 1
            throw new UpdateException("unable to set ownere email alias: " +
@


1.9
log
@* handle project deletion w/ anzu
* switch some method signatures in AnzuTigrisTask and add deleteProject
* switch from remove to delete where appropriate (when removing an
  object entirely, rather than just removing it from a container)
@
text
@d83 1
a83 1
            User onBehalfOf, String list, String projectID, String type,
d101 1
a101 1
        new AnzuTigrisTask(conn, dMgr, onBehalfOf.getID(),
d105 26
d193 2
d213 28
@


1.8
log
@make project addition a task so that better error reporting is possible.
@
text
@d57 1
d67 1
d106 1
a106 1
            User onBehalfOf, String projectID)
d109 10
a118 5
        String onBehalfOfID = null;
        if (onBehalfOf != null)
            onBehalfOfID = onBehalfOf.getID();
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, projectID,
                "addproject", "");
d122 1
a122 1
            User onBehalfOf, String projectID, boolean exists)
a124 3
        String onBehalfOfID = null;
        if (onBehalfOf != null) 
            onBehalfOfID = onBehalfOf.getID();
d169 2
d222 2
a223 3
    private void addProject(String projectID) throws UpdateException {
        DomainManager domMgr = (DomainManager)
            dMgr.getManager("org.tigris.helm.database.DomainManager");
d225 3
a227 3
            Project project = new Project(conn, dMgr, projectID);
            String projectName = project.getName();
            String domain = project.getDomainName();
d230 2
a231 1
            MailingList.addProject(domain, projectName);
d237 19
@


1.7
log
@use domain email rather than user email -- otherwise we'll have to update
far too many files when the user changes his/her address.
@
text
@d104 1
a104 1
            User onBehalfOf, String domainID, String project)
d110 2
a111 2
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, domainID,
                "addproject", project);
d216 1
a216 1
    private void addProject(String domainID) throws UpdateException {
d220 3
a222 2
            String domain = domMgr.getDomainName(domainID);
            String project = getArguments();
d224 2
a225 2
            // (AddressManager client library), since this is ugly
            MailingList.addProject(null, domain, project);
@


1.6
log
@support for owner aliases -- basically, owner@@{project}.{domain}
is an alias which sends e-mail to each of the people who's listed
as project owner for {project}.
@
text
@d194 1
a194 1
                String ownerEmail = ((User)i.next()).getEmail();
@


1.5
log
@finish adjusting to changes in TigrisTask
@
text
@d57 1
d65 1
d103 22
d149 8
d158 3
a160 12
        if (command != null && objectID != null && userID != null)
        {
            try {
                String argsArray[] = readArgs();
                if (debug) {
                    for (int i = 0 ; i < argsArray.length ; ++i) {
                        log.info("argsArray["+i+"] = " + argsArray[i]);
                    }
                }
                String list = argsArray[0];
                String type = argsArray[1];
                String description = argsArray[2];
d162 5
a166 12
                    // object is a project
                    Project project = new Project(conn, dMgr, objectID);
                    User user = new User(conn, dMgr, userID);

                    MailingList ml =
                        new MailingList(conn, dMgr, list, description,
                                project.getID(), type);
                    ml.setOwner(user);
                    ml.create();
                } else {
                    ue = new UpdateException("invalid command for " +
                            "AnzuTigrisTask: " + command);
a167 6
            } catch (Exception e) {
                log.exception(e);
                if (debug) log.info("exception in AnzuTigrisTask: " +
                        e.getMessage());
                ue = new UpdateException("exception in AnzuTigrisTask: " +
                        e.getMessage());
d169 2
d179 85
@


1.5.2.1
log
@changes to support owner email aliases.  tested in head, tested in
branch, and ok'ed by jr.
@
text
@a56 1
import org.tigris.helm.database.DomainManager;
a63 1
import org.tigris.anzu.client.MailingAliasSpec;
a100 11
    public static void setOwnerAlias(Connection conn, DataManager dMgr,
            User onBehalfOf, String projectID, boolean exists)
        throws SQLException, DataSetException
    {
        String onBehalfOfID = null;
        if (onBehalfOf != null) 
            onBehalfOfID = onBehalfOf.getID();
        new AnzuTigrisTask(conn, dMgr, onBehalfOfID, projectID,
                "owneralias", (exists ? "true" : "false"));
    }

d125 3
a127 2
        User user = null;
        if (userID != null && !userID.equals("0")) {
d129 9
a137 9
                user = new User(conn, dMgr, userID);
            } catch (Exception e) {
                throw new UpdateException("invalid userID : " + userID);
            }
        }
        UpdateException ue = null;
        try {
            if (command != null && objectID != null && userID != null)
            {
d139 12
a150 3
                    addList(objectID, user);
                } else if (command.equals("owneralias")) {
                    setOwnerAlias(objectID);
d152 6
a158 2
        } catch (UpdateException e) {
            ue = e;
a166 67
    }

    private void setOwnerAlias(String projectID) throws UpdateException
    {
        try {
            Project project = new Project(conn, dMgr, projectID);
            String domain = project.getDomainName();
            boolean exists = getArguments().equals("true");

            List owners = project.getOwners();
            StringBuffer address = new StringBuffer();
            Iterator i = owners.iterator();
            while (i.hasNext()) {
                if (address.length() > 0)
                    address.append("\n");
                String ownerEmail = ((User)i.next()).getDomainEmail();
                address.append(ownerEmail);
            }
            // TODO : handle error case where address.length() == 0 ?
            if (debug) log.info("set owner alias: " + address.toString());

            MailingAliasSpec ma = new MailingAliasSpec(domain,
                    project.getName(), "owner");
            ma.setDestination(address.toString());
            if (exists) 
                ma.update();
            else
                ma.create();
        } catch (Exception e) {
            if (debug) log.info("unable to set owner email alias: " + 
                    e.getMessage());
            log.exception(e);
            throw new UpdateException("unable to set ownere email alias: " +
                    e.getMessage());
        }
    }

    private void addList(String projectID, User user) throws UpdateException {
        UpdateException ue = null;
        try {
            String argsArray[] = readArgs();
            if (debug) {
                for (int i = 0 ; i < argsArray.length ; ++i) {
                    log.info("argsArray["+i+"] = " + argsArray[i]);
                }
            }
            String list = argsArray[0];
            String type = argsArray[1];
            String description = argsArray[2];

            // TODO : should we validate the projectID?  it
            // got in the database, it should be valid ...
            MailingList ml =
                new MailingList(conn, dMgr, list, description,
                        projectID, type);
            ml.setOwner(user);
            ml.create();
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.info("exception in AnzuTigrisTask addlist: " +
                    e.getMessage());
            ue = new UpdateException("exception in AnzuTigrisTask addlist: " +
                    e.getMessage());
        }
        if (ue != null) {
            throw ue;
        }
@


1.5.2.2
log
@fix typo
@
text
@d198 1
a198 1
            throw new UpdateException("unable to set owner email alias: " +
@


1.4
log
@My side of the changes edk made.
@
text
@a110 1
        String args = null;
d123 1
a123 1
                    args + " / " + objectID + " / " + userID);
d126 1
a126 2
        if (command != null && args != null && objectID != null &&
                userID != null)
d129 9
a142 10
                    String argsArray[] = readArgs();
                    if (debug) {
                        for (int i = 0 ; i < argsArray.length ; ++i) {
                            log.info("argsArray["+i+"] = " + argsArray[i]);
                        }
                    }

                    String list = argsArray[0];
                    String type = argsArray[1];
                    String description = argsArray[2];
@


1.3
log
@use AnzuTigrisTask for mailing list additions during project creation
@
text
@d67 2
d74 1
a74 1
        super(conn, dMgr, onBehalfOf, TigrisTask.ANZU_COMPONENT,
d89 1
a89 1
             arguments = writeArgs(args);
a115 1
            args = getArguments();
d136 1
a136 1
                    String argsArray[] = readArgs(args);
@


1.2
log
@make these methods static
@
text
@d121 3
d136 4
a139 3
                    log.info("argsArray: " + argsArray);
                    for (int i = 0 ; i < argsArray.length ; ++i) {
                        log.info("arg " + i + " is : " +argsArray[i]);
d141 1
d145 5
a149 5
                    //MailingList ml =
                        //new MailingList(conn, dMgr, list, description,
                                //project.getID(), type);
                    //ml.setOwner(user);
                    //ml.create();
@


1.1
log
@rename HelmAnzuTask to AnzuTigrisTask; remove an unused function from
TigrisUpdate ; and add functions (thanks to leonardr) for storing
arguments via serialization/deserialization in TigrisTask
@
text
@d77 1
a77 1
            User onBehalfOf, String projectID, String type,
d81 13
a93 1
        String arguments = type + " " + description;
d132 8
a139 9
                    String type = null;
                    String description = null;
                    int spaceIndex = args.indexOf(' ');
                    int spaceIndex2 = args.indexOf(spaceIndex, ' ');

                    type = args.substring(0, spaceIndex);
                    description = args.substring(spaceIndex, spaceIndex2);
                    log.info("type: " + type + " description: " +
                            description);
@

