head	1.9;
access;
symbols
	TIGRIS_1_0_5:1.6.6.1
	TIGRIS_1_0_5RC6:1.6.6.1
	TIGRIS_1_0_5RC5:1.6.6.1
	TIGRIS_1_0_5RC4:1.6.6.1
	TIGRIS_1_0_5RC3:1.6.6.1
	TIGRIS_1_0_5RC2:1.6.6.1
	TIGRIS_1_0_5RC1:1.6.6.1
	TIGRIS_1_0_4:1.6.6.1
	TIGRIS_1_0_3:1.6.6.1
	TIGRIS_1_0_2:1.6.6.1
	TIGRIS_1_0_1:1.6
	TIGRIS_1_0:1.6.0.6
	TIGRIS_1_0_0:1.6
	TIGRIS_1_0_0_RC1:1.6.0.2
	dlr:1.1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1;
locks; strict;
comment	@# @;


1.9
date	2001.05.17.14.51.17;	author leonardr;	state dead;
branches;
next	1.8;

1.8
date	2001.04.19.02.30.29;	author leonardr;	state Exp;
branches;
next	1.7;

1.7
date	2001.04.19.01.04.38;	author leonardr;	state Exp;
branches;
next	1.6;

1.6
date	2001.03.13.02.19.32;	author leonardr;	state Exp;
branches
	1.6.6.1;
next	1.5;

1.5
date	2001.03.09.22.41.21;	author leonardr;	state Exp;
branches;
next	1.4;

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

1.3
date	2001.03.07.01.53.28;	author lucas;	state Exp;
branches;
next	1.2;

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

1.1
date	2001.02.05.16.39.42;	author leonardr;	state dead;
branches
	1.1.1.1
	1.1.2.1;
next	;

1.1.1.1
date	2001.02.21.00.35.39;	author dlr;	state Exp;
branches;
next	;

1.1.2.1
date	2001.02.05.16.39.42;	author leonardr;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.02.15.20.50.46;	author leonardr;	state Exp;
branches;
next	;

1.6.6.1
date	2001.04.24.16.07.53;	author leonardr;	state Exp;
branches;
next	1.6.6.2;

1.6.6.2
date	2001.05.24.23.31.10;	author leonardr;	state dead;
branches;
next	;


desc
@@


1.9
log
@Refactored a lot of code to get rid of the good-looking but very slow IssueTrackingAccount{Descriptor,Map} classes. Also cleaned up the script-running interface quite a bit.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 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.task;

import java.io.*;
import java.net.*;
import java.sql.*;

import java.util.*;

import org.apache.turbine.util.Log;

import org.tigris.helm.om.*;
/**
 * IssueTrackingAccountMap is a convenience class used for determining
 * which scripts to run for a project. It maps Users to Strings
 * describing Roles.
 *
 * It looks like:
 *  User1 -> "Role1"
 *  User2 -> "Role1"
 *  User3 -> "Role2"
 *  
 */
public class IssueTrackingAccountMap extends HashMap
{    
    private static final boolean DEBUG = false;

    private Project project;
    
    /**
     * Construct an IssueTrackingAccountMap for the given project.
     */
    public IssueTrackingAccountMap(Project p)
        throws Exception
    {
        project = p;
    }

    public void registerAccountForUser(User u)
        throws Exception
    {
        String acct = u.issueTrackingAccountType(project);
        if (acct != null && !"".equals(acct)) 
        {
            if (DEBUG)
            {
                Log.debug("Giving account type " + acct + " to " + u.getLoginName() + " in " + project.getName());
            }
            put(u, acct);
        }
    }

