head	1.11;
access;
symbols
	TIGRIS_0_9_2_4:1.6
	TIGRIS_0_9_2_3:1.6
	HELM_PEER_PORT_BRANCH:1.10.0.2
	TURBINE_PEER:1.10
	TIGRIS_0_9_2_1:1.10
	TIGRIS_0_9_2:1.6.0.2
	TIGRIS_0_9_0:1.4.0.2;
locks; strict;
comment	@# @;


1.11
date	2001.02.21.03.23.57;	author edk;	state dead;
branches;
next	1.10;

1.10
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.10.2.1;
next	1.9;

1.9
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.8;

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

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

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

1.5
date	2000.12.22.03.02.59;	author dlr;	state Exp;
branches;
next	1.4;

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

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

1.2
date	2000.12.05.23.53.30;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2000.12.05.23.28.58;	author leonardr;	state Exp;
branches;
next	;

1.10.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	;


desc
@@


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

package org.tigris.helm.domain;

import java.sql.*;
import java.util.Dictionary;

import org.webmacro.util.*;

import com.workingdogs.village.*;

import org.joist.database.*;
import org.tigris.helm.database.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
/**
 * Business object representing a resource.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 */
public class Resource extends BusinessObject
{
    /**
     * Open the log file.
     */
    private static Log log = new Log("Resource", "Resource Business Object");

    /**
     * Whether to log debugging information.
     */
    private static boolean debug = true;

    protected final String getTableName() { return ResourceManager.TABLE_NAME; }

    private ResourceManager resMgr;

    public Resource (Connection conn, DataManager dMgr, Record rec)
        throws DoesNotExist, DataSetException
    {
        super(conn, dMgr, rec);
    }

    public Resource (Connection conn, DataManager dMgr, String resourceID)
	throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        super(conn, dMgr);        
        setRecord(resMgr.getResource(conn, resourceID));
    }
    
    public Resource (Connection conn, DataManager dMgr, AccessControlList acl,
                     Domain domain, String pattern, String description)
        throws ACLException, SQLException, DataSetException
    {
        super(conn, dMgr);
        acl.assertPermissionForDomain("Resource - Add", domain.getID());
        Record r = resMgr.addResource(conn, pattern, description);
        try {
            setRecord(r);
        } catch (DoesNotExist ignore) {} //Can't happen for records.
    }

    public void update (AccessControlList acl, Domain domain,
                        String newPattern, String newDescription)
        throws ACLException, SQLException, DataSetException, 
               JoistDatabaseException
    {
        acl.assertPermissionForDomain("Resource - Edit", domain.getID());
        if (newPattern == null) 
        {
            newPattern = getPattern();
        }
        if (newDescription == null)
        {
            newDescription = getDescription();
        }
        Record r = resMgr.updateResource
            (conn, getID(), newPattern, newDescription);
        try {
            setRecord(r);
        } catch (DoesNotExist ignore) {} //Can't happen for records.
    }

    protected void createManagers()
    {
        resMgr=(ResourceManager)dMgr.getManager
            ("org.tigris.helm.database.ResourceManager");
    }

    public String getID()
        throws DataSetException
    {
        return getField(ResourceManager.RESOURCE_ID);
    }

    public String getPattern()
        throws DataSetException
    {
        return getField(ResourceManager.RESOURCE_PATTERN);
    }

    public String getDescription()
        throws DataSetException
    {
        return getField(ResourceManager.RESOURCE_DESCRIPTION);
    }
}

@


1.10
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@@


1.10.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@@


1.9
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@d70 1
a70 1
    private static Log log = new Log("resrc", "Resource Business Object");
d77 2
d81 2
a82 1
    protected final String getTableName()
d84 1
a84 1
        return ResourceManager.TABLE_NAME;
d87 3
a89 2
    public Resource (DataManager dMgr, Record rec)
        throws DoesNotExist, DBException
d91 2
a92 7
        super(dMgr, rec);
    }

    public Resource (DataManager dMgr, String resourceID)
	throws DoesNotExist, DBException
    {
        super(dMgr, resMgr.getResource(resourceID));
d95 3
a97 3
    public Resource (DataManager dMgr, AccessControlList acl, Domain domain, 
                     String pattern, String description)
        throws ACLException, DBException
d99 1
a99 1
        super(dMgr);
d101 1
a101 1
        Record r = resMgr.addResource(pattern, description);
d109 2
a110 1
        throws ACLException, DBException
d121 2
a122 1
        Record r = resMgr.updateResource(getID(), newPattern, newDescription);
d130 1
a130 1
        resMgr = (ResourceManager)dMgr.getManager
d135 1
a135 1
        throws DBException
d141 1
a141 1
        throws DBException
d147 1
a147 1
        throws DBException
d152 1
@


1.8
log
@* Removed all references to JDBC connections.  Connections are now pulled
  directly from the connection pool.
* Made use of DBException.
- dlr@@collab.net
@
text
@@


1.7
log
@Making use of DBException.
@
text
@d70 1
a70 1
    private static Log log = new Log("Resource", "Resource Business Object");
d77 1
a77 1
    protected final String getTableName() { return ResourceManager.TABLE_NAME; }
d79 4
a82 1
    private ResourceManager resMgr;
d84 1
a84 1
    public Resource (Connection conn, DataManager dMgr, Record rec)
d87 1
a87 1
        super(conn, dMgr, rec);
d90 1
a90 1
    public Resource (Connection conn, DataManager dMgr, String resourceID)
d93 1
a93 2
        super(conn, dMgr);        
        setRecord(resMgr.getResource(conn, resourceID));
d96 2
a97 2
    public Resource (Connection conn, DataManager dMgr, AccessControlList acl,
                     Domain domain, String pattern, String description)
d100 1
a100 1
        super(conn, dMgr);
d102 1
a102 1
        Record r = resMgr.addResource(conn, pattern, description);
d121 1
a121 2
        Record r = resMgr.updateResource
            (conn, getID(), newPattern, newDescription);
d129 1
a129 1
        resMgr=(ResourceManager)dMgr.getManager
a150 1

@


1.6
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d82 1
a82 1
        throws DoesNotExist, DataSetException
d88 1
a88 2
	throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d96 1
a96 1
        throws ACLException, SQLException, DataSetException
d108 1
a108 2
        throws ACLException, SQLException, DataSetException, 
               JoistDatabaseException
d133 1
a133 1
        throws DataSetException
d139 1
a139 1
        throws DataSetException
d145 1
a145 1
        throws DataSetException
@


1.5
log
@Propogated object cache interface.
@
text
@a106 5
    protected Dictionary getCache ()
    {
        return null;
    }

@


1.4
log
@Support for updating resources.
@
text
@d50 2
d53 1
d105 5
@


1.3
log
@New servlet - Resource Add
@
text
@d101 22
a122 1
        } catch (DoesNotExist ignore) {} //We just created it
@


1.2
log
@Enabled security check of records passed into business objects.
@
text
@d56 1
a56 1

d90 12
@


1.1
log
@Added a check so that business objects cannot be created with records from the wrong table. Also added some new business objects.
@
text
@d74 2
a76 2

    private static final String tableName = "HELM_RESOURCE";
@

