org.priha.core
Class ProviderManager

java.lang.Object
  extended by org.priha.core.ProviderManager
All Implemented Interfaces:
ItemStore

public class ProviderManager
extends java.lang.Object
implements ItemStore

This is a front-end class for managing multiple providers for a single repository.

The ProviderManager is a singleton per Repository.


Field Summary
static java.lang.String DEFAULT_PROVIDERLIST
           
static java.lang.String PROP_PRIHA_PROVIDER_PREFIX
           
static java.lang.String PROP_PRIHA_PROVIDERS
           
 
Constructor Summary
ProviderManager(RepositoryImpl repository)
           
 
Method Summary
 void addNode(StoreTransaction tx, NodeImpl ni)
           
 void close(WorkspaceImpl impl)
           
 void copy(WorkspaceImpl m_workspace, Path srcpath, Path destpath)
           
static java.util.Properties filterProperties(RepositoryImpl repository, java.lang.String providerName)
          Filters the properties set when the Repository was created to find the property set for a provider.
 NodeImpl findByUUID(WorkspaceImpl ws, java.lang.String uuid)
           
 java.lang.String getDefaultWorkspace()
          Returns the name of the default workspace.
 ItemImpl getItem(WorkspaceImpl ws, Path path)
           
 java.util.Collection<? extends PropertyImpl> getReferences(WorkspaceImpl ws, java.lang.String uuid)
          Locate all properties of type REFERENCE with the content of the particular UUID.
static RepositoryProvider instantiateProvider(RepositoryImpl rep, java.lang.String className, java.util.Properties props)
          Instantiates a RepositoryProvider using the given class name and the properties, and calls its start() method.
 boolean itemExists(WorkspaceImpl ws, Path path, ItemType type)
           
 java.util.List<Path> listNodes(WorkspaceImpl impl, Path path)
           
 java.util.List<QName> listProperties(WorkspaceImpl ws, Path path)
           
 java.util.Collection<java.lang.String> listWorkspaces()
          Returns the set of workspaces declared in the config file.
 NodeImpl loadNode(WorkspaceImpl ws, Path path)
          Loads the state of a node from the repository.
 void open(javax.jcr.Credentials credentials, java.lang.String workspaceName)
           
 void putProperty(StoreTransaction tx, Path path, ValueContainer value)
           
 void remove(StoreTransaction tx, Path path)
          Removes the item at the end of the path.
 void reorderNodes(StoreTransaction tx, Path internalPath, java.util.List<Path> childOrder)
           
 void stop()
           
 void storeCancelled(StoreTransaction tx)
           
 void storeFinished(StoreTransaction tx)
           
 StoreTransaction storeStarted(WorkspaceImpl ws)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_PRIHA_PROVIDERS

public static final java.lang.String PROP_PRIHA_PROVIDERS
See Also:
Constant Field Values

PROP_PRIHA_PROVIDER_PREFIX

public static final java.lang.String PROP_PRIHA_PROVIDER_PREFIX
See Also:
Constant Field Values

DEFAULT_PROVIDERLIST

public static final java.lang.String DEFAULT_PROVIDERLIST
See Also:
Constant Field Values
Constructor Detail

ProviderManager

public ProviderManager(RepositoryImpl repository)
                throws ConfigurationException
Throws:
ConfigurationException
Method Detail

filterProperties

public static java.util.Properties filterProperties(RepositoryImpl repository,
                                                    java.lang.String providerName)
Filters the properties set when the Repository was created to find the property set for a provider.

Essentially returns a property set where all instances of priha.provider.[providerName].property = value are replaced with property = value.

Parameters:
repository - The repository from which the properties are read
providerName - The name to filter with
Returns:
A valid set of Properties. It can also be empty, if there were no properties defined for this providerName.
See Also:
instantiateProvider(RepositoryImpl, String, Properties)

instantiateProvider

public static RepositoryProvider instantiateProvider(RepositoryImpl rep,
                                                     java.lang.String className,
                                                     java.util.Properties props)
                                              throws ConfigurationException
Instantiates a RepositoryProvider using the given class name and the properties, and calls its start() method.

Parameters:
rep - The RepositoryImpl who will own this RepositoryProvider
className - The FQN of the class.
props - A filtered set of Properties
Returns:
A started RepositoryProvider.
Throws:
ConfigurationException - If the provider cannot be instantiated or the configuration is faulty.
See Also:
filterProperties(RepositoryImpl, String)

open

public void open(javax.jcr.Credentials credentials,
                 java.lang.String workspaceName)
          throws javax.jcr.NoSuchWorkspaceException,
                 javax.jcr.RepositoryException
