org.acegisecurity.acls.jdbc
Class JdbcMutableAclService

java.lang.Object
  extended by org.acegisecurity.acls.jdbc.JdbcAclService
      extended by org.acegisecurity.acls.jdbc.JdbcMutableAclService
All Implemented Interfaces:
AclService, MutableAclService

public class JdbcMutableAclService
extends JdbcAclService
implements MutableAclService

Provides a base implementation of MutableAclService.

Version:
$Id: JdbcMutableAclService.java 1784 2007-02-24 21:00:24Z luke_t $
Author:
Ben Alex, Johannes Zlattinger

Field Summary
 
Fields inherited from class org.acegisecurity.acls.jdbc.JdbcAclService
jdbcTemplate, log
 
Constructor Summary
JdbcMutableAclService(javax.sql.DataSource dataSource, LookupStrategy lookupStrategy, AclCache aclCache)
           
 
Method Summary
 MutableAcl createAcl(ObjectIdentity objectIdentity)
          Creates an empty Acl object in the database.
protected  void createEntries(MutableAcl acl)
          Creates a new row in acl_entry for every ACE defined in the passed MutableAcl object.
protected  void createObjectIdentity(ObjectIdentity object, Sid owner)
          Creates an entry in the acl_object_identity table for the passed ObjectIdentity.
protected  java.lang.Long createOrRetrieveClassPrimaryKey(java.lang.Class clazz, boolean allowCreate)
          Retrieves the primary key from acl_class, creating a new row if needed and the allowCreate property is true.
protected  java.lang.Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate)
          Retrieves the primary key from acl_sid, creating a new row if needed and the allowCreate property is true.
 void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren)
          Removes the specified entry from the database.
protected  void deleteEntries(ObjectIdentity oid)
          Deletes all ACEs defined in the acl_entry table belonging to the presented ObjectIdentity
protected  void deleteObjectIdentityAndOptionallyClass(ObjectIdentity oid)
          Deletes a single row from acl_object_identity that is associated with the presented ObjectIdentity.
protected  java.lang.Long retrieveObjectIdentityPrimaryKey(ObjectIdentity oid)
          Retrieves the primary key from the acl_object_identity table for the passed ObjectIdentity.
 MutableAcl updateAcl(MutableAcl acl)
          This implementation will simply delete all ACEs in the database and recreate them on each invocation of this method.
protected  void updateObjectIdentity(MutableAcl acl)
          Updates an existing acl_object_identity row, with new information presented in the passed MutableAcl object.
 
Methods inherited from class org.acegisecurity.acls.jdbc.JdbcAclService
findChildren, readAclById, readAclById, readAclsById, readAclsById
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.acegisecurity.acls.AclService
findChildren, readAclById, readAclById, readAclsById, readAclsById
 

Constructor Detail

JdbcMutableAclService

public JdbcMutableAclService(javax.sql.DataSource dataSource,
                             LookupStrategy lookupStrategy,
                             AclCache aclCache)
Method Detail

createAcl

public MutableAcl createAcl(ObjectIdentity objectIdentity)
                     throws AlreadyExistsException
Description copied from interface: MutableAclService
Creates an empty Acl object in the database. It will have no entries. The returned object will then be used to add entries.

Specified by:
createAcl in interface MutableAclService
Parameters:
objectIdentity - the object identity to create
Returns:
an ACL object with its ID set
Throws:
AlreadyExistsException - if the passed object identity already has a record

createEntries

protected void createEntries(MutableAcl acl)
Creates a new row in acl_entry for every ACE defined in the passed MutableAcl object.

Parameters:
acl - containing the ACEs to insert

createObjectIdentity

protected void createObjectIdentity(ObjectIdentity object,
                                    Sid owner)
Creates an entry in the acl_object_identity table for the passed ObjectIdentity. The Sid is also necessary, as acl_object_identity has defined the sid column as non-null.

Parameters:
object - to represent an acl_object_identity for
owner - for the SID column (will be created if there is no acl_sid entry for this particular Sid already)

createOrRetrieveClassPrimaryKey

protected java.lang.Long createOrRetrieveClassPrimaryKey(java.lang.Class clazz,
                                                         boolean allowCreate)
Retrieves the primary key from acl_class, creating a new row if needed and the allowCreate property is true.

Parameters:
clazz - to find or create an entry for (this implementation uses the fully-qualified class name String)
allowCreate - true if creation is permitted if not found
Returns:
the primary key or null if not found

createOrRetrieveSidPrimaryKey

protected java.lang.Long createOrRetrieveSidPrimaryKey(Sid sid,
                                                       boolean allowCreate)
Retrieves the primary key from acl_sid, creating a new row if needed and the allowCreate property is true.

Parameters:
sid - to find or create
allowCreate - true if creation is permitted if not found
Returns:
the primary key or null if not found
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

deleteAcl

public void deleteAcl(ObjectIdentity objectIdentity,
                      boolean deleteChildren)
               throws ChildrenExistException
Description copied from interface: MutableAclService
Removes the specified entry from the database.

Specified by:
deleteAcl in interface MutableAclService
Parameters:
objectIdentity - the object identity to remove
deleteChildren - whether to cascade the delete to children
Throws:
ChildrenExistException - if the deleteChildren argument was false but children exist

deleteEntries

protected void deleteEntries(ObjectIdentity oid)
Deletes all ACEs defined in the acl_entry table belonging to the presented ObjectIdentity

Parameters:
oid - the rows in acl_entry to delete

deleteObjectIdentityAndOptionallyClass

protected void deleteObjectIdentityAndOptionallyClass(ObjectIdentity oid)
Deletes a single row from acl_object_identity that is associated with the presented ObjectIdentity. In addition, deletes the corresponding row from acl_class if there are no more entries in acl_object_identity that use that particular acl_class. This keeps the acl_class table reasonably small.

Parameters:
oid - to delete the acl_object_identity (and clean up acl_class for that class name if appropriate)

retrieveObjectIdentityPrimaryKey

protected java.lang.Long retrieveObjectIdentityPrimaryKey(ObjectIdentity oid)
Retrieves the primary key from the acl_object_identity table for the passed ObjectIdentity. Unlike some other methods in this implementation, this method will NOT create a row (use createObjectIdentity(ObjectIdentity, Sid) instead).

Parameters:
oid - to find
Returns:
the object identity or null if not found

updateAcl

public MutableAcl updateAcl(MutableAcl acl)
                     throws NotFoundException
This implementation will simply delete all ACEs in the database and recreate them on each invocation of this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM capabilities for create, update and delete operations of MutableAcl.

Specified by:
updateAcl in interface MutableAclService
Parameters:
acl - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
NotFoundException - DOCUMENT ME!

updateObjectIdentity

protected void updateObjectIdentity(MutableAcl acl)
Updates an existing acl_object_identity row, with new information presented in the passed MutableAcl object. Also will create an acl_sid entry if needed for the Sid that owns the MutableAcl.

Parameters:
acl - to modify (a row must already exist in acl_object_identity)
Throws:
NotFoundException - DOCUMENT ME!


Copyright © 2004-2012 Interface21, Inc. All Rights Reserved.