head	1.12;
access;
symbols
	TIGRIS_0_9_2_4:1.7
	TIGRIS_0_9_2_3:1.7
	HELM_PEER_PORT_BRANCH:1.11.0.2
	TURBINE_PEER:1.11
	TIGRIS_0_9_2_1:1.11
	TIGRIS_0_9_2:1.7.0.2
	TIGRIS_0_9_0:1.4.0.2;
locks; strict;
comment	@# @;


1.12
date	2001.02.21.02.17.29;	author dlr;	state dead;
branches;
next	1.11;

1.11
date	2001.01.26.18.29.00;	author edk;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2001.01.26.05.24.05;	author edk;	state dead;
branches;
next	1.9;

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

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

1.7
date	2000.12.29.17.11.52;	author leonardr;	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.13.23.45.52;	author leonardr;	state Exp;
branches;
next	1.3;

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

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

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

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


desc
@@


1.12
log
@Deprecated by peer port merge.
@
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.business;

import java.sql.*;
import java.util.*;
import java.io.*;

import org.webmacro.util.Log;

import com.workingdogs.village.*;

import org.joist.database.*;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.database.AuditLogEntryManager;
import org.tigris.helm.domain.*;
import org.tigris.helm.project.Project;

public class AuditLogEntry extends BusinessObject
{
    private AuditLogEntryManager aleMgr;

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

    public static Log log = new Log("AuditEntry", "Audit Log Entry");

    public static final boolean debug = true;

    public AuditLogEntry (Connection conn, DataManager dMgr, 
                          String affectedType, String affectedObjectID, 
                          String initiatingUser, String description)
        throws SQLException, DataSetException
    {
        super(conn, dMgr);
        try {
            setRecord(aleMgr.addAuditLogEntry
                      (conn, affectedType, affectedObjectID, initiatingUser, 
                       description));
        } catch (DoesNotExist ignore) {}
    }

    public AuditLogEntry (Connection conn, DataManager dMgr, String entryID)
        throws SQLException, DataSetException, DoesNotExist
    {
        super(conn, dMgr);
        setRecord(aleMgr.getEntry(conn, entryID));
    }

    public AuditLogEntry (Connection conn, DataManager dMgr, Record r)
        throws DataSetException
    {
        super(conn, dMgr);
        try {
            setRecord(r);
        } catch (DoesNotExist ignore) {}
    }

    public boolean isViewable (AccessControlList acl)
        throws DataSetException
    {
        boolean viewable = true;
        String type = getAffectedObjectType();
        String id = getAffectedObjectID();        
        if (acl.hasPermissionForHost("Host - Audit Log - View"))
        {
            viewable = true;
        }
      
        //FIXME: Return true if of project type and if user has domain view
        //in the domain in which that project resides.
        if (type.equals(AuditLogEntryManager.DOMAIN_TYPE)
            && acl.hasPermissionForDomain("Domain - Audit Log - View", id))
        {
            viewable = true;
        }

        if (type.equals(AuditLogEntryManager.PROJECT_TYPE) 
            && acl.hasPermissionForProject("Project - Audit Log - View", id))
        {
            viewable = true;
        }
        return viewable;
    }

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

    public void appendToRationale(String appendage)
        throws SQLException, DataSetException
    {
        try {
            setRecord(aleMgr.appendToRationale(conn, getID(), appendage));
        } catch (DoesNotExist ignore) {}
    }
        
