head	1.34;
access;
symbols
	TIGRIS_1_1_0RC2:1.16.6.2
	TIGRIS_1_1_0RC1:1.16.6.2
	TIGRIS_1_1:1.16.6.2.0.2
	TIGRIS_1_0_8:1.16.6.2
	TIGRIS_1_0_8RC3:1.16.6.2
	TIGRIS_1_0_8RC2:1.16.6.2
	TIGRIS_1_0_8RC1:1.16.6.2
	TIGRIS_1_0_7:1.16.6.2
	TIGRIS_1_0_7RC3:1.16.6.2
	TIGRIS_1_0_7RC2:1.16.6.2
	TIGRIS_1_0_7RC1:1.16.6.2
	TIGRIS_1_0_6:1.16.6.2
	TIGRIS_1_0_6RC5:1.16.6.2
	TIGRIS_1_0_6RC4:1.16.6.2
	TIGRIS_1_0_6RC3:1.16.6.2
	TIGRIS_1_0_6RC2:1.16.6.2
	TIGRIS_1_0_6RC1:1.16.6.2
	TIGRIS_1_0_5:1.16.6.2
	TIGRIS_1_0_5RC6:1.16.6.2
	TIGRIS_1_0_5RC5:1.16.6.2
	TIGRIS_1_0_5RC4:1.16.6.2
	TIGRIS_1_0_5RC3:1.16.6.2
	TIGRIS_1_0_5RC2:1.16.6.2
	TIGRIS_1_0_5RC1:1.16.6.1
	TIGRIS_1_0_4:1.16
	TIGRIS_1_0_3:1.16
	TIGRIS_1_0_2:1.16
	TIGRIS_1_0_1:1.16
	TIGRIS_1_0:1.16.0.6
	TIGRIS_1_0_0:1.16
	TIGRIS_1_0_0_RC1:1.16.0.2
	dlr:1.1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1;
locks; strict;
comment	@# @;


1.34
date	2001.08.30.16.57.41;	author dlr;	state Exp;
branches;
next	1.33;

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

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

1.31
date	2001.07.24.18.35.41;	author leonardr;	state Exp;
branches;
next	1.30;

1.30
date	2001.07.19.19.08.42;	author dlr;	state Exp;
branches;
next	1.29;

1.29
date	2001.07.19.18.42.22;	author dlr;	state Exp;
branches;
next	1.28;

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

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

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

1.25
date	2001.06.07.02.59.48;	author dlr;	state Exp;
branches;
next	1.24;

1.24
date	2001.06.07.02.58.29;	author dlr;	state Exp;
branches;
next	1.23;

1.23
date	2001.06.07.02.56.29;	author dlr;	state Exp;
branches;
next	1.22;

1.22
date	2001.06.06.16.42.44;	author edk;	state Exp;
branches;
next	1.21;

1.21
date	2001.06.06.16.13.37;	author edk;	state Exp;
branches;
next	1.20;

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

1.19
date	2001.05.15.15.27.12;	author leonardr;	state Exp;
branches;
next	1.18;

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

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

1.16
date	2001.03.26.18.51.48;	author dlr;	state Exp;
branches
	1.16.6.1;
next	1.15;

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

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

1.13
date	2001.03.07.01.53.22;	author lucas;	state Exp;
branches;
next	1.12;

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

1.11
date	2001.02.27.08.29.50;	author dlr;	state Exp;
branches;
next	1.10;

1.10
date	2001.02.24.03.59.53;	author dlr;	state Exp;
branches;
next	1.9;

1.9
date	2001.02.24.00.46.30;	author elicia;	state Exp;
branches;
next	1.8;

1.8
date	2001.02.23.23.33.52;	author elicia;	state Exp;
branches;
next	1.7;

1.7
date	2001.02.22.23.42.02;	author jody;	state Exp;
branches;
next	1.6;

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

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

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

1.3
date	2001.02.21.23.05.03;	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.28.01.18.22;	author dlr;	state dead;
branches
	1.1.1.1
	1.1.2.1;
next	;

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

1.1.2.1
date	2001.01.28.01.18.22;	author dlr;	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.02.16.13.28;	author leonardr;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2001.02.02.20.11.00;	author leonardr;	state Exp;
branches;
next	1.1.2.5;

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

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

1.1.2.7
date	2001.02.07.02.58.08;	author leonardr;	state Exp;
branches;
next	1.1.2.8;

1.1.2.8
date	2001.02.07.19.23.21;	author dlr;	state Exp;
branches;
next	1.1.2.9;

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

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

1.1.2.11
date	2001.02.07.21.35.30;	author leonardr;	state Exp;
branches;
next	1.1.2.12;

1.1.2.12
date	2001.02.08.00.35.48;	author elicia;	state Exp;
branches;
next	1.1.2.13;

1.1.2.13
date	2001.02.08.01.28.35;	author elicia;	state Exp;
branches;
next	1.1.2.14;

1.1.2.14
date	2001.02.08.01.35.08;	author elicia;	state Exp;
branches;
next	1.1.2.15;

1.1.2.15
date	2001.02.08.18.19.12;	author leonardr;	state Exp;
branches;
next	1.1.2.16;

1.1.2.16
date	2001.02.09.00.42.34;	author leonardr;	state Exp;
branches;
next	1.1.2.17;

1.1.2.17
date	2001.02.12.15.09.40;	author leonardr;	state Exp;
branches;
next	1.1.2.18;

1.1.2.18
date	2001.02.12.18.01.22;	author leonardr;	state Exp;
branches;
next	1.1.2.19;

1.1.2.19
date	2001.02.12.21.57.35;	author leonardr;	state Exp;
branches;
next	1.1.2.20;

1.1.2.20
date	2001.02.13.03.35.34;	author leonardr;	state Exp;
branches;
next	1.1.2.21;

1.1.2.21
date	2001.02.14.00.34.10;	author leonardr;	state Exp;
branches;
next	1.1.2.22;

1.1.2.22
date	2001.02.14.23.20.29;	author leonardr;	state Exp;
branches;
next	1.1.2.23;

1.1.2.23
date	2001.02.16.03.01.27;	author dlr;	state Exp;
branches;
next	1.1.2.24;

1.1.2.24
date	2001.02.16.23.10.07;	author leonardr;	state Exp;
branches;
next	1.1.2.25;

1.1.2.25
date	2001.02.17.20.32.36;	author leonardr;	state Exp;
branches;
next	;

1.16.6.1
date	2001.05.10.02.10.26;	author dlr;	state Exp;
branches;
next	1.16.6.2;

1.16.6.2
date	2001.05.15.16.25.38;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.34
log
@Updated for latest Turbine API changes.
@
text
@package org.tigris.helm.om;

import java.util.*;

import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
import org.apache.commons.util.ObjectUtils;
import org.apache.commons.util.StringUtils;
import org.apache.turbine.ParameterParser;
import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;
import org.apache.commons.util.exception.NestableException;
import org.apache.torque.pool.DBConnection;

import org.tigris.helm.tool.HelmProperties;

