org.apache.portals.graffito.jcr.persistence
Interface PersistenceManager

All Known Implementing Classes:
PersistenceManagerImpl

public interface PersistenceManager

The persistence manager encapsulates a JCR session. This is the main component used to manage objects into the JCR repository.

Author:
Sandro Boehme, Lombart Christophe

Method Summary
 void addVersionLabel(java.lang.String path, java.lang.String versionName, java.lang.String versionLabel)
          Add a new label to a particular version
 void checkin(java.lang.String path)
          Checkin an object
 void checkin(java.lang.String path, java.lang.String[] versionLabels)
          Checkin an object and apply some labels to this new version Within a particular object path, a given label may appear a maximum of once
 void checkout(java.lang.String path)
          Checkout - Create a new version This is only possible if the object is based on mix:versionable node type
 java.lang.String[] getAllVersionLabels(java.lang.String path)
          Get all version labels assigned to all versions
 VersionIterator getAllVersions(java.lang.String path)
          Get all object versions
 Version getBaseVersion(java.lang.String path)
          Get the lastest object version
 java.lang.Object getObject(java.lang.Class objectClass, java.lang.String path)
          Get an object from the JCR repository
 java.lang.Object getObject(java.lang.Class objectClass, java.lang.String path, java.lang.String versionNumber)
          Get an object from the JCR repository
 java.lang.Object getObject(Query query)
          Retrieve an object matching to a query
 java.lang.Object getObject(java.lang.String path)
          Get an object from the JCR repository
 java.lang.Object getObject(java.lang.String path, java.lang.String versionNumber)
          Get an object from the JCR repository
 java.util.Iterator getObjectIterator(Query query)
          Retrieve some objects matching to a query.
 java.util.Collection getObjects(Query query)
          Retrieve some objects matching to a query
 QueryManager getQueryManager()
           
 Version getRootVersion(java.lang.String path)
          Get the first object version
 Version getVersion(java.lang.String path, java.lang.String versionName)
          Get a particular version
 java.lang.String[] getVersionLabels(java.lang.String path, java.lang.String versionName)
          Get all version labels assigned to a particular object version
 void insert(java.lang.Object object)
          Insert an object into the JCR repository
 boolean isLocked(java.lang.String absPath)
          Is that path locked?
 boolean isPersistent(java.lang.Class clazz)
          Can this persistence manager insert, update, delete, ...
 java.lang.String lock(java.lang.String path, boolean isDeep, boolean isSessionScoped)
          Lock object saved on .
 void logout()
          Close the session
 boolean objectExists(java.lang.String path)
          Check if an object exists
 void remove(java.lang.Object object)
          Remove an object from a JCR repository
 void remove(Query query)
          Remove all objects matching to a query
 void remove(java.lang.String path)
          Remove an object from a JCR repository
 void retrieveAllMappedAttributes(java.lang.Object object)
          Retrieve all mapped attributes for the given persistent object.
 void retrieveMappedAttribute(java.lang.Object object, java.lang.String attributeName)
          Retrieve the specified attribute for the given persistent object.
 void save()
          Save all modifications made by the persistence manager
 void unlock(java.lang.String path, java.lang.String lockToken)
          Unlock object stored on .
 void update(java.lang.Object object)
          Update an object
 

Method Detail

objectExists

boolean objectExists(java.lang.String path)
                     throws PersistenceException
Check if an object exists

Parameters:
path - the object path
Returns:
true if the item exists
Throws:
PersistenceException - when it is not possible to check if the item exist

isPersistent

boolean isPersistent(java.lang.Class clazz)
Can this persistence manager insert, update, delete, ... that type?

Parameters:
clazz - class for question
Returns:
true if the class is persistence

insert

void insert(java.lang.Object object)
            throws PersistenceException
Insert an object into the JCR repository

Parameters:
object - the object to add
Throws:
PersistenceException - when it is not possible to insert the object

update

