head	1.14;
access;
symbols
	TIGRIS_1_1_0RC2:1.6.6.1
	TIGRIS_1_1_0RC1:1.6.6.1
	TIGRIS_1_1:1.6.6.1.0.2
	TIGRIS_1_0_8:1.6.6.1
	TIGRIS_1_0_8RC3:1.6.6.1
	TIGRIS_1_0_8RC2:1.6.6.1
	TIGRIS_1_0_8RC1:1.6.6.1
	TIGRIS_1_0_7:1.6.6.1
	TIGRIS_1_0_7RC3:1.6.6.1
	TIGRIS_1_0_7RC2:1.6.6.1
	TIGRIS_1_0_7RC1:1.6.6.1
	TIGRIS_1_0_6:1.6.6.1
	TIGRIS_1_0_6RC5:1.6.6.1
	TIGRIS_1_0_6RC4:1.6.6.1
	TIGRIS_1_0_6RC3:1.6.6.1
	TIGRIS_1_0_6RC2:1.6.6.1
	TIGRIS_1_0_6RC1:1.6.6.1
	TIGRIS_1_0_5:1.6.6.1
	TIGRIS_1_0_5RC6:1.6.6.1
	TIGRIS_1_0_5RC5:1.6.6.1
	TIGRIS_1_0_5RC4:1.6.6.1
	TIGRIS_1_0_5RC3:1.6.6.1
	TIGRIS_1_0_5RC2:1.6.6.1
	TIGRIS_1_0_5RC1:1.6.6.1
	TIGRIS_1_0_4:1.6.6.1
	TIGRIS_1_0_3:1.6.6.1
	TIGRIS_1_0_2:1.6
	TIGRIS_1_0_1:1.6
	TIGRIS_1_0:1.6.0.6
	TIGRIS_1_0_0:1.6
	TIGRIS_1_0_0_RC1:1.6.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.07.30.18.40.41;	author leonardr;	state Exp;
branches;
next	1.10;

1.10
date	2001.06.18.22.12.20;	author leonardr;	state Exp;
branches;
next	1.9;

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

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

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

1.6
date	2001.03.07.01.53.21;	author lucas;	state Exp;
branches
	1.6.6.1;
next	1.5;

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

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

1.3
date	2001.02.22.19.14.04;	author leonardr;	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.37;	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.02.14.17;	author dlr;	state Exp;
branches;
next	1.1.2.3;

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

1.1.2.4
date	2001.02.12.16.24.32;	author leonardr;	state Exp;
branches;
next	1.1.2.5;

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

1.6.6.1
date	2001.04.27.19.48.44;	author leonardr;	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.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.torque.pool.DBConnection;
import org.apache.torque.util.Criteria;

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

/** 
 * Helm audit log entry.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: AuditLogEntry.java,v 1.13 2001/08/27 08:41:27 dlr Exp $
 */
public class AuditLogEntry extends BaseAuditLogEntry 
    implements BOType, ViewableBy
{

    //
    // Mutator methods.
    //

    /**
     * Creates and returns new audit log entry.
     */
    public static AuditLogEntry add (String type, String affectedID, 
                                     User initiatingUser, String description) 
        throws Exception
    {
        AuditLogEntry entry = new AuditLogEntry();
        entry.setAffectedType(type);
        entry.setAffectedId(Integer.parseInt(affectedID));
        entry.setInitiatingUser(initiatingUser.getUserId());
        entry.setDescription(description);
        entry.save();
        return entry;
    }

    /**
     * Adds the specified text to the rationale for this action.
     */
    public void appendToRationale(String appendage)
        throws Exception
    {
        String oldRationale = getRationale();
        if (oldRationale == null) oldRationale = "";
        StringBuffer rationale = new StringBuffer(oldRationale);
        if (!"".equals(oldRationale))
        {
            rationale.append("\n<hr>\n");
        }
        rationale.append(appendage);
        setRationale(rationale.toString());
        save();
    }

    //
    // Permission-related methods.
    //

    /**
     * Returns whether or not the specified ACL has permission to look
     * at this audit log entry.
     */
    public boolean isViewableBy(AccessControlList acl)
        throws Exception
    {
        boolean viewable = false;
        
        Project associatedProject = null;
        try 
        {           
            associatedProject = ProjectPeer.getInstance(getAffectedID());
        }
        catch (Exception ignore)
        {
        }
        
        if (associatedProject == null)
        {
            if (acl.hasPermission("Audit Log - View"))
            {
                viewable = true;
            }
        }
        else if (acl.hasPermission("Audit Log - View", associatedProject))
        {
            viewable = true;
        }

        return viewable;
    }
        

    //
    // Accessor methods.
    //

    /**
     * Returns a string describing the business object under which this
     * entry was logged.
     */
    public String getWhere()
        throws Exception
    {
        String type = getAffectedType();
        String id = getAffectedID();
        String where = "Host";
        if (type.equals(DOMAIN_TYPE))
        {
            try 
            {
                Domain domain = (Domain)ProjectPeer.getInstance(id);
                where = "Domain " + domain.getName();
            }
            catch (Exception e) 
            {
                where = "Now-defunct domain with id " + id;
            }
        } 
        else if (type.equals(PROJECT_TYPE)) 
        {
            try 
            {
                Project project = ProjectPeer.getInstance(id);            
                where = "Project " + project.getName()
                    + " in domain " +  project.getDomain().getName();
            }
            catch (Exception e) 
            {
                where = "Now-defunct project with id " + id;
            }
        }
        return where;
    }


    public String getAffectedID()
    {
        return String.valueOf(getAffectedId());
    }
}
@