import org.tigris.helm.om.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*; 
import org.tigris.helm.tool.PeerTool; 
import org.tigris.helm.tool.paginate.*; 

/** 
 * The Tigris representation of a DNS domain name.
 *
 * @@author <a href="mailto:dev@@helm.tigris.org">Helm Development Team</a>
 */
public class Domain extends Project
{
    /**
     * List of valid subproject types.
     */
    protected static String[] VALID_SUBPROJECT_TYPES = 
    {
        REGULAR_TYPE,
        GROUP_TYPE,
        CATEGORY_TYPE
    };

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

    /**
     * The key used to reference the short site name property associated with
     * the domain.
     */
    public static final String SHORT_SITE_NAME_KEY = "ShortSiteName";

    /**
     * The key used to reference the property which determines whether or
     * not users -- with only User - Edit - Self -- can change their
     * organization field.
     */
    public static final String USER_EDIT_SELF_ALLOWS_EDIT_ORGANIZATION_KEY =
        "UserEditSelfAllowsEditOrganization";

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

    /**
     * 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;
    }

    //
    // Methods which return direct subprojects of the domain.
    //

    /**
     * Lists only the direct subprojects of this domain which the
     * given user can see.
     *
     * @@deprecated Use getSubprojects instead.
     * @@return The project list.  
     */
    public PeerBackedList getProjects(Integer itemsPerPage, Criteria filter, 
                                      AccessControlList acl)
        throws Exception
    {
        return getSubprojects(itemsPerPage, filter, acl);
    }


    /**
     * Lists the direct project groups in this domain which the given
     * user can see.
     *
     * @@return The list of project groups.  
     */
    public PeerBackedList getProjectGroups(AccessControlList acl)
        throws Exception
    {
        return getProjectGroups(new Integer(0), null, acl);
    }