Specified by:
open in interface ItemStore
Throws:
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException

listWorkspaces

public java.util.Collection<java.lang.String> listWorkspaces()
                                                      throws ConfigurationException
Returns the set of workspaces declared in the config file.

Specified by:
listWorkspaces in interface ItemStore
Throws:
ConfigurationException

listNodes

public java.util.List<Path> listNodes(WorkspaceImpl impl,
                                      Path path)
                               throws javax.jcr.RepositoryException
Specified by:
listNodes in interface ItemStore
Throws:
javax.jcr.RepositoryException

close

public void close(WorkspaceImpl impl)
Specified by:
close in interface ItemStore

remove

public void remove(StoreTransaction tx,
                   Path path)
            throws javax.jcr.RepositoryException
Removes the item at the end of the path.

Specified by:
remove in interface ItemStore
Parameters:
impl -
path -
Throws:
javax.jcr.RepositoryException

loadNode

public NodeImpl loadNode(WorkspaceImpl ws,
                         Path path)
                  throws javax.jcr.RepositoryException
Loads the state of a node from the repository.

Parameters:
ws - TODO
path -
Returns:
A brand new NodeImpl.
Throws:
javax.jcr.RepositoryException

addNode

public void addNode(StoreTransaction tx,
                    NodeImpl ni)
             throws javax.jcr.RepositoryException
Specified by:
addNode in interface ItemStore
Throws:
javax.jcr.RepositoryException

copy

public void copy(WorkspaceImpl m_workspace,
                 Path srcpath,
                 Path destpath)
          throws javax.jcr.RepositoryException
Specified by:
copy in interface ItemStore
Throws:
javax.jcr.RepositoryException

findByUUID

public NodeImpl findByUUID(WorkspaceImpl ws,
                           java.lang.String uuid)
                    throws javax.jcr.RepositoryException
Specified by:
findByUUID in interface ItemStore
Throws:
javax.jcr.RepositoryException

getItem

public ItemImpl getItem(WorkspaceImpl ws,
                        Path path)
                 throws InvalidPathException,
                        javax.jcr.RepositoryException
Specified by:
getItem in interface ItemStore
Throws:
InvalidPathException
javax.jcr.RepositoryException

itemExists

public boolean itemExists(WorkspaceImpl ws,
                          Path path,
                          ItemType type)
                   throws javax.jcr.RepositoryException
Specified by:
itemExists in interface ItemStore
Throws:
javax.jcr.RepositoryException

putProperty

public void putProperty(StoreTransaction tx,
                        Path path,
                        ValueContainer value)
                 throws javax.jcr.RepositoryException
Specified by:
putProperty in interface ItemStore
Throws:
javax.jcr.RepositoryException

stop

public void stop()
Specified by:
stop in interface ItemStore

getReferences

public java.util.Collection<? extends PropertyImpl> getReferences(WorkspaceImpl ws,
                                                                  java.lang.String uuid)
                                                           throws javax.jcr.RepositoryException
Description copied from interface: ItemStore
Locate all properties of type REFERENCE with the content of the particular UUID.

Specified by:
getReferences in interface ItemStore
Returns:
Throws:
javax.jcr.RepositoryException

listProperties

public java.util.List<QName> listProperties(WorkspaceImpl ws,
                                            Path path)
                                     throws javax.jcr.RepositoryException
Specified by:
listProperties in interface ItemStore
Throws:
javax.jcr.RepositoryException

storeStarted

public StoreTransaction storeStarted(WorkspaceImpl ws)
                              throws javax.jcr.RepositoryException
Specified by:
storeStarted in interface ItemStore
Throws:
javax.jcr.RepositoryException

storeFinished

public void storeFinished(StoreTransaction tx)
                   throws javax.jcr.RepositoryException
Specified by:
storeFinished in interface ItemStore
Throws:
javax.jcr.RepositoryException

storeCancelled

public void storeCancelled(StoreTransaction tx)
                    throws javax.jcr.RepositoryException
Specified by:
storeCancelled in interface ItemStore
Throws:
javax.jcr.RepositoryException

getDefaultWorkspace

public java.lang.String getDefaultWorkspace()
Returns the name of the default workspace. This is usually "default", but it may change depending on how you configure Priha.

Returns:

reorderNodes

public void reorderNodes(StoreTransaction tx,
                         Path internalPath,
                         java.util.List<Path> childOrder)
                  throws javax.jcr.RepositoryException
Specified by:
reorderNodes in interface ItemStore
Throws:
javax.jcr.RepositoryException