head	1.47;
access;
symbols
	TIGRIS_0_9_2_4:1.41
	TIGRIS_0_9_2_3:1.41
	HELM_PEER_PORT_BRANCH:1.46.0.2
	TURBINE_PEER:1.46
	TIGRIS_0_9_2_1:1.46
	TIGRIS_0_9_2:1.41.0.2
	TIGRIS_0_9_0:1.30.0.2
	TIGRIS_0_8_4:1.14.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.47
date	2001.02.21.03.23.56;	author edk;	state dead;
branches;
next	1.46;

1.46
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.46.2.1;
next	1.45;

1.45
date	2001.01.26.05.24.05;	author edk;	state dead;
branches;
next	1.44;

1.44
date	2001.01.24.23.36.14;	author leonardr;	state Exp;
branches;
next	1.43;

1.43
date	2001.01.24.21.41.49;	author leonardr;	state Exp;
branches;
next	1.42;

1.42
date	2001.01.24.20.42.48;	author dlr;	state Exp;
branches;
next	1.41;

1.41
date	2001.01.15.17.50.47;	author leonardr;	state Exp;
branches;
next	1.40;

1.40
date	2001.01.12.18.47.52;	author leonardr;	state Exp;
branches;
next	1.39;

1.39
date	2001.01.05.21.42.38;	author leonardr;	state Exp;
branches;
next	1.38;

1.38
date	2001.01.05.03.03.38;	author dlr;	state Exp;
branches;
next	1.37;

1.37
date	2001.01.02.22.55.50;	author leonardr;	state Exp;
branches;
next	1.36;

1.36
date	2000.12.30.02.25.36;	author leonardr;	state Exp;
branches;
next	1.35;

1.35
date	2000.12.30.01.03.32;	author leonardr;	state Exp;
branches;
next	1.34;

1.34
date	2000.12.29.17.11.53;	author leonardr;	state Exp;
branches;
next	1.33;

1.33
date	2000.12.29.02.36.29;	author dlr;	state Exp;
branches;
next	1.32;

1.32
date	2000.12.23.00.48.18;	author dlr;	state Exp;
branches;
next	1.31;

1.31
date	2000.12.22.03.02.59;	author dlr;	state Exp;
branches;
next	1.30;

1.30
date	2000.12.20.19.53.20;	author leonardr;	state Exp;
branches;
next	1.29;

1.29
date	2000.12.20.18.39.55;	author leonardr;	state Exp;
branches;
next	1.28;

1.28
date	2000.12.15.18.58.40;	author leonardr;	state Exp;
branches;
next	1.27;

1.27
date	2000.12.14.03.09.59;	author leonardr;	state Exp;
branches;
next	1.26;

1.26
date	2000.12.08.19.27.02;	author leonardr;	state Exp;
branches;
next	1.25;

1.25
date	2000.12.08.02.19.04;	author leonardr;	state Exp;
branches;
next	1.24;

1.24
date	2000.12.07.22.27.24;	author leonardr;	state Exp;
branches;
next	1.23;

1.23
date	2000.12.07.18.58.41;	author leonardr;	state Exp;
branches;
next	1.22;

1.22
date	2000.12.07.02.21.33;	author leonardr;	state Exp;
branches;
next	1.21;

1.21
date	2000.12.06.22.59.30;	author dlr;	state Exp;
branches;
next	1.20;

1.20
date	2000.12.06.22.55.53;	author dlr;	state Exp;
branches;
next	1.19;

1.19
date	2000.12.06.04.15.22;	author dlr;	state Exp;
branches;
next	1.18;

1.18
date	2000.12.05.23.53.30;	author leonardr;	state Exp;
branches;
next	1.17;

1.17
date	2000.12.05.23.28.58;	author leonardr;	state Exp;
branches;
next	1.16;

1.16
date	2000.12.05.20.08.54;	author dlr;	state Exp;
branches;
next	1.15;

1.15
date	2000.12.05.03.07.59;	author dlr;	state Exp;
branches;
next	1.14;

1.14
date	2000.11.29.20.36.54;	author leonardr;	state Exp;
branches;
next	1.13;

1.13
date	2000.11.29.17.29.50;	author leonardr;	state Exp;
branches;
next	1.12;

1.12
date	2000.11.28.21.08.23;	author leonardr;	state Exp;
branches;
next	1.11;

1.11
date	2000.11.27.23.16.53;	author leonardr;	state Exp;
branches;
next	1.10;

1.10
date	2000.11.27.18.17.45;	author leonardr;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.21.22.47.36;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.21.20.45.55;	author stack;	state Exp;
branches;
next	1.7;

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

1.6
date	2000.11.17.21.49.37;	author leonardr;	state Exp;
branches;
next	1.5;

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

1.4
date	2000.11.14.20.56.34;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.14.18.30.45;	author stack;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.14.02.21.32;	author stack;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.15.19;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

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

1.46.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	;


desc
@@


1.47
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.domain;

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

import org.webmacro.util.*;
import org.webmacro.servlet.WebContext;

import com.workingdogs.village.*;

import org.joist.util.QuotedString;
import org.joist.database.*;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;
import org.tigris.helm.database.*;
import org.tigris.helm.project.Project;
import org.tigris.helm.business.*;
import org.tigris.helm.tool.*;
import org.tigris.helm.tool.paginate.*;

public class Domain extends BusinessObject
{
    private static Log log = new Log("dom", "Domain");
    
    private static DomainManager domMgr;
    private static ProjectManager pMgr;
    private static RoleManager roleMgr;
    private static UserManager uMgr;
    private static UserUserGroupManager usrGrpMgr;
    private static ActionManager actMgr;
    private static ResourceManager resMgr;    

    /**
     * @@see org.tigris.helm.domain.BusinessObject#BusinessObject
     */
    public Domain (Connection conn, DataManager dMgr, Record rec)
        throws DoesNotExist, DataSetException
    {
        super(conn, dMgr, rec);
    }

    /**
     * Creates a new instance corresponding to the specified database entry.
     */
    public Domain(Connection c, DataManager dMgr, String domainID)
        throws DoesNotExist, DataSetException, JoistDatabaseException
    {
        super(c, dMgr);
        setRecord(domMgr.getDomainRecordByID(domainID));
    }

    /**
     * Creates a new instance corresponding to the specified database entry.
     */
    public Domain(Connection c, String domainName, DataManager dMgr)
        throws DoesNotExist, DataSetException, JoistDatabaseException
    {
        super(c, dMgr);
        setRecord(domMgr.getDomainRecordByName(domainName));
    }

    protected final String getTableName()
    {
        return DomainManager.TABLE_NAME;
    }

