org.priha.core
Class SessionProvider

java.lang.Object
  extended by org.priha.core.SessionProvider

public class SessionProvider
extends java.lang.Object

This is a special provider which stores the state of the Session.

At the moment this could be O(N) depending on the size of the unsaved items.


Constructor Summary
SessionProvider(SessionImpl session, ItemStore source)
           
 
Method Summary
 void addNode(NodeImpl ni)
          Call when you wish to add a new Node in this Session.
 void clear()
           
 void close()
           
 void copy(Path srcpath, Path destpath)
           
 NodeImpl findByUUID(java.lang.String uuid)
           
 ItemImpl getItem(Path path)
           
 Path getPath(PathRef p)
           
 PathManager getPathManager()
           
 java.util.List<PropertyImpl> getReferences(java.lang.String uuid)
          Finds all references to the given UUID.
 ItemState getState(PathRef m_path)
           
 boolean hasPendingChanges()
           
 boolean itemExists(Path path, ItemType type)
           
 java.util.List<Path> listNodes(Path parentpath)
           
 java.util.Collection<? extends Path> listProperties(Path path)
           
 java.util.Collection<? extends java.lang.String> listWorkspaces()
           
 boolean nodeExistsInRepository(Path path)
          Goes directly into the repository, to find whether a Node exists currently.
 void putProperty(NodeImpl impl, PropertyImpl property)
           
 void refresh(boolean keepChanges, Path path)
          Refreshes all the items within the given path.
 void remove(ItemImpl item)
           
 void save()
          Saves everything starting from root node.
 void save(Path path)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionProvider

public SessionProvider(SessionImpl session,
                       ItemStore source)
Method Detail

save

public void save()
          throws javax.jcr.RepositoryException
Saves everything starting from root node.

Throws:
javax.jcr.RepositoryException - If something goes wrong.

addNode

public void addNode(NodeImpl ni)
             throws javax.jcr.RepositoryException
Call when you wish to add a new Node in this Session.

Parameters:
ni - Node to add
Throws:
javax.jcr.RepositoryException - If the Path cannot be determined.

getItem

public ItemImpl getItem(Path path)
                 throws InvalidPathException,
                        javax.jcr.RepositoryException
Throws:
InvalidPathException
javax.jcr.RepositoryException

close

public void close()

copy

public void copy(Path srcpath,
                 Path destpath)
          throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

findByUUID

public NodeImpl findByUUID(java.lang.String uuid)
                    throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

getReferences

public java.util.List<PropertyImpl> getReferences(java.lang.String uuid)
                                           throws javax.jcr.RepositoryException
Finds all references to the given UUID.

Parameters:
uuid -
Returns:
Throws:
javax.jcr.RepositoryException

listNodes

public java.util.List<Path> listNodes(Path parentpath)
                               throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

listWorkspaces

public java.util.Collection<? extends java.lang.String> listWorkspaces()
                                                                throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

itemExists

public boolean itemExists(Path path,
                          ItemType type)
                   throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

remove

public void remove(ItemImpl item)
            throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

stop

public void stop()

hasPendingChanges

public boolean hasPendingChanges()

clear

public void clear()

save

public void save(Path path)
          throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

listProperties

public java.util.Collection<? extends Path> listProperties(Path path)
                                                    throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

putProperty

public void putProperty(NodeImpl impl,
                        PropertyImpl property)
                 throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

refresh

public void refresh(boolean keepChanges,
                    Path path)
Refreshes all the items within the given path.

Parameters:
keepChanges - If true, does nothing (Priha implements COPY-ON-WRITE). If false, purges all changes from the path.
path - The path from which to start refreshing.

nodeExistsInRepository

public boolean nodeExistsInRepository(Path path)
                               throws javax.jcr.RepositoryException
Goes directly into the repository, to find whether a Node exists currently. It ignores the transient state; so any new node additions or removals are ignored.

Parameters:
path - The path to check
Returns:
True, if the backend holds a given Node.
Throws:
javax.jcr.RepositoryException - If something goes wrong.

getPath

public Path getPath(PathRef p)
             throws javax.jcr.PathNotFoundException
Throws:
javax.jcr.PathNotFoundException

getPathManager

public PathManager getPathManager()

getState

public ItemState getState(PathRef m_path)
                   throws javax.jcr.PathNotFoundException
Throws:
javax.jcr.PathNotFoundException