org.apache.jackrabbit.ocm.manager
Interface ObjectContentManager

All Known Implementing Classes:
ObjectContentManagerImpl

public interface ObjectContentManager

The object content 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(String path, String versionName, String versionLabel)
          Add a new label to a particular version
 void checkin(String path)
          Checkin an object
 void checkin(String path, 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(String path)
          Checkout - Create a new version This is only possible if the object is based on mix:versionable node type
 void copy(String srcPath, String destPath)
          Copy an object
 String[] getAllVersionLabels(String path)
          Get all version labels assigned to all versions
 VersionIterator getAllVersions(String path)
          Get all object versions
 Version getBaseVersion(String path)
          Get the lastest object version
 Object getObject(Class objectClass, String path)
          Get an object from the JCR repository
 Object getObject(Class objectClass, String path, String versionNumber)
          Get an object from the JCR repository
 Object getObject(Query query)
          Retrieve an object matching to a query
 Object getObject(String path)
          Get an object from the JCR repository
 Object getObject(String path, String versionNumber)
          Get an object from the JCR repository
 Object getObjectByUuid(String uuid)
          Get an object from the JCR repository
 Iterator getObjectIterator(Query query)
          Retrieve some objects matching to a query.
 Iterator getObjectIterator(String query, String language)
          Retrieve an objects matching a query specified in a specific query language.
 Collection getObjects(Class objectClass, String path)
          Returns a list of objects of that particular class which are associated to a specific path.
 Collection getObjects(Query query)
          Retrieve some objects matching to a query
 Collection getObjects(String query, String language)
          Return a list of object matching to a JCR query
 QueryManager getQueryManager()
           
 Version getRootVersion(String path)
          Get the first object version
 Session getSession()
          This method returns the JCR session.
 Version getVersion(String path, String versionName)
          Get a particular version
 String[] getVersionLabels(String path, String versionName)
          Get all version labels assigned to a particular object version
 void insert(Object object)
          Insert an object into the JCR repository
 boolean isLocked(String absPath)
          Is that path locked?
 boolean isPersistent(Class clazz)
          Can this object content manager insert, update, delete, ... that type?
 Lock lock(String path, boolean isDeep, boolean isSessionScoped)
          Lock object saved on .
 void logout()
          Close the session
 void move(String srcPath, String destPath)
          Move an object
 boolean objectExists(String path)
          Check if an object exists
 void refresh(boolean keepChanges)
          Refresh the underlying jcr session (see the jcr spec)
 void remove(Object object)
          Remove an object from a JCR repository
 void remove(Query query)
          Remove all objects matching to a query
 void remove(String path)
          Remove an object from a JCR repository
 void retrieveAllMappedAttributes(Object object)
          Retrieve all mapped attributes for the given persistent object.
 void retrieveMappedAttribute(Object object, String attributeName)
          Retrieve the specified attribute for the given persistent object. this attribute is either a bean or a collection.
 void save()
          Save all modifications made by the object content manager
 void unlock(String path, String lockToken)
          Unlock object stored on .
 void update(Object object)
          Update an object
 

Method Detail

objectExists

boolean objectExists(String path)
                     throws ObjectContentManagerException
Check if an object exists

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

isPersistent

boolean isPersistent(Class clazz)
Can this object content manager insert, update, delete, ... that type?

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

insert

void insert(Object object)
            throws ObjectContentManagerException
Insert an object into the JCR repository

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

update

void update(Object object)
            throws ObjectContentManagerException
Update an object

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

getObject

Object getObject(String path)
                 throws ObjectContentManagerException
Get an object from the JCR repository

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

getObjectByUuid

Object getObjectByUuid(String uuid)
                       throws ObjectContentManagerException
Get an object from the JCR repository

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

getObject

Object getObject(String path,
                 String versionNumber)
                 throws ObjectContentManagerException
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:
ObjectContentManagerException - when it is not possible to retrieve the object

getObject

Object getObject(Class objectClass,
                 String path)
                 throws ObjectContentManagerException
Get an object from the JCR repository

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

getObject

Object getObject(Class objectClass,
                 String path,
                 String versionNumber)
                 throws ObjectContentManagerException
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:
ObjectContentManagerException - when it is not possible to retrieve the object

retrieveMappedAttribute

void retrieveMappedAttribute(Object object,
                             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(Object object)
Retrieve all mapped attributes for the given persistent object.

Parameters:
object - The persistent object

remove

void remove(String path)
            throws ObjectContentManagerException
Remove an object from a JCR repository

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

remove

void remove(Object object)
            throws ObjectContentManagerException
Remove an object from a JCR repository

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

remove

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

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

getObject

Object getObject(Query query)
                 throws ObjectContentManagerException
Retrieve an object matching to a query

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

getObjects

Collection getObjects(Query query)
                      throws ObjectContentManagerException
Retrieve some objects matching to a query

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

getObjects

Collection getObjects(Class objectClass,
                      String path)
                      throws ObjectContentManagerException
Returns a list of objects of that particular class which are associated to a specific path. This method is helpfull when same name sibling is used to create nodes. This would not return the objects anywhere below the denoted path.

Parameters:
objectClass -
path - Node path.
Returns:
a collection of object found
Throws:
ObjectContentManagerException

getObjects

Collection getObjects(String query,
                      String language)
Return a list of object matching to a JCR query

Parameters:
query - the JCR query
language - the JCR Language ("XPATH" or "SQL").
Returns:

getObjectIterator

Iterator getObjectIterator(Query query)
                           throws ObjectContentManagerException
Retrieve some objects matching to a query.

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

getObjectIterator

Iterator getObjectIterator(String query,
                           String language)
Retrieve an objects matching a query specified in a specific query language. This method is expected to call create a Query using the session's QueryManager with the given query exception and language parameters.

If the query statement is syntactically invalid, given the language specified, an InvalidQueryException is thrown. The language must be a string from among those returned by javax.jcr.QueryManager.getSupportedQueryLanguages(); if it is not, then an InvalidQueryException is thrown.

Parameters:
query - The query to execute to find the objects.
language - The language in which the query is written
Returns:
An iterator of objects instances. Each entry in the iterator represents the mapping of a node returned by the query. If the query returns a node, which may not be mapped, the respective node is ignored.
Throws:
InvalidQueryException - If the query is not a valid JCR Query according to the specified language
ObjectContentManagerException - If an error occurrs querying for the objects.
See Also:
QueryManager.createQuery(String, String), QueryManager.getSupportedQueryLanguages()

checkout

void checkout(String path)
              throws 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:
VersionException - when it is not possible to create a new version

checkin

void checkin(String path)
             throws VersionException
Checkin an object

Parameters:
path - the object path
Throws:
VersionException - when it is not possible to checkin

checkin

void checkin(String path,
             String[] versionLabels)
             throws 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:
VersionException - when it is possible to checkin

getVersionLabels

String[] getVersionLabels(String path,
                          String versionName)
                          throws 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:
VersionException - when it is not to get all version labels

getAllVersionLabels

String[] getAllVersionLabels(String path)
                             throws VersionException
Get all version labels assigned to all versions

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

addVersionLabel

void addVersionLabel(String path,
                     String versionName,
                     String versionLabel)
                     throws 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:
VersionException - when it is not possible to add a new version label to this version

getAllVersions

VersionIterator getAllVersions(String path)
                               throws VersionException
Get all object versions

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

getRootVersion

Version getRootVersion(String path)
                       throws VersionException
Get the first object version

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

getBaseVersion

Version getBaseVersion(String path)
                       throws VersionException
Get the lastest object version

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

getVersion

Version getVersion(String path,
                   String versionName)
                   throws VersionException
Get a particular version

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

save

void save()
          throws ObjectContentManagerException
Save all modifications made by the object content manager

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

logout

void logout()
            throws ObjectContentManagerException
Close the session

Throws:
ObjectContentManagerException - when it is not possible to logout

lock

Lock lock(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 - Wrapper object for a JCR lock
Throws:
LockedException - if path is locked (cannot lock same path again)

unlock

void unlock(String path,
            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(String absPath)
Is that path locked?

Parameters:
absPath -
Returns:
true if path locked

getQueryManager

QueryManager getQueryManager()
Returns:
The query manager reference

refresh

void refresh(boolean keepChanges)
Refresh the underlying jcr session (see the jcr spec)

Parameters:
keepChanges -

move

void move(String srcPath,
          String destPath)
          throws ObjectContentManagerException
Move an object

Parameters:
srcPath - path of the object to move
destPath - destination path
Throws:
ObjectContentManagerException

copy

void copy(String srcPath,
          String destPath)
          throws ObjectContentManagerException
Copy an object

Parameters:
srcPath - path of the object to copy
destPath - destination path
Throws:
ObjectContentManagerException

getSession

Session getSession()
This method returns the JCR session. The JCR session could be used to make some JCR specific calls.

Returns:
the associated JCR session


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