org.apache.jackrabbit.ocm.nodemanagement.impl
Class RepositoryUtil

java.lang.Object
  extended by org.apache.jackrabbit.ocm.nodemanagement.impl.RepositoryUtil

public class RepositoryUtil
extends 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 String OCM_NAMESPACE
          namespace constant
static String OCM_NAMESPACE_PREFIX
          namespace prefix constant
static String PATH_SEPARATOR
          Item path separator
 
Constructor Summary
RepositoryUtil()
           
 
Method Summary
static String encodePath(String path)
          Encode a path
static Repository getRepository(String repositoryName)
          Get a repository
static Session login(Repository repository, String user, String password)
          Connect to a JCR repository
static void registerRepository(String repositoryName, String configFile, String homeDir)
          Register a new repository
static void setupSession(Session session)
          Setup the session.
static void unRegisterRepository(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

OCM_NAMESPACE_PREFIX

public static final String OCM_NAMESPACE_PREFIX
namespace prefix constant

See Also:
Constant Field Values

OCM_NAMESPACE

public static final String OCM_NAMESPACE
namespace constant

See Also:
Constant Field Values

PATH_SEPARATOR

public static final String PATH_SEPARATOR
Item path separator

See Also:
Constant Field Values
Constructor Detail

RepositoryUtil

public RepositoryUtil()
Method Detail

registerRepository

public static void registerRepository(String repositoryName,
                                      String configFile,
                                      String homeDir)
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(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 Repository getRepository(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 Session login(Repository repository,
                            String user,
                            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

setupSession

public static void setupSession(Session session)
                         throws RepositoryException
Setup the session. Until now, we check only if the namespace prefix exist in the repository

Throws:
RepositoryException

encodePath

public static String encodePath(String path)
Encode a path

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


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