Package org.apache.jackrabbit.core
Class RepositoryImpl
- java.lang.Object
-
- org.apache.jackrabbit.commons.AbstractRepository
-
- org.apache.jackrabbit.core.RepositoryImpl
-
- All Implemented Interfaces:
Repository
,JackrabbitRepository
,WorkspaceListener
,SessionListener
public class RepositoryImpl extends AbstractRepository implements Repository, JackrabbitRepository, SessionListener, WorkspaceListener
ARepositoryImpl
...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RepositoryImpl.DescriptorValue
Represents a Repository Descriptor Value (either Value or Value[])class
RepositoryImpl.WorkspaceInfo
WorkspaceInfo
holds the objects that are shared among multiple per-sessionWorkspaceImpl
instances representing the same named workspace, i.e.
-
Field Summary
Fields Modifier and Type Field Description static NodeId
ACTIVITIES_NODE_ID
hardcoded id of the "/jcr:system/jcr:activities" nodestatic NodeId
CONFIGURATIONS_NODE_ID
hardcoded id of the "/jcr:system/jcr:configurations" nodeprotected RepositoryContext
context
static String
JACKRABBIT_CLUSTER_ID
Key to astring
descriptor.protected NodeIdFactory
nodeIdFactory
static NodeId
NODETYPES_NODE_ID
hardcoded id of the "/jcr:system/jcr:nodeTypes" nodeprotected RepositoryConfig
repConfig
static NodeId
ROOT_NODE_ID
hardcoded id of the repository root nodestatic NodeId
SYSTEM_ROOT_NODE_ID
hardcoded id of the "/jcr:system" nodestatic NodeId
VERSION_STORAGE_NODE_ID
hardcoded id of the "/jcr:system/jcr:versionStorage" node-
Fields inherited from interface org.apache.jackrabbit.api.JackrabbitRepository
OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED, OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED, OPTION_USER_MANAGEMENT_SUPPORTED
-
Fields inherited from interface javax.jcr.Repository
IDENTIFIER_STABILITY, IDENTIFIER_STABILITY_INDEFINITE_DURATION, IDENTIFIER_STABILITY_METHOD_DURATION, IDENTIFIER_STABILITY_SAVE_DURATION, IDENTIFIER_STABILITY_SESSION_DURATION, LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_INHERITANCE, NODE_TYPE_MANAGEMENT_INHERITANCE_MINIMAL, NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE, NODE_TYPE_MANAGEMENT_INHERITANCE_SINGLE, NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, OPTION_ACCESS_CONTROL_SUPPORTED, OPTION_ACTIVITIES_SUPPORTED, OPTION_BASELINES_SUPPORTED, OPTION_JOURNALED_OBSERVATION_SUPPORTED, OPTION_LIFECYCLE_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_RETENTION_SUPPORTED, OPTION_SHAREABLE_NODES_SUPPORTED, OPTION_SIMPLE_VERSIONING_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_UNFILED_CONTENT_SUPPORTED, OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, OPTION_VERSIONING_SUPPORTED, OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, OPTION_XML_EXPORT_SUPPORTED, OPTION_XML_IMPORT_SUPPORTED, QUERY_FULL_TEXT_SEARCH_SUPPORTED, QUERY_JOINS, QUERY_JOINS_INNER, QUERY_JOINS_INNER_OUTER, QUERY_JOINS_NONE, QUERY_LANGUAGES, QUERY_STORED_QUERIES_SUPPORTED, QUERY_XPATH_DOC_ORDER, QUERY_XPATH_POS_INDEX, REP_NAME_DESC, REP_VENDOR_DESC, REP_VENDOR_URL_DESC, REP_VERSION_DESC, SPEC_NAME_DESC, SPEC_VERSION_DESC, WRITE_SUPPORTED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RepositoryImpl(RepositoryConfig repConfig)
Protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RepositoryImpl
create(RepositoryConfig config)
Creates a newRepositoryImpl
instance.protected ClusterNode
createClusterNode()
Creates the cluster node.GarbageCollector
createDataStoreGarbageCollector()
Creates a data store garbage collector for this repository.protected SharedItemStateManager
createItemStateManager(PersistenceManager persistMgr, boolean usesReferences, ISMLocking locking)
Creates aSharedItemStateManager
or derivative.protected NamespaceRegistryImpl
createNamespaceRegistry()
Protected factory method for creating the namespace registry.protected NodeTypeRegistry
createNodeTypeRegistry()
Protected factory method for creating the node type registry.protected SessionImpl
createSession(Subject subject, String workspaceName)
Creates a new repository session on the specified workspace for the given authenticated subject and adds it to the active sessions.protected SessionImpl
createSession(AuthContext loginContext, String workspaceName)
Creates a new repository session on the specified workspace for the authenticated subject of the given login context and adds it to the active sessions.protected SessionImpl
createSessionInstance(Subject subject, WorkspaceConfig wspConfig)
Creates an instance of theSessionImpl
class representing a user represented by thesubject
instance attached to the workspace configured by thewspConfig
.protected SessionImpl
createSessionInstance(AuthContext loginContext, WorkspaceConfig wspConfig)
Creates an instance of theSessionImpl
class representing a user authenticated by theloginContext
instance attached to the workspace configured by thewspConfig
.protected InternalVersionManagerImpl
createVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher)
Creates the version manager.protected void
createWorkspace(String workspaceName)
Creates a workspace with the given name.protected void
createWorkspace(String workspaceName, InputSource configTemplate)
Creates a workspace with the given name and given workspace configuration template.protected RepositoryImpl.WorkspaceInfo
createWorkspaceInfo(WorkspaceConfig wspConfig)
Creates a newRepositoryImpl.WorkspaceInfo
instance forwspConfig
.protected void
doShutdown()
Protected method that performs the actual shutdown after the shutdown lock has been acquired by theshutdown()
method.void
externalWorkspaceCreated(String workspaceName, InputSource configTemplate)
Workspace created on another cluster node.CacheManager
getCacheManager()
Get the cache manager of this repository, useful for setting its memory parameters.RepositoryConfig
getConfig()
Returns the configuration of this repository.protected Properties
getCustomRepositoryDescriptors()
Returns aProperties
object containing custom repository descriptors ornull
if none exist.String
getDescriptor(String key)
String[]
getDescriptorKeys()
Value
getDescriptorValue(String key)
Value[]
getDescriptorValues(String key)
protected SearchManager
getSystemSearchManager(String wspName)
Returns the system search manager ornull
if none is configured.protected RepositoryImpl.WorkspaceInfo
getWorkspaceInfo(String workspaceName)
Returns theRepositoryImpl.WorkspaceInfo
for the named workspace.protected String[]
getWorkspaceNames()
Returns the names of all workspaces in this repository.protected void
initRepositoryDescriptors()
Initializes the repository descriptors by executing the following steps: Sets standard descriptorsgetCustomRepositoryDescriptors()
is called afterwards in order to add custom/overwrite standard repository descriptors.protected void
initStartupWorkspaces()
Initialize startup workspaces.boolean
isSingleValueDescriptor(String key)
void
loggedOut(SessionImpl session)
Called when aSession
has been 'closed' by calling
.Session.logout()
void
loggingOut(SessionImpl session)
Called when aSession
is about to be 'closed' by calling
.Session.logout()
Session
login(Credentials credentials, String workspaceName)
protected void
onSessionCreated(SessionImpl session)
Adds the given session to the list of active sessions and registers this repository as listener.protected void
sanityCheck()
Performs a sanity check on this repository instance.protected void
setDescriptor(String desc, String value)
protected void
setDescriptor(String desc, Value value)
protected void
setDescriptor(String desc, Value[] values)
protected void
setReferentialIntegrityChecking(String workspace, boolean enabled)
Enables or disables referential integrity checking for given workspace.void
shutdown()
Shuts down this repository.-
Methods inherited from class org.apache.jackrabbit.commons.AbstractRepository
isStandardDescriptor, login, login, login, login
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.api.JackrabbitRepository
login
-
Methods inherited from interface javax.jcr.Repository
isStandardDescriptor, login, login, login
-
-
-
-
Field Detail
-
ROOT_NODE_ID
public static final NodeId ROOT_NODE_ID
hardcoded id of the repository root node
-
SYSTEM_ROOT_NODE_ID
public static final NodeId SYSTEM_ROOT_NODE_ID
hardcoded id of the "/jcr:system" node
-
VERSION_STORAGE_NODE_ID
public static final NodeId VERSION_STORAGE_NODE_ID
hardcoded id of the "/jcr:system/jcr:versionStorage" node
-
ACTIVITIES_NODE_ID
public static final NodeId ACTIVITIES_NODE_ID
hardcoded id of the "/jcr:system/jcr:activities" node
-
CONFIGURATIONS_NODE_ID
public static final NodeId CONFIGURATIONS_NODE_ID
hardcoded id of the "/jcr:system/jcr:configurations" node
-
NODETYPES_NODE_ID
public static final NodeId NODETYPES_NODE_ID
hardcoded id of the "/jcr:system/jcr:nodeTypes" node
-
JACKRABBIT_CLUSTER_ID
public static final String JACKRABBIT_CLUSTER_ID
Key to astring
descriptor. Returns the repository cluster id if and only if clustering is enabled.- See Also:
- Constant Field Values
-
context
protected final RepositoryContext context
-
repConfig
protected final RepositoryConfig repConfig
-
nodeIdFactory
protected NodeIdFactory nodeIdFactory
-
-
Constructor Detail
-
RepositoryImpl
protected RepositoryImpl(RepositoryConfig repConfig) throws RepositoryException
Protected constructor.- Parameters:
repConfig
- the repository configuration.- Throws:
RepositoryException
- if there is already another repository instance running on the given configuration or another error occurs.
-
-
Method Detail
-
createNamespaceRegistry
protected NamespaceRegistryImpl createNamespaceRegistry() throws RepositoryException
Protected factory method for creating the namespace registry. Called by the constructor after the repository file system has been initialised.- Returns:
- namespace registry
- Throws:
RepositoryException
- if the namespace registry can not be created
-
createNodeTypeRegistry
protected NodeTypeRegistry createNodeTypeRegistry() throws RepositoryException
Protected factory method for creating the node type registry. Called by the constructor after the repository file system and namespace registry have been initialised.- Returns:
- node type registry
- Throws:
RepositoryException
- if the node type registry can not be created
-
getCacheManager
public CacheManager getCacheManager()
Get the cache manager of this repository, useful for setting its memory parameters.- Returns:
- the cache manager
- Since:
- 1.3
-
createVersionManager
protected InternalVersionManagerImpl createVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher) throws RepositoryException
Creates the version manager.- Parameters:
vConfig
- the versioning config- Returns:
- the newly created version manager
- Throws:
RepositoryException
- if an error occurs
-
initStartupWorkspaces
protected void initStartupWorkspaces() throws RepositoryException
Initialize startup workspaces. Base implementation will initialize the default workspace. Derived classes may initialize their own startup workspaces after having called the base implementation.- Throws:
RepositoryException
- if an error occurs
-
create
public static RepositoryImpl create(RepositoryConfig config) throws RepositoryException
Creates a newRepositoryImpl
instance.- Parameters:
config
- the configuration of the repository- Returns:
- a new
RepositoryImpl
instance - Throws:
RepositoryException
- If an error occurs
-
sanityCheck
protected void sanityCheck() throws RepositoryException
Performs a sanity check on this repository instance.- Throws:
RepositoryException
- if this repository has been rendered invalid for some reason (e.g. if it has been shut down)
-
getSystemSearchManager
protected SearchManager getSystemSearchManager(String wspName) throws RepositoryException
Returns the system search manager ornull
if none is configured.- Throws:
RepositoryException
-
createClusterNode
protected ClusterNode createClusterNode() throws RepositoryException
Creates the cluster node.- Returns:
- clustered node
- Throws:
RepositoryException
-
getWorkspaceNames
protected String[] getWorkspaceNames()
Returns the names of all workspaces in this repository.- Returns:
- the names of all workspaces in this repository.
- See Also:
Workspace.getAccessibleWorkspaceNames()
-
getWorkspaceInfo
protected RepositoryImpl.WorkspaceInfo getWorkspaceInfo(String workspaceName) throws NoSuchWorkspaceException, RepositoryException
Returns theRepositoryImpl.WorkspaceInfo
for the named workspace.- Parameters:
workspaceName
- The name of the workspace whoseRepositoryImpl.WorkspaceInfo
is to be returned. This must not benull
.- Returns:
- The
RepositoryImpl.WorkspaceInfo
for the named workspace. This will never benull
. - Throws:
NoSuchWorkspaceException
- If the named workspace does not exist.RepositoryException
- If this repository has been shut down.
-
createWorkspace
protected void createWorkspace(String workspaceName) throws RepositoryException
Creates a workspace with the given name.- Parameters:
workspaceName
- name of the new workspace- Throws:
RepositoryException
- if a workspace with the given name already exists or if another error occurs- See Also:
WorkspaceImpl.createWorkspace(String)
-
externalWorkspaceCreated
public void externalWorkspaceCreated(String workspaceName, InputSource configTemplate) throws RepositoryException
Description copied from interface:WorkspaceListener
Workspace created on another cluster node.- Specified by:
externalWorkspaceCreated
in interfaceWorkspaceListener
- Throws:
RepositoryException
-
createWorkspace
protected void createWorkspace(String workspaceName, InputSource configTemplate) throws RepositoryException
Creates a workspace with the given name and given workspace configuration template.- Parameters:
workspaceName
- name of the new workspaceconfigTemplate
- the workspace configuration template of the new workspace- Throws:
RepositoryException
- if a workspace with the given name already exists or if another error occurs- See Also:
WorkspaceImpl.createWorkspace(String,InputSource)
-
setReferentialIntegrityChecking
protected void setReferentialIntegrityChecking(String workspace, boolean enabled) throws RepositoryException
Enables or disables referential integrity checking for given workspace. Disabling referential integrity checks can result in a corrupted workspace, and thus this feature is only available to customized implementations that subclass RepositoryImpl.- Parameters:
workspace
- name of the workspaceenabled
-true
to enable integrity checking (default),false
to disable it- Throws:
RepositoryException
- if an error occurs- See Also:
- Issue JCR-954
-
createSession
protected final SessionImpl createSession(AuthContext loginContext, String workspaceName) throws NoSuchWorkspaceException, AccessDeniedException, RepositoryException
Creates a new repository session on the specified workspace for the authenticated subject of the given login context and adds it to the active sessions.Calls
createSessionInstance(AuthContext, WorkspaceConfig)
to create the actualSessionImpl
instance.- Parameters:
loginContext
- login context with authenticated subjectworkspaceName
- workspace name- Returns:
- a new session
- Throws:
NoSuchWorkspaceException
- if the specified workspace does not existAccessDeniedException
- if the subject of the given login context is not granted access to the specified workspaceRepositoryException
- if another error occurs
-
createSession
protected final SessionImpl createSession(Subject subject, String workspaceName) throws NoSuchWorkspaceException, AccessDeniedException, RepositoryException
Creates a new repository session on the specified workspace for the given authenticated subject and adds it to the active sessions.Calls
createSessionInstance(Subject, WorkspaceConfig)
to create the actualSessionImpl
instance.- Parameters:
subject
- authenticated subjectworkspaceName
- workspace name- Returns:
- a new session
- Throws:
NoSuchWorkspaceException
- if the specified workspace does not existAccessDeniedException
- if the subject of the given login context is not granted access to the specified workspaceRepositoryException
- if another error occurs
-
onSessionCreated
protected void onSessionCreated(SessionImpl session)
Adds the given session to the list of active sessions and registers this repository as listener.- Parameters:
session
- the session to register
-
shutdown
public void shutdown()
Shuts down this repository. The shutdown is guarded by a shutdown lock that prevents any new sessions from being started simultaneously.- Specified by:
shutdown
in interfaceJackrabbitRepository
-
doShutdown
protected void doShutdown()
Protected method that performs the actual shutdown after the shutdown lock has been acquired by theshutdown()
method.
-
getConfig
public RepositoryConfig getConfig()
Returns the configuration of this repository.- Returns:
- repository configuration
-
initRepositoryDescriptors
protected void initRepositoryDescriptors() throws RepositoryException
Initializes the repository descriptors by executing the following steps:- Sets standard descriptors
getCustomRepositoryDescriptors()
is called afterwards in order to add custom/overwrite standard repository descriptors.
- Throws:
RepositoryException
-
getCustomRepositoryDescriptors
protected Properties getCustomRepositoryDescriptors() throws RepositoryException
Returns aProperties
object containing custom repository descriptors ornull
if none exist.Overridable to allow subclasses to add custom descriptors or to override standard descriptor values.
Note that the properties entries will be set as single-valued
STRING
descriptor values.This method tries to load the
Properties
from theorg/apache/jackrabbit/core/repository.properties
resource found in the class path.- Throws:
RepositoryException
- if the properties can not be loaded
-
createItemStateManager
protected SharedItemStateManager createItemStateManager(PersistenceManager persistMgr, boolean usesReferences, ISMLocking locking) throws ItemStateException
Creates aSharedItemStateManager
or derivative.- Parameters:
persistMgr
- persistence managerusesReferences
-true
if the item state manager should use node references to verify integrity of its reference properties;false
otherwise- Returns:
- item state manager
- Throws:
ItemStateException
- if an error occurs
-
createDataStoreGarbageCollector
public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException
Creates a data store garbage collector for this repository.Note that you should use the
RepositoryManager
interface to access this functionality. This RepositoryImpl method may be removed in future Jackrabbit versions.- Throws:
RepositoryException
-
login
public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException
- Specified by:
login
in interfaceRepository
- Throws:
LoginException
NoSuchWorkspaceException
RepositoryException
-
getDescriptor
public String getDescriptor(String key)
- Specified by:
getDescriptor
in interfaceRepository
-
getDescriptorKeys
public String[] getDescriptorKeys()
- Specified by:
getDescriptorKeys
in interfaceRepository
-
getDescriptorValue
public Value getDescriptorValue(String key)
- Specified by:
getDescriptorValue
in interfaceRepository
-
getDescriptorValues
public Value[] getDescriptorValues(String key)
- Specified by:
getDescriptorValues
in interfaceRepository
-
isSingleValueDescriptor
public boolean isSingleValueDescriptor(String key)
- Specified by:
isSingleValueDescriptor
in interfaceRepository
-
loggingOut
public void loggingOut(SessionImpl session)
Called when aSession
is about to be 'closed' by calling
. At this moment the session is still valid.Session.logout()
- Specified by:
loggingOut
in interfaceSessionListener
- Parameters:
session
- theSession
that is about to be 'closed'
-
loggedOut
public void loggedOut(SessionImpl session)
Called when aSession
has been 'closed' by calling
.Session.logout()
- Specified by:
loggedOut
in interfaceSessionListener
- Parameters:
session
- theSession
that has been 'closed'
-
createSessionInstance
protected SessionImpl createSessionInstance(AuthContext loginContext, WorkspaceConfig wspConfig) throws AccessDeniedException, RepositoryException
Creates an instance of theSessionImpl
class representing a user authenticated by theloginContext
instance attached to the workspace configured by thewspConfig
.- Throws:
AccessDeniedException
- if the subject of the given login context is not granted access to the specified workspaceRepositoryException
- If any other error occurs creating the session.
-
createSessionInstance
protected SessionImpl createSessionInstance(Subject subject, WorkspaceConfig wspConfig) throws AccessDeniedException, RepositoryException
Creates an instance of theSessionImpl
class representing a user represented by thesubject
instance attached to the workspace configured by thewspConfig
.- Throws:
AccessDeniedException
- if the subject of the given login context is not granted access to the specified workspaceRepositoryException
- If any other error occurs creating the session.
-
createWorkspaceInfo
protected RepositoryImpl.WorkspaceInfo createWorkspaceInfo(WorkspaceConfig wspConfig)
Creates a newRepositoryImpl.WorkspaceInfo
instance forwspConfig
.- Parameters:
wspConfig
- the workspace configuration.- Returns:
- a new
WorkspaceInfo
instance.
-
-