void update(java.lang.Object object)
            throws PersistenceException
Update an object

Parameters:
object - the object to update
Throws:
PersistenceException - when it is not possible to update the object

getObject

java.lang.Object getObject(java.lang.String path)
                           throws PersistenceException
Get an object from the JCR repository

Parameters:
path - the object path
Returns:
the object found or null
Throws:
PersistenceException - when it is not possible to retrieve the object

getObject

java.lang.Object getObject(java.lang.String path,
                           java.lang.String versionNumber)
                           throws PersistenceException
Get an object from the JCR repository

Parameters:
path - the object path
versionNumber - The desired object version number
Returns:
the object found or null
Throws:
PersistenceException - when it is not possible to retrieve the object

getObject

java.lang.Object getObject(java.lang.Class objectClass,
                           java.lang.String path)
                           throws PersistenceException
Get an object from the JCR repository

Parameters:
objectClass - the object class
path - the object path
Returns:
the object found or null
Throws:
PersistenceException - when it is not possible to retrieve the object

getObject

java.lang.Object getObject(java.lang.Class objectClass,
                           java.lang.String path,
                           java.lang.String versionNumber)
                           throws PersistenceException
Get an object from the JCR repository

Parameters:
objectClass - the object class
path - the object path
versionNumber - The desired object version number
Returns:
the object found or null
Throws:
PersistenceException - when it is not possible to retrieve the object

retrieveMappedAttribute

void retrieveMappedAttribute(java.lang.Object object,
                             java.lang.String attributeName)
Retrieve the specified attribute for the given persistent object. this attribute is either a bean or a collection. This method is usefull if the corresponding descriptor has an autoRetrieve="false"

Parameters:
object - The persistent object
attributeName - The name of the attribute to retrieve

retrieveAllMappedAttributes

void retrieveAllMappedAttributes(java.lang.Object object)
Retrieve all mapped attributes for the given persistent object.

Parameters:
object - The persistent object

remove

void remove(java.lang.String path)
            throws PersistenceException
Remove an object from a JCR repository

Parameters:
path - the object path
Throws:
PersistenceException - when it is not possible to remove the object

remove

void remove(java.lang.Object object)
            throws PersistenceException
Remove an object from a JCR repository

Parameters:
object - the object to remove
Throws:
PersistenceException - when it is not possible to remove the object

remove

void remove(Query query)
            throws PersistenceException
Remove all objects matching to a query

Parameters:
query - The query used to find the objects to remove
Throws:
PersistenceException - when it is not possible to remove all objects

getObject

java.lang.Object getObject(Query query)
                           throws PersistenceException
Retrieve an object matching to a query

Parameters:
query - The Graffito Query object used to seach the object
Returns:
The object found or null
Throws:
PersistenceException - when it is not possible to retrieve the object

getObjects

java.util.Collection getObjects(Query query)
                                throws PersistenceException
Retrieve some objects matching to a query

Parameters:
query - The query used to seach the objects
Returns:
a collection of objects found
Throws:
PersistenceException - when it is not possible to retrieve the objects

getObjectIterator

java.util.Iterator getObjectIterator(Query query)
                                     throws PersistenceException
Retrieve some objects matching to a query.

Parameters:
query - The query used to seach the objects
Returns:
an iterator of objects found
Throws:
PersistenceException - when it is not possible to retrieve the objects

checkout

void checkout(java.lang.String path)
              throws javax.jcr.version.VersionException
Checkout - Create a new version This is only possible if the object is based on mix:versionable node type

Parameters:
path - The object path
Throws:
javax.jcr.version.VersionException - when it is not possible to create a new version

checkin

void checkin(java.lang.String path)
             throws javax.jcr.version.VersionException
Checkin an object

Parameters:
path - the object path
Throws:
javax.jcr.version.VersionException - when it is not possible to checkin

checkin

void checkin(java.lang.String path,
             java.lang.String[] versionLabels)
             throws javax.jcr.version.VersionException