    /**
     * Lists only the project groups in this domain which the given
     * user can see.
     *
     * @@return The list of project groups. 
     */
    public PeerBackedList getProjectGroups
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        return getSubprojects(itemsPerPage, filter, acl, Project.GROUP_TYPE);
    }

    /**
     * List the top-level categories of the domain in one big list.
     */
    public List getCategories(AccessControlList acl)
        throws Exception
    {
        return getCategories(new Integer(0), null, acl);
    }

    /**
     * List the top-level categories of the domain as a paginatable list.
     */
    public PeerBackedList getCategories(Integer itemsPerPage, Criteria filter,
                                        AccessControlList acl)
        throws Exception
    {
        return getSubprojects(itemsPerPage, filter, acl, 
                              Project.CATEGORY_TYPE);
    }

    // Methods which return projects associated with the domain.    

    /**
     * List the categories of the domain.
     */
    public List getUnapprovedProjects(AccessControlList acl)
        throws Exception
    {
        return getUnapprovedProjects(new Integer(0), null, acl);
    }

    /**
     * Get the unapproved projects for this domain. 
     *
     * LEONARDR-FIXME: This needs to get all unapproved projects, not just
     * top-level unapproved projects.
     */
    public PeerBackedList getUnapprovedProjects
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria(2)
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE)
            .add(ProjectPeer.APPROVED_BY,
                 UserPeer.getNobodyUser().getUserId());
        return getSubprojects(itemsPerPage, base, filter, acl);
    }

    /**
     * Gets the project of the specified name in this domain. 
     *
     * @@exception  DoesNotExist if there is no project of that name. 
     * @@exception ACLException if the project exists but the ACL
     *            does not have permission to view it.
     *
     * @@return The requested project.  
     */
    public Project getProject(AccessControlList acl, String name)
        throws ACLException, DoesNotExist, Exception
    {
        Project p = ProjectPeer.getInstanceByName(this, name);
        if (!p.isViewableBy(acl))
        {
            throw new ACLException(acl, "Project - View", null, null);
        }
        return p;
    }

    /**
     * Gets the projects which the given user could use as the
     * superproject of a new project.  
     */
    public List getPotentialParents(AccessControlList acl, String type)
        throws Exception
    {
        Project p = null;
        if (type.equals(REGULAR_TYPE))
        {
            p = new Project();
        }
        else if (type.equals(CATEGORY_TYPE))
        {
            p = new Category();
        }
        else if (type.equals(GROUP_TYPE))
        {
            p = new ProjectGroup();
        }
        else if (type.equals(DOMAIN_TYPE))
        {
            p = new Domain();
        }
        else
        {
            p = new Host();
        }
        return p.getPotentialParents(acl);
    }
        
    //
    // Methods which return (non-special) users associated with this
    // domain. 
    //

    /**
     * Returns the special user group containing all this domain's users.
     *
     * @@return The special user representing all users in this domain.
     */
    public User getSpecialUser()
        throws Exception
    {
        return UserPeer.getDomainUser(this);
    }

    /**
     * Overrides a generated method in BaseDomain which returns all
     * users, not just the base ones. Returns a Vector. Bleah.
     */
    public Vector getUsers()
        throws Exception
    {
        Criteria c = new Criteria()
            .add(UserPeer.DOMAIN_ID, getID())
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        return UserPeer.doSelect(c);
    }

    /**
     * Lists the regular users of this domain (including system users).
     *
     * @@return The user list.
     */
    public PeerBackedList getUsers(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        PeerBackedList a = getUsers(itemsPerPage, base, filter);
        Log.debug("Foudn " + a.size());
        return a;
    }

    /**
     * Lists only the regular users of this domain.  Uses the
     * <code>ADMIN_EMAIL_ACCOUNT</code> property to filter system users.
     *
     * @@return The user list.
     */
    public PeerBackedList getNonSystemUsers(Integer itemsPerPage,
                                            Criteria filter)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.TYPE, User.REGULAR_TYPE)
            .add(UserPeer.EMAIL,
                 (Object)HelmProperties.getProperty("ADMIN_EMAIL"),
                 Criteria.NOT_EQUAL);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
     */
    public PaginatableList getUserGroups()
        throws Exception
    {
        return getUserGroups(new Integer(0), null);
    }

    /**
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
     */
    public PaginatableList getUserGroups(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.TYPE, User.GROUP_TYPE);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists the user groups and then the users of the domain.
     *
     * @@return The user list.
     */
    public PeerBackedList getGroupsAndUsers
        (Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Object[] types = {User.GROUP_TYPE, User.REGULAR_TYPE};
        Criteria base = new Criteria().addIn(UserPeer.TYPE, types);
        base.addDescendingOrderByColumn(UserPeer.TYPE);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists the users in the domain which do not belong to the given
     * user group. Used for displaying lists of users which can be
     * added to the group.
     */ 
    public PeerBackedList getUsersNotInGroup
        (UserGroup group, Integer itemsPerPage, Criteria filter)
         throws Exception
    {
        PeerBackedList users = getUsers(itemsPerPage, filter);
        List myUsers = group.getUsers();
        users.removeAll(myUsers);
        return users;
        /* This doesn't work; we need to do (I think) an outer join.
           Criteria base = new Criteria()
            .addJoin(UserUsergroupPeer.USER_ID, UserPeer.USER_ID)
            .add(UserUsergroupPeer.USER_GROUP_ID, group.getUserId(), 
                 Criteria.ALT_NOT_EQUAL)
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        base.setDistinct();
        return getUsers(itemsPerPage, base, filter);*/
    }

    /**
     * General user list retriever which most of the others call.
     *
     * @@return The user list.
     */
    public PeerBackedList getUsers(Integer itemsPerPage, Criteria base,
                                   Criteria filter)
        throws Exception
    {
        if (base == null) base = new Criteria();
        base.add(UserPeer.DOMAIN_ID, getID());
        Log.debug("Itemsperpage: "+ itemsPerPage.intValue());
        Log.debug("Base: " + base + ", filter " + filter);
        return new PeerBackedList(UserPeer.class, itemsPerPage, base, filter);
    }

    //
    // URL retrieval methods
    //

    /**
     * Returns the URL you'd go to to approve projects for this domain.
     */
    public String projectApprovalURL()
    {
        return getDomainHomeServletURL("ProjectApproval");
    }
    
   /**
    * 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 IllegalArgumentException Thrown if you pass anything but 
    * 'http' or 'http' in the inProtocol param.
    */
    public String getDomainHomeServletURL( String inServlet )
        throws IllegalArgumentException
    {
        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
    */
    public String getDomainHomeFileURL( String file )
        throws IllegalArgumentException
    {
        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 IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     */
    public String getDomainHomeServletURL( String inServlet, String inProtocol )
        throws IllegalArgumentException
    {
        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
    {            
        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 IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     */
    public String getDomainHome( )
        throws IllegalArgumentException
    {
        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 IllegalArgumentException Thrown if you pass anything but 
     * 'http' or 'http' in the inProtocol param.
     */
    public String getDomainHome( String inProtocol )
        throws IllegalArgumentException
    {
        StringBuffer buff = new StringBuffer();

        final String DOMAIN_KEY = "DOMAIN";

        org.tigris.helm.util.URL urlUtil = new org.tigris.helm.util.URL( );
        String protocol = urlUtil.getProtocol( inProtocol );
        String port = urlUtil.getPort( protocol );
        String domain = HelmProperties.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();
    }

    /** 
     * Lists all the user emails in this domain (regular users only).  This 
     * implementation might be better handled entirely in the database. 
     * 
     * @@return The email list. 
     */
    public Set getUniqueUserEmails()
        throws Exception
    {
        Set uniqueEmails = new HashSet();
        List users = getUsers();
        for (Iterator i = users.iterator(); i.hasNext(); ) {
            User user = (User)i.next();
            uniqueEmails.add(user.getEmail());
        }
        return uniqueEmails;
    }

    /**
     * Returns a criteria set up for getting projects in this domain.
     */
    public Criteria getProjectsInDomainCriteria()
    {
        return new Criteria(3)
            .addJoin(ProjectPeer.PROJECT_ID, 
                     ProjectProjectgroupPeer.PROJECT_ID)
            .add(ProjectProjectgroupPeer.PROJECT_GROUP_ID, getID());
    }

    //Deprecated methods

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

    /**
     * @@deprecated Use projectPeer.getHost(), or use $host in
     * templates.
     */
    public Domain getHost()
    {
        return ProjectPeer.getHost();
    }
}
@


1.33
log
@Updated for Turbine API change.
@
text
@d9 1
a9 1
import org.apache.fulcrum.util.parser.ParameterParser;
@


1.32
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d9 1
a9 1
import org.apache.turbine.util.ParameterParser;
@


1.31
log
@Make getPotentialParents work for regular projects.
@
text
@d5 4
a8 5
import org.apache.turbine.om.*;
import org.apache.turbine.om.peer.BasePeer;
import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
d11 3
a13 3
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.db.pool.DBConnection;
@


1.30
log
@Updated to use Helm URL class (just ported from Joist).
@
text
@d210 1
a210 1
        if (type.equals(CATEGORY_TYPE))
a225 1

@


1.29
log
@Updated in light of the port of Joist JoistProperties class to Helm (as class HelmProperties).
@
text
@d482 1
a482 1
        org.joist.util.URL urlUtil = new org.joist.util.URL( );
@


1.28
log
@Implemented project-scoped roles.
@
text
@d16 1
a16 1
import org.joist.util.JoistProperties;
d287 1
a287 1
                 (Object)JoistProperties.getProperty("ADMIN_EMAIL"),
d485 1
a485 1
        String domain = JoistProperties.getProperty( DOMAIN_KEY );
@


1.27
log
@Implemented basic project group and category nesting.
@
text
@d269 3
a271 1
        return getUsers(itemsPerPage, base, filter);
d365 2
@


1.26
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
@d29 1
a29 1
public class Domain extends ProjectGroup
d32 15
d68 18
d87 1
a87 1
    // Methods which return related (non-special) projects.
d91 2
a92 1
     * Lists only the projects in this domain which the given user can see.
d94 2
a95 1
     * @@return The project list.
d101 1
a101 3
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);           
        return getProjects(itemsPerPage, base, filter, acl);
d106 1
a106 1
     * Lists only the project groups in this domain which the given
d109 1
a109 1
     * @@return The list of project groups. 
d127 1
a127 3
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.GROUP_TYPE);
        return getProjects(itemsPerPage, base, filter, acl);
d131 1
a131 23
     * List the categories of the domain in one big lump.
     */
    public List getUnapprovedProjects(AccessControlList acl)
        throws Exception
    {
        return getUnapprovedProjects(new Integer(0), null, acl);
    }

    /**
     * Get the unapproved projects for this domain.
     */
    public PeerBackedList getUnapprovedProjects
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.APPROVED_BY,
                 UserPeer.getNobodyUser().getUserId());
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * List the categories of the domain in one big lump.
d140 1
a140 1
     * List the categories of the domain as a paginatable list.
d146 2
a147 3
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.CATEGORY_TYPE);
        return getProjects(itemsPerPage, base, filter, acl);
d150 2
d153 1
a153 3
     * Lists the base projects in the domain which do not belong to
     * the given project group. Used for displaying lists of projects
     * which can be added to the project group.  
d155 1
a155 3
    public PeerBackedList getProjectsNotInGroup
        (ProjectGroup group, Integer itemsPerPage, Criteria filter, 
         AccessControlList acl)
d158 1
a158 13
        PeerBackedList projects = getProjects(itemsPerPage, filter, acl);
        List myProjects = group.getProjects(acl);
        projects.removeAll(myProjects);
        return projects;
        /* This doesn't work; we need to do (I think) an outer join.
        Criteria base = new Criteria()
            .addJoin(ProjectProjectgroupPeer.PROJECT_ID,
                     ProjectPeer.PROJECT_ID)
            .add(ProjectProjectgroupPeer.PROJECT_GROUP_ID, 
                 group.getProjectId(), Criteria.NOT_EQUAL)
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);
        base.setDistinct();
        return getProjects(itemsPerPage, base, filter, acl);*/
d162 4
a165 1
     * Returns the projects the web pages of which this user can view.
d167 2
a168 1
    public PeerBackedList getProjectsForContentViewing(AccessControlList acl)
d171 5
a175 3
        //TODO: Pass in a method to the future PeerBackedList constructor
        //which takes an ACL.
        return null;
d198 32
@


1.25
log
@Corrected twice-bollexed commit.
@
text
@d29 1
a29 1
public class Domain extends BaseDomain
a30 1

a44 18
    public boolean isHost()
    {
        return (getName().equals(DomainPeer.HOST_DOMAIN_NAME));
    }

    /**
     * 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 Exception
    {
        return ProjectPeer.getDomainProject(this);
    }

d46 3
a48 6
     * Returns the special user which is contains all this domain's users.
     *
     * @@return The special user representing all users in this domain.
     */
    public User getSpecialUser()
        throws Exception
d50 1
a50 28
        return UserPeer.getDomainUser(this);
    }

    //
    // Methods which return related business objects.
    //

    /**
     * Returns the host in which this project resides.
     *
     * @@return The host object.
     */
    public Host getHost()
        throws Exception
    {
        return new Host();
    }

    /**
     * Returns the special project representing the host in which this
     * project resides.
     *
     * @@return The host object.  
     */
    public Project getHostProject()
        throws Exception
    {
        return getHost().getSpecialProject();
a99 19
     * Lists only the projects in this domain which the given user can see.
     */
    public List getProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(new Integer(0), null, acl);
    }

    /**
     * Returns the number of projects in the domain which this user can know
     * about.
     */
    public int getNumberOfProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(acl).size();
    }

    /**
a178 13
     * Get a list of projects matching a base Criteria and a filter
     * criteria, filtering the list further by removing projects
     * that cannot be viewed by the user whose ACL is passed in.
     */    
    private PeerBackedList getProjects(Integer itemsPerPage, Criteria base,
                                       Criteria filter, AccessControlList acl)
        throws Exception
    {
        base.add(ProjectPeer.DOMAIN_ID, getDomainId());
        return ProjectPeer.getProjects(itemsPerPage, base, filter, acl);
    }

    /**
d204 11
d222 1
a222 1
            .add(UserPeer.DOMAIN_ID, getDomainId())
d321 1
a321 1
     * Private general user list retriever which most of the others call.
d325 2
a326 2
    private PeerBackedList getUsers(Integer itemsPerPage, Criteria base,
                                    Criteria filter)
d330 1
a330 1
        base.add(UserPeer.DOMAIN_ID, getDomainId());
a333 12

    /**
     * Lists the news items for this domain.
     */ 
    public PeerBackedList getNews(Integer itemsPerPage, Criteria filter,
                                  AccessControlList acl)
        throws Exception
    {
        return getSpecialProject().getNews(itemsPerPage, filter, acl);
    }