    public String accountType(User u)
    {
        String acctType = "";
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User x = (User)i.next();
            if (x.equals(u))
            {
                acctType = (String)get(x);
            }
        }
        return acctType;
    }

    /**
     * Dumps the map to the Log.
     */
    public String dump()
    {
	StringBuffer s = new StringBuffer();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            s.append("  User " + u.getRealName() + " has role " + (String)get(u))
		.append("\n");
        }
	return s.toString();
    }

    /**
     * Runs whatever scripts are neccessary to bridge the delta between this
     * IssueTrackingAccountMap and another (assumed to be more recent).     
     */
    public void syncTo(IssueTrackingAccountMap newMap, User onBehalfOf)
        throws Exception
    {
	if (newMap == null)
	{
	    newMap = new IssueTrackingAccountMap(project);
	}

        List usersToDelete = usersLosingAccounts(newMap);
        Map scriptsToRun = usersChangingAccounts(newMap);

        for (Iterator i = scriptsToRun.keySet().iterator(); i.hasNext();)
	{
	    String type = (String)i.next();
            if (DEBUG)
            {
                Log.debug("Considering accounts of type " + type);
            }
            List list = (List)scriptsToRun.get(type);
            if (list.size() > 0 )
            {
                HelmTask.addMembers(onBehalfOf, project, list, type);
            }
        }

        if (usersToDelete.size() > 0)
        {
            HelmTask.deleteMembers(onBehalfOf, project, usersToDelete);
        }
    }

    /**
     * Returns a list of users who have an account in the current
     * map but not in the new map.
     */
    public List usersLosingAccounts(IssueTrackingAccountMap newMap)    
    {
        List usersToDelete = new ArrayList();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAcct = (String)get(u);
            if (!oldAcct.equals(""))
            {
                String newAcct = newMap.accountType(u);
                if (newAcct.equals(""))
                {
                    usersToDelete.add(u);
                }
            }
        }
        return usersToDelete;
    }

    /**
     * Returns a Map of users who get a different account in the new
     * IssueTrackingAccountMap (or who don't have an account in this
     * one at all, and who do in the new one).  
     */
    public Map usersChangingAccounts(IssueTrackingAccountMap newMap)
    {
        Map changedAccounts = new HashMap();
        for (Iterator i = newMap.keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAccountType = accountType(u);
            String newAccountType = newMap.accountType(u);
            if (!newAccountType.equals(oldAccountType))
            {
                if (!changedAccounts.containsKey(newAccountType))
                {
                    changedAccounts.put(newAccountType, new ArrayList());
                }
            
                List usersWithAccountType = 
                    (List)changedAccounts.get(newAccountType);
                usersWithAccountType.add(u);
                changedAccounts.put(newAccountType, usersWithAccountType);
            }
        }
        return changedAccounts;
    }    
}
@


1.8
log
@Compile errors are also bad.
@
text
@@


1.7
log
@Because large sites will have more users than there are slots in the ACL cache, iterate over users and then projects (instead of projects and then users) when building account descriptors. This way, an ACL gets made once and used as often as it's ever going to be used in this rebuild, and it's not a big deal if subsequent ACLs bump it out of the cache.
@
text
@d93 1
a93 1
                Log.debug("Giving account type " + acct + " to " + u.getLoginName() + " in " + p.getName());
@


1.6
log
@Check for empty string better.
@
text
@d77 1
a77 2
     * Construct an IssueTrackingAccountMap for the given project and
     * the given users.
d79 1
a79 1
    public IssueTrackingAccountMap(Project p, List users)
d83 1
d85 5
a89 1
        for (Iterator i = users.iterator(); i.hasNext();)
d91 1
a91 3
            User u = (User)i.next();
            String acct = u.issueTrackingAccountType(project);
            if (acct != null && !"".equals(acct)) 
d93 1
a93 2
                //Log.debug("Giving account type " + acct + " to " + u.getLoginName() + " in " + p.getName());
                put(u, acct);
d95 2
a96 8
        }        
        //Log.debug("Done with project " + p.getName());
            
    }

    public IssueTrackingAccountMap(Project p)
    {
	project = p;
@


1.6.6.1
log
@Backported changes to prevent ACL cache thrashing on sites with large numbers of users.
@
text
@d77 2
a78 1
     * Construct an IssueTrackingAccountMap for the given project.
d80 1
a80 1
    public IssueTrackingAccountMap(Project p)
a83 1
    }
d85 1
a85 5
    public void registerAccountForUser(User u)
        throws Exception
    {
        String acct = u.issueTrackingAccountType(project);
        if (acct != null && !"".equals(acct)) 
d87 3
a89 1
            if (DEBUG)
d91 2
a92 1
                Log.debug("Giving account type " + acct + " to " + u.getLoginName() + " in " + project.getName());
d94 8
a101 2
            put(u, acct);
        }
@


1.6.6.2
log
@Ported task running system in from HEAD.
@
text
@@


1.5
log
@Run MemberAdd and MemberDelete in batch mode so as to avoid task bloat.
@
text
@d89 1
a89 1
            if (!acct.equals("")) 
d91 1
d95 2
@


1.4
log
@Only you can prevent log bloat.
@
text
@d153 1
a153 1
            for (Iterator j = list.iterator(); j.hasNext();)
d155 1
a155 7
                User u = (User)j.next();
            if (DEBUG)
            {
                Log.debug("Giving " + u.getRealName() + " a " + type 
                          + " account.");
            }
                HelmTask.addMember(onBehalfOf, project, u, type);