Checkin an object and apply some labels to this new version Within a particular object path, a given label may appear a maximum of once

Parameters:
path - The object path
versionLabels - the version labels to apply to the new version
Throws:
javax.jcr.version.VersionException - when it is possible to checkin

getVersionLabels

java.lang.String[] getVersionLabels(java.lang.String path,
                                    java.lang.String versionName)
                                    throws javax.jcr.version.VersionException
Get all version labels assigned to a particular object version

Parameters:
path - the object path
versionName - the object version name (1.0, ...)
Returns:
a array of string (version labels)
Throws:
javax.jcr.version.VersionException - when it is not to get all version labels

getAllVersionLabels

java.lang.String[] getAllVersionLabels(java.lang.String path)
                                       throws javax.jcr.version.VersionException
Get all version labels assigned to all versions

Parameters:
path - the object path
Returns:
a array of string (version labels)
Throws:
javax.jcr.version.VersionException - when it is not to get all version labels

addVersionLabel

void addVersionLabel(java.lang.String path,
                     java.lang.String versionName,
                     java.lang.String versionLabel)
                     throws javax.jcr.version.VersionException
Add a new label to a particular version

Parameters:
path - the object path
versionName - the object versio name (1.0, 1.1, ...)
versionLabel - The new label to apply
Throws:
javax.jcr.version.VersionException - when it is not possible to add a new version label to this version

getAllVersions

VersionIterator getAllVersions(java.lang.String path)
                               throws javax.jcr.version.VersionException
Get all object versions

Parameters:
path - the object path
Returns:
a version iterator
Throws:
javax.jcr.version.VersionException - when it is not possible to retrieve all versions

getRootVersion

Version getRootVersion(java.lang.String path)
                       throws javax.jcr.version.VersionException
Get the first object version

Parameters:
path - the object path
Returns:
the first version found
Throws:
javax.jcr.version.VersionException - when it is not possible to get the root version

getBaseVersion

Version getBaseVersion(java.lang.String path)
                       throws javax.jcr.version.VersionException
Get the lastest object version

Parameters:
path - the object path
Returns:
the last version found
Throws:
javax.jcr.version.VersionException - when it is not possible to get the last version

getVersion

Version getVersion(java.lang.String path,
                   java.lang.String versionName)
                   throws javax.jcr.version.VersionException
Get a particular version

Parameters:
path - the object path
versionName - the version name
Returns:
the version found or null
Throws:
javax.jcr.version.VersionException - when it is not possible to retrieve this particular version

save

void save()
          throws PersistenceException
Save all modifications made by the persistence manager

Throws:
PersistenceException - when it is not possible to save all pending operation into the JCR repo

logout

void logout()
            throws PersistenceException
Close the session

Throws:
PersistenceException - when it is not possible to logout

lock

java.lang.String lock(java.lang.String path,
                      boolean isDeep,
                      boolean isSessionScoped)
                      throws LockedException
Lock object saved on .

Parameters:
path - path to saved object.
isDeep - is lock deep? See JCR spec: 8.4.3 Shallow and Deep Locks
isSessionScoped - is lock session scoped? See JCR spec: Session-scoped and Open-scoped Locks
Returns:
lock token - see JCR spec: 8.4.6 Lock Token; Other user with this token can perform unlock
Throws:
LockedException - if path is locked (cannot lock same path again)

unlock

void unlock(java.lang.String path,
            java.lang.String lockToken)
            throws IllegalUnlockException
Unlock object stored on .

Parameters:
path - path to stored object
lockToken - see JCR spec: 8.4.6 Lock Token; can be null
Throws:
IllegalUnlockException - throws if the current operation does not own the current lock

isLocked

boolean isLocked(java.lang.String absPath)
Is that path locked?

Parameters:
absPath -
Returns:
true if path locked

getQueryManager

QueryManager getQueryManager()
Returns:
The query manager reference


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.