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

java.lang.Object
  extended by org.apache.turbine.services.security.torque.RolePeerManager
All Implemented Interfaces:
RolePeerManagerConstants

public class RolePeerManager
extends java.lang.Object
implements RolePeerManagerConstants

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

Version:
$Id: RolePeerManager.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.RolePeerManagerConstants
ROLE_CLASS_KEY, ROLE_ID_COLUMN_DEFAULT, ROLE_ID_COLUMN_KEY, ROLE_ID_PROPERTY_DEFAULT, ROLE_ID_PROPERTY_KEY, ROLE_NAME_COLUMN_DEFAULT, ROLE_NAME_COLUMN_KEY, ROLE_NAME_PROPERTY_DEFAULT, ROLE_NAME_PROPERTY_KEY, ROLE_PEER_CLASS_DEFAULT, ROLE_PEER_CLASS_KEY
 
Constructor Summary
RolePeerManager()
           
 
Method Summary
static org.apache.torque.util.Criteria buildCriteria(Role role)
          Calls buildCriteria(Role role) in the configured RolePeer.
static boolean checkExists(Role role)
          Checks if a Role 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.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 role
static java.lang.String getNameColumn()
          Returns the fully qualified name of the Column to use as the Name Column for a role
static Role getNewRole(org.apache.torque.om.Persistent p)
          Returns a new, configured Role Object with a supplied Persistent object at its core
static java.lang.String getRoleName(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 RolePeerManager, loading the class object for the Peer used to retrieve Role objects
static org.apache.torque.om.Persistent newPersistentInstance()
          Returns a new, empty object for the underlying peer.
static RoleSet retrieveSet(org.apache.torque.util.Criteria criteria)
          Retrieves/assembles a RoleSet based on the Criteria passed in
static RoleSet retrieveSet(User user, Group group)
          Retrieves a set of Roles that an User was assigned in a Group
static void setId(org.apache.torque.om.Persistent obj, int id)
          Invokes setId(int n) on the supplied base object
static void setRoleName(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

RolePeerManager

public RolePeerManager()
Method Detail

init

public static void init(org.apache.commons.configuration.Configuration conf)
                 throws InitializationException
Initializes the RolePeerManager, loading the class object for the Peer used to retrieve Role 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 role

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 role

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

retrieveSet

public static RoleSet retrieveSet(org.apache.torque.util.Criteria criteria)
                           throws java.lang.Exception
Retrieves/assembles a RoleSet based on the Criteria passed in

Parameters:
criteria - A criteria containing a pre-assembled set of criterias for the RoleSet
Returns:
A Set of roles which fulfil the required criterias
Throws:
java.lang.Exception - A generic exception.

retrieveSet

public static RoleSet retrieveSet(User user,
                                  Group group)
                           throws java.lang.Exception
Retrieves a set of Roles that an User was assigned in a Group

Parameters:
user - An user object
group - A group object
Returns:
A Set of Roles of this User in the Group
Throws:
java.lang.Exception - A generic exception.

checkExists

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

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

buildCriteria

public static org.apache.torque.util.Criteria buildCriteria(Role role)
Calls buildCriteria(Role role) in the configured RolePeer. If you get a ClassCastException in this routine, you put a Role 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:
role - An object which implements the Role interface
Returns:
A criteria for the supplied role 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 Role 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.

setRoleName

public static void setRoleName(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

getRoleName

public static java.lang.String getRoleName(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

getNewRole

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

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


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