d159 1
a159 1
        for (Iterator i = usersToDelete.iterator(); i.hasNext();)
d161 1
a161 6
            User u = (User)i.next();
            if (DEBUG)
            {
                Log.debug("Deleting " + u.getRealName()); 
            }
            HelmTask.deleteMember(onBehalfOf, project, u);
@


1.3
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d72 2
d148 4
a151 1
            Log.debug("Considering accounts of type " + type);
d156 5
a160 1
                Log.debug("Giving " + u.getRealName() + " a " + type + " account.");
d168 4
a171 1
            Log.debug("Deleting " + u.getRealName()); 
@


1.2
log
@adding files from the branch to the head
@
text
@a58 1

@


1.1
log
@file IssueTrackingAccountMap.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 216
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 216
/* ================================================================
 * Copyright (c) 2000-2001 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.task;

import java.io.*;
import java.net.*;
import java.sql.*;

import java.util.*;

import org.apache.turbine.util.Log;

import org.tigris.helm.om.*;

/**
 * IssueTrackingAccountMap is a convenience class used for determining
 * which scripts to run for a project. It maps Users to Strings
 * describing Roles.
 *
 * It looks like:
 *  User1 -> "Role1"
 *  User2 -> "Role1"
 *  User3 -> "Role2"
 *  
 */
public class IssueTrackingAccountMap extends HashMap
{    
    private Project project;
    
    /**
     * Construct an IssueTrackingAccountMap for the given project and
     * the given users.
     */
    public IssueTrackingAccountMap(Project p, List users)
        throws Exception
    {
        project = p;

        for (Iterator i = users.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String acct = u.issueTrackingAccountType(project);
            if (!acct.equals("")) 
            {
                put(u, acct);
            }
        }        
    }

    public IssueTrackingAccountMap(Project p)
    {
	project = p;
    }

    public String accountType(User u)
    {
        String acctType = "";
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User x = (User)i.next();
            if (x.equals(u))
            {
                acctType = (String)get(x);
            }
        }
        return acctType;
    }

    /**
     * Dumps the map to the Log.
     */
    public String dump()
    {
	StringBuffer s = new StringBuffer();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            s.append("  User " + u.getRealName() + " has role " + (String)get(u))
		.append("\n");
        }
	return s.toString();
    }

    /**
     * Runs whatever scripts are neccessary to bridge the delta between this
     * IssueTrackingAccountMap and another (assumed to be more recent).     
     */
    public void syncTo(IssueTrackingAccountMap newMap, User onBehalfOf)
        throws Exception
    {
	if (newMap == null)
	{
	    newMap = new IssueTrackingAccountMap(project);
	}

        List usersToDelete = usersLosingAccounts(newMap);
        Map scriptsToRun = usersChangingAccounts(newMap);

        for (Iterator i = scriptsToRun.keySet().iterator(); i.hasNext();)
	{
	    String type = (String)i.next();
            Log.debug("Considering accounts of type " + type);
            List list = (List)scriptsToRun.get(type);
            for (Iterator j = list.iterator(); j.hasNext();)
            {
                User u = (User)j.next();
                Log.debug("Giving " + u.getRealName() + " a " + type + " account.");
                HelmTask.addMember(onBehalfOf, project, u, type);
            }
        }

        for (Iterator i = usersToDelete.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            Log.debug("Deleting " + u.getRealName()); 
            HelmTask.deleteMember(onBehalfOf, project, u);
        }
    }

    /**
     * Returns a list of users who have an account in the current
     * map but not in the new map.
     */
    public List usersLosingAccounts(IssueTrackingAccountMap newMap)    
    {
        List usersToDelete = new ArrayList();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAcct = (String)get(u);
            if (!oldAcct.equals(""))
            {
                String newAcct = newMap.accountType(u);
                if (newAcct.equals(""))
                {
                    usersToDelete.add(u);
                }
            }
        }
        return usersToDelete;
    }

    /**
     * Returns a Map of users who get a different account in the new
     * IssueTrackingAccountMap (or who don't have an account in this
     * one at all, and who do in the new one).  
     */
    public Map usersChangingAccounts(IssueTrackingAccountMap newMap)
    {
        Map changedAccounts = new HashMap();
        for (Iterator i = newMap.keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAccountType = accountType(u);
            String newAccountType = newMap.accountType(u);
            if (!newAccountType.equals(oldAccountType))
            {
                if (!changedAccounts.containsKey(newAccountType))
                {
                    changedAccounts.put(newAccountType, new ArrayList());
                }
            
                List usersWithAccountType = 
                    (List)changedAccounts.get(newAccountType);
                usersWithAccountType.add(u);
                changedAccounts.put(newAccountType, usersWithAccountType);
            }
        }
        return changedAccounts;
    }    
}
@