    protected void createManagers ()
    {
        if (domMgr == null)
        {
            domMgr = (DomainManager)
                dMgr.getManager("org.tigris.helm.database.DomainManager");
        }

        if (pMgr == null) 
        {
            pMgr = (ProjectManager)
                dMgr.getManager("org.tigris.helm.database.ProjectManager");
        }

        if (actMgr == null) 
        {
            actMgr = (ActionManager)
                dMgr.getManager("org.tigris.helm.database.ActionManager");
        }

        if (resMgr == null) 
        {
            resMgr = (ResourceManager)
                dMgr.getManager("org.tigris.helm.database.ResourceManager");
        }

        if (roleMgr == null) 
        {
            roleMgr = (RoleManager)
                dMgr.getManager("org.joist.database.RoleManager");
        }

        if (uMgr == null) 
        {
            uMgr = (UserManager)
                dMgr.getManager("org.joist.database.UserManager");
        }

        if (usrGrpMgr == null)
        {
            usrGrpMgr = (UserUserGroupManager)
                dMgr.getManager("org.tigris.helm.database.UserUserGroupManager");
        }
    }

    /**
     * Returns a List of domain objects representing all domains on
     * the host (including the special host domain).  
     */
    public static List listDomains(Connection connection, DataManager dMgr)
        throws DataSetException, SQLException
    {
        domMgr = (DomainManager)
            dMgr.getManager("org.tigris.helm.database.DomainManager");
        
        List domains = new ArrayList();

        DataSet domainSet = domMgr.listDomains(connection);
        for (int i = 0; i < domainSet.size(); i++)
        {
            Record r = domainSet.getRecord(i);
            try {
                Domain d = new Domain(connection, dMgr, r);
                domains.add(d);
            } catch (DoesNotExist ignore) {}
        }
        return domains;
    }

    /**
     * Returns the Host in which this domain (and, indeed, all
     * domains) reside.  
     */
    public Host getHost()
    {
        return new Host(conn, dMgr);
    }

    /**
     * Returns the Domain representing the Host.
     */
    public Domain getHostDomain()
        throws SQLException, DataSetException, JoistDatabaseException
    {
        Domain domain = null;
        try
        {
            domain = new Domain(conn, dMgr, domMgr.getHostDomain());
        }
        catch (DoesNotExist e)
        {
            log.error("Domain representing this host does not exist");
        }
        return domain;
    }

    /**
     * Returns the special project which is a placeholder for this domain in 
     * the project table (it's the group that all projects in this domain are
     * a member of).
     *
     * @@return The special project representing all projects in this domain.
     */
    public Project getSpecialProject ()
        throws DataSetException, SQLException
    {
        Project project = null;
        try
        {
            project = new Project(conn, dMgr, pMgr.getDomainProjectID(getID()));
        }
        catch (DoesNotExist e)
        {
            String err = "Special project for domain '" + getName() +
                "' does not exist.";
            log.error(err);
            throw new DataSetException(err);            
        }
        return project;
    }

    /**
     * Returns the special project which is a placeholder for the host
     * the project table (it's the group that all projects in the host are
     * members of).
     *
     * @@return The special project representing all projects on the host
     */
    public Project getHostProject()
        throws DataSetException, SQLException, DoesNotExist
    {
        return new Project(conn, dMgr, pMgr.getHostProjectID());
    }

    /**
     * Returns the special user which is a placeholder for all users
     * in this domain.
     *
     * @@return The special user representing all host users.
     */
    public User getSpecialUser()
        throws DataSetException, SQLException, JoistDatabaseException, DoesNotExist
    {
        return new User(conn, dMgr, usrGrpMgr.getUserIDForDomainUserGroup(conn, getID()));
    }

