org.openanzo.server.repository.structures
Class ACL

java.lang.Object
  extended by org.openanzo.server.repository.structures.ACL
All Implemented Interfaces:
Batchable

public class ACL
extends java.lang.Object
implements Batchable

Provides read and write access to an access control list (ACL) stored in the repository. ACLs are composed of access control items (or ACIs, see the AccessControl class) which grant rights to NamedGraphs in the repository as well as the ownership right needed to change the ACL itself. ACL data is cached in memory and is not persisted to the repository until commit is called or a batch commit (via the Batchable interface) is performed.

Author:
Joe Betz, Matthew Roy ( mroy@cambridgesemantics.com )
See Also:
Batchable, ACI

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openanzo.jdbc.utils.batchable.Batchable
Batchable.BatchGroup, Batchable.BatchOperation, Batchable.BatchOperationSet, Batchable.NullBatch
 
Field Summary
 
Fields inherited from interface org.openanzo.jdbc.utils.batchable.Batchable
EMPTY_BATCH
 
Constructor Summary
ACL(RepositoryConnection repositoryConnection, java.lang.Long id)
          New ACL with given ID, and RepositoryConnection
 
Method Summary
 void commit()
          Commit changes to this ACL to the database
 ACL createAclFromTemplate(org.openrdf.model.URI namedGraphUri, TransactionUpdateResults updateResults)
          Create a new ACL object based on the contents of an AclTemplate
static ACL createAclInstance(RepositoryConnection repositoryConnection, java.lang.Long modified, java.lang.Long aclId, java.lang.Long roleId, boolean template, boolean read, boolean add, boolean remove, boolean changeNamedGraphAcl, boolean insertNamedGraph, boolean removeNamedGraph)
          Create an instance of an ACL
 java.lang.Long getId()
          Get the unique id of this ACL
 org.openrdf.model.URI getURI()
          Get the URI of this ACL
 boolean hasPrivilege(Privilege privilege, java.lang.Long userId)
          Does the given userId has the provided privilege
 ClosableIterator<java.lang.Long> listACIs()
          List the ACIs for this ACL
 java.util.List<Batchable.BatchOperation> listBatchOperations()
          Get the current list of batch operations for this object
 void remove(java.lang.Long modified)
          Remove this ACL from the database
 void setId(long id)
          Set the unique id for this ACL
 ACI updatePrivileges(Role role, java.util.List<Privilege> addPrivileges, java.util.List<Privilege> removePrivileges, java.lang.Long modified)
          Adds and removes the given privileges to the given role for this ACI and returns the ACI containing the updated privileges which must be committed by the caller.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ACL

public ACL(RepositoryConnection repositoryConnection,
           java.lang.Long id)
New ACL with given ID, and RepositoryConnection

Parameters:
repositoryConnection - connection to the database
id - id of the ACL
Method Detail

createAclFromTemplate

public ACL createAclFromTemplate(org.openrdf.model.URI namedGraphUri,
                                 TransactionUpdateResults updateResults)
                          throws AnzoException
Create a new ACL object based on the contents of an AclTemplate

Parameters:
namedGraphUri - URI of NamedGraph to apply new ACL
updateResults - UpdateResults to which update results are written
Returns:
a new ACL object based on the contents of an AclTemplate
Throws:
AnzoException

getId

public java.lang.Long getId()
Get the unique id of this ACL

Returns:
the unique id of this ACL

getURI

public org.openrdf.model.URI getURI()
Get the URI of this ACL

Returns:
the URI of this ACL

setId

public void setId(long id)
Set the unique id for this ACL

Parameters:
id - the unique id for this ACL

remove

public void remove(java.lang.Long modified)
            throws AnzoException
Remove this ACL from the database

Parameters:
modified - Timestamp when ACL was removed
Throws:
AnzoException

hasPrivilege

public boolean hasPrivilege(Privilege privilege,
                            java.lang.Long userId)
                     throws AnzoException
Does the given userId has the provided privilege

Parameters:
privilege - privilege to check
userId - id of user to check
Returns:
true if the given userId has the provided privilege
Throws:
AnzoException

commit

public void commit()
            throws RdbException
Commit changes to this ACL to the database

Throws:
RdbException

listBatchOperations

public java.util.List<Batchable.BatchOperation> listBatchOperations()
Description copied from interface: Batchable
Get the current list of batch operations for this object

Specified by:
listBatchOperations in interface Batchable
Returns:
the current list of batch operations for this object

listACIs

public ClosableIterator<java.lang.Long> listACIs()
                                          throws AnzoException
List the ACIs for this ACL

Returns:
the ACIs for this ACL
Throws:
AnzoException

updatePrivileges

public ACI updatePrivileges(Role role,
                            java.util.List<Privilege> addPrivileges,
                            java.util.List<Privilege> removePrivileges,
                            java.lang.Long modified)
                     throws AnzoException
Adds and removes the given privileges to the given role for this ACI and returns the ACI containing the updated privileges which must be committed by the caller. Due to the current ACI immutability limitation, when privileges are changed the ACI containing the existing permissions is deleted and another is created in its place with the new permissions. IMPORTANT: When the ACI with the existing permissions is removed it is committed immediately.

Parameters:
role - role whose privileges are being changed
addPrivileges - set of privileges to add to this role for the given user
removePrivileges - set of privileges to remove to this role for the given user
modified - timestamp that this modification took place
Returns:
ACI containing updated privileges
Throws:
AnzoException

createAclInstance

public static ACL createAclInstance(RepositoryConnection repositoryConnection,
                                    java.lang.Long modified,
                                    java.lang.Long aclId,
                                    java.lang.Long roleId,
                                    boolean template,
                                    boolean read,
                                    boolean add,
                                    boolean remove,
                                    boolean changeNamedGraphAcl,
                                    boolean insertNamedGraph,
                                    boolean removeNamedGraph)
                             throws AnzoException
Create an instance of an ACL

Parameters:
repositoryConnection - connection to the database
modified - timestamp for acl
aclId - id of acl
roleId - id for role
template - is this acl a template
read - canRead permission
add - canAdd permission
remove - canRemove permission
changeNamedGraphAcl - canChangeNamedGraphAcl permission
insertNamedGraph - canInsertNamedGraph permission
removeNamedGraph - canRemoveNamedGraph permission
Returns:
new instance of an acl
Throws:
AnzoException


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.