1.13
log
@Updated for Turbine API change.
@
text
@d8 1
a8 1
import org.apache.fulcrum.util.parser.ParameterParser;
d23 1
a23 1
 * @@version $Id: AuditLogEntry.java,v 1.12 2001/08/11 09:08:02 dlr Exp $
@


1.12
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d8 1
a8 1
import org.apache.turbine.util.ParameterParser;
d23 1
a23 1
 * @@version $Id: AuditLogEntry.java,v 1.11 2001/07/30 18:40:41 leonardr Exp $
@


1.11
log
@Action cleanup. Some role actions, and Audit Log - View, had three actions apiece when one would do. We're now down to 76 actions.
@
text
@d5 3
a7 4
import org.apache.turbine.om.*;
import org.apache.turbine.om.peer.BasePeer;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
d10 4
a13 4
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.db.pool.DBConnection;
import org.apache.turbine.util.db.Criteria;
d23 1
a23 1
 * @@version $Id: AuditLogEntry.java,v 1.10 2001/06/18 22:12:20 leonardr Exp $
@


1.10
log
@Huge patch of the day: Got rid of redundant HELM_DOMAIN table. The project representation of the domain and the host is now the canonical one. Host and Domain now subclass ProjectGroup. The canonical representation of a project's membership in a domain group is now the corresponding mapping in HELM_PROJECT_PROJECTGROUP. Schema changes: No more HELM_DOMAIN table (obviously); no more DOMAIN_ID in HELM_PROJECT; HELM_USER and HELM_VC_VIEW now have foreign keys in HELM_PROJECT instead of HELM_DOMAIN.
@
text
@d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.9 2001/06/12 23:10:43 leonardr Exp $
d80 7
a86 3
        String type = getAffectedType();
        String id = getAffectedID();        
        if (acl.hasPermission("Host - Audit Log - View"))
a87 1
            viewable = true;
d90 1
a90 3
        //FIXME: Return true if of project type and if user has domain view
        //in the domain in which that project resides.
        if (type.equals(DOMAIN_TYPE))