    public List getCategories()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList categoryList = new ArrayList();
        DataSet categorySet = pMgr.getCategoriesForDomain(conn, 
                                                           getID());
        if (categorySet != null)
        {
            for (int i = 0; i < categorySet.size(); i++)
            {
                categoryList.add(new Category (conn, dMgr,
                                               categorySet.getRecord(i)));
            }        
        }
        return categoryList;
    }

    public List getHostActions()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getActionsForType(ActionManager.HOST_TYPE);
    }

    public List getDomainActions()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getActionsForType(ActionManager.DOMAIN_TYPE);
    }
    
    public List getProjectActions()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getActionsForType(ActionManager.PROJECT_TYPE);
    }
    
    private List getActionsForType(String type)
        throws DataSetException, SQLException, JoistDatabaseException
    {
        ArrayList actions = new ArrayList();
        DataSet actionSet = actMgr.getActionsForType(conn, type);
        for (int i = 0; i < actionSet.size(); i++)
        {
            try {
                actions.add(new Action(conn, dMgr, actionSet.getRecord(i)));
                //Can't happen with records.
            } catch (DoesNotExist ignore) {}
        }
        return actions;
    }

    public List getResources()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        ArrayList resources = new ArrayList();
        DataSet resourceSet = resMgr.listResources(conn);
        for (int i = 0; i < resourceSet.size(); i++)
        {
            try {
                resources.add
                    (new Resource(conn, dMgr, resourceSet.getRecord(i)));
                //Can't happen with records.
            } catch (DoesNotExist ignore) {}
        }
        return resources;
    }

    public List getRoles()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList roles = new ArrayList();
        DataSet roleSet = roleMgr.listRoles(conn);
        for (int i = 0; i < roleSet.size(); i++)
        {
            roles.add(new Role(conn, dMgr, roleSet.getRecord(i)));
        }        
        return roles;
    }

    public List getHostRoles()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getTypedRoles("host");
    }

    public List getDomainRoles()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getTypedRoles("domain");
    }

    public List getProjectRoles()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        return getTypedRoles("project");
    }

    private List getTypedRoles(String type)
        throws DataSetException, SQLException, JoistDatabaseException
    {
        ArrayList roles = new ArrayList();
        DataSet roleSet = roleMgr.listRolesByType(conn, type);
        for (int i = 0; i < roleSet.size(); i++)
        {
            try {                
                roles.add(new Role(conn, dMgr, roleSet.getRecord(i)));
            } catch (DoesNotExist ignore) {
                //Can't happen for records.
            }
        }        
        return roles;
    }

    public List getRequestableProjectRoles()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList roles = new ArrayList();
        DataSet roleSet = roleMgr.listRolesByType(conn, "project");
        for (int i = 0; i < roleSet.size(); i++)
        {
            Role role = new Role(conn, dMgr, roleSet.getRecord(i));
            if (role.isRequestable())
            {
                roles.add(role);
            }
        }        
        return roles;
    }

    public PaginatableProjectList getProjects
        (Integer itemsPerPage, Criterion searchCriterion, 
         AccessControlList acl)
        throws DataSetException, SQLException
    {
        PaginatableProjectList p = null;
        String query = pMgr.getProjectsForDomainQuery(getID());
        p = new PaginatableProjectList(conn, dMgr, itemsPerPage, query, 
                                       searchCriterion, acl);
        return p;
    }

    public PaginatableProjectList getProjectsNotInGroup
        (ProjectGroup group, Integer itemsPerPage, Criterion searchCriterion, 
         AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        List toRemove = group.getProjects(acl);        
        PaginatableProjectList toFilter = 
            getProjects(itemsPerPage, searchCriterion, acl);
        toFilter.retrieveRecords();

        for (Iterator i = toRemove.iterator(); i.hasNext();)
        {
            Project p = (Project)i.next();
            for (Iterator j = toFilter.iterator(); j.hasNext();)
            {
                Record r = (Record)j.next();
                if (p.getID().equals
                    (r.getValue(ProjectManager.PROJECT_ID).asString()))
               {
                   toFilter.remove(r);
                   break;
               }
            }
        }
        return toFilter;
    }

    public List getProjectsBypassingChecks(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList projects = new ArrayList();        
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
        return AccessControlledDatabaseFilter.getViewableProjects
            (conn, dMgr, acl, projectSet);
    }

    public List getProjectsForContentViewing(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList projects = new ArrayList();        
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
        return AccessControlledDatabaseFilter.getContentViewableProjects
            (conn, dMgr, acl, projectSet);
    }

    public List getUnapprovedProjects(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList projects = new ArrayList();
        DataSet projectSet = pMgr
            .getUnapprovedProjectsForDomain(conn, getID());
        return AccessControlledDatabaseFilter.getViewableProjects
            (conn, dMgr, acl, projectSet);
    }
    
    public int numberOfProjects(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
        return AccessControlledDatabaseFilter.getViewableProjects
            (conn, dMgr, acl, projectSet).size();
    }

    /**
     * Lists only the regular users of this domain.
     *
     * @@return The user list.
     */
    public PaginatableUserList getUsers
        (Integer itemsPerPage, Criterion searchCriterion)
        throws DataSetException, SQLException
    {
        PaginatableUserList u = null;
        Criterion c = new Criterion(UserManager.DOMAIN_ID, getID());
        c.and(new Criterion(UserManager.TYPE, UserType.REGULAR));

        //String query = uMgr.getUsersForDomainQuery(getID());
        String query = "SELECT * FROM " + UserManager.TABLE_NAME + " WHERE " + 
            c.toString();
        u = new PaginatableUserList(conn, dMgr, itemsPerPage, query, 
                                    searchCriterion);
        return u;
    }

    /**
     * Lists the user groups and then the users of the domain.
     *
     * @@return The user list.
     */
    public PaginatableUserList getGroupsAndUsers
        (Integer itemsPerPage, Criterion searchCriterion)
        throws DataSetException, SQLException
    {
        PaginatableUserList u = null;
        Criterion c = new Criterion(UserManager.DOMAIN_ID, getID());
        Criterion t = (new Criterion(UserManager.TYPE, UserType.GROUP));
        t.or(new Criterion(UserManager.TYPE, UserType.REGULAR));
        c.and(t);

        String orderBy = UserManager.TYPE + " DESC," + UserManager.NAME;

        String query = "SELECT * FROM " + UserManager.TABLE_NAME 
            + " WHERE " + c.toString();
        u = new PaginatableUserList(conn, dMgr, itemsPerPage, query, 
                                    searchCriterion, orderBy);
        return u;
    }

    public List getUsers()
        throws DataSetException, SQLException
    {
        return getUsers(new Integer(0), null).getPage(new Integer(1));
    }

    public List getGroupsAndUsers()
        throws DataSetException, SQLException
    {
        return getGroupsAndUsers(new Integer(0), null).getPage(new Integer(1));
    }

    public PaginatableUserList getUsersNotInGroup
        (UserGroup group, Integer itemsPerPage, Criterion searchCriterion)
        throws DataSetException, SQLException, JoistDatabaseException, DoesNotExist
    {
        List toRemove = group.getUsers();        
        PaginatableUserList toFilter = 
            getUsers(itemsPerPage, searchCriterion);
        toFilter.retrieveRecords();

        for (Iterator i = toRemove.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            for (Iterator j = toFilter.iterator(); j.hasNext();)
            {
                Record r = (Record)j.next();
                if (u.getID().equals
                    (r.getValue(UserManager.USER_ID).asString()))
                {
                    toFilter.remove(r);
                    break;
                }
            }
        }
        return toFilter;
    }

    /**
     * Lists the user groups in this domain. Does not return the
     * special group containing all users in the domain.
     *
     * @@return A List of UserGroup objects.
     */
    public List getUserGroups ()
        throws DataSetException, SQLException, JoistDatabaseException
    {
        ArrayList users = new ArrayList();
        TableDataSet userSet = null;
        try
        {
            userSet = new TableDataSet(conn, UserManager.TABLE_NAME);
            userSet.where(buildUsersClause(getID(), UserType.GROUP, null));
            userSet.fetchRecords();
        }
        finally
        {
            dMgr.registerToClose(userSet);
        }
        for (int i = 0; i < userSet.size(); i++)
        {
            Record r = userSet.getRecord(i);
            UserGroup g = null;
            try {
                g = new UserGroup(conn, dMgr, r);
            } catch (DoesNotExist ignore) {}
            users.add(g);
        }
        return users;
    }

    /**
     * Lists the project groups in this domain. Does not return the
     * special groups
     *
     * @@return A List of ProjectGroup objects.
     */
    public List getProjectGroups ()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList projects = new ArrayList();
        TableDataSet projectSet = null;
        try
        {
            projectSet = new TableDataSet(conn, ProjectManager.TABLE_NAME);
            String where = ProjectManager.PROJECT_DOMAIN_ID + "=" + getID() 
                + " and " + ProjectManager.PROJECT_TYPE + "=" 
                + QuotedString.from(ProjectType.GROUP);
            log.info("Getting project groups: " + where);
            projectSet.where(where);
            projectSet.fetchRecords();
        }
        finally
        {
            dMgr.registerToClose(projectSet);
        }
        for (int i = 0; i < projectSet.size(); i++)
        {
            Record r = projectSet.getRecord(i);
            ProjectGroup g = new ProjectGroup(conn, dMgr, r);
            projects.add(g);
        }
        return projects;
    }

    /**
     * Gets the domain database key.
     */
    public String getID()
    {
        try {
            return rec.getValue(DomainManager.DOMAIN_ID).toString();
        }
        catch (DataSetException dse) {
            log.exception(dse);
            return "had DataSetException";
        }
    }

    /**
     * Gets the domain name.
     */
    public String getName()
    {
        try {
            return rec.getValue(DomainManager.DOMAIN_NAME).toString();
        }
        catch (DataSetException dse) {
            log.exception(dse);
            return "had DataSetException";
        }
    }

    ////////////////////////////////////////////////////////////////
    // mutator methods

    /**
     * This is the Tigris version of Joist's <code>addUser()</code> method.
     * <p>
     * HELP: This does not belong in this class.
     */
    public User addNewUser (Connection conn, WebContext ctx, 
                            String name, String loginID, 
                            String password, String domainID)
        throws SQLException, DataSetException, JoistDatabaseException,
               InsertFailedException, DoesNotExist
    {
        Integer userID = null;
        User user = null;
        userID = uMgr.addUser(conn, ctx, name, loginID, password);
        PreparedStatement stmt = null;
        try
        {
            stmt = conn.prepareStatement
                ("update User set domainID=? where userID=?");
            stmt.setInt(1, Integer.parseInt(domainID));
            stmt.setInt(2, userID.intValue());
            stmt.executeUpdate();
        }
        finally
        {
            if (stmt != null) stmt.close();
        }
        user = new User(conn, dMgr, userID.toString());
        return user;
    }


    ////////////////////////////////////////////////////////////////
    // internal methods

    /**
     * Builds up the SQL <code>where</code> clause used to retrieve the users 
     * for a domain.
     * TODO: Move into DomainManager.
     *
     * @@param domainID The domain to retrieve users for.
     * @@param type     The type of users to retrieve.
     * @@param loginID  The user name, supplied when only a specific user is 
     *                 desired (<code>null</code> otherwise).
     * @@return         The clause.
     */
    private String buildUsersClause(String domainID, String type, 
                                    String loginID)
    {
        StringBuffer buf = new StringBuffer();
        boolean isFirstCond = true;
        if (domainID != null)
        {
            buf.append(DomainManager.USER_DOMAIN_ID).append('=')
                .append(escapeAndQuoteSQL(domainID));
            isFirstCond = false;
        }
        if (type != null)
        {
            if (!isFirstCond)
            {
                buf.append(" and ");
            }
            buf.append(UserManager.TYPE).append('=')
                .append(escapeAndQuoteSQL(type));
            isFirstCond = false;
        }
        if (loginID != null)
        {
            if (!isFirstCond)
            {
                buf.append(" and ");
            }
            buf.append(UserManager.LOGIN_ID).append('=')
                .append(escapeAndQuoteSQL(loginID));
        }
        buf.append(uMgr.alphabeticalOrderBy());
        return buf.toString();
    }

   /**
    * Build up a domain-homed url for the passed in servlet.
    * 
    * @@param inServlet Name of servlet to use in manufactured url.
    * 
    * @@return http://www.DOMAIN[:PORT]/servlets/inServlet
    * 
    *
    * @@exception NullPointerException If i can't get JoistProperties instance.
    * @@exception IllegalArgumentException Thrown if you pass anything but 
    * 'http' or 'http' in the inProtocol param.
    * @@exception DataSetException Thrown by getName( ).
    */
    public String getDomainHomeServletURL( String inServlet )
        throws NullPointerException, IllegalArgumentException, DataSetException
    {
        return getDomainHomeServletURL( inServlet, ( String )null );
    }
    
   /**
    * Build up a domain-homed url for the passed in non-servlet URL.
    * 
    * @@param file Path to file to use in manufactured url.
    * 
    * @@return http://www.DOMAIN[:PORT]/file
    * 
    *
    * @@exception NullPointerException If i can't get JoistProperties instance.
    * @@exception DataSetException Thrown by getName().
    */
    public String getDomainHomeFileURL( String file )
        throws NullPointerException, IllegalArgumentException, DataSetException
    {
        return getDomainHomePageURL( null, file, ( String )null );
    }
    
    /**
     * Build up a domain-homed url for the passed in servlet.
     * 
     * @@param Protocol to use.  If you want the current scheme, pass 
     * context.getRequest( ).getScheme( ), else pass null and will make up 
     * an url w/ default 'http' protocol.
     * @@param inServlet Name of servlet to use in manufactured url.
     * 
     * @@return [http|https]://www.DOMAIN[:PORT]/servlets/inServlet
     * 
     *
     * @@exception NullPointerException If i can't get JoistProperties instance.
     * @@exception IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     * @@exception DataSetException Thrown by getName( ).
     */
    public String getDomainHomeServletURL( String inServlet, String inProtocol )
        throws NullPointerException, IllegalArgumentException, DataSetException
    {
        final String servletPath = "/servlets/";
        if( inServlet == null || inServlet.length( ) <= 0 )
            throw new NullPointerException( "Servletname is null" );        
        return getDomainHomePageURL(servletPath, inServlet, inProtocol);
    }

    public String getDomainHomePageURL(String prefix, String file, 
                                   String inProtocol)
        throws IllegalArgumentException, DataSetException
    {            
        StringBuffer url = new StringBuffer( getDomainHome( inProtocol ) );
        url.append( prefix );
        url.append( file );        
        return url.toString( );
    }    
    
    /**
     * Return the Domain Home url.
     *
     * Use this method to write out links to the Domain Home page. 
     *
     * @@return http://www.DOMAIN[:PORT]
     *
     * @@exception NullPointerException If i can't get JoistProperties instance.
     * @@exception IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     * @@exception DataSetException Thrown by getName( ).
     */
    public String getDomainHome( )
        throws NullPointerException, IllegalArgumentException, DataSetException
    {
        return getDomainHome( ( String )null );
    }
        
        
    /**
     * Return the Domain Home url.
     *
     * Use this method to write out links to the Domain Home page. 
     *
     * @@param inProtocol The protocol being used.  We use it making up url.
     * If null, we return default 'http'.
     *
     * @@return [http|https]://www.DOMAIN[:PORT]
     *
     * @@exception NullPointerException If i can't get JoistProperties instance.
     * @@exception IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     * @@exception DataSetException Thrown by getName( ).
     */
    public String getDomainHome( String inProtocol )
        throws NullPointerException, IllegalArgumentException, DataSetException
    {
        // JoistProperties is a singleton of system properties.
        org.joist.util.JoistProperties properties
            = org.joist.util.JoistProperties.getInstance( );
        if( properties == null )
            throw new NullPointerException( "JoistProperties is null" );
                    
        StringBuffer buff = new StringBuffer();

        final String DOMAIN_KEY = "DOMAIN";

        org.joist.util.URL urlUtil = new org.joist.util.URL( );
        String protocol = urlUtil.getProtocol( inProtocol );
        String port = urlUtil.getPort( protocol );
        String domain = properties.getProperty( DOMAIN_KEY );
        if( domain == null || domain.length( ) <= 0 )
            throw new NullPointerException( DOMAIN_KEY + " is null" );

        buff.append( protocol );
        buff.append( "://" ); 
        buff.append( "www." );
        buff.append( domain );  
        if( port != null)
        {
            buff.append( ":" );
            buff.append( port );
        }
        return buff.toString();
    }
}
@


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


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


