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


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

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

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

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

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

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

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

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

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

1.5
date	2001.03.08.02.39.35;	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.32.53;	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.09.00.57.57;	author dlr;	state Exp;
branches;
next	1.1.2.3;

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

1.1.2.4
date	2001.02.16.03.01.27;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.14
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.commons.util.exception.NestableException;
import org.apache.torque.pool.DBConnection;

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

/**
 * Business object representing an invitation.
 */
public class Invitation extends BaseInvitation
{
    public static final String BAD_TICKET_MESSAGE = "Your ticket is no longer valid. It may have been used already. For more information or to get another ticket, reply to the original invitation message you received.";

    public static final String WRONG_PROJECT_FOR_TICKET_MESSAGE = "Your ticket is not valid for this project.";

    /**
     * Creates a new instance.
     * <p>
     * TODO: Refactor Joist's Emailer class to make use of 
     * <code>senderName</code>.
     */
    public static void sendInvitations(Domain domain, List recipients,
                                       User sender, Project project,
                                       String msg)
        throws DoesNotExist, NestableException, Exception
    {
        Iterator i = recipients.iterator();
        while (i.hasNext()) 
        {
            String recipient = (String) i.next();
            InvitationPeer.add(domain, recipient, sender, project, msg);
        }
    }

    /**
     * Is this invitation valid for a given project?
     */
    public boolean isMatch(Project project)
    {
        if (project == null)
        {
            return false;
        }
        else
        {
            return (getProjectId().equals(project.getProjectId()));
        }
    }

    /**
     * Deletes an invitation
     */
    public void delete()
        throws Exception
    {
        Criteria c = new Criteria(1)
            .add(InvitationPeer.INVITATION_ID, getID());
        Log.debug("Deleting invitation " + c);
        InvitationPeer.doDelete(c);
    }
}
@


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


1.12
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.11
log
@Ported Helm from WebMacro to Velocity.
@
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 4
a14 4
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.db.pool.DBConnection;
d39 1
a39 1
        throws DoesNotExist, TurbineException, Exception
@


1.10
log
@cleanup
@
text
@d13 2
@


1.9
log
@Invitation message is now in a template where it belongs.
@
text
@a24 1

d53 2
a54 1
        if (project == null) {
d57 2
a58 1
        else {
d69 2
a70 1
        Criteria c = new Criteria(1).add(InvitationPeer.INVITATION_ID, getID());
@


1.8
log
@Factored out messages into constants, and used message in another place.
@
text
@a40 19
        String senderName = sender.getRealName();
        String host = domain.getName();
        String projectName = project.getName();
        String projectDescription = project.getLongDescription();

        StringBuffer buf = new StringBuffer();
        buf.append(senderName).append(" invites you to join the ");
        buf.append(projectName).append(" project");
        String subject = buf.toString();

        buf.setLength(0);
        buf.append(msg);
        buf.append("\n\nThe description of this project is as follows:\n\n");
        buf.append(projectDescription);
        buf.append("\n\nYou can reply to this message to ask the owner for " +
                   "more information\nabout this project.\n");

        String partialMessage = buf.toString();

d42 2
a43 1
        while (i.hasNext()) {
d45 1
a45 2
            InvitationPeer.add(domain, recipient, sender, project, subject,
                               partialMessage);
@


1.7
log
@Implemented delete method.
@
text
@d25 5
@


1.6
log
@Added delete(acl) stub.
@
text
@d77 1
a77 1
     * TODO: Finish implementing method.
d79 2
a80 2
    public void delete(AccessControlList acl)
        throws ACLException
d82 3
a84 2
        //TODO: acl.assertPermission("Invitation - Delete", ...);
        //InvitationPeer.doDelete(this);
@


1.5
log
@Corrected implementation of isMatch() method.  Previously,
getProjectId() returned an int and this was the correct
implementation.  Times, they are constantly a'changing.
@
text
@d17 2
d20 2
a21 1
/** 
d74 10
@


1.4
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d69 1
a69 1
            return (getProjectId() == project.getProjectId());
@


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
@d15 1
a15 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
@d5 1
a5 1
import org.apache.turbine.om.BaseObject;
@


1.1
log
@file Invitation.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 73
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 73
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.TurbineException;
import org.apache.turbine.util.db.pool.DBConnection;

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

/** 
 */
public class Invitation extends BaseInvitation
{
    /**
     * Creates a new instance.
     * <p>
     * TODO: Refactor Joist's Emailer class to make use of 
     * <code>senderName</code>.
     */
    public static void sendInvitations(Domain domain, List recipients,
                                       User sender, Project project,
                                       String msg)
        throws DoesNotExist, TurbineException, Exception
    {
        String senderName = sender.getRealName();
        String host = domain.getName();
        String projectName = project.getName();
        String projectDescription = project.getLongDescription();

        StringBuffer buf = new StringBuffer();
        buf.append(senderName).append(" invites you to join the ");
        buf.append(projectName).append(" project");
        String subject = buf.toString();

        buf.setLength(0);
        buf.append(msg);
        buf.append("\n\nThe description of this project is as follows:\n\n");
        buf.append(projectDescription);
        buf.append("\n\nYou can reply to this message to ask the owner for " +
                   "more information\nabout this project.\n");

        String partialMessage = buf.toString();

        Iterator i = recipients.iterator();
        while (i.hasNext()) {
            String recipient = (String) i.next();
            InvitationPeer.add(domain, recipient, sender, project, subject,
                               partialMessage);
        }
    }

    /**
     * Is this invitation valid for a given project?
     */
    public boolean isMatch(Project project)
    {
        if (project == null) {
            return false;
        }
        else {
            return (getProjectId() == project.getProjectId());
        }
    }
}
@


1.1.2.1
log
@Classes ported to the Turbine Peer system. -dlr and leonardr
@
text
@a0 20
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.*;

/** 
 */
public class Invitation extends BaseInvitation
{
}
@


1.1.2.2
log
@Ported most methods.
@
text
@a11 1
import org.apache.turbine.util.TurbineException;
a14 1
import org.tigris.helm.*;
a19 58
    /**
     * Creates a new instance.
     * <p>
     * TODO: Refactor Joist's Emailer class to make use of 
     * <code>senderName</code>.
     */
    public static void sendInvitations(Domain domain, List recipients,
                                       User sender, Project project,
                                       String msg)
        throws DoesNotExist, TurbineException, Exception
    {
        String senderName = sender.getRealName();
        String host = domain.getName();
        String projectName = project.getName();
        String projectDescription = project.getLongDescription();

        StringBuffer buf = new StringBuffer();
        buf.append(senderName).append(" invites you to join the ");
        buf.append(projectName).append(" project");
        String subject = buf.toString();

        buf.setLength(0);
        buf.append(msg);
        buf.append("\n\nThe description of this project is as follows:\n\n");
        buf.append(projectDescription);
        buf.append("\n\nYou can reply to this message to ask the owner for " +
                   "more information\nabout this project.\n");

        String partialMessage = buf.toString();

        Iterator i = recipients.iterator();
        while (i.hasNext()) {
            String recipient = (String) i.next();
            InvitationPeer.add(domain, recipient, sender, project, subject,
                               partialMessage);
        }
    }

    /**
     * @@deprecated Use isMatch(String projectID) instead.
     */
    public boolean isValidForProject(String projectID)
    {
        return isMatch(projectID);
    }

    /**
     * Is this invitation valid for a given project?
     */
    public boolean isMatch(String projectID)
    {
        if (projectID == null) {
            return false;
        }
        else {
            return (getProjectId() == Integer.parseInt(projectID));
        }
    }
@


1.1.2.3
log
@Take an object instead of an ID.
@
text
@d61 8
d71 1
a71 1
    public boolean isMatch(Project project)
d73 1
a73 1
        if (project == null) {
d77 1
a77 1
            return (getProjectId() == project.getProjectId());
@


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