d481 31
@


1.24
log
@Removed stray 'y' introduced by last commit.  Oops.  ;P
@
text
@d363 1
a363 1
        base.addOrderByColumn(UserPeer.TYPE);
@


1.23
log
@Switched to non-deprecated version of method.
@
text
@d363 1
a363 1
        base.addOrderByColumny(UserPeer.TYPE);
@


1.22
log
@change name internally from UserEditAllows.. to UserEditSelfAllows.. --
which is more accurate
@
text
@d363 1
a363 1
        base.addOrderByColumn(UserPeer.TYPE + " DESC");
@


1.21
log
@support for a new conf item (whose default is the current behavior)
to determine whether or not users can edit their own organizations
(if they don't have the User - Edit permission)
@
text
@d43 2
a44 2
    public static final String USER_EDIT_ALLOWS_EDIT_ORGANIZATION_KEY =
        "UserEditAllowsEditOrganization";
@


1.20
log
@Ported Helm from WebMacro to Velocity.
@
text
@d31 1
d33 2
a34 1
     * The key used to reference the short site name property associated with the domain.
d37 8
@


1.19
log
@Added method to obtain a named project from a domain.
@
text
@d12 2
@


1.18
log
@A Heartbreaking Patch of Staggering Genius: adds capacity (but no interface) for deeply nested projects, categories, and project groups. As a side effect, gets rid of the hacky special 'all public projects in domain' group. There are probably bugs in this, and some of those bugs are probably security holes, so watch out.
@
text
@d18 1
a18 1
import org.tigris.helm.security.AccessControlList; 
d245 20
@


1.17
log
@The short site name will be shown instead of "SourceCast" in welcome messages (as specified in the properties file).  If the short site name is not available, the domain name will be used as a fallback.  If even that is not available, then the text "SourceCast" will be used.  This fixes helm.tigris.org IZ #3.
@
text
@a52 12
     * Return the special group containing all public projects in this domain.
     *
     * @@return The special project representing all public projects in this
     *         domain.
     */
    public Project getSpecialPublicProject()
        throws Exception
    {
        return ProjectPeer.getPublicDomainProject(this);
    }   

    /**
@


1.16
log
@Broke long line in JavaDoc comment.
@
text
@d29 5
@


1.16.6.1
log
@Backporting changes (reviewed by edk): The short site name will be shown instead of "SourceCast" in welcome messages (as specified in the properties file).  If the short site name is not available, the domain name will be used as a fallback.  If even that is not available, then the text "SourceCast" will be used.  This fixes helm.tigris.org IZ #3.
@
text
@a28 5
    /**
     * The key used to reference the short site name property associated with the domain.
     */
    public static final String SHORT_SITE_NAME_KEY = "ShortSiteName";

@


1.16.6.2
log
@Backported method by leonardr@@collab.net:

Added method to obtain a named project from a domain.
@
text
@d18 1
a18 1
import org.tigris.helm.security.*; 
a256 20
    }

    /**
     * Gets the project of the specified name in this domain. 
     *
     * @@exception  DoesNotExist if there is no project of that name. 
     * @@exception ACLException if the project exists but the ACL
     *            does not have permission to view it.
     *
     * @@return The requested project.  
     */
    public Project getProject(AccessControlList acl, String name)
        throws ACLException, DoesNotExist, Exception
    {
        Project p = ProjectPeer.getInstanceByName(this, name);
        if (!p.isViewableBy(acl))
        {
            throw new ACLException(acl, "Project - View", null, null);
        }
        return p;
@


1.15
log
@Added header comment.
@
text
@d50 2
a51 1
     * @@return The special project representing all public projects in this domain.
@


1.14
log
@Pushed getID() method into base class as a final method.
@
text
@d23 3
@


1.13
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@a25 10

    //
    // Accessor methods
    //

    public String getID()
    {
        return "" + getDomainId();
    }

a29 4

    //
    // Special representations of this domain.
    //
@


1.12
log
@Added method to return the project approval URL for a domain.
@
text
@d16 1
a16 2
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
@


1.11
log
@* Imported JoistProperties to avoid referencing it by its full path
  unnecessarilly.
* Added getNonSystemUsers() method to return a PeerBackedList for use
  on UserList.  Filters via the email address value of the ADMIN_EMAIL
  property.
* Removed useless and annoying NullPointerExceptions.  That a method
  can throw a NullPointerException is *implicit* in Java.
* TODO: Make use of org.joist.util.URL methods and constants.
@
text
@d405 8
@


1.10
log
@Sync'd with latest Turbine changes.  Mostly this consists of the use of the new SimpleKey class to handle primary database keys.
@
text
@d14 2
d277 1
a277 1
        Criteria base = new Criteria()
d280 1
a280 1
        return UserPeer.doSelect(base);
d284 1
a284 1
     * Lists only the regular users of this domain.
d297 18
d370 1
a370 1
                 Criteria.NOT_EQUAL)