d92 1
a92 9
            Domain domain = null;
            try 
            {
                domain = (Domain)ProjectPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (domain != null &&
                acl.hasPermission("Domain - Audit Log - View", domain))
d97 1
a97 2

        if (type.equals(PROJECT_TYPE))
d99 1
a99 12
            Project project = null;
            try 
            {
                project = ProjectPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (project != null && acl.hasPermission
                ("Project - Audit Log - View", project))
            {
                viewable = true;
            }
@


1.9
log
@PeerBackedList performance boost and refactoring. This may be more complicated than it needs to be; rather than getting ever-increasing proportions of the table, it might be faster in most cases to get the whole table, so long as you stop processing results when the list is full enough.
@
text
@d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.8 2001/05/23 01:50:13 dlr Exp $
d94 1
a94 1
                domain = DomainPeer.getInstance(id);
d141 3
a143 2
            try {
                Domain domain = DomainPeer.getInstance(id);
d145 3
a147 1
            } catch (Exception e) {
d150 5
a154 2
        } else if (type.equals(PROJECT_TYPE)) {
            try {
d158 3
a160 1
            } catch (Exception e) {
@


1.8
log
@Ported Helm from WebMacro to Velocity.
@
text
@d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.7 2001/04/27 19:44:37 leonardr Exp $
d26 2
a27 1
public class AuditLogEntry extends BaseAuditLogEntry implements BOType
@


1.7
log
@Default to not viewable, not to viewable.
@
text
@d11 2
d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.6 2001/03/07 01:53:21 lucas Exp $
@


1.6
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d22 1
a22 1
 * @@version $Id: AuditLogEntry.java,v 1.5 2001/02/24 03:59:53 dlr Exp $
d76 1
a76 1
        boolean viewable = true;
@


1.6.6.1
log
@Default to deny access, not to grant it.
@
text
@d22 1
a22 1
 * @@version $Id: AuditLogEntry.java,v 1.6 2001/03/07 01:53:21 lucas Exp $
d76 1
a76 1
        boolean viewable = false;
@


1.5
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 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

d22 1
a22 1
 * @@version $Id: AuditLogEntry.java,v 1.4 2001/02/22 19:16:46 leonardr Exp $
@


1.4
log
@Most people make the opposite mistake, but not me!
@
text
@d5 1
a5 1
import org.apache.turbine.om.BaseObject;
d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.3 2001/02/22 19:14:04 leonardr Exp $
@


1.3
log
@Handle null rationales.
@
text
@d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.2 2001/02/21 03:02:22 edk Exp $
d56 1
a56 1
        if (oldRationale == null) oldRationale == "";
@


1.2
log
@adding files from the branch to the head
@
text
@d24 1
a24 1
 * @@version $Id: AuditLogEntry.java,v 1.1.1.1 2001/02/21 00:32:37 dlr Exp $
d49 3
d56 1
d58 1
a58 1
        if (!oldRationale.equals(""))
@


1.1
log
@file AuditLogEntry.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@d1 159
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 159
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.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.apache.turbine.util.db.Criteria;

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

import org.tigris.helm.security.AccessControlList;

/** 
 * Helm audit log entry.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: AuditLogEntry.java,v 1.1.2.5 2001/02/16 03:01:27 dlr Exp $
 */
public class AuditLogEntry extends BaseAuditLogEntry implements BOType
{

    //
    // Mutator methods.
    //

    /**
     * Creates and returns new audit log entry.
     */
    public static AuditLogEntry add (String type, String affectedID, 
                                     User initiatingUser, String description) 
        throws Exception
    {
        AuditLogEntry entry = new AuditLogEntry();
        entry.setAffectedType(type);
        entry.setAffectedId(Integer.parseInt(affectedID));
        entry.setInitiatingUser(initiatingUser.getUserId());
        entry.setDescription(description);
        entry.save();
        return entry;
    }

    public void appendToRationale(String appendage)
        throws Exception
    {
        String oldRationale = getRationale();
        StringBuffer rationale = new StringBuffer(oldRationale);
        if (!oldRationale.equals(""))
        {
            rationale.append("\n<hr>\n");
        }
        rationale.append(appendage);
        setRationale(rationale.toString());
        save();
    }

    //
    // Permission-related methods.
    //

    /**
     * Returns whether or not the specified ACL has permission to look
     * at this audit log entry.
     */
    public boolean isViewableBy(AccessControlList acl)
        throws Exception
    {
        boolean viewable = true;
        String type = getAffectedType();
        String id = getAffectedID();        
        if (acl.hasPermission("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(DOMAIN_TYPE))
        {
            Domain domain = null;
            try 
            {
                domain = DomainPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (domain != null &&
                acl.hasPermission("Domain - Audit Log - View", domain))
            {
                viewable = true;
            }
        }

        if (type.equals(PROJECT_TYPE))
        {
            Project project = null;
            try 
            {
                project = ProjectPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (project != null && acl.hasPermission
                ("Project - Audit Log - View", project))
            {
                viewable = true;
            }
        }

        return viewable;
    }
        

    //
    // Accessor methods.
    //

    /**
     * Returns a string describing the business object under which this
     * entry was logged.
     */
    public String getWhere()
        throws Exception
    {
        String type = getAffectedType();
        String id = getAffectedID();
        String where = "Host";
        if (type.equals(DOMAIN_TYPE))
        {
            try {
                Domain domain = DomainPeer.getInstance(id);
                where = "Domain " + domain.getName();
            } catch (Exception e) {
                where = "Now-defunct domain with id " + id;
            }
        } else if (type.equals(PROJECT_TYPE)) {
            try {
                Project project = ProjectPeer.getInstance(id);            
                where = "Project " + project.getName()
                    + " in domain " +  project.getDomain().getName();
            } catch (Exception e) {
                where = "Now-defunct project with id " + id;
            }
        }
        return where;
    }


    public String getAffectedID()
    {
        return String.valueOf(getAffectedId());
    }
}
@


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.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.apache.turbine.util.db.Criteria;

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

/** 
 */
public class AuditLogEntry extends BaseAuditLogEntry
{
}
@


1.1.2.2
log
@Implement BOType.
@
text
@a16 4
 * Helm audit log entry.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: $
d18 1
a18 1
public class AuditLogEntry extends BaseAuditLogEntry implements BOType
@


1.1.2.3
log
@Ported audit log functionality.
@
text
@a13 1
import org.tigris.helm.om.*;
a15 2
import org.tigris.helm.security.AccessControlList;

d20 1
a20 1
 * @@version $Id: AuditLogEntry.java,v 1.1.2.2 2001/02/09 02:14:17 dlr Exp $
a23 131

    //
    // Mutator methods.
    //

    /**
     * Creates and returns new audit log entry.
     */
    public static AuditLogEntry add (String type, String affectedID, 
                                     User initiatingUser, String description) 
        throws Exception
    {
        AuditLogEntry entry = new AuditLogEntry();
        entry.setAffectedType(type);
        entry.setAffectedId(Integer.parseInt(affectedID));
        entry.setInitiatingUser(initiatingUser.getUserId());
        entry.setDescription(description);
        entry.save();
        return entry;
    }

    public void appendToRationale(String appendage)
        throws Exception
    {
        String oldRationale = getRationale();
        StringBuffer rationale = new StringBuffer(oldRationale);
        if (!oldRationale.equals(""))
        {
            rationale.append("\n<hr>\n");
        }
        rationale.append(appendage);
        setRationale(rationale.toString());
        save();
    }

    //
    // Permission-related methods.
    //

    /**
     * Returns whether or not the specified ACL has permission to look
     * at this audit log entry.
     */
    public boolean isViewableBy(AccessControlList acl)
        throws Exception
    {
        boolean viewable = true;
        String type = getAffectedType();
        String id = getAffectedID();        
        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(DOMAIN_TYPE))
        {
            Domain domain = null;
            try 
            {
                domain = DomainPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (domain != null &&
                acl.hasPermission("Domain - Audit Log - View", domain))
            {
                viewable = true;
            }
        }

        if (type.equals(PROJECT_TYPE))
        {
            Project project = null;
            try 
            {
                project = ProjectPeer.getInstance(id);
            } 
            catch (Exception ignore) {}

            if (project != null && acl.hasPermission
                ("Project - Audit Log - View", project))
            {
                viewable = true;
            }
        }

        return viewable;
    }
        

    //
    // Accessor methods.
    //

    /**
     * Returns a string describing the business object under which this
     * entry was logged.
     */
    public String getWhere()
        throws Exception
    {
        String type = getAffectedType();
        String id = getAffectedID();
        String where = "Host";
        if (type.equals(DOMAIN_TYPE))
        {
            try {
                Domain domain = DomainPeer.getInstance(id);
                where = "Domain " + domain.getName();
            } catch (Exception e) {
                where = "Now-defunct domain with id " + id;
            }
        } else if (type.equals(PROJECT_TYPE)) {
            try {
                Project project = ProjectPeer.getInstance(id);            
                where = "Project " + project.getName()
                    + " in domain " +  project.getDomain().getName();
            } catch (Exception e) {
                where = "Now-defunct project with id " + id;
            }
        }
        return where;
    }


    public String getAffectedID()
    {
        return String.valueOf(getAffectedId());
    }
@


1.1.2.4
log
@Changed code to no longer use deprecated methods.
@
text
@d23 1
a23 1
 * @@version $Id: AuditLogEntry.java,v 1.1.2.3 2001/02/09 18:26:16 leonardr Exp $
d76 1
a76 1
        if (acl.hasPermission("Host - Audit Log - View"))
@


1.1.2.5
log
@Added new imports necessitated by Torque.
@
text
@a15 1
import org.tigris.helm.om.base.*;
d23 1
a23 1
 * @@version $Id: AuditLogEntry.java,v 1.1.2.4 2001/02/12 16:24:32 leonardr Exp $
@