    public String getID()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.ENTRY_ID).asString();
    }

    public String getTimestamp()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.TIMESTAMP).asString();
    }

    public String getAffectedObjectType()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.AFFECTED_TYPE).asString();
    }

    public String getAffectedObjectID()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.AFFECTED_OBJECT_ID).asString();
    }

    public String getWhere()
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        String type = getAffectedObjectType();
        String id = getAffectedObjectID();
        String where = "Host";
        if (type.equals(AuditLogEntryManager.DOMAIN_TYPE))
        {
            log.info("Trying to get domain record for domain " + id);
            try {
                Domain domain = new Domain(conn, dMgr, id);
                where = "Domain " + domain.getName();
            } catch (DoesNotExist e) {
                where = "Now-defunct domain with id " + id;
            }
        } else if (type.equals(AuditLogEntryManager.PROJECT_TYPE)) {
            log.info("Trying to get project record for project " + id);
            try {
                Project project = new Project(conn, dMgr, id);            
                where = "Project " + project.getName()
                    + " in domain " +  project.getDomainName();
            } catch (DoesNotExist e) {
                where = "Now-defunct project with id " + id;
            }
        }
        return where;
    }

    public String getInitiatingUserID()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.INITIATING_USER).asString();
    }

    public User getInitiatingUser()
        throws DataSetException, SQLException, DoesNotExist, 
               JoistDatabaseException
    {
        String userID = getInitiatingUserID();
        return User.getInstance(conn, dMgr, userID);            
    }

    public String getDescription()
        throws DataSetException
    {
        return rec.getValue(AuditLogEntryManager.DESCRIPTION).asString();
    }

    public String getRationale()
        throws DataSetException
    {
        String rationale = rec.getValue(AuditLogEntryManager.RATIONALE).asString();
        return rationale == null ? "" : rationale;
    }
}

@


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


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


1.10
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
@a59 1
import org.tigris.helm.database.DBException;
d81 1
a81 1
        throws DBException
d86 1
a86 1
                      (affectedType, affectedObjectID, initiatingUser, 
d92 1
a92 1
        throws DBException, DoesNotExist
d95 1
a95 1
        setRecord(aleMgr.getEntry(entryID));
d99 1
a99 1
        throws DBException
d141 1
a141 1
        throws DBException
d173 2
a174 1
        throws DoesNotExist, DBException
d202 1
a202 1
        throws DBException
d208 2
a209 1
        throws DoesNotExist, DBException
d216 1
a216 1
        throws DBException
d222 1
a222 1
        throws DBException
d224 2
a225 3
        String rationale =
            rec.getValue(AuditLogEntryManager.RATIONALE).asString();
        return (rationale == null ? "" : rationale);
@


1.9
log
@Ported UserManager and RoleManager to Helm. Started moving other TableManagers toward a grab-connection-on-demand model. Massive breakage ensues. dlr and I are working on it.
@
text
@@


1.8
log
@Making use of DBException.
@
text
@d87 1
a87 1
                      (conn, affectedType, affectedObjectID, initiatingUser, 
d96 1
a96 1
        setRecord(aleMgr.getEntry(conn, entryID));
d100 1
a100 1
        throws DataSetException
@


1.7
log
@Many, many pagination changes.
@
text
@d60 1
d82 1
a82 1
        throws SQLException, DataSetException
d93 1
a93 1
        throws SQLException, DataSetException, DoesNotExist
d142 1
a142 1
        throws SQLException, DataSetException
d174 1
a174 2
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d202 1
a202 1
        throws DataSetException
d208 1
a208 2
        throws DataSetException, SQLException, DoesNotExist, 
               JoistDatabaseException
d215 1
a215 1
        throws DataSetException
d221 1
a221 1
        throws DataSetException
d223 3
a225 2
        String rationale = rec.getValue(AuditLogEntryManager.RATIONALE).asString();
        return rationale == null ? "" : rationale;
@


1.6
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d99 1
a99 1
        throws SQLException, DataSetException
@


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

d212 1
a212 1
        return new User(conn, dMgr, userID);            
@


1.4
log
@More changes for audit log detail.
@
text
@d107 5
@


1.3
log
@Rationale append works now.
@
text
@d62 2
a63 2
import org.tigris.helm.domain.BusinessObject;
import org.tigris.helm.domain.User;
d172 28
a199 1
    //BusinessObject getAffectedObject (?)
@


1.2
log
@More work on AuditEventDetail.
@
text
@d143 3
a145 1
        aleMgr.appendToRationale(conn, getID(), appendage);
@


1.1
log
@Added Host object--this has some code which will be phased out of Domain.
@
text
@d195 2
a196 1
        return rec.getValue(AuditLogEntryManager.RATIONALE).asString();
@

