org.apache.portals.graffito.jcr.repository
Class RepositoryUtil

java.lang.Object
  extended by org.apache.portals.graffito.jcr.repository.RepositoryUtil

public class RepositoryUtil
extends java.lang.Object

Utility class for managing JCR repositories. Note: most of the utility methods in this class can be used only with Jackrabbit.

Version:
$Id: Exp $
Author:
Lombart Christophe

Field Summary
static java.lang.String GRAFFITO_NAMESPACE
          Graffito namespace constant.
static java.lang.String GRAFFITO_NAMESPACE_PREFIX
          Graffito namespace prefix constant.
static org.apache.commons.logging.Log log
           
static java.lang.String PATH_SEPARATOR
          Item path separator
 
Constructor Summary
RepositoryUtil()
           
 
Method Summary
static java.lang.String encodePath(java.lang.String path)
          Encode a path
static java.lang.String getNodeName(java.lang.String path)
          Get the node name
static java.lang.String getParentPath(java.lang.String path)
          Get the parent path
static javax.jcr.Repository getRepository(java.lang.String repositoryName)
          Get a repository
static boolean isValidPath(java.lang.String path)
          Check if a path is valid
static javax.jcr.Session login(javax.jcr.Repository repository, java.lang.String user, java.lang.String password)
          Connect to a JCR repository
static void registerRepository(java.lang.String repositoryName, java.lang.String configFile, java.lang.String homeDir)
          Register a new repository
static void unRegisterRepository(java.lang.String repositoryName)
          Unregister a repository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRAFFITO_NAMESPACE_PREFIX

public static final java.lang.String GRAFFITO_NAMESPACE_PREFIX
Graffito namespace prefix constant.

See Also:
Constant Field Values

GRAFFITO_NAMESPACE

public static final java.lang.String GRAFFITO_NAMESPACE
Graffito namespace constant.

See Also:
Constant Field Values

PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR
Item path separator

See Also:
Constant Field Values

log

public static final org.apache.commons.logging.Log log
Constructor Detail

RepositoryUtil

public RepositoryUtil()
Method Detail

registerRepository

public static void registerRepository(java.lang.String repositoryName,
                                      java.lang.String configFile,
                                      java.lang.String homeDir)
                               throws RepositoryException
Register a new repository

Parameters:
repositoryName - The repository unique name
configFile - The JCR config file
homeDir - The directory containing the complete repository settings (workspace, node types, ...)
Throws:
RepositoryException - when it is not possible to register the repository

unRegisterRepository

public static void unRegisterRepository(java.lang.String repositoryName)
                                 throws RepositoryException
Unregister a repository

Parameters:
repositoryName - The repository unique name
Throws:
RepositoryException - when it is not possible to unregister the repository

getRepository

public static javax.jcr.Repository getRepository(java.lang.String repositoryName)
                                          throws RepositoryException
Get a repository

Parameters:
repositoryName - The repository name
Returns:
a JCR repository reference
Throws:
RepositoryException - when it is not possible to get the repository. Before calling this method, the repository has to be registered (@see RepositoryUtil#registerRepository(String, String, String)

login

public static javax.jcr.Session login(javax.jcr.Repository repository,
                                      java.lang.String user,
                                      java.lang.String password)
                               throws RepositoryException
Connect to a JCR repository

Parameters:
repository - The JCR repository
user - The user name
password - The password
Returns:
a valid JCR session
Throws:
RepositoryException - when it is not possible to connect to the JCR repository

isValidPath

public static boolean isValidPath(java.lang.String path)
Check if a path is valid

Parameters:
path - The path to validate
Returns:
true if the path is valid, else false

getParentPath

public static java.lang.String getParentPath(java.lang.String path)
                                      throws PersistenceException
Get the parent path

Parameters:
path - The path from wich the parent path has to be returned
Returns:
The parent path
Throws:
PersistenceException - when the path is invalid

getNodeName

public static java.lang.String getNodeName(java.lang.String path)
                                    throws PersistenceException
Get the node name

Parameters:
path - The path from which the node name has to be retrieved
Returns:
The node name
Throws:
PersistenceException - when the path is invalid

encodePath

public static java.lang.String encodePath(java.lang.String path)
Encode a path

Parameters:
path - the path to encode
Returns:
the encoded path


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