org.chromattic.api
Interface ChromatticSession


public interface ChromatticSession

Version:
$Revision$
Author:
Julien Viet

Method Summary
 void addEventListener(EventListener listener)
           
 void close()
           
<O> O
create(Class<O> clazz)
          Creates a transient instance of the specified object.
<O> O
create(Class<O> clazz, String name)
          Creates a transient instance of the specified object.
 QueryBuilder<?> createQueryBuilder()
           
<O> O
findById(Class<O> clazz, String id)
          Finds an object from its identifier or return null if no such object can be found.
<O> O
findByNode(Class<O> clazz, javax.jcr.Node node)
          Finds an object mapped to the provided node.
<O> O
findByPath(Class<O> clazz, String relPath)
          Finds an object with a path relative to a chromattic root object.
<O> O
findByPath(Object origin, Class<O> clazz, String relPath)
          Finds an object with a path relative to a specified origin object.
 String getId(Object o)
           
 javax.jcr.Session getJCRSession()
           
 String getName(Object o)
           
 String getPath(Object o)
           
 Status getStatus(Object o)
           
<O> O
insert(Class<O> clazz, String name)
          Creates a persistent instance of the specified object.
<O> O
insert(Object parent, Class<O> clazz, String name)
          Creates a persistent instance of the specified object.
 String persist(Object o)
          Persists a transient object relative to the root node.
 String persist(Object parent, Object child)
          Persists a transient object.
 String persist(Object parent, Object o, String name)
          Persists a transient object.
 String persist(Object o, String name)
          Persists a transient object.
 void remove(Object o)
           
 void save()
           
 

Method Detail

create

<O> O create(Class<O> clazz)
         throws NullPointerException,
                IllegalArgumentException,
                ChromatticException
Creates a transient instance of the specified object.

Parameters:
clazz - the object class
Returns:
the instance
Throws:
NullPointerException - if the specified clazz is null
IllegalArgumentException - if the specified class is not a chromattic class
ChromatticException - any chromattic exception

create

<O> O create(Class<O> clazz,
             String name)
         throws NullPointerException,
                IllegalArgumentException,
                ChromatticException
Creates a transient instance of the specified object. The name if it is not null will be used later when the object is inserted in the JCR session. The clazz argument must be annotated class with the NodeMapping annotation.

Type Parameters:
O - the object class parameter
Parameters:
clazz - the object class
name - the node name
Returns:
the transient object
Throws:
NullPointerException - if the clazz argument is null
IllegalArgumentException - if the name format is not valid or the class is not a chromattic class
ChromatticException - any chromattic exception

insert

<O> O insert(Class<O> clazz,
             String name)
         throws NullPointerException,
                IllegalArgumentException,
                ChromatticException
Creates a persistent instance of the specified object.

Type Parameters:
O - the object class parameter
Parameters:
clazz - the object class
name - the name under root node
Returns:
the persistent object
Throws:
NullPointerException - if any argument is null
IllegalArgumentException - if the name is not valid or the class is not a chromattic class
ChromatticException - any chromattic exception

insert

<O> O insert(Object parent,
             Class<O> clazz,
             String name)
         throws NullPointerException,
                IllegalArgumentException,
                ChromatticException
Creates a persistent instance of the specified object.

Type Parameters:
O - the object class parameter
Parameters:
parent - the parent object
clazz - the object class
name - the object name
Returns:
the persistent object
Throws:
NullPointerException - if any argument is null
IllegalArgumentException - if the name is not valid or the class is not a chromattic class or the parent is not a persistent object
ChromatticException - any chromattic exception

persist

String persist(Object o,
               String name)
               throws NullPointerException,
                      IllegalArgumentException,
                      ChromatticException
Persists a transient object.

Parameters:
o - the object to persist
name - the object relative path to the root
Returns:
the object id
Throws:
NullPointerException - if any argument is null
IllegalArgumentException - if the name is not valid or the object is not a chromattic transient object
ChromatticException - any chromattic exception

persist

String persist(Object parent,
               Object child)
               throws NullPointerException,
                      IllegalArgumentException,
                      ChromatticException
