org.apache.turbine.services.security.torque
Class PermissionPeerManager

java.lang.Object
  extended byorg.apache.turbine.services.security.torque.PermissionPeerManager
All Implemented Interfaces:
PermissionPeerManagerConstants

public class PermissionPeerManager
extends java.lang.Object
implements PermissionPeerManagerConstants

This class capsulates all direct Peer access for the Permission entities. It allows the exchange of the default Turbine supplied TurbinePermissionPeer class against a custom class.

Version:
$Id: PermissionPeerManager.java 534527 2007-05-02 16:10:59Z tv $
Author:
Henning P. Schmiedehausen

Field Summary
 
Fields inherited from interface org.apache.turbine.services.security.torque.PermissionPeerManagerConstants
PERMISSION_CLASS_KEY, PERMISSION_ID_COLUMN_DEFAULT, PERMISSION_ID_COLUMN_KEY, PERMISSION_ID_PROPERTY_DEFAULT, PERMISSION_ID_PROPERTY_KEY, PERMISSION_NAME_COLUMN_DEFAULT, PERMISSION_NAME_COLUMN_KEY, PERMISSION_NAME_PROPERTY_DEFAULT, PERMISSION_NAME_PROPERTY_KEY, PERMISSION_PEER_CLASS_DEFAULT, PERMISSION_PEER_CLASS_KEY
 
Constructor Summary
PermissionPeerManager()
           
 
Method Summary
static org.apache.torque.util.Criteria buildCriteria(Permission permission)
          Calls buildCriteria(Permission permission) in the configured PermissionPeer.
static boolean checkExists(Permission permission)
          Checks if a Permission is defined in the system.
static void doDelete(org.apache.torque.util.Criteria criteria)
          Invokes doDelete(Criteria c) on the configured Peer Object
static void doInsert(org.apache.torque.util.Criteria criteria)
          Invokes doInsert(Criteria c) on the configured Peer Object
static java.util.List doSelect(org.apache.torque.util.Criteria criteria)
          Invokes doSelect(Criteria c) on the configured Peer Object
static void doUpdate(org.apache.torque.util.Criteria criteria)
          Invokes doUpdate(Criteria c) on the configured Peer Object
static java.lang.String getColumnName(java.lang.String name)
          Returns the full name of a column.
static java.util.Vector getDifference(java.util.Vector some, java.util.Vector all)
          Pass in two Vector's of Permission Objects.
static java.lang.Integer getIdAsObj(org.apache.torque.om.Persistent obj)
          Invokes getId() on the supplied base object
static java.lang.String getIdColumn()
          Returns the fully qualified name of the Column to use as the Id Column for a permission
static java.lang.String getNameColumn()
          Returns the fully qualified name of the Column to use as the Name Column for a permission
static Permission getNewPermission(org.apache.torque.om.Persistent p)
          Returns a new, configured Permission Object with a supplied Persistent object at its core
static java.lang.String getPermissionName(org.apache.torque.om.Persistent obj)
          Invokes getName() on the supplied base object
static java.lang.String getTableName()
          Get the name of this table.
static void init(org.apache.commons.configuration.Configuration conf)
          Initializes the PermissionPeerManager, loading the class object for the Peer used to retrieve Permission objects
static org.apache.torque.om.Persistent newPersistentInstance()
          Returns a new, empty object for the underlying peer.
static PermissionSet retrieveSet(org.apache.torque.util.Criteria criteria)
          Retrieves/assembles a PermissionSet
static PermissionSet retrieveSet(Role role)
          Retrieves a set of Permissions associated with a particular Role.
static void setId(org.apache.torque.om.Persistent obj, int id)
          Invokes setId(int n) on the supplied base object
static void setPermissionName(org.apache.torque.om.Persistent obj, java.lang.String name)
          Invokes setName(String s) on the supplied base object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionPeerManager

public PermissionPeerManager()
Method Detail

init

public static void init(org.apache.commons.configuration.Configuration conf)
                 throws InitializationException
Initializes the PermissionPeerManager, loading the class object for the Peer used to retrieve Permission objects

Parameters:
conf - The configuration object used to configure the Manager
Throws:
InitializationException - A problem occured during initialization

getTableName

public static java.lang.String getTableName()
Get the name of this table.

Returns:
A String with the name of the table.

getNameColumn

public static java.lang.String getNameColumn()
Returns the fully qualified name of the Column to use as the Name Column for a permission

Returns:
A String containing the column name

getIdColumn

public static java.lang.String getIdColumn()
Returns the fully qualified name of the Column to use as the Id Column for a permission

Returns:
A String containing the column id

getColumnName

public static java.lang.String getColumnName(java.lang.String name)
Returns the full name of a column.

Parameters:
name - The column to fully qualify
Returns:
A String with the full name of the column.

newPersistentInstance

public static org.apache.torque.om.Persistent newPersistentInstance()
Returns a new, empty object for the underlying peer. Used to create a new underlying object

Returns:
A new object which is compatible to the Peer and can be used as a User object

checkExists

public static boolean checkExists(Permission permission)
                           throws DataBackendException,
                                  java.lang.Exception
Checks if a Permission is defined in the system. The name is used as query criteria.

Parameters:
permission - The Permission to be checked.
Returns:
true if given Permission exists in the system.
Throws:
DataBackendException - when more than one Permission with the same name exists.
java.lang.Exception - A generic exception.

retrieveSet

public static PermissionSet retrieveSet(org.apache.torque.util.Criteria criteria)
                                 throws java.lang.Exception
Retrieves/assembles a PermissionSet

Parameters:
criteria - The criteria to use.
Returns:
A PermissionSet.
Throws:
java.lang.Exception - A generic Exception.

retrieveSet

public static PermissionSet retrieveSet(Role role)
                                 throws java.lang.Exception
Retrieves a set of Permissions associated with a particular Role.

Parameters:
role - The role to query permissions of.
Returns:
A set of permissions associated with the Role.
Throws:
java.lang.Exception - A generic Exception.

getDifference

public static final java.util.Vector getDifference(java.util.Vector some,
                                                   java.util.Vector all)
Pass in two Vector's of Permission Objects. It will return a new Vector with the difference of the two Vectors: C = (A - B).

Parameters:
some - Vector B in C = (A - B).
all - Vector A in C = (A - B).
Returns:
Vector C in C = (A - B).

buildCriteria

public static org.apache.torque.util.Criteria buildCriteria(Permission permission)
Calls buildCriteria(Permission permission) in the configured PermissionPeer. If you get a ClassCastException in this routine, you put a Permission object into this method which can't be cast into an object for the TorqueSecurityService. This is a configuration error most of the time.

Parameters:
permission - An object which implements the Permission interface
Returns:
A criteria for the supplied permission object

doUpdate

public static void doUpdate(org.apache.torque.util.Criteria criteria)
                     throws org.apache.torque.TorqueException
Invokes doUpdate(Criteria c) on the configured Peer Object

Parameters:
criteria - A Criteria Object
Throws:
org.apache.torque.TorqueException - A problem occured.

doInsert

public static void doInsert(org.apache.torque.util.Criteria criteria)
                     throws org.apache.torque.TorqueException
Invokes doInsert(Criteria c) on the configured Peer Object

Parameters:
criteria - A Criteria Object
Throws:
org.apache.torque.TorqueException - A problem occured.

doSelect

public static java.util.List doSelect(org.apache.torque.util.Criteria criteria)
                               throws org.apache.torque.TorqueException
Invokes doSelect(Criteria c) on the configured Peer Object

Parameters:
criteria - A Criteria Object
Returns:
A List of Permission Objects selected by the Criteria
Throws:
org.apache.torque.TorqueException - A problem occured.

doDelete

public static void doDelete(org.apache.torque.util.Criteria criteria)
                     throws org.apache.torque.TorqueException
Invokes doDelete(Criteria c) on the configured Peer Object

Parameters:
criteria - A Criteria Object
Throws:
org.apache.torque.TorqueException - A problem occured.

setPermissionName

public static void setPermissionName(org.apache.torque.om.Persistent obj,
                                     java.lang.String name)
Invokes setName(String s) on the supplied base object

Parameters:
obj - The object to use for setting the name
name - The Name to set

getPermissionName

public static java.lang.String getPermissionName(org.apache.torque.om.Persistent obj)
Invokes getName() on the supplied base object

Parameters:
obj - The object to use for getting the name
Returns:
A string containing the name

setId

public static void setId(org.apache.torque.om.Persistent obj,
                         int id)
Invokes setId(int n) on the supplied base object

Parameters:
obj - The object to use for setting the name
id - The new Id

getIdAsObj

public static java.lang.Integer getIdAsObj(org.apache.torque.om.Persistent obj)
Invokes getId() on the supplied base object

Parameters:
obj - The object to use for getting the id
Returns:
The Id of this object

getNewPermission

public static Permission getNewPermission(org.apache.torque.om.Persistent p)
Returns a new, configured Permission Object with a supplied Persistent object at its core

Parameters:
p - The persistent object
Returns:
a new, configured Permission Object
Throws:
java.lang.Exception - Could not create a new Object


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.