head	1.17;
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.17
date	2001.08.30.00.41.25;	author dlr;	state Exp;
branches;
next	1.16;

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

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

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

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

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

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

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

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

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

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

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

1.5
date	2001.05.23.01.50.13;	author dlr;	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.24.03.59.53;	author dlr;	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.33.05;	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.16.03.01.27;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.17
log
@Added sanity check.
@
text
@package org.tigris.helm.om;

import org.apache.torque.util.Criteria;
import org.apache.commons.util.exception.NestableException;

import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;

/** 
 * Expression of a user's interest in a project.  Any edits to objects
 * of this type are considered equvialent to edits to a user.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 */
public class UserProjectInterest extends BaseUserProjectInterest
{
    /**
     * Records expression of user interest in a project.
     *
     * @@param user The user who is expressing the interest, and whose
     * ACL is checked for permission.
     * @@param project The project in which the user has interest.
     * @@return The new expression of interest.
     * @@exception ACLException Insufficient permission.
     * @@exception ACLException Internal error, likely database-related.
     */
    public static UserProjectInterest add(User user, Project project)
        throws ACLException, Exception
    {
        if (user.isAlreadyInterestedBy(project))
        {
            throw new Exception("User " + user.getLoginName() +
                                " is already interested by project " +
                                project.getWordMark());
        }

        user.assertEditPermission(user.getACL());
        UserProjectInterest interest = new UserProjectInterest();
        interest.setUser(user);
        interest.setProject(project);
        interest.save();
        return interest;
    }

    /**
     * Removes this interest.
     *
     * @@param acl The ACL of the user attempting the removal.
     * @@exception ACLException Insufficient permission.
     * @@exception Exception Internal error.
     */
    public void delete(AccessControlList acl)
        throws ACLException, Exception
    {
        getUser().assertEditPermission(acl);
        UserProjectInterestPeer.doDelete(this);
    }
}
@


1.16
log
@Added proper JavaDoc and a permission check.
@
text
@d30 7
@


1.15
log
@delete() now done.
@
text
@d10 2
a11 1
 * Expression of a user's interest in a project.
d17 10
d28 1
a28 1
        throws Exception
d30 1
a30 1
        // TODO: check user ACL?
@


1.14
log
@Added necessary import.
@
text
@d37 2
a38 8
        if (acl.getUser().equals(getUser()))
        {
            UserProjectInterestPeer.doDelete(this);
        }
        else
        {
            getUser().assertEditPermission(acl);
        }
@


1.13
log
@Much slicker implementation of delete().  Thanks to Leonard for the
idea.
@
text
@d7 1
@


1.12
log
@doDelete() is in our peer
@
text
@d30 2
a31 2
     * @@exception Exception Internal error or invalid operation for
     * ACL.
d34 1
a34 1
        throws Exception
d42 1
a42 3
            throw new Exception("User " + acl.getUser() +
                                " attempted to remove interest of user " +
                                getUser() + " in project " + getProject());
@


1.11
log
@Fleshed out delete().  Does not use standard permission system
checking; we may want to change it so it does (?).
@
text
@d38 1
a38 1
            doDelete(this);
@


1.10
log
@Added delete() stub.
@
text
@d9 1
a9 1
 * A user's interest in a project.
d26 7
d34 1
d36 10
a45 1
        // TODO: Check ACL and do delete.
@


1.9
log
@It's helpful to save our new interest to the database.
@
text
@d6 2
d24 5
@


1.8
log
@Added add() class method.
@
text
@d20 1
@


1.7
log
@Updated for Turbine API change.
@
text
@a2 6
// JDK classes
import java.util.*;

// Turbine classes
import org.apache.torque.util.BasePeer;
import org.tigris.helm.om.*;
a3 5
import org.apache.commons.util.ObjectUtils;
import org.apache.commons.util.StringUtils;
import org.apache.fulcrum.util.parser.ParameterParser;
import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;
a4 1
import org.apache.torque.pool.DBConnection;
d7 4
a10 5
    The skeleton for this class was autogenerated by Torque on: Fri Jan 26 19:21:34 PST 2001. 
    You should add additional methods to this class to meet the
    application requirements.  This class will only be generated as
    long as the firstTime file does not exist in the build directory.
*/
d13 9
@


1.6
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d12 1
a12 1
import org.apache.turbine.util.ParameterParser;
@


1.5
log
@Ported Helm from WebMacro to Velocity.
@
text
@d7 1
a7 2
import org.apache.turbine.om.*;
import org.apache.turbine.om.peer.BasePeer;
d9 3
a11 3
import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
d14 3
a16 3
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.db.pool.DBConnection;
@


1.4
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d15 2
@


1.3
log
@Sync'd with latest Turbine changes.  Mostly this consists of the use of the new SimpleKey class to handle primary database keys.
@
text
@d9 1
a9 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
@d7 1
a7 1
import org.apache.turbine.om.BaseObject;
@


1.1
log
@file UserProjectInterest.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 26
@


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

// JDK classes
import java.util.*;

// Turbine classes
import org.apache.turbine.om.BaseObject;
import org.apache.turbine.om.peer.BasePeer;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
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;

/** 
    The skeleton for this class was autogenerated by Torque on: Fri Jan 26 19:21:34 PST 2001. 
    You should add additional methods to this class to meet the
    application requirements.  This class will only be generated as
    long as the firstTime file does not exist in the build directory.
*/
public class UserProjectInterest extends BaseUserProjectInterest
{
}
@


1.1.2.1
log
@Classes ported to the Turbine Peer system. -dlr and leonardr
@
text
@a0 25
package org.tigris.helm.om;

// JDK classes
import java.util.*;

// Turbine classes
import org.apache.turbine.om.BaseObject;
import org.apache.turbine.om.peer.BasePeer;
import org.tigris.helm.om.peer.*;
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;

/** 
    The skeleton for this class was autogenerated by Torque on: Fri Jan 26 19:21:34 PST 2001. 
    You should add additional methods to this class to meet the
    application requirements.  This class will only be generated as
    long as the firstTime file does not exist in the build directory.
*/
public class UserProjectInterest extends BaseUserProjectInterest
{
}
@


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