1.45
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
@d58 1
a58 5

import org.joist.database.Criterion;
import org.joist.database.DataManager;
import org.joist.database.JoistDatabaseException;
import org.joist.database.UserType;
d84 2
a85 2
    public Domain (DataManager dMgr, Record rec)
        throws DoesNotExist, DBException
d87 1
a87 1
        super(dMgr, rec);
d93 2
a94 2
    public Domain(DataManager dMgr, String domainID)
        throws DoesNotExist, DBException
d96 2
a97 1
        super(dMgr, domMgr.getDomainRecordByID(domainID));
d103 2
a104 2
    public Domain(String domainName, DataManager dMgr)
        throws DoesNotExist, DBException
d106 2
a107 1
        super(dMgr, domMgr.getDomainRecordByName(domainName));
d144 1
a144 1
                dMgr.getManager("org.tigris.helm.database.RoleManager");
d150 1
a150 1
                dMgr.getManager("org.tigris.helm.database.UserManager");
d164 2
a165 2
    public static List listDomains(DataManager dMgr)
        throws DBException
d172 1
a172 1
        DataSet domainSet = domMgr.listDomains();
d177 1
a177 1
                Domain d = new Domain(dMgr, r);
d190 1
a190 1
        return new Host(dMgr);
d197 1
a197 1
        throws DBException