d401 1
a413 1
    * @@exception NullPointerException If i can't get JoistProperties instance.
d418 1
a418 1
        throws NullPointerException, IllegalArgumentException
a428 3
    * 
    *
    * @@exception NullPointerException If i can't get JoistProperties instance.
d431 1
a431 1
        throws NullPointerException, IllegalArgumentException
a446 1
     * @@exception NullPointerException If i can't get JoistProperties instance.
d451 1
a451 1
        throws NullPointerException, IllegalArgumentException
a475 1
     * @@exception NullPointerException If i can't get JoistProperties instance.
d480 1
a480 1
        throws NullPointerException, IllegalArgumentException
a495 1
     * @@exception NullPointerException If i can't get JoistProperties instance.
d500 1
a500 1
        throws NullPointerException, IllegalArgumentException
a501 6
        // 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" );
                    
d509 1
a509 1
        String domain = properties.getProperty( DOMAIN_KEY );
@


1.9
log
@separated out groups from categories in get methods
@
text
@d5 1
a5 1
import org.apache.turbine.om.BaseObject;
@


1.8
log
@now listing both groups and categories
@
text
@d147 2
a148 3
        Object[] types = {Project.GROUP_TYPE, Project.CATEGORY_TYPE};
        Criteria base = new Criteria().addIn(ProjectPeer.TYPE, types);
        base.addOrderByColumn(ProjectPeer.TYPE + " DESC");
@


1.7
log
@added the method getUniqueUserEmails(). :jody
PR:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d147 3
a149 2
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.GROUP_TYPE);           
@


1.6
log
@Added way of getting all project groups.
@
text
@d516 18
@


1.5
log
@Added wrapper method to get all the user groups.
@
text
@d124 13
@


1.4
log
@Oops, I mixed my metaphors.
@
text
@d286 11
@


1.3
log
@This isn't pretty, but it has the advantage of working.
@
text
@d212 1
a212 1
        List myProjects = group.getProjects($acl);
@


1.2
log
@adding files from the branch to the head
@
text
@d211 5
d223 1
a223 1
        return getProjects(itemsPerPage, base, filter, acl);
d318 6
a323 1
        Criteria base = new Criteria()
d329 1
a329 1
        return getUsers(itemsPerPage, base, filter);
@


1.1
log
@file Domain.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 482
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 482
package org.tigris.helm.om;

import java.util.*;

import org.apache.turbine.om.BaseObject;
import org.apache.turbine.om.peer.BasePeer;
import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.ParameterParser;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.db.pool.DBConnection;

import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.AccessControlList; 
import org.tigris.helm.tool.PeerTool; 
import org.tigris.helm.tool.paginate.*; 

/** 
 */
public class Domain extends BaseDomain
{

    //
    // Accessor methods
    //

    public String getID()
    {
        return "" + getDomainId();
    }

    public boolean isHost()
    {
        return (getName().equals(DomainPeer.HOST_DOMAIN_NAME));
    }

    //
    // Special representations of this 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 Exception
    {
        return ProjectPeer.getDomainProject(this);
    }

    /**
     * Return the special group containing all public projects in this domain.
     *
     * @@return The special project representing all public projects in this domain.
     */
    public Project getSpecialPublicProject()
        throws Exception
    {
        return ProjectPeer.getPublicDomainProject(this);
    }   

    /**
     * Returns the special user which is contains all this domain's users.
     *
     * @@return The special user representing all users in this domain.
     */
    public User getSpecialUser()
        throws Exception
    {
        return UserPeer.getDomainUser(this);
    }

    //
    // Methods which return related business objects.
    //

    /**
     * Returns the host in which this project resides.
     *
     * @@return The host object.
     */
    public Host getHost()
        throws Exception
    {
        return new Host();
    }

    /**
     * Returns the special project representing the host in which this
     * project resides.
     *
     * @@return The host object.  
     */
    public Project getHostProject()
        throws Exception
    {
        return getHost().getSpecialProject();
    }

    //
    // Methods which return related (non-special) projects.
    //

    /**
     * Lists only the projects in this domain which the given user can see.
     *
     * @@return The project list.
     */
    public PeerBackedList getProjects(Integer itemsPerPage, Criteria filter, 
                                      AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);           
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Lists only the project groups in this domain which the given
     * user can see.
     *
     * @@return The list of project groups. 
     */
    public PeerBackedList getProjectGroups
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.GROUP_TYPE);           
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Lists only the projects in this domain which the given user can see.
     */
    public List getProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(new Integer(0), null, acl);
    }

    /**
     * Returns the number of projects in the domain which this user can know
     * about.
     */
    public int getNumberOfProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(acl).size();
    }

    /**
     * List the categories of the domain in one big lump.
     */
    public List getUnapprovedProjects(AccessControlList acl)
        throws Exception
    {
        return getUnapprovedProjects(new Integer(0), null, acl);
    }

    /**
     * Get the unapproved projects for this domain.
     */
    public PeerBackedList getUnapprovedProjects
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.APPROVED_BY,
                 UserPeer.getNobodyUser().getUserId());
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * List the categories of the domain in one big lump.
     */
    public List getCategories(AccessControlList acl)
        throws Exception
    {
        return getCategories(new Integer(0), null, acl);
    }

    /**
     * List the categories of the domain as a paginatable list.
     */
    public PeerBackedList getCategories(Integer itemsPerPage, Criteria filter,
                                        AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.CATEGORY_TYPE);
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Lists the base projects in the domain which do not belong to
     * the given project group. Used for displaying lists of projects
     * which can be added to the project group.  
     */
    public PeerBackedList getProjectsNotInGroup
        (ProjectGroup group, Integer itemsPerPage, Criteria filter, 
         AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .addJoin(ProjectProjectgroupPeer.PROJECT_ID,
                     ProjectPeer.PROJECT_ID)
            .add(ProjectProjectgroupPeer.PROJECT_GROUP_ID, 
                 group.getProjectId(), Criteria.NOT_EQUAL)
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);
        base.setDistinct();
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Returns the projects the web pages of which this user can view.
     */
    public PeerBackedList getProjectsForContentViewing(AccessControlList acl)
        throws Exception
    {
        //TODO: Pass in a method to the future PeerBackedList constructor
        //which takes an ACL.
        return null;
    }

    /**
     * Get a list of projects matching a base Criteria and a filter
     * criteria, filtering the list further by removing projects
     * that cannot be viewed by the user whose ACL is passed in.
     */    
    private PeerBackedList getProjects(Integer itemsPerPage, Criteria base,
                                       Criteria filter, AccessControlList acl)
        throws Exception
    {
        base.add(ProjectPeer.DOMAIN_ID, getDomainId());
        return ProjectPeer.getProjects(itemsPerPage, base, filter, acl);
    }

    //
    // Methods which return (non-special) users associated with this
    // domain. 
    //

    /**
     * Overrides a generated method in BaseDomain which returns all
     * users, not just the base ones. Returns a Vector. Bleah.
     */
    public Vector getUsers()
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.DOMAIN_ID, getDomainId())
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        return UserPeer.doSelect(base);
    }

    /**
     * Lists only the regular users of this domain.
     *
     * @@return The user list.
     */
    public PeerBackedList getUsers(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
     */
    public PaginatableList getUserGroups(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(UserPeer.TYPE, User.GROUP_TYPE);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists the user groups and then the users of the domain.
     *
     * @@return The user list.
     */
    public PeerBackedList getGroupsAndUsers
        (Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        Object[] types = {User.GROUP_TYPE, User.REGULAR_TYPE};
        Criteria base = new Criteria().addIn(UserPeer.TYPE, types);
        base.addOrderByColumn(UserPeer.TYPE + " DESC");
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists the users in the domain which do not belong to the given
     * user group. Used for displaying lists of users which can be
     * added to the group.
     */ 
    public PeerBackedList getUsersNotInGroup
        (UserGroup group, Integer itemsPerPage, Criteria filter)
         throws Exception
    {
        Criteria base = new Criteria()
            .addJoin(UserUsergroupPeer.USER_ID, UserPeer.USER_ID)
            .add(UserUsergroupPeer.USER_GROUP_ID, group.getUserId(), 
                 Criteria.NOT_EQUAL)
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        base.setDistinct();
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Private general user list retriever which most of the others call.
     *
     * @@return The user list.
     */
    private PeerBackedList getUsers(Integer itemsPerPage, Criteria base,
                                    Criteria filter)
        throws Exception
    {
        if (base == null) base = new Criteria();
        base.add(UserPeer.DOMAIN_ID, getDomainId());
        return new PeerBackedList(UserPeer.class, itemsPerPage, base, filter);
    }


    /**
     * Lists the news items for this domain.
     */ 
    public PeerBackedList getNews(Integer itemsPerPage, Criteria filter,
                                  AccessControlList acl)
        throws Exception
    {
        return getSpecialProject().getNews(itemsPerPage, filter, acl);
    }

    //
    // URL retrieval methods
    //
    
   /**
    * 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.
    */
    public String getDomainHomeServletURL( String inServlet )
        throws NullPointerException, IllegalArgumentException
    {
        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.
    */
    public String getDomainHomeFileURL( String file )
        throws NullPointerException, IllegalArgumentException
    {
        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.
     */
    public String getDomainHomeServletURL( String inServlet, String inProtocol )
        throws NullPointerException, IllegalArgumentException
    {
        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
    {            
        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.
     */
    public String getDomainHome( )
        throws NullPointerException, IllegalArgumentException
    {
        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.
     */
    public String getDomainHome( String inProtocol )
        throws NullPointerException, IllegalArgumentException
    {
        // 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.1.2.1
log
@Classes ported to the Turbine Peer system. -dlr and leonardr
@
text
@a0 55
package org.tigris.helm.om;

import java.util.*;

import org.apache.turbine.om.BaseObject;
import org.apache.turbine.om.peer.BasePeer;
import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.ParameterParser;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.db.pool.DBConnection;

import org.tigris.helm.om.peer.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.tool.PeerTool;

/** 
 */
public class Domain extends BaseDomain
{

    //
    // Accessor methods
    //

    public String getID()
    {
        return "" + getDomainId();
    }

    /**
     * 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 Exception
    {
        return ProjectPeer.getDomainProject(this);
    }

    /**
     * Return the special group containing all public projects in this domain.
     *
     * @@return The special project representing all public projects in this domain.
     */
    public Project getSpecialPublicProject()
        throws Exception
    {
        return ProjectPeer.getPublicDomainProject(this);
    }
}
@


1.1.2.2
log
@Misc. changes to support PermissionDump.
@
text
@a45 23
     * Returns the host in which this project resides.
     *
     * @@return The host object.
     */
    public Host getHost()
        throws Exception
    {
        return new Host();
    }

    /**
     * Returns the special project representing the host in which this
     * project resides.
     *
     * @@return The host object.  
     */
    public Project getHostProject()
        throws Exception
    {
        return getHost().getSpecialProject();
    }

    /**
d54 1
a54 1
    }   
@


1.1.2.3
log
@Ported url methods.
@
text
@a77 136

    //
    // URL retrieval methods
    //
    
   /**
    * 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.
    */
    public String getDomainHomeServletURL( String inServlet )
        throws NullPointerException, IllegalArgumentException
    {
        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.
    */
    public String getDomainHomeFileURL( String file )
        throws NullPointerException, IllegalArgumentException
    {
        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.
     */
    public String getDomainHomeServletURL( String inServlet, String inProtocol )
        throws NullPointerException, IllegalArgumentException
    {
        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
    {            
        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.
     */
    public String getDomainHome( )
        throws NullPointerException, IllegalArgumentException
    {
        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.
     */
    public String getDomainHome( String inProtocol )
        throws NullPointerException, IllegalArgumentException
    {
        // 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.1.2.4
log
@Ported methods for obtaining users.
@
text
@a78 27
    /**
     * Lists only the regular users of this domain.
     *
     * @@return The user list.
     */
    //TODO: Paginate this. public PaginatableUserList getUsers
    public List getUsers
        (Integer itemsPerPage, Criteria searchCriteria)
        throws Exception
    {
        //PaginatableUserList u = null;
        List u = null;
        if (searchCriteria == null) searchCriteria = new Criteria();
        searchCriteria.add(UserPeer.DOMAIN_ID, getDomainId())
            .add(UserPeer.TYPE, User.REGULAR_TYPE);

        u = UserPeer.doSelect(searchCriteria);
        //u = new PaginatableUserList(itemsPerPage, query, searchCriterion);
        return u;
    }

    public List getUsers()
        throws Exception
    {
        return getUsers(new Integer(0), null);
    }

@


1.1.2.5
log
@Ported getSpecialUser message.
@
text
@a45 11
     * Returns the special user which is contains all this domain's users.
     *
     * @@return The special user representing all users in this domain.
     */
    public User getSpecialUser()
        throws Exception
    {
        return UserPeer.getDomainUser(this);
    }

    /**
@


1.1.2.6
log
@Made method paginatable.
@
text
@d16 1
a16 2
import org.tigris.helm.tool.PeerTool; 
import org.tigris.helm.tool.paginate.*; 
d95 2
a96 1
    public PeerBackedList getUsers
d100 4
a103 2
        Criteria baseCriteria = new Criteria();
        baseCriteria.add(UserPeer.DOMAIN_ID, getDomainId())
d106 3
a108 2
        return new PeerBackedList(UserPeer.class, 
                                  itemsPerPage, baseCriteria, searchCriteria);
@


1.1.2.7
log
@Brought getUsers wrapper up to speed, pagination-wise.
@
text
@d108 1
a108 1
    public PeerBackedList getUsers()
@


1.1.2.8
log
@Removed unused overload of getUsers() which conflicts with the version
defined in the parent class.
@
text
@d96 2
a97 2
    public PeerBackedList getUsers(Integer itemsPerPage,
                                   Criteria searchCriteria)
d106 6
@


1.1.2.9
log
@Additions to User to support the new face of pagination/filtering.
@
text
@d96 2
a97 1
    public PeerBackedList getUsers(Integer itemsPerPage, Criteria filter)
d105 1
a105 7
                                  itemsPerPage, baseCriteria, filter);
    }

    public PeerBackedList getUsers()
        throws Exception
    {
        return getUsers(new Integer(0), null);
@


1.1.2.10
log
@Newest generated code (complex model this time).  Removed getUsers from Domain to side step decl conflict.
@
text
@d107 6
@


1.1.2.11
log
@Added method overriding similar method in BaseDomain.
@
text
@a106 13
    /**
     * Overrides a generated method in BaseDomain which returns all
     * users, not just the base ones.
     */
    public Vector getUsers()
        throws Exception
    {
        Criteria c = new Criteria();
        c.add(UserPeer.DOMAIN_ID, getDomainId())
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        return UserPeer.doSelect(c);
    }

@


1.1.2.12
log
@leonardr commit: New method for ProjectList.
@
text
@a15 1
import org.tigris.helm.security.AccessControlList; 
a117 24
    }

    /**
     * Lists only the projects in this domain which the given user can see.
     *
     * @@return The user list.
     */
    public PeerBackedList getProjects(Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria baseCriteria = new Criteria();
        baseCriteria.add(ProjectPeer.DOMAIN_ID, getDomainId())
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);           
        PeerBackedList l = new PeerBackedList
            (ProjectPeer.class, itemsPerPage, baseCriteria, filter);
        for (Iterator i = l.iterator(); i.hasNext();)
        {
            Project p = (Project)i.next();            
            if (!p.isViewableBy(acl))
            {
                l.remove(p);
            }
        }
        return l;
@


1.1.2.13
log
@Added method by which a domain can determine whether or not it is the host domain.
@
text
@a33 5
    public boolean isHost()
    {
        return (getName().equals(HostPeer.HOST_DOMAIN_NAME));
    }

@


1.1.2.14
log
@Fixed typo.
@
text
@d36 1
a36 1
        return (getName().equals(DomainPeer.HOST_DOMAIN_NAME));
@


1.1.2.15
log
@New support for properly filtered paginated lists.
@
text
@a97 69
     * List the categories of the domain in one big lump.
     */
    public List getCategories(AccessControlList acl)
        throws Exception
    {
        return getCategories(new Integer(0), null, acl);
    }

    /**
     * List the categories of the domain as a paginatable list.
     */
    public PeerBackedList getCategories(Integer itemsPerPage, Criteria filter,
                                        AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.DOMAIN_ID, getDomainId())
            .add(ProjectPeer.TYPE, Project.CATEGORY_TYPE);
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * List the categories of the domain in one big lump.
     */
    public List getUnapprovedProjects(AccessControlList acl)
        throws Exception
    {
        return getUnapprovedProjects(new Integer(0), null, acl);
    }

    /**
     * Get the unapproved projects for this domain.
     */
    public PeerBackedList getUnapprovedProjects
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.APPROVED_BY, 
                 UserPeer.getNobodyUser().getUserId());
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Get a list of projects matching a base Criteria and a filter
     * criteria, filtering the list further by removing projects
     * that cannot be viewed by the user whose ACL is passed in.
     */
    private PeerBackedList getProjects(Integer itemsPerPage, Criteria base,
                                       Criteria filter, AccessControlList acl)
        throws Exception
    {
        List toRemove = new ArrayList();
        if (base == null) base = new Criteria();
        PeerBackedList l = new PeerBackedList(ProjectPeer.class, 
                                              itemsPerPage, base, filter);
        for (Iterator i = l.iterator(); i.hasNext();)
        {
            Project p = (Project)i.next();
            if (!p.isViewableBy(acl))
            {
                toRemove.add(p);
            }           
        }
        l.removeAll(toRemove);
        return l;
    }

    /**
@


1.1.2.16
log
@Added in all the Domain methods from the head which are still relevant. All but three are actually implemented.
@
text
@a38 4
    //
    // Special representations of this domain.
    //

a52 11
     * Return the special group containing all public projects in this domain.
     *
     * @@return The special project representing all public projects in this domain.
     */
    public Project getSpecialPublicProject()
        throws Exception
    {
        return ProjectPeer.getPublicDomainProject(this);
    }   

    /**
a62 4
    //
    // Methods which return related business objects.
    //

a85 4
    //
    // Methods which return related (non-special) projects.
    //

d87 1
a87 1
     * Lists only the projects in this domain which the given user can see.
d89 1
a89 1
     * @@return The user list.
d91 1
a91 2
    public PeerBackedList getProjects(Integer itemsPerPage, Criteria filter, 
                                      AccessControlList acl)
d94 2
a95 49
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);           
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Returns the number of projects in the domain which this user can know
     * about.
     */
    public int getNumberOfProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(new Integer(0), null, acl).size();
    }

    /**
     * List the categories of the domain in one big lump.
     */
    public List getUnapprovedProjects(AccessControlList acl)
        throws Exception
    {
        return getUnapprovedProjects(new Integer(0), null, acl);
    }

    /**
     * Get the unapproved projects for this domain.
     */
    public PeerBackedList getUnapprovedProjects
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.APPROVED_BY,
                 UserPeer.getNobodyUser().getUserId());
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
     */
    public PeerBackedList getProjectGroups(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        //TODO: Fix doSelect so that it will return ProjectGroups
        //so that this can call getProjects();
        return null;
    }
d114 1
d120 4
a123 8
     * Lists the projects in the domain which do not belong to the given
     * project group. Used for displaying lists of projects which can be
     * added to the project group.
     */ 
    public PeerBackedList getProjectsNotInGroup
        (ProjectGroup group, Integer itemsPerPage, Criteria filter, 
         AccessControlList acl)
         throws Exception
d125 1
a125 4
        Criteria base = new Criteria()
            .add(ProjectProjectgroupPeer.PROJECT_GROUP_ID, group.getProjectId(), 
                 Criteria.NOT_EQUAL);
        return getProjects(itemsPerPage, base, filter, acl);
d129 1
a129 1
     * Returns the projects the web pages of which this user can view.
d131 2
a132 1
    public PeerBackedList getProjectsForContentViewing(AccessControlList acl)
d135 4
a138 3
        //TODO: Pass in a method to the future PeerBackedList constructor
        //which takes an ACL.
        return null;
d150 1
a151 2
        base.add(ProjectPeer.DOMAIN_ID, getDomainId());

a153 1
        List toRemove = new ArrayList();
a165 5
    //
    // Methods which return (non-special) users associated with this
    // domain. 
    //

d174 2
a175 1
        Criteria base = new Criteria()
a176 2
        return getUsers(itemsPerPage, base, filter);
    }
d178 2
a179 11
    /**
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
     */
    public PeerBackedList getUserGroups(Integer itemsPerPage, Criteria filter)
        throws Exception
    {
        //TODO: Fix doSelect so that it will return UserGroups
        //so that this can call getUsers();
        return null;
d184 1
a184 1
     * users, not just the base ones. Returns a Vector. Bleah.
d189 2
a190 2
        Criteria base = new Criteria()
            .add(UserPeer.DOMAIN_ID, getDomainId())
d192 1
a192 1
        return UserPeer.doSelect(base);
d196 1
a196 1
     * Lists the user groups and then the users of the domain.
d200 1
a200 2
    public PeerBackedList getGroupsAndUsers
        (Integer itemsPerPage, Criteria filter)
d203 14
a216 33
        Object[] types = {User.GROUP_TYPE, User.REGULAR_TYPE};
        Criteria base = new Criteria().addIn(UserPeer.TYPE, types);
        base.addOrderByColumn(UserPeer.TYPE + " DESC");
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Lists the users in the domain which do not belong to the given
     * user group. Used for displaying lists of users which can be
     * added to the group.
     */ 
    public PeerBackedList getUsersNotInGroup
        (UserGroup group, Integer itemsPerPage, Criteria filter)
         throws Exception
    {
        Criteria base = new Criteria()
            .add(UserUsergroupPeer.USER_GROUP_ID, group.getUserId(), 
                 Criteria.NOT_EQUAL);
        return getUsers(itemsPerPage, base, filter);
    }

    /**
     * Private general user list retriever which most of the others call.
     *
     * @@return The user list.
     */
    private PeerBackedList getUsers(Integer itemsPerPage, Criteria base,
                                    Criteria filter)
        throws Exception
    {
        if (base == null) base = new Criteria();
        base.add(UserPeer.DOMAIN_ID, getDomainId());
        return new PeerBackedList(UserPeer.class, itemsPerPage, base, filter);
@


1.1.2.17
log
@Hacky support for user group listing.
@
text
@d262 3
a264 2
     * Overrides a generated method in BaseDomain which returns all
     * users, not just the base ones. Returns a Vector. Bleah.
d266 1
a266 1
    public Vector getUsers()
d269 3
a271 4
        Criteria base = new Criteria()
            .add(UserPeer.DOMAIN_ID, getDomainId())
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
        return UserPeer.doSelect(base);
d275 2
a276 3
     * Lists only the non-special user groups in this domain.
     *
     * @@return The user group list.
d278 1
a278 1
    public PaginatableList getUserGroups(Integer itemsPerPage, Criteria filter)
a280 2
        //TODO: Fix doSelect so that it will return UserGroups
        //so that this can call getUsers();
d283 2
a284 4
            .add(UserPeer.TYPE, User.GROUP_TYPE);
        base.putAll(filter);
        List users = UserPeer.doGroupSelect(base);
        return new PrebuiltList(itemsPerPage, users);
@


1.1.2.18
log
@Fixed criteria for NotInGroup methods.
@
text
@d200 2
a201 4
            .addJoin(ProjectProjectgroupPeer.PROJECT_ID, ProjectPeer.PROJECT_ID)
            .add(ProjectProjectgroupPeer.PROJECT_GROUP_ID, 
                 group.getProjectId(), Criteria.NOT_EQUAL)
            .add(ProjectPeer.TYPE, Project.REGULAR_TYPE);
a316 1
            .addJoin(UserUsergroupPeer.USER_ID, UserPeer.USER_ID)
d318 1
a318 2
                 Criteria.NOT_EQUAL)
            .add(UserPeer.TYPE, User.REGULAR_TYPE);
@


1.1.2.19
log
@Ported UserRoleAdd servlet.
@
text
@a123 9
     * Lists only the projects in this domain which the given user can see.
     */
    public List getProjects(AccessControlList acl)
        throws Exception
    {
        return getProjects(new Integer(0), null, acl);
    }

    /**
d130 1
a130 1
        return getProjects(acl).size();
@


1.1.2.20
log
@Fixing compile errors.
@
text
@d299 2
a300 1
        return new PeerBackedList(UserPeer.class, itemsPerPage, base, filter);
@


1.1.2.21
log
@Adding support for project group manipulation servlets.
@
text
@d112 1
a112 1
     * @@return The project list.
a123 15
     * Lists only the project groups in this domain which the given
     * user can see.
     *
     * @@return The list of project groups. 
     */
    public PeerBackedList getProjectGroups
        (Integer itemsPerPage, Criteria filter, AccessControlList acl)
        throws Exception
    {
        Criteria base = new Criteria()
            .add(ProjectPeer.TYPE, Project.GROUP_TYPE);           
        return getProjects(itemsPerPage, base, filter, acl);
    }

    /**
d165 13
d231 1
a231 1
     */    
d236 1
d238 14
a251 1
        return ProjectPeer.getProjects(itemsPerPage, base, filter, acl);
@


1.1.2.22
log
@Big wide-ranging patch being committed all at once due to network downness. Features of this patch include: lots of added and updated JavaDoc, conversion of emails to use TemplateInterpolator and HelmEmailer, rearrangement of methods, changing code that gets mappings and loops over them to code that just gets the appropriate objects from the peer using AddJoin.
@
text
@d201 4
a204 4
     * Lists the base projects in the domain which do not belong to
     * the given project group. Used for displaying lists of projects
     * which can be added to the project group.  
     */
d208 1
a208 1
        throws Exception
d211 1
a211 2
            .addJoin(ProjectProjectgroupPeer.PROJECT_ID,
                     ProjectPeer.PROJECT_ID)
a214 1
        base.setDistinct();
a318 1
        base.setDistinct();
@


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


1.1.2.24
log
@Corrected some methods now that doSelect returns subclasses.
@
text
@d251 3
a253 2
     * Overrides a generated method in BaseDomain which returns all
     * users, not just the base ones. Returns a Vector. Bleah.
d255 1
a255 1
    public Vector getUsers()
a258 1
            .add(UserPeer.DOMAIN_ID, getDomainId())
d260 1
a260 1
        return UserPeer.doSelect(base);
d264 2
a265 3
     * Lists only the regular users of this domain.
     *
     * @@return The user list.
d267 1
a267 1
    public PeerBackedList getUsers(Integer itemsPerPage, Criteria filter)
d271 1
d273 1
a273 1
        return getUsers(itemsPerPage, base, filter);
d284 2
d287 1
d289 2
a290 1
        return getUsers(itemsPerPage, base, filter);
@


1.1.2.25
log
@Added method to get domain news.
@
text
@a335 11

    /**
     * Lists the news items for this domain.
     */ 
    public PeerBackedList getNews(Integer itemsPerPage, Criteria filter,
                                  AccessControlList acl)
        throws Exception
    {
        return getSpecialProject().getNews(itemsPerPage, filter, acl);
    }

@