Persists a transient object.

Parameters:
parent - the parent object
child - the object to persist
Returns:
the object id
Throws:
NullPointerException - if any argument is not valid
IllegalArgumentException - if the parent is not a persistent object or the object is not a chromattic transient object
ChromatticException - any chromattic exception

persist

String persist(Object o)
               throws NullPointerException,
                      IllegalArgumentException,
                      ChromatticException
Persists a transient object relative to the root node.

Parameters:
o - the object to persist
Returns:
the object id
Throws:
NullPointerException - if any argument is not valid
IllegalArgumentException - if the object is not a chromattic transient object
ChromatticException - any chromattic exception

persist

String persist(Object parent,
               Object o,
               String name)
               throws NullPointerException,
                      IllegalArgumentException,
                      ChromatticException
Persists a transient object.

Parameters:
parent - the parent object
o - the object to persist
name - the object relative name to the parent
Returns:
the object id
Throws:
NullPointerException - if the parent or object argument is null
IllegalArgumentException - if the parent is not a persistent object or the name is not valid or the object is not a chromattic transient object
ChromatticException - any chromattic exception

findByPath

<O> O findByPath(Object origin,
                 Class<O> clazz,
                 String relPath)
             throws NullPointerException,
                    IllegalArgumentException,
                    ClassCastException,
                    ChromatticException
Finds an object with a path relative to a specified origin object. If the object is not found then the method returns null.

Type Parameters:
O - the object type
Parameters:
origin - the origin object
clazz - the expected class
relPath - the path relative to the origin
Returns:
the object
Throws:
NullPointerException - if any argument is null
IllegalArgumentException - if the origin object is not a chromattic object
ClassCastException - if the object cannot be cast to the specified class
ChromatticException - any chromattic exception

findByPath

<O> O findByPath(Class<O> clazz,
                 String relPath)
             throws NullPointerException,
                    ClassCastException,
                    ChromatticException
Finds an object with a path relative to a chromattic root object. If the object is not found then the method returns null.

Type Parameters:
O - the object type
Parameters:
clazz - the expected class
relPath - the path relative to the chromattic root
Returns:
the object
Throws:
NullPointerException - if any argument is null
ClassCastException - if the object cannot be cast to the specified class
ChromatticException - any chromattic exception

findByNode

<O> O findByNode(Class<O> clazz,
                 javax.jcr.Node node)
             throws NullPointerException,
                    ClassCastException,
                    ChromatticException
Finds an object mapped to the provided node.

Type Parameters:
O - the object type
Parameters:
clazz - the expected class
node - the node
Returns:
the object
Throws:
NullPointerException - if any argument is null
ClassCastException - if the mapped object cannot be cast to the specified class
ChromatticException - any chromattic exception

findById

<O> O findById(Class<O> clazz,
               String id)
           throws NullPointerException,
                  ClassCastException,
                  ChromatticException
Finds an object from its identifier or return null if no such object can be found.

Type Parameters:
O - the object type
Parameters:
clazz - the expected class
id - the id
Returns:
the object
Throws:
NullPointerException - if any argument is null
ClassCastException - if the mapped object cannot be cast to the specified class
ChromatticException - any chromattic exception

createQueryBuilder

QueryBuilder<?> createQueryBuilder()
                                   throws ChromatticException
Throws:
ChromatticException

remove

void remove(Object o)
            throws ChromatticException
Throws:
ChromatticException

getStatus

Status getStatus(Object o)
                 throws ChromatticException
Throws:
ChromatticException

getId

String getId(Object o)
             throws ChromatticException
Throws:
ChromatticException

getName

String getName(Object o)
               throws ChromatticException
Throws:
ChromatticException

getPath

String getPath(Object o)
               throws ChromatticException
Throws:
ChromatticException

addEventListener

void addEventListener(EventListener listener)

save

void save()
          throws ChromatticException
Throws:
ChromatticException

close

void close()

getJCRSession

javax.jcr.Session getJCRSession()


Copyright © 2010 eXo Platform SAS. All Rights Reserved.