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


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

1.5
date	2001.03.07.01.53.27;	author lucas;	state Exp;
branches;
next	1.4;

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

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

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

1.1
date	2001.01.28.01.19.02;	author dlr;	state dead;
branches
	1.1.1.1
	1.1.2.1;
next	;

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

1.1.2.1
date	2001.01.28.01.19.02;	author dlr;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.01.29.04.41.21;	author dlr;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2001.02.01.21.07.23;	author dlr;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2001.02.15.20.50.44;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.6
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.CollabNet/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.tool;

import java.util.List;

import org.apache.torque.om.BaseObject;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.Domain;

/**
 * Tigris-specific Turbine Peer interface.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: PeerTool.java,v 1.5 2001/03/07 01:53:27 lucas Exp $
 */
public class PeerTool
{
    /**
     * @@see #getFirstBO(List baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what, (String)null);
    }

    /**
     * @@see #getFirstBO(List baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              Domain where)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what,
                          "domain named " + where.getName());
    }

    /**
     * Gets the first business object from a <code>List</code> of such objects.
     *
     * @@param baseObjects A list of <code>BaseObject</code> instances.
     * @@param what        Description of the business object that may not exist.
     * @@param where       Description of where the business object may 
     *                    not exist, or <code>null</code> to ignore.
     * @@return            The first business object.
     *
     * @@exception DoesNotExist If there are no business objects in the list.
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              String where)
        throws DoesNotExist
    {
        if (baseObjects != null && baseObjects.size() > 0) {
            return (BaseObject)baseObjects.get(0);
        }

        // If we reach this point the business object does not exist.
        if (where != null) {
            throw new DoesNotExist(what, where);
        }
        else {
            throw new DoesNotExist(what);
        }
    }

    /**
     * Macro to pull the <code>SimpleKey</code> from a <code>BaseObject</a>
     * in a format usable by a <code>Criteria</code> object.
     */
    public static final long getKey(BaseObject bo)
    {
        return Long.parseLong(bo.getPrimaryKey().toString());
    }
}
@


1.5
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d52 1
a52 1
import org.apache.turbine.om.*;
d56 1
d61 1
a61 1
 * @@version $Id: PeerTool.java,v 1.4 2001/02/24 02:06:18 dlr Exp $
@


1.4
log
@Added getKey(BaseObject bo) to hold us until John comes up with
something better.
@
text
@a55 1

d60 1
a60 1
 * @@version $Id: PeerTool.java,v 1.3 2001/02/23 18:57:01 stack Exp $
@


1.3
log
@Fixing getFirstBO method overrides javadoc 'see' references
@
text
@d52 1
a52 1
import org.apache.turbine.om.BaseObject;
d61 1
a61 1
 * @@version $Id: PeerTool.java,v 1.2 2001/02/21 03:02:30 edk Exp $
d111 9
@


1.2
log
@adding files from the branch to the head
@
text
@d61 1
a61 1
 * @@version $Id: PeerTool.java,v 1.1.1.1 2001/02/21 00:35:21 dlr Exp $
d66 1
a66 1
     * @@see #getFirstBO(String baseObjects, String what, String where)
d75 1
a75 1
     * @@see #getFirstBO(String baseObjects, String what, String where)
@


1.1
log
@file PeerTool.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 112
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 112
/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.CollabNet/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.tool;

import java.util.List;

import org.apache.turbine.om.BaseObject;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.Domain;

/**
 * Tigris-specific Turbine Peer interface.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: PeerTool.java,v 1.1.2.4 2001/02/15 20:50:44 leonardr Exp $
 */
public class PeerTool
{
    /**
     * @@see #getFirstBO(String baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what, (String)null);
    }

    /**
     * @@see #getFirstBO(String baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              Domain where)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what,
                          "domain named " + where.getName());
    }

    /**
     * Gets the first business object from a <code>List</code> of such objects.
     *
     * @@param baseObjects A list of <code>BaseObject</code> instances.
     * @@param what        Description of the business object that may not exist.
     * @@param where       Description of where the business object may 
     *                    not exist, or <code>null</code> to ignore.
     * @@return            The first business object.
     *
     * @@exception DoesNotExist If there are no business objects in the list.
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              String where)
        throws DoesNotExist
    {
        if (baseObjects != null && baseObjects.size() > 0) {
            return (BaseObject)baseObjects.get(0);
        }

        // If we reach this point the business object does not exist.
        if (where != null) {
            throw new DoesNotExist(what, where);
        }
        else {
            throw new DoesNotExist(what);
        }
    }
}
@


1.1.2.1
log
@Classes ported to the Turbine Peer system. -dlr and leonardr
@
text
@a0 100
/* ================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.CollabNet/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.tool;

import java.util.List;

import org.apache.turbine.om.BaseObject;

import org.tigris.helm.DoesNotExist;

/**
 * Tigris-specific Turbine Peer interface.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: $
 */
public class PeerTool
{
    /**
     * @@see #getFirstBO(String baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what, null);
    }

    /**
     * Gets the first business object from a <code>List</code> of such objects.
     *
     * @@param baseObjects A list of <code>BaseObject</code> instances.
     * @@param what        Description of the business object that may not exist.
     * @@param where       Description of where the business object may 
     *                    not exist, or <code>null</code> to ignore.
     * @@return            The first business object.
     *
     * @@exception DoesNotExist If there are no business objects in the list.
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              String where)
        throws DoesNotExist
    {
        if (baseObjects != null && baseObjects.size() > 0) {
            return (BaseObject)baseObjects.get(0);
        }

        // If we reach this point the business object does not exist.
        if (where != null) {
            throw new DoesNotExist(what, where);
        }
        else {
            throw new DoesNotExist(what);
        }
    }
}
@


1.1.2.2
log
@Overloaded getFirstBO() method to a Domain object for the "where"
parameter.
@
text
@a54 1
import org.tigris.helm.om.Domain;
d60 1
a60 1
 * @@version $Id: PeerTool.java,v 1.1.2.1 2001/01/28 01:19:02 dlr Exp $
d70 1
a70 12
        return getFirstBO(baseObjects, what, (String)null);
    }

    /**
     * @@see #getFirstBO(String baseObjects, String what, String where)
     */
    public static final BaseObject getFirstBO(List baseObjects, String what,
                                              Domain where)
        throws DoesNotExist
    {
        return getFirstBO(baseObjects, what,
                          "in domain named " + where.getName());
@


1.1.2.3
log
@No "in" necessary in "where" description string.
@
text
@d61 1
a61 1
 * @@version $Id: PeerTool.java,v 1.1.2.2 2001/01/29 04:41:21 dlr Exp $
d82 1
a82 1
                          "domain named " + where.getName());
@


1.1.2.4
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d61 1
a61 1
 * @@version $Id: PeerTool.java,v 1.1.2.3 2001/02/01 21:07:23 dlr Exp $
@