d202 1
a202 1
            domain = new Domain(dMgr, domMgr.getHostDomain());
a207 8
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
d219 1
a219 1
        throws DBException
d224 1
a224 1
            project = new Project(dMgr, pMgr.getDomainProjectID(getID()));
d231 1
a231 9
            throw new DBException(err);            
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
d244 1
a244 1
        throws DoesNotExist, DBException
d246 1
a246 1
        return new Project(dMgr, pMgr.getHostProjectID());
d256 1
a256 1
        throws DoesNotExist, DBException
d258 1
a258 2
        return new User
            (dMgr, usrGrpMgr.getUserIDForDomainUserGroup(getID()));
d262 2
a263 1
        throws DoesNotExist, DBException
d266 2
a267 1
        DataSet categorySet = pMgr.getCategoriesForDomain(getID());
d272 2
a273 1
                categoryList.add(new Category(dMgr, categorySet.getRecord(i)));
d280 1
a280 1
        throws DBException
d286 1
a286 1
        throws DBException
d292 1
a292 1
        throws DBException
d298 1
a298 1
        throws DBException
d301 1
a301 1
        DataSet actionSet = actMgr.getActionsForType(type);
d305 1
a305 1
                actions.add(new Action(dMgr, actionSet.getRecord(i)));
d313 1
a313 1
        throws DBException
d316 1
a316 1
        DataSet resourceSet = resMgr.listResources();
d321 1
a321 1
                    (new Resource(dMgr, resourceSet.getRecord(i)));
d329 2
a330 1
        throws DoesNotExist, DBException
d333 1
a333 1
        DataSet roleSet = roleMgr.listRoles();
d336 1
a336 1
            roles.add(new Role(dMgr, roleSet.getRecord(i)));
d342 1
a342 1
        throws DBException
d348 1
a348 1
        throws DBException
d354 1
a354 1
        throws DBException
d360 1
a360 1
        throws DBException
d363 1
a363 1
        DataSet roleSet = roleMgr.listRolesByType(type);
d367 1
a367 1
                roles.add(new Role(dMgr, roleSet.getRecord(i)));
d376 2
a377 1
        throws DoesNotExist, DBException
d380 1
a380 1
        DataSet roleSet = roleMgr.listRolesByType("project");
d383 1
a383 1
            Role role = new Role(dMgr, roleSet.getRecord(i));
d395 1
a395 1
        throws DBException
d399 1
a399 1
        p = new PaginatableProjectList(dMgr, itemsPerPage, query, 
d407 2
a408 1
        throws DoesNotExist, DBException
d433 2
a434 1
        throws DoesNotExist, DBException
d437 2
a438 1
        DataSet projectSet = pMgr.getProjectsForDomain(getID());
d440 1
a440 1
            (dMgr, acl, projectSet);
d444 2
a445 1
        throws DoesNotExist, DBException
d449 1
a449 1
            .getProjectsForDomain(getID());
d451 1
a451 1
            (dMgr, acl, projectSet);
d455 2
a456 1
        throws DoesNotExist, DBException
d460 1
a460 1
            .getUnapprovedProjectsForDomain(getID());
d462 1
a462 1
            (dMgr, acl, projectSet);
d466 2
a467 1
        throws DoesNotExist, DBException
d469 2
a470 1
        DataSet projectSet = pMgr.getProjectsForDomain(getID());
d472 1
a472 1
            (dMgr, acl, projectSet).size();
d480 3
a482 3
    public PaginatableUserList getUsers (Integer itemsPerPage,
                                         Criterion searchCriterion)
        throws DBException
d491 1
a491 1
        u = new PaginatableUserList(dMgr, itemsPerPage, query, 
d503 1
a503 1
        throws DBException
d515 1
a515 1
        u = new PaginatableUserList(dMgr, itemsPerPage, query, 
d521 1
a521 1
        throws DBException
d527 1
a527 1
        throws DBException
d534 1
a534 1
        throws DoesNotExist, DBException
d565 1
a565 1
        throws DBException
d571 1
a571 1
            userSet = new TableDataSet(UserManager.TABLE_NAME);
d584 1
a584 1
                g = new UserGroup(dMgr, r);
d598 2
a599 1
        throws DoesNotExist, DBException
d605 1
a605 1
            projectSet = new TableDataSet(ProjectManager.TABLE_NAME);
d620 1
a620 1
            ProjectGroup g = new ProjectGroup(dMgr, r);
a629 1
        throws DBException
d634 3
a636 2
        catch (DataSetException e) {
            throw new DBException(e);
a643 1
        throws DBException
d648 3
a650 2
        catch (DataSetException e) {
            throw new DBException(e);
d665 2
a666 1
        throws DoesNotExist, DBException
a679 4
        catch (SQLException e)
        {
            throw new DBException(e);
        }
d682 1
a682 11
            if (stmt != null)
            {
                try
                {
                    stmt.close();
                }
                catch (SQLException e)
                {
                    throw new DBException(e);
                }
            }
d710 1
a710 1
            buf.append(UserManager.DOMAIN_ID).append('=')
d748 1
a748 1
    * @@exception DBException
d751 1
a751 1
        throws NullPointerException, IllegalArgumentException, DBException
d765 1
a765 1
    * @@exception DBException
d768 1
a768 1
        throws NullPointerException, IllegalArgumentException, DBException
d787 1
a787 1
     * @@exception DBException
d790 1
a790 1
        throws NullPointerException, IllegalArgumentException, DBException
d804 2
a805 2
        url.append( file );
        return url.toString();
d818 1
a818 1
     * @@exception DBException
d820 2
a821 2
    public String getDomainHome()
        throws NullPointerException, IllegalArgumentException, DBException
d840 1
a840 1
     * @@exception DBException
d843 1
a843 1
        throws NullPointerException, IllegalArgumentException, DBException
@


1.44
log
@* Removed all references to JDBC connections.  Connections are now pulled
  directly from the connection pool.
* Made use of DBException.
- dlr@@collab.net
@
text
@@


1.43
log
@Ported UserManager and RoleManager to Helm. Started moving other TableManagers toward a grab-connection-on-demand model. Massive breakage ensues. dlr and I are working on it.
@
text
@d88 1
a88 1
    public Domain (Connection conn, DataManager dMgr, Record rec)
d91 1
a91 1
        super(conn, dMgr, rec);
d97 1
a97 1
    public Domain(Connection c, DataManager dMgr, String domainID)
d100 1
a100 2
        super(c, dMgr);
        setRecord(domMgr.getDomainRecordByID(domainID));
d106 1
a106 1
    public Domain(Connection c, String domainName, DataManager dMgr)
d109 1
a109 2
        super(c, dMgr);
        setRecord(domMgr.getDomainRecordByName(domainName));
d166 1
a166 1
    public static List listDomains(Connection connection, DataManager dMgr)
d174 1
a174 1
        DataSet domainSet = domMgr.listDomains(connection);
d179 1
a179 1
                Domain d = new Domain(connection, dMgr, r);
d192 1
a192 1
        return new Host(conn, dMgr);
d204 1
a204 1
            domain = new Domain(conn, dMgr, domMgr.getHostDomain());
d234 1
a234 1
            project = new Project(conn, dMgr, pMgr.getDomainProjectID(getID()));
d241 1
a241 1
            throw new DataSetException(err);            
d264 1
a264 1
        return new Project(conn, dMgr, pMgr.getHostProjectID());
d277 1
a277 1
            (conn, dMgr, usrGrpMgr.getUserIDForDomainUserGroup(conn, getID()));
d284 1
a284 2
        DataSet categorySet = pMgr.getCategoriesForDomain(conn, 
                                                           getID());
d289 1
a289 2
                categoryList.add(new Category (conn, dMgr,
                                               categorySet.getRecord(i)));
d317 1
a317 1
        DataSet actionSet = actMgr.getActionsForType(conn, type);
d321 1
a321 1
                actions.add(new Action(conn, dMgr, actionSet.getRecord(i)));
d332 1
a332 1
        DataSet resourceSet = resMgr.listResources(conn);
d337 1
a337 1
                    (new Resource(conn, dMgr, resourceSet.getRecord(i)));
d348 1
a348 1
        DataSet roleSet = roleMgr.listRoles(conn);
d351 1
a351 1
            roles.add(new Role(conn, dMgr, roleSet.getRecord(i)));
d378 1
a378 1
        DataSet roleSet = roleMgr.listRolesByType(conn, type);
d382 1
a382 1
                roles.add(new Role(conn, dMgr, roleSet.getRecord(i)));
d391 1
a391 2
        throws DBException,
               DoesNotExist
d394 1
a394 1
        DataSet roleSet = roleMgr.listRolesByType(conn, "project");
d397 1
a397 1
            Role role = new Role(conn, dMgr, roleSet.getRecord(i));
d413 1
a413 1
        p = new PaginatableProjectList(conn, dMgr, itemsPerPage, query, 
d421 1
a421 2
        throws DBException,
               DoesNotExist
d446 1
a446 2
        throws DBException,
               DoesNotExist
d449 1
a449 2
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
d451 1
a451 1
            (conn, dMgr, acl, projectSet);
d455 1
a455 2
        throws DBException,
               DoesNotExist
d459 1
a459 1
            .getProjectsForDomain(conn, getID());
d461 1
a461 1
            (conn, dMgr, acl, projectSet);
d465 1
a465 2
        throws DBException,
               DoesNotExist
d469 1
a469 1
            .getUnapprovedProjectsForDomain(conn, getID());
d471 1
a471 1
            (conn, dMgr, acl, projectSet);
d475 1
a475 2
        throws DBException,
               DoesNotExist
d477 1
a477 2
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
d479 1
a479 1
            (conn, dMgr, acl, projectSet).size();
d498 1
a498 1
        u = new PaginatableUserList(conn, dMgr, itemsPerPage, query, 
d522 1
a522 1
        u = new PaginatableUserList(conn, dMgr, itemsPerPage, query, 
d578 1
a578 1
            userSet = new TableDataSet(conn, UserManager.TABLE_NAME);
d591 1
a591 1
                g = new UserGroup(conn, dMgr, r);
d611 1
a611 1
            projectSet = new TableDataSet(conn, ProjectManager.TABLE_NAME);
d626 1
a626 1
            ProjectGroup g = new ProjectGroup(conn, dMgr, r);
d636 1
d641 2
a642 3
        catch (DataSetException dse) {
            log.exception(dse);
            return "had DataSetException";
d650 1
d655 2
a656 3
        catch (DataSetException dse) {
            log.exception(dse);
            return "had DataSetException";
d671 1
a671 2
        throws SQLException, DataSetException, JoistDatabaseException,
               InsertFailedException, DoesNotExist
d685 4
d691 11
a701 1
            if (stmt != null) stmt.close();
d767 1
a767 1
    * @@exception DataSetException Thrown by getName( ).
d770 1
a770 1
        throws NullPointerException, IllegalArgumentException, DataSetException
d784 1
a784 1
    * @@exception DataSetException Thrown by getName().
d787 1
a787 1
        throws NullPointerException, IllegalArgumentException, DataSetException
d806 1
a806 1
     * @@exception DataSetException Thrown by getName( ).
d809 1
a809 1
        throws NullPointerException, IllegalArgumentException, DataSetException
d823 2
a824 2
        url.append( file );        
        return url.toString( );
d837 1
a837 1
     * @@exception DataSetException Thrown by getName( ).
d839 2
a840 2
    public String getDomainHome( )
        throws NullPointerException, IllegalArgumentException, DataSetException
d859 1
a859 1
     * @@exception DataSetException Thrown by getName( ).
d862 1
a862 1
        throws NullPointerException, IllegalArgumentException, DataSetException
@


1.42
log
@Making use of DBException.
@
text
@d58 5
a62 1
import org.joist.database.*;
d148 1
a148 1
                dMgr.getManager("org.joist.database.RoleManager");
d154 1
a154 1
                dMgr.getManager("org.joist.database.UserManager");
d728 1
a728 1
            buf.append(DomainManager.USER_DOMAIN_ID).append('=')
@


1.41
log
@Get rid of incorrect dataset results for getGroupsAndUsers
@
text
@d85 1
a85 1
        throws DoesNotExist, DataSetException
d94 1
a94 1
        throws DoesNotExist, DataSetException, JoistDatabaseException
d104 1
a104 1
        throws DoesNotExist, DataSetException, JoistDatabaseException
d165 1
a165 1
        throws DataSetException, SQLException
d197 1
a197 1
        throws SQLException, DataSetException, JoistDatabaseException
d208 8
d227 1
a227 1
        throws DataSetException, SQLException
d241 8
d260 1
a260 1
        throws DataSetException, SQLException, DoesNotExist
d272 1
a272 1
        throws DataSetException, SQLException, JoistDatabaseException, DoesNotExist
d274 2
a275 1
        return new User(conn, dMgr, usrGrpMgr.getUserIDForDomainUserGroup(conn, getID()));
d279 1
a279 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d296 1
a296 1
        throws DataSetException, SQLException, JoistDatabaseException
d302 1
a302 1
        throws DataSetException, SQLException, JoistDatabaseException
d308 1
a308 1
        throws DataSetException, SQLException, JoistDatabaseException
d314 1
a314 1
        throws DataSetException, SQLException, JoistDatabaseException
d329 1
a329 1
        throws DataSetException, SQLException, JoistDatabaseException
d345 1
a345 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d357 1
a357 1
        throws DataSetException, SQLException, JoistDatabaseException
d363 1
a363 1
        throws DataSetException, SQLException, JoistDatabaseException
d369 1
a369 1
        throws DataSetException, SQLException, JoistDatabaseException
d375 1
a375 1
        throws DataSetException, SQLException, JoistDatabaseException
d391 1
a391 1
        throws DataSetException, SQLException, JoistDatabaseException,
d410 1
a410 1
        throws DataSetException, SQLException
d422 1
a422 1
        throws DataSetException, SQLException, JoistDatabaseException,
d448 1
a448 1
        throws DataSetException, SQLException, JoistDatabaseException,
d459 1
a459 1
        throws DataSetException, SQLException, JoistDatabaseException,
d470 1
a470 1
        throws DataSetException, SQLException, JoistDatabaseException,
d481 1
a481 1
        throws DataSetException, SQLException, JoistDatabaseException,
d495 3
a497 3
    public PaginatableUserList getUsers
        (Integer itemsPerPage, Criterion searchCriterion)
        throws DataSetException, SQLException
d518 1
a518 1
        throws DataSetException, SQLException
d536 1
a536 1
        throws DataSetException, SQLException
d542 1
a542 1
        throws DataSetException, SQLException
d549 1
a549 1
        throws DataSetException, SQLException, JoistDatabaseException, DoesNotExist
d580 1
a580 1
        throws DataSetException, SQLException, JoistDatabaseException
d613 1
a613 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
@


1.40
log
@Added static method to list domains.
@
text
@d506 5
a510 4
        Criterion c = new Criterion(UserManager.TYPE, UserType.REGULAR);
        c.or(new Criterion(UserManager.TYPE, UserType.GROUP));
        c.and(new Criterion(UserManager.DOMAIN_ID, getID()));
        
@


1.39
log
@Big patch bringing the smart script runner online.
@
text
@d161 24
d519 7
a525 1
    public PaginatableUserList getUsers()
d528 1
a528 1
        return getUsers(new Integer(0), null);
@


1.38
log
@Improved error reporting.
@
text
@d77 1
d152 6
d223 12
@


1.37
log
@If the special project for a domain doesn't exist, you're in big trouble.
@
text
@d169 2
a170 1
        try {
d172 5
a176 1
        } catch (DoesNotExist ignore) {}
d191 2
a192 1
        try {
d194 7
a200 3
        } catch (DoesNotExist e) {
            log.info("Major problem: Domain's special project does not exist.");
            throw new DataSetException("Special project for domain " + getName() + " does not exist.");            
@


1.36
log
@More pagination updates.
@
text
@d183 1
a183 1
        throws DataSetException, SQLException, DoesNotExist
d185 8
a192 1
        return new Project(conn, dMgr, pMgr.getDomainProjectID(getID()));
@


1.35
log
@More pagination changes--allow paginated lists to filter out items already in a group.
@
text
@d436 23
@


1.34
log
@Many, many pagination changes.
@
text
@d347 2
a348 1
        throws DataSetException, SQLException
d350 20
a369 5
        PaginatableProjectList p = null;
        String query = pMgr.getProjectsNotInGroupQuery(getID(), group.getID());
        p = new PaginatableProjectList(conn, dMgr, itemsPerPage, query, 
                                       searchCriterion, acl);
        return p;
d440 26
@


1.33
log
@Tiny JavaDoc addition.
@
text
@d344 12
a377 6
    public List getPaginatedUsers(WebContext context)
        throws DataSetException, SQLException
    {
        return UserPaginator.paginate(conn, dMgr, context, this);
    }

d404 18
a421 2
    public List getUsers ()
        throws DataSetException, SQLException, JoistDatabaseException
d423 1
a423 21
        ArrayList users = new ArrayList();
        TableDataSet userSet = null;
        try
        {
            userSet = new TableDataSet(conn, UserManager.TABLE_NAME);
            userSet.where(buildUsersClause(getID(), UserType.REGULAR, null));
            userSet.fetchRecords();
        }
        finally
        {
            dMgr.registerToClose(userSet);
        }

        for (int i = 0; i < userSet.size(); i++)
        {
            Record r = userSet.getRecord(i);
            try {
                users.add(new User(conn, dMgr, r));
            } catch (DoesNotExist ignore) {}
        }
        return users;
@


1.32
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d162 3
@


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

@


1.30
log
@Got rid of some now-unneccessary classes.
@
text
@d109 5
@


1.29
log
@First tenative steps towards the new pagination/filtering regime.
@
text
@d335 1
a335 3
        String query = pMgr.getProjectsForDomainQuery(getID());        
        log.info("Creating paginatable project list for query \"" + query
                 + "\" and criterion \"" + searchCriterion.toString() + "\"");
a360 6
    }

    public List getPaginatedProjects(AccessControlList acl, WebContext context)
        throws DataSetException, SQLException
    {
        return ProjectPaginator.paginate(conn, dMgr, context, acl, this);
@


1.28
log
@Wide-ranging patch containing code which will eventually cause fewer MemberAdd and MemberDelete scripts to be run.
@
text
@d329 4
a332 3
    public List getProjects(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d334 7
a340 5
        ArrayList projects = new ArrayList();        
        DataSet projectSet = pMgr
            .getProjectsForDomain(conn, getID());
        return AccessControlledDatabaseFilter.getViewableProjects
            (conn, dMgr, acl, projectSet);
@


1.27
log
@Moved paginator stuff to its own directory.
@
text
@d65 1
d154 2
a155 1
     * Returns the 
d157 14
d340 11
d401 1
a401 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d419 3
a421 1
            users.add(new User(conn, dMgr, r));
d433 1
a433 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d450 4
a453 1
            UserGroup g = new UserGroup(conn, dMgr, r);
@


1.26
log
@Factored out some code.
@
text
@d66 1
@


1.25
log
@First stab at dynamic role creation.
@
text
@d261 12
d274 7
a280 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d283 1
a283 1
        DataSet roleSet = roleMgr.listRolesByType(conn, "project");
d286 5
a290 1
            roles.add(new Role(conn, dMgr, roleSet.getRecord(i)));
@


1.24
log
@New method to allow you to get the appropriate project URL without '/servlets/' in there
@
text
@d76 2
a77 1
    
d132 6
d230 16
@


1.23
log
@Made PermissionDump more modular.
@
text
@d549 16
a585 1
        
d587 8
a594 2
            throw new NullPointerException( "Servletname is null" );
            
d596 2
a597 3
        url.append( servletPath );
        url.append( inServlet );
        
d599 1
a599 2
    }
    
@


1.22
log
@New (and extremely bulky) PermissionDump servlet.
@
text
@d161 13
d192 19
a210 1
    public List getActions()
d214 1
a214 1
        DataSet actionSet = actMgr.listActions(conn);
@


1.21
log
@I promise to compile before checking in.
I promise to compile before checking in.
I promise to compile before checking in.
I promise to compile before checking in.
I promise to compile before checking in.
@
text
@d75 2
a76 1

d125 6
d177 15
@


1.20
log
@Moved escapeAndQuoteSQL() into superclass.
@
text
@d57 1
@


1.19
log
@Added a ctor which takes the domain name.
@
text
@a57 2
import org.joist.util.EscapedString;
import org.joist.util.QuotedString;
a473 13
    }

    /**
     * Escapes and quotes <code>String</code> inputs used in SQL queries.  
     * This method should be run on all Strings used in <code>where</code> 
     * clauses which contain non-numeric values.
     *
     * @@param s The text to sanitize.
     * @@return  The sanitized text.
     */
    protected static final String escapeAndQuoteSQL (String s)
    {
        return (s == null ? "null" : QuotedString.from(EscapedString.from(s)));
@


1.18
log
@Enabled security check of records passed into business objects.
@
text
@a76 2
    protected final String getTableName() { return DomainManager.TABLE_NAME; }

d96 15
d139 4
d396 1
a396 1
    // modifier methods
@


1.17
log
@Added a check so that business objects cannot be created with records from the wrong table. Also added some new business objects.
@
text
@d77 2
@


1.16
log
@formatting cleanup
@
text
@d81 1
a81 1
        throws DoesNotExist
d90 1
a90 1
        throws DoesNotExist, JoistDatabaseException
@


1.15
log
@Removed an unused ctor and added doc.
@
text
@d385 2
a386 2
                                    String name, String loginID, 
                                    String password, String domainID)
a410 1

d417 1
d467 1
a467 2
        protected static final String 
    escapeAndQuoteSQL (String s)
d471 14
a484 14
    
    
   /** Build up a domain-homed url for the passed in servlet.
     * 
     * @@param inServlet Name of servlet to use in manufactured url.
     * 
     * @@return http://www.DOMAIN[:PORT]/servlets/inServlet
     * 
     *
     * @@exception NullPointerException If i can't get JoistProperties instance.
     * @@exception IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     * @@exception DataSetException Thrown by getName( ).
     */
d492 2
a493 1
    /** Build up a domain-homed url for the passed in servlet.
@


1.14
log
@Added ProjectGroupList servlet.
@
text
@d77 3
d86 3
a88 8
    public Domain(Connection c, DataManager dMgr, AccessControlList acl,
                  String domainName)
        throws DoesNotExist, JoistDatabaseException
    {
        super(c, dMgr);
        setRecord(domMgr.getDomainRecordByName(domainName));
    }

@


1.13
log
@First stab at role grant to uesr groups.
@
text
@d316 35
a459 1

@


1.12
log
@Mega patch providing more user group admin functionality.
@
text
@a305 1

d309 2
a310 1
            users.add(new UserGroup(conn, dMgr, r));
@


1.11
log
@Added method for stack's benefit.
@
text
@d66 1
a66 2
import org.tigris.helm.tool.ProjectPaginator;
import org.tigris.helm.tool.AccessControlledDatabaseFilter;
d225 6
@


1.10
log
@More Paginator changes.
@
text
@d211 11
@


1.9
log
@Order users by name
@
text
@d66 1
d210 7
a216 1
    
@


1.8
log
@Method for leonard, getDomainHomeServletURL
@
text
@d399 1
@


1.7
log
@Give registered users the project member list permission in public projects.
@
text
@d418 50
d473 22
d502 1
a502 1
    public String getDomainHome( )
d516 1
a516 1
        String protocol = urlUtil.getProtocol( ( String )null );
@


1.6
log
@Implemented requestable roles and requesting roles in proprietary projects.
@
text
@d262 31
@


1.5
log
@Send mail to domain admins on creation of unapproved project.
@
text
@d182 17
@


1.4
log
@Added a getSpecialProject() method to return the special project
representing all projects in this domain.
@
text
@d85 1
a85 1
        throws Exception
d92 1
a92 1
        throws Exception
@


1.3
log
@Use new narrower interface for call to getPort
@
text
@d125 13
@


1.2
log
@Added a getDomainHome method at JR's request.  Like project.getProjectHome.  Returns http://www.DOMAIN[:PORT_IF_NON_STANDARD]
@
text
@d384 1
a384 1
        String port = urlUtil.getPort( properties, protocol );
@


1.1
log
@Initial revision
@
text
@d355 24
d380 20
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@