1.1.2.1
log
@Ported IssueTrackingAccount* tool classes.
@
text
@a0 216
/* ================================================================
 * 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.task;

import java.io.*;
import java.net.*;
import java.sql.*;

import java.util.*;

import org.apache.turbine.util.Log;

import org.tigris.helm.om.*;

/**
 * IssueTrackingAccountMap is a convenience class used for determining
 * which scripts to run for a project. It maps Users to Strings
 * describing Roles.
 *
 * It looks like:
 *  User1 -> "Role1"
 *  User2 -> "Role1"
 *  User3 -> "Role2"
 *  
 */
public class IssueTrackingAccountMap extends HashMap
{    
    private Project project;
    
    /**
     * Construct an IssueTrackingAccountMap for the given project and
     * the given users.
     */
    public IssueTrackingAccountMap(Project p, List users)
        throws Exception
    {
        project = p;

        for (Iterator i = users.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String acct = u.issueTrackingAccountType(project);
            if (!acct.equals("")) 
            {
                put(u, acct);
            }
        }        
    }

    public IssueTrackingAccountMap(Project p)
    {
	project = p;
    }

    public String accountType(User u)
    {
        String acctType = "";
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User x = (User)i.next();
            if (x.equals(u))
            {
                acctType = (String)get(x);
            }
        }
        return acctType;
    }

    /**
     * Dumps the map to the Log.
     */
    public String dump()
    {
	StringBuffer s = new StringBuffer();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            s.append("  User " + u.getRealName() + " has role " + (String)get(u))
		.append("\n");
        }
	return s.toString();
    }

    /**
     * Runs whatever scripts are neccessary to bridge the delta between this
     * IssueTrackingAccountMap and another (assumed to be more recent).     
     */
    public void syncTo(IssueTrackingAccountMap newMap, User onBehalfOf)
        throws Exception
    {
	if (newMap == null)
	{
	    newMap = new IssueTrackingAccountMap(project);
	}

        List usersToDelete = usersLosingAccounts(newMap);
        Map scriptsToRun = usersChangingAccounts(newMap);

        for (Iterator i = scriptsToRun.keySet().iterator(); i.hasNext();)
	{
	    String type = (String)i.next();
            Log.debug("Considering accounts of type " + type);
            List list = (List)scriptsToRun.get(type);
            for (Iterator j = list.iterator(); j.hasNext();)
            {
                User u = (User)j.next();
                Log.debug("Giving " + u.getRealName() + " a " + type + " account.");
                HelmTask.addMember(onBehalfOf, project, u, type);
            }
        }

        for (Iterator i = usersToDelete.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            Log.debug("Deleting " + u.getRealName()); 
            HelmTask.deleteMember(onBehalfOf, project, u);
        }
    }

    /**
     * Returns a list of users who have an account in the current
     * map but not in the new map.
     */
    public List usersLosingAccounts(IssueTrackingAccountMap newMap)    
    {
        List usersToDelete = new ArrayList();
        for (Iterator i = keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAcct = (String)get(u);
            if (!oldAcct.equals(""))
            {
                String newAcct = newMap.accountType(u);
                if (newAcct.equals(""))
                {
                    usersToDelete.add(u);
                }
            }
        }
        return usersToDelete;
    }

    /**
     * Returns a Map of users who get a different account in the new
     * IssueTrackingAccountMap (or who don't have an account in this
     * one at all, and who do in the new one).  
     */
    public Map usersChangingAccounts(IssueTrackingAccountMap newMap)
    {
        Map changedAccounts = new HashMap();
        for (Iterator i = newMap.keySet().iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            String oldAccountType = accountType(u);
            String newAccountType = newMap.accountType(u);
            if (!newAccountType.equals(oldAccountType))
            {
                if (!changedAccounts.containsKey(newAccountType))
                {
                    changedAccounts.put(newAccountType, new ArrayList());
                }
            
                List usersWithAccountType = 
                    (List)changedAccounts.get(newAccountType);
                usersWithAccountType.add(u);
                changedAccounts.put(newAccountType, usersWithAccountType);
            }
        }
        return changedAccounts;
    }    
}
@


1.1.2.2
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
@


