Class RepositoryConfig
- java.lang.Object
-
- org.apache.jackrabbit.core.config.RepositoryConfig
-
- All Implemented Interfaces:
DataStoreFactory
,FileSystemFactory
,QueryHandlerFactory
public class RepositoryConfig extends Object implements FileSystemFactory, DataStoreFactory, QueryHandlerFactory
Repository configuration. This configuration class is used to create configured repository objects.The contained configuration information are: the home directory and name of the repository, the access manager, file system and versioning configuration, repository index configuration, the workspace directory, the default workspace name, and the workspace configuration template. In addition the workspace configuration object keeps track of all configured workspaces.
-
-
Constructor Summary
Constructors Constructor Description RepositoryConfig(String home, SecurityConfig sec, FileSystemFactory fsf, String workspaceDirectory, String workspaceConfigDirectory, String defaultWorkspace, int workspaceMaxIdleTime, Element template, VersioningConfig vc, QueryHandlerFactory qhf, ClusterConfig cc, DataStoreFactory dsf, RepositoryLockMechanismFactory rlf, DataSourceConfig dsc, ConnectionFactory cf, RepositoryConfigurationParser parser)
Creates a repository configuration object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static RepositoryConfig
create(File dir)
Returns the configuration of a repository in a given repository directory.static RepositoryConfig
create(File xml, File dir)
Returns the configuration of a repository with the given configuration file and repository home directory.static RepositoryConfig
create(InputStream input, String home)
Convenience method that wraps the configuration input stream into anInputSource
and invokes thecreate(InputSource, String)
method.static RepositoryConfig
create(String file, String home)
Convenience method that wraps the configuration file name into anInputSource
and invokes thecreate(InputSource, String)
method.static RepositoryConfig
create(URI uri, String home)
Convenience method that wraps the configuration URI into anInputSource
and invokes thecreate(InputSource, String)
method.static RepositoryConfig
create(RepositoryConfig config)
Creates a repository configuration object based on an existing configuration.static RepositoryConfig
create(InputSource xml, String home)
Convenience method that invokes thecreate(InputSource, Properties)
method with the given repository home home directory path set as the ${rep.home} parser variable.static RepositoryConfig
create(InputSource xml, Properties variables)
Parses the given repository configuration document using the given parser variables.WorkspaceConfig
createWorkspaceConfig(String name, StringBuffer configContent)
Creates a new workspace configuration with the specified name.WorkspaceConfig
createWorkspaceConfig(String name, InputSource template)
Creates a new workspace configuration with the specified name.AccessManagerConfig
getAccessManagerConfig()
Deprecated.UseSecurityConfig.getAccessManagerConfig()
instead.String
getAppName()
Deprecated.UseSecurityConfig.getAppName()
instead.ClusterConfig
getClusterConfig()
Returns the cluster configuration.ConnectionFactory
getConnectionFactory()
Returns theConnectionFactory
for this repository.DataStore
getDataStore()
Creates and returns the configured data store.String
getDefaultWorkspaceName()
Returns the name of the default workspace.FileSystem
getFileSystem()
Creates and returns the configured repository file system.String
getHomeDir()
Returns the repository home directory.LoginModuleConfig
getLoginModuleConfig()
Deprecated.UseSecurityConfig.getLoginModuleConfig()
instead.QueryHandler
getQueryHandler(QueryHandlerContext context)
Returns the initialized query handler, ornull
if one has not been configured.static File
getRepositoryHome(Properties variables)
RepositoryLockMechanism
getRepositoryLockMechanism()
Creates and returns the configured repository lock mechanism.SecurityConfig
getSecurityConfig()
Returns the repository security configuration.VersioningConfig
getVersioningConfig()
Returns the repository versioning configuration.WorkspaceConfig
getWorkspaceConfig(String name)
Returns the configuration of the specified workspace.Collection<WorkspaceConfig>
getWorkspaceConfigs()
Returns all workspace configurations.int
getWorkspaceMaxIdleTime()
Returns the amount of time in seconds after which an idle workspace is automatically shutdown.String
getWorkspacesConfigRootDir()
Returns the workspace root directory.void
init()
Initializes the repository configuration.static RepositoryConfig
install(File dir)
Returns the configuration of a repository in a given repository directory.static RepositoryConfig
install(File xml, File dir)
Returns the configuration of a repository with the given configuration file and repository home directory.static RepositoryConfig
install(Properties variables)
Returns the configuration of a repository with the home directory, configuration file, and other options as specified in the given configuration parser variables.boolean
isSearchEnabled()
Checks whether search configuration is present.
-
-
-
Constructor Detail
-
RepositoryConfig
public RepositoryConfig(String home, SecurityConfig sec, FileSystemFactory fsf, String workspaceDirectory, String workspaceConfigDirectory, String defaultWorkspace, int workspaceMaxIdleTime, Element template, VersioningConfig vc, QueryHandlerFactory qhf, ClusterConfig cc, DataStoreFactory dsf, RepositoryLockMechanismFactory rlf, DataSourceConfig dsc, ConnectionFactory cf, RepositoryConfigurationParser parser)
Creates a repository configuration object.- Parameters:
home
- repository home directorysec
- the security configurationfsf
- file system factoryworkspaceDirectory
- workspace root directoryworkspaceConfigDirectory
- optional workspace configuration directorydefaultWorkspace
- name of the default workspaceworkspaceMaxIdleTime
- maximum workspace idle time in secondstemplate
- workspace configuration templatevc
- versioning configurationqhf
- query handler factory for the system search managercc
- optional cluster configurationdsf
- data store factoryrlf
- the RepositoryLockMechanismFactorydsc
- the DataSource configurationcf
- the ConnectionFactory for all DatabasAware beansparser
- configuration parser
-
-
Method Detail
-
install
public static RepositoryConfig install(File dir) throws IOException, ConfigurationException
Returns the configuration of a repository in a given repository directory. The repository configuration is read from a "repository.xml" file inside the repository directory.The directory is created if it does not exist. If the repository configuration file does not exist, then it is created using the default Jackrabbit configuration settings.
- Parameters:
dir
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errorsIOException
- If an error occurs.- Since:
- Apache Jackrabbit 1.6
-
install
public static RepositoryConfig install(Properties variables) throws IOException, ConfigurationException
Returns the configuration of a repository with the home directory, configuration file, and other options as specified in the given configuration parser variables.The directory is created if it does not exist. If the repository configuration file does not exist, then it is created using the default Jackrabbit configuration settings.
- Parameters:
variables
- parser variables- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errorsIOException
- If an error occurs.- Since:
- Apache Jackrabbit 2.1
-
getRepositoryHome
public static File getRepositoryHome(Properties variables)
-
install
public static RepositoryConfig install(File xml, File dir) throws IOException, ConfigurationException
Returns the configuration of a repository with the given configuration file and repository home directory.The directory is created if it does not exist. If the repository configuration file does not exist, then it is created using the default Jackrabbit configuration settings.
- Parameters:
xml
- the configuration file.dir
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errorsIOException
- If another error occurs.- Since:
- Apache Jackrabbit 1.6
-
create
public static RepositoryConfig create(File dir) throws ConfigurationException
Returns the configuration of a repository in a given repository directory. The repository configuration is read from a "repository.xml" file inside the repository directory.An exception is thrown if the directory does not exist or if the repository configuration file can not be read.
- Parameters:
dir
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- Since:
- Apache Jackrabbit 1.6
-
create
public static RepositoryConfig create(File xml, File dir) throws ConfigurationException
Returns the configuration of a repository with the given configuration file and repository home directory.An exception is thrown if the directory does not exist or if the repository configuration file can not be read.
- Parameters:
xml
- The configuration file.dir
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- Since:
- Apache Jackrabbit 1.6
-
create
public static RepositoryConfig create(String file, String home) throws ConfigurationException
Convenience method that wraps the configuration file name into anInputSource
and invokes thecreate(InputSource, String)
method.- Parameters:
file
- repository configuration file namehome
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- See Also:
create(InputSource, String)
-
create
public static RepositoryConfig create(URI uri, String home) throws ConfigurationException
Convenience method that wraps the configuration URI into anInputSource
and invokes thecreate(InputSource, String)
method.- Parameters:
uri
- repository configuration URIhome
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- See Also:
create(InputSource, String)
-
create
public static RepositoryConfig create(InputStream input, String home) throws ConfigurationException
Convenience method that wraps the configuration input stream into anInputSource
and invokes thecreate(InputSource, String)
method.- Parameters:
input
- repository configuration input streamhome
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- See Also:
create(InputSource, String)
-
create
public static RepositoryConfig create(InputSource xml, String home) throws ConfigurationException
Convenience method that invokes thecreate(InputSource, Properties)
method with the given repository home home directory path set as the ${rep.home} parser variable. Also all system properties are used as parser variables.- Parameters:
xml
- repository configuration documenthome
- repository home directory- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors
-
create
public static RepositoryConfig create(InputSource xml, Properties variables) throws ConfigurationException
Parses the given repository configuration document using the given parser variables. Note that the ${rep.home} variable should be set by the caller!Note that in addition to parsing the repository configuration, this method also initializes the configuration (creates the configured directories, etc.). The
ConfigurationParser
class should be used directly to just parse the configuration.- Parameters:
xml
- repository configuration documentvariables
- parser variables- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors- Since:
- Apache Jackrabbit 2.1
-
create
public static RepositoryConfig create(RepositoryConfig config) throws ConfigurationException
Creates a repository configuration object based on an existing configuration. The factories contained within the configuration will be newly initialized, but all other information will be the same.- Parameters:
config
- repository configuration to create the new instance from- Returns:
- repository configuration
- Throws:
ConfigurationException
- on configuration errors
-
init
public void init() throws ConfigurationException, IllegalStateException
Initializes the repository configuration. This method loads the configurations for all available workspaces.- Throws:
ConfigurationException
- on initialization errorsIllegalStateException
- if the repository configuration has already been initialized
-
createWorkspaceConfig
public WorkspaceConfig createWorkspaceConfig(String name, StringBuffer configContent) throws ConfigurationException
Creates a new workspace configuration with the specified name. This method creates a workspace configuration subdirectory, copies the workspace configuration template into it, and finally adds the created workspace configuration to the repository. The initialized workspace configuration object is returned to the caller.- Parameters:
name
- workspace nameconfigContent
- optional StringBuffer that will have the content of workspace configuration file written in- Returns:
- created workspace configuration
- Throws:
ConfigurationException
- if creating the workspace configuration failed
-
createWorkspaceConfig
public WorkspaceConfig createWorkspaceConfig(String name, InputSource template) throws ConfigurationException
Creates a new workspace configuration with the specified name. This method uses the provided workspacetemplate
to create the repository config instead of the template that is present in the repository configuration.This method creates a workspace configuration subdirectory, copies the workspace configuration template into it, and finally adds the created workspace configuration to the repository. The initialized workspace configuration object is returned to the caller.
- Parameters:
name
- workspace nametemplate
- the workspace template- Returns:
- created workspace configuration
- Throws:
ConfigurationException
- if creating the workspace configuration failed
-
getHomeDir
public String getHomeDir()
Returns the repository home directory.- Returns:
- repository home directory
-
getFileSystem
public FileSystem getFileSystem() throws RepositoryException
Creates and returns the configured repository file system.- Specified by:
getFileSystem
in interfaceFileSystemFactory
- Returns:
- the configured
FileSystem
- Throws:
RepositoryException
- if the file system can not be created
-
getAppName
public String getAppName()
Deprecated.UseSecurityConfig.getAppName()
instead.Returns the repository name. The repository name can be used for JAAS app-entry configuration.- Returns:
- repository name
-
getAccessManagerConfig
public AccessManagerConfig getAccessManagerConfig()
Deprecated.UseSecurityConfig.getAccessManagerConfig()
instead.Returns the repository access manager configuration.- Returns:
- access manager configuration
-
getLoginModuleConfig
public LoginModuleConfig getLoginModuleConfig()
Deprecated.UseSecurityConfig.getLoginModuleConfig()
instead.Returns the repository login module configuration.- Returns:
- login module configuration, or
null
if standard JAAS mechanism should be used.
-
getSecurityConfig
public SecurityConfig getSecurityConfig()
Returns the repository security configuration.- Returns:
- security configuration
-
getWorkspacesConfigRootDir
public String getWorkspacesConfigRootDir()
Returns the workspace root directory.- Returns:
- workspace root directory
-
getDefaultWorkspaceName
public String getDefaultWorkspaceName()
Returns the name of the default workspace.- Returns:
- name of the default workspace
-
getWorkspaceMaxIdleTime
public int getWorkspaceMaxIdleTime()
Returns the amount of time in seconds after which an idle workspace is automatically shutdown. If zero then idle workspaces will never be automatically shutdown.- Returns:
- maximum workspace idle time in seconds
-
getWorkspaceConfigs
public Collection<WorkspaceConfig> getWorkspaceConfigs()
Returns all workspace configurations.- Returns:
- workspace configurations
-
getWorkspaceConfig
public WorkspaceConfig getWorkspaceConfig(String name)
Returns the configuration of the specified workspace.- Parameters:
name
- workspace name- Returns:
- workspace configuration, or
null
if the named workspace does not exist
-
getVersioningConfig
public VersioningConfig getVersioningConfig()
Returns the repository versioning configuration.- Returns:
- versioning configuration
-
isSearchEnabled
public boolean isSearchEnabled()
Checks whether search configuration is present.- Returns:
true
if search is configured,false
otherwise
-
getQueryHandler
public QueryHandler getQueryHandler(QueryHandlerContext context) throws RepositoryException
Returns the initialized query handler, ornull
if one has not been configured.- Specified by:
getQueryHandler
in interfaceQueryHandlerFactory
- Returns:
- initialized query handler, or
null
- Throws:
RepositoryException
-
getClusterConfig
public ClusterConfig getClusterConfig()
Returns the cluster configuration. Returnsnull
if clustering has not been configured.- Returns:
- the cluster configuration or
null
if clustering has not been configured.
-
getConnectionFactory
public ConnectionFactory getConnectionFactory()
Returns theConnectionFactory
for this repository. Please note that it must be closed explicitly.- Returns:
- The connection factory configured for this repository.
-
getDataStore
public DataStore getDataStore() throws RepositoryException
Creates and returns the configured data store. Returnsnull
if a data store has not been configured.- Specified by:
getDataStore
in interfaceDataStoreFactory
- Returns:
- the configured data store, or
null
- Throws:
RepositoryException
- if the data store can not be created
-
getRepositoryLockMechanism
public RepositoryLockMechanism getRepositoryLockMechanism() throws RepositoryException
Creates and returns the configured repository lock mechanism. This method returns the default repository lock mechanism if no other mechanism is configured.- Returns:
- the repository lock mechanism (never
null
) - Throws:
RepositoryException
- if the repository lock mechanism can not be created
-
-