head	1.18;
access;
symbols
	TIGRIS_1_1_0RC2:1.4
	TIGRIS_1_1_0RC1:1.4
	TIGRIS_1_1:1.4.0.4
	TIGRIS_1_0_8:1.4
	TIGRIS_1_0_8RC3:1.4
	TIGRIS_1_0_8RC2:1.4
	TIGRIS_1_0_8RC1:1.4
	TIGRIS_1_0_7:1.4
	TIGRIS_1_0_7RC3:1.4
	TIGRIS_1_0_7RC2:1.4
	TIGRIS_1_0_7RC1:1.4
	TIGRIS_1_0_6:1.4
	TIGRIS_1_0_6RC5:1.4
	TIGRIS_1_0_6RC4:1.4
	TIGRIS_1_0_6RC3:1.4
	TIGRIS_1_0_6RC2:1.4
	TIGRIS_1_0_6RC1:1.4
	TIGRIS_1_0_5:1.4
	TIGRIS_1_0_5RC6:1.4
	TIGRIS_1_0_5RC5:1.4
	TIGRIS_1_0_5RC4:1.4
	TIGRIS_1_0_5RC3:1.4
	TIGRIS_1_0_5RC2:1.4
	TIGRIS_1_0_5RC1:1.4
	TIGRIS_1_0_4:1.4
	TIGRIS_1_0_3:1.4
	TIGRIS_1_0_2:1.4
	TIGRIS_1_0_1:1.4
	TIGRIS_1_0:1.4.0.6
	TIGRIS_1_0_0:1.4
	TIGRIS_1_0_0_RC1:1.4.0.2
	dlr:1.1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1;
locks; strict;
comment	@# @;


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

1.17
date	2001.08.11.09.08.02;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2001.07.02.18.56.42;	author leonardr;	state Exp;
branches;
next	1.15;

1.15
date	2001.06.29.00.57.49;	author leonardr;	state Exp;
branches;
next	1.14;

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

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

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

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

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

1.9
date	2001.05.23.01.50.13;	author dlr;	state Exp;
branches;
next	1.8;

1.8
date	2001.05.02.08.11.04;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.05.02.07.59.24;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2001.05.02.07.06.23;	author dlr;	state Exp;
branches;
next	1.5;

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

1.4
date	2001.03.07.01.53.22;	author lucas;	state Exp;
branches;
next	1.3;

1.3
date	2001.02.22.02.25.42;	author leonardr;	state Exp;
branches;
next	1.2;

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

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

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

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

1.1.2.2
date	2001.02.01.18.03.00;	author leonardr;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2001.02.01.21.09.34;	author leonardr;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2001.02.01.21.53.29;	author dlr;	state Exp;
branches;
next	1.1.2.5;

1.1.2.5
date	2001.02.02.16.51.22;	author leonardr;	state Exp;
branches;
next	1.1.2.6;

1.1.2.6
date	2001.02.02.20.11.00;	author leonardr;	state Exp;
branches;
next	1.1.2.7;

1.1.2.7
date	2001.02.02.20.40.55;	author dlr;	state Exp;
branches;
next	1.1.2.8;

1.1.2.8
date	2001.02.09.01.15.22;	author leonardr;	state Exp;
branches;
next	1.1.2.9;

1.1.2.9
date	2001.02.15.20.50.37;	author leonardr;	state Exp;
branches;
next	1.1.2.10;

1.1.2.10
date	2001.02.16.03.01.27;	author dlr;	state Exp;
branches;
next	1.1.2.11;

1.1.2.11
date	2001.02.20.22.05.57;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.18
log
@Minor cleanup.
@
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.om;

import java.util.*;

import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;
import org.apache.fulcrum.*;
import org.apache.torque.util.Criteria;

import org.tigris.helm.om.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.tool.DBFlag; 
import org.tigris.helm.tool.HelmService; 
import org.tigris.helm.tool.audit.AuditLog;
import org.tigris.helm.tool.cluster.ClusteredSingletonService;
import org.tigris.helm.tool.paginate.PeerBackedList;
import org.tigris.helm.security.AccessControlList;

public class Host extends Domain
{
    /**
     * List of valid subproject types.
     */
    protected static Class[] VALID_SUBPROJECT_CLASSES = {Domain.class};

    /**
     * List of valid superproject types.
     */
    protected static String[] VALID_SUPERPROJECT_TYPES = {};

    /**
     * Constructor; make nice with Torque;
     */
    public Host()
    {
        setType(ProjectPeer.CLASSKEY_HOST);
    }

    /**
     * Returns the types of projects which can be subprojects of this type
     * of project.
     */
    protected String[] getValidSubprojectTypes()
    {
        return this.VALID_SUBPROJECT_TYPES;
    }

    /**
     * Returns the types of projects which can be superprojects of this type
     * of project.
     */
    protected String[] getValidSuperprojectTypes()
    {
        return this.VALID_SUPERPROJECT_TYPES;
    }

    /**
     * Returns a list of all domains, including the special host domain.
     */
    public List getDomains()
        throws Exception
    {
        String[] types = {Project.DOMAIN_TYPE, Project.HOST_TYPE};
        Criteria c = new Criteria().addIn(ProjectPeer.TYPE, types);
        return ProjectPeer.doSelect(c);
    }

    /**
     * Returns a list of all host actions.
     */
    public List getHostActions()
        throws Exception
    {
        return ActionPeer.getHostActions();
    }

    /**
     * Returns a list of all domain actions.
     */
    public List getDomainActions()
        throws Exception
    {
        return ActionPeer.getDomainActions();
    }

    /**
     * Returns a list of all project actions.
     */    
    public List getProjectActions()
        throws Exception
    {
        return ActionPeer.getProjectActions();
    }

    /**
     * Returns a list of all role attributes.
     */    
    public List getRoleAttributes()
        throws Exception
    {
        return AttributePeer.getAttributes(Attribute.ROLE_TYPE);
    }

    /**
     * Returns the audit log for the host.
     */ 
    public PeerBackedList getAuditLog(AccessControlList acl,
                                      Integer itemsPerPage, Criteria filter)
        throws DoesNotExist, Exception
    {
        return AuditLog.getLog(itemsPerPage, filter, acl);
    }

    /**
     * Returns all currently registered services.
     */
    public List getServices()
    {
        TurbineServices serviceBroker = 
            (TurbineServices)TurbineServices.getInstance();
        List services = new ArrayList();
        for (Iterator names = serviceBroker.getServiceNames(); 
             names.hasNext();)
        {
            String name = (String)names.next();
            Service service = (Service)serviceBroker.getService(name);
            services.add(service);
        }
        return services;
    }

    /**
     * Returns all currently registered clustered singletons.
     */
    public List getClusteredSingletons()
    {
        List services = getServices();
        List matchingServices = new ArrayList();
        for (Iterator i = services.iterator(); i.hasNext();)
        {
            Service service = (Service)i.next();
            {
                if (service instanceof ClusteredSingletonService)
                {
                    matchingServices.add(service);
                }
            }
        }
        return matchingServices;
    }

    /**
     * Returns all currently registered clustered singletons.
     */
    public List getHelmServices()
    {
        List services = getServices();
        List matchingServices = new ArrayList();
        for (Iterator i = services.iterator(); i.hasNext();)
        {
            Service service = (Service)i.next();
            {
                if (service instanceof HelmService)
                {
                    matchingServices.add(service);
                }
            }
        }
        return matchingServices;
    }


    /**
     * Returns all host attributes.
     */
    public List getHostAttributes()
        throws Exception
    {
        return AttributePeer.getAttributes(Attribute.HOST_TYPE);
    }


    /**
     * Returns the value of the given host attribute.
     */
    public AttributeValue getHostAttributeValue(String name)
        throws Exception
    {
        return AttributeValuePeer.getInstanceByName
            (Attribute.HOST_TYPE, getID(), name);
    }

    //Deprecated methods
    /**
     * @@deprecated Host now subclasses ProjectGroup, so there's no need
     * to call this method at all.
     */
    public Domain getSpecialProject()
    {
        return this;
    }

    /**
     * Returns a list of all host roles.
     * @@deprecated use host.getRoles() instead
     */    
    public List getHostRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.HOST_TYPE);
    }

    /**
     * Returns a list of all domain roles.
     * @@deprecated use domain.getRoles() instead
     */    
    public List getDomainRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.DOMAIN_TYPE);
    }

    /**
     * Returns a list of all project roles.
     * @@deprecated use project.getRoles() instead
     */        
    public List getProjectRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.PROJECT_TYPE);
    }

}
@


1.17
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@a166 1
        Iterator names = serviceBroker.getServiceNames();
d168 2
a169 1
        for (Iterator i = names; i.hasNext();)
d171 1
a171 1
            String name = (String)i.next();
@


1.16
log
@Implemented project-scoped roles.
@
text
@d52 3
a54 3
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.services.*;
import org.apache.turbine.util.db.Criteria;
@


1.15
log
@Implemented basic project group and category nesting.
@
text
@a114 9
     * Returns a list of all defined resources.
     */
    public List getResources()
        throws Exception
    {
        return ResourcePeer.doSelect(HelmPeer.NO_CRITERIA);
    }

    /**
d151 2
a152 38
     * Returns a list of all host roles.
     */    
    public List getHostRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.HOST_TYPE);
    }

    /**
     * Returns a list of all domain roles.
     */    
    public List getDomainRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.DOMAIN_TYPE);
    }

    /**
     * Returns a list of all project roles.
     */        
    public List getProjectRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.PROJECT_TYPE);
    }

    /**
     * Returns a list of all requestable project roles.
     */            
    public List getRequestableProjectRoles()
        throws Exception
    {
        Criteria base = RolePeer.getCriteriaForRolesWithBooleanAttribute
            (Attribute.REQUESTABLE)
            .add(RolePeer.TYPE, Role.PROJECT_TYPE);
        return RolePeer.doSelect(base);
    }

d248 31
@


1.14
log
@Huge patch of the day: Got rid of redundant HELM_DOMAIN table. The project representation of the domain and the host is now the canonical one. Host and Domain now subclass ProjectGroup. The canonical representation of a project's membership in a domain group is now the corresponding mapping in HELM_PROJECT_PROJECTGROUP. Schema changes: No more HELM_DOMAIN table (obviously); no more DOMAIN_ID in HELM_PROJECT; HELM_USER and HELM_VC_VIEW now have foreign keys in HELM_PROJECT instead of HELM_DOMAIN.
@
text
@d68 10
d83 18
@


1.13
log
@TableTrackingBufferCache now watches the attribute containing its fractional size, rather than the fractional size itself.
@
text
@d65 1
a65 1
public class Host
a66 17
    //
    // Special representations of the host.
    //

    /**
     * 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 ProjectGroup getSpecialProject()    
        throws Exception
    {
        return ProjectPeer.getHostProject();
    }

d68 1
a68 4
     * Returns the special user which is a placeholder for the host
     * users.
     *
     * @@return The special user representing all host users.
d70 1
a70 2
    public User getSpecialUser()
        throws Exception
d72 1
a72 47
        return UserPeer.getHostUser();
    }

    //
    // Retrieval of business objects associated with the site.
    //

    /**
     * Returns a list of the host users.
     */
    public List getUsers()
        throws Exception
    {
        return getSpecialUser().expand();
    }

    /**
     * Returns a list of the base host users.
     */
    public List getBaseUsers()
        throws Exception
    {
        List allUsers = getUsers();
        for (Iterator i = allUsers.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            if (!u.isBase()) {
                allUsers.remove(u);
            }
        }
        return allUsers;
    }

    /**
     * Returns a list of all the base users on the site. 
     */
    public List getAllSiteUsers()
        throws Exception
    {
        List users = new ArrayList();
        List domains = getDomains();
        for (Iterator i = domains.iterator(); i.hasNext();)
        {
            Domain d = (Domain)i.next();
            users.addAll(d.getUsers());
        }
        return users;
d81 3
a83 1
        return DomainPeer.doSelect(HelmPeer.NO_CRITERIA);
d253 11
a263 2
            (Attribute.HOST_TYPE, ProjectPeer.getHostProject().getID(),
             name);
@


1.12
log
@Rearranged attribute constants and added generic host attribute-editing interface to AdminUtils.
@
text
@d318 2
a319 1
            (Attribute.HOST_TYPE, ProjectPeer.getHostProject().getID(), name);
@


1.11
log
@Added getStatus method to HelmService until it gets added to Turbine.
@
text
@d230 1
a230 1
            (AttributePeer.REQUESTABLE_ATTRIBUTE)
d299 21
a319 1
    
@


1.10
log
@Finally got rid of REQUESTABLE and DENOTES_OWNER fields in HELM_ROLE.
@
text
@d53 2
a54 1
import org.apache.turbine.util.TurbineException;
a55 1
import org.apache.turbine.util.db.Criteria;
d58 2
a59 1
import org.tigris.helm.tool.DBFlag;
d61 1
d241 59
@


1.9
log
@Ported Helm from WebMacro to Velocity.
@
text
@d227 2
a228 2
        Criteria base = new Criteria()
            .add(RolePeer.REQUESTABLE, DBFlag.flagValueOf(true))
@


1.8
log
@Corrected getAttributes() call in Role and made use of HelmPeer's new NO_CRITERIA constant.
@
text
@d52 2
@


1.7
log
@Allow attribute retrieval by attribute entity type.
@
text
@d144 1
a144 1
        return DomainPeer.doSelect(new Criteria(0));
d153 1
a153 1
        return ResourcePeer.doSelect(new Criteria(0));
@


1.6
log
@Migrating code to make proper use of the new generic attribute tables.  Things are still a bit rough.
@
text
@d189 1
a189 2
        // TODO: Only get Role-specific entries.
        return AttributePeer.getAttributes();
@


1.5
log
@Big architecture and schema change: booleans in the HELM_ROLE table have been replaced by entries in the HELM_ROLE_ATTRIBUTE_VALUE table. Also, a new attribute has been added which controls which roles a user gets upon creation of a project.
@
text
@d189 2
a190 1
        return RoleAttributePeer.getAttributes();
@


1.4
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d184 9
@


1.3
log
@Use DBFlag.
@
text
@d54 1
a54 2
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
@


1.2
log
@adding files from the branch to the head
@
text
@d57 1
d218 1
a218 1
            .add(RolePeer.REQUESTABLE, true)
@


1.1
log
@file Host.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 228
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 228
/* ================================================================
 * 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.om;

import java.util.*;

import org.apache.turbine.util.Log;

import org.apache.turbine.util.db.Criteria;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.tool.audit.AuditLog;
import org.tigris.helm.tool.paginate.PeerBackedList;
import org.tigris.helm.security.AccessControlList;

public class Host
{
    //
    // Special representations of the host.
    //

    /**
     * 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 ProjectGroup getSpecialProject()    
        throws Exception
    {
        return ProjectPeer.getHostProject();
    }

    /**
     * Returns the special user which is a placeholder for the host
     * users.
     *
     * @@return The special user representing all host users.
     */
    public User getSpecialUser()
        throws Exception
    {
        return UserPeer.getHostUser();
    }

    //
    // Retrieval of business objects associated with the site.
    //

    /**
     * Returns a list of the host users.
     */
    public List getUsers()
        throws Exception
    {
        return getSpecialUser().expand();
    }

    /**
     * Returns a list of the base host users.
     */
    public List getBaseUsers()
        throws Exception
    {
        List allUsers = getUsers();
        for (Iterator i = allUsers.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            if (!u.isBase()) {
                allUsers.remove(u);
            }
        }
        return allUsers;
    }

    /**
     * Returns a list of all the base users on the site. 
     */
    public List getAllSiteUsers()
        throws Exception
    {
        List users = new ArrayList();
        List domains = getDomains();
        for (Iterator i = domains.iterator(); i.hasNext();)
        {
            Domain d = (Domain)i.next();
            users.addAll(d.getUsers());
        }
        return users;
    }

    /**
     * Returns a list of all domains, including the special host domain.
     */
    public List getDomains()
        throws Exception
    {
        return DomainPeer.doSelect(new Criteria(0));
    }

    /**
     * Returns a list of all defined resources.
     */
    public List getResources()
        throws Exception
    {
        return ResourcePeer.doSelect(new Criteria(0));
    }

    /**
     * Returns a list of all host actions.
     */
    public List getHostActions()
        throws Exception
    {
        return ActionPeer.getHostActions();
    }

    /**
     * Returns a list of all domain actions.
     */
    public List getDomainActions()
        throws Exception
    {
        return ActionPeer.getDomainActions();
    }

    /**
     * Returns a list of all project actions.
     */    
    public List getProjectActions()
        throws Exception
    {
        return ActionPeer.getProjectActions();
    }

    /**
     * Returns a list of all host roles.
     */    
    public List getHostRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.HOST_TYPE);
    }

    /**
     * Returns a list of all domain roles.
     */    
    public List getDomainRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.DOMAIN_TYPE);
    }

    /**
     * Returns a list of all project roles.
     */        
    public List getProjectRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(Role.PROJECT_TYPE);
    }

    /**
     * Returns a list of all requestable project roles.
     */            
    public List getRequestableProjectRoles()
        throws Exception
    {
        Criteria base = new Criteria()
            .add(RolePeer.REQUESTABLE, true)
            .add(RolePeer.TYPE, Role.PROJECT_TYPE);
        return RolePeer.doSelect(base);
    }

    public PeerBackedList getAuditLog(AccessControlList acl,
                                      Integer itemsPerPage, Criteria filter)
        throws DoesNotExist, Exception
    {
        return AuditLog.getLog(itemsPerPage, filter, acl);
    }
}
@


1.1.2.1
log
@Ported heavily commented Host object.
@
text
@a0 254
/* ================================================================
 * 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.om;

import java.util.*;

import org.apache.turbine.util.Log;

import org.tigris.helm.om.peer.*;

public class Host
{
    /**
     * 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 ProjectGroup getSpecialProject()    
        throws Exception
    {
        return ProjectPeer.getHostProject();
    }

    /**
     * Returns the special user which is a placeholder for the host
     * users.
     *
     * @@return The special user representing all host users.
     */
    public User getSpecialUser()
        throws Exception
    {
        return UserPeer.getHostUser();
    }

//     /**
//      * Returns a list of all the base users on the site. 
//      */
//     public List getAllSiteUsers()
//         throws Exception
//     {
//         List domains = getDomains();
//         List users = new ArrayList();
//         for (Iterator i = domains.iterator(); i.hasNext();)
//         {
//             Domain d = (Domain)i.next();
//             users.addAll(d.getUsers());
//         }
//         return users;
//     }

    /**
     * Returns a list of the host users.
     */
    public List getUsers()
        throws Exception
    {
        return getSpecialUser().expand();
    }

    /**
     * Returns a list of the base host users.
     */
    public List getBaseUsers()
        throws Exception
    {
        List allUsers = getUsers();
        for (Iterator i = allUsers.iterator(); i.hasNext();)
        {
            User u = (User)i.next();
            if (!u.isBase()) allUsers.remove(u);
        }
        return allUsers;
    }


//     /**
//      * Returns a list of all domains, including the special host domain.
//      */
//     public List getDomains()
//         throws DataSetException, SQLException
//     {
//         return Domain.listDomains(conn, dMgr);
//     }

//     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 PaginatableAuditLogEntryList getAuditLog
//         (Integer itemsPerPage, Criterion criterion, AccessControlList acl, 
//          Domain currentDomain)
//         throws SQLException, DataSetException
//     {
//         return AuditLog.getLog 
//             (conn, dMgr, itemsPerPage, criterion, acl, currentDomain);
//     }

}
@


1.1.2.2
log
@Misc. changes to support PermissionDump.
@
text
@d132 5
a136 5
    public List getHostActions()
        throws Exception
    {
        return ActionPeer.getHostActions();
    }
d138 5
a142 5
    public List getDomainActions()
        throws Exception
    {
        return ActionPeer.getDomainActions();
    }
d144 5
a148 5
    public List getProjectActions()
        throws Exception
    {
        return ActionPeer.getProjectActions();
    }
d150 15
@


1.1.2.3
log
@Added methods of getting roles.
@
text
@a148 18

    public List getHostRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(RolePeer.HOST_TYPE);
    }

    public List getDomainRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(RolePeer.DOMAIN_TYPE);
    }
    
    public List getProjectRoles()
        throws Exception
    {
        return RolePeer.getRolesForType(RolePeer.PROJECT_TYPE);
    }
@


1.1.2.4
log
@Made use of the proper constants.
@
text
@d153 1
a153 1
        return RolePeer.getRolesForType(Role.HOST_TYPE);
d159 1
a159 1
        return RolePeer.getRolesForType(Role.DOMAIN_TYPE);
d165 1
a165 1
        return RolePeer.getRolesForType(Role.PROJECT_TYPE);
@


1.1.2.5
log
@Added getResources method and ported getDomains() method.
@
text
@a52 1
import org.apache.turbine.util.db.Criteria;
d123 8
a130 14
    /**
     * Returns a list of all domains, including the special host domain.
     */
    public List getDomains()
        throws Exception
    {
        return DomainPeer.doSelect(new Criteria());
    }

    public List getResources()
        throws Exception
    {
        return ResourcePeer.doSelect(new Criteria());
    }
@


1.1.2.6
log
@Ported methods for obtaining users.
@
text
@d83 15
a97 15
    /**
     * Returns a list of all the base users on the site. 
     */
    public List getAllSiteUsers()
        throws Exception
    {
        List domains = getDomains();
        List users = new ArrayList();
        for (Iterator i = domains.iterator(); i.hasNext();)
        {
            Domain d = (Domain)i.next();
            users.addAll(d.getUsers());
        }
        return users;
    }
@


1.1.2.7
log
@Prep'd for porting.
@
text
@d89 1
a90 1
        List domains = getDomains();
d118 1
a118 3
            if (!u.isBase()) {
                allUsers.remove(u);
            }
d130 1
a130 1
        return DomainPeer.doSelect(new Criteria(0));
d136 1
a136 1
        return ResourcePeer.doSelect(new Criteria(0));
d176 1
a176 1
//         throws DoesNotExist, Exception
d192 2
a193 1
//         throws DoesNotExist, Exception
d197 2
a198 1
//         for (int i = 0; i < roleSet.size(); i++) {
d205 1
a205 1
//         throws DoesNotExist, Exception
d211 1
a211 1
//         throws DoesNotExist, Exception
d217 1
a217 1
//         throws DoesNotExist, Exception
d223 1
a223 1
//         throws DoesNotExist, Exception
d239 2
a240 1
//         throws DoesNotExist, Exception
d244 2
a245 1
//         for (int i = 0; i < roleSet.size(); i++) {
d247 2
a248 1
//             if (role.isRequestable()) {
d258 1
a258 1
//         throws DoesNotExist, Exception
d263 1
@


1.1.2.8
log
@Added all methods which are present in the head and still relevant. GetAuditLog is still commented out; I'm not sure it belongs in Host.
@
text
@a54 1
import org.tigris.helm.tool.paginate.PeerBackedList;
a57 5

    //
    // Special representations of the host.
    //

d83 15
a97 3
    //
    // Retrieval of business objects associated with the site.
    //
a124 15
    /**
     * Returns a list of all the base users on the site. 
     */
    public List getAllSiteUsers()
        throws Exception
    {
        List users = new ArrayList();
        List domains = getDomains();
        for (Iterator i = domains.iterator(); i.hasNext();)
        {
            Domain d = (Domain)i.next();
            users.addAll(d.getUsers());
        }
        return users;
    }
a134 3
    /**
     * Returns a list of all defined resources.
     */
a140 3
    /**
     * Returns a list of all host actions.
     */
a146 3
    /**
     * Returns a list of all domain actions.
     */
d152 1
a152 4

    /**
     * Returns a list of all project actions.
     */    
a158 3
    /**
     * Returns a list of all host roles.
     */    
a164 3
    /**
     * Returns a list of all domain roles.
     */    
d170 1
a170 4

    /**
     * Returns a list of all project roles.
     */        
d176 16
d193 58
a250 11
    /**
     * Returns a list of all requestable project roles.
     */            
    public List getRequestableProjectRoles()
        throws Exception
    {
        Criteria base = new Criteria()
            .add(RolePeer.REQUESTABLE, true)
            .add(RolePeer.TYPE, Role.PROJECT_TYPE);
        return RolePeer.doSelect(base);
    }
d252 2
a253 2
//     public PeerBackedList getAuditLog
//         (Integer itemsPerPage, Criterion filter, AccessControlList acl, 
a259 1

@


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


1.1.2.10
log
@Added new imports necessitated by Torque.
@
text
@a54 1
import org.tigris.helm.om.base.*;
@


1.1.2.11
log
@Ported getAuditLog(), removing the currentDomain parameter on advice
from LR.
@
text
@a55 2
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.tool.audit.AuditLog;
a56 1
import org.tigris.helm.security.AccessControlList;
d60 1
d220 9
a228 6
    public PeerBackedList getAuditLog(AccessControlList acl,
                                      Integer itemsPerPage, Criteria filter)
        throws DoesNotExist, Exception
    {
        return AuditLog.getLog(itemsPerPage, filter, acl);
    }
@


