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 classRepositoryImpl.DescriptorValueRepresents a Repository Descriptor Value (either Value or Value[])classRepositoryImpl.WorkspaceInfoWorkspaceInfoholds the objects that are shared among multiple per-sessionWorkspaceImplinstances representing the same named workspace, i.e.
-
Field Summary
Fields Modifier and Type Field Description static NodeIdACTIVITIES_NODE_IDhardcoded id of the "/jcr:system/jcr:activities" nodestatic NodeIdCONFIGURATIONS_NODE_IDhardcoded id of the "/jcr:system/jcr:configurations" nodeprotected RepositoryContextcontextstatic StringJACKRABBIT_CLUSTER_IDKey to astringdescriptor.protected NodeIdFactorynodeIdFactorystatic NodeIdNODETYPES_NODE_IDhardcoded id of the "/jcr:system/jcr:nodeTypes" nodeprotected RepositoryConfigrepConfigstatic NodeIdROOT_NODE_IDhardcoded id of the repository root nodestatic NodeIdSYSTEM_ROOT_NODE_IDhardcoded id of the "/jcr:system" nodestatic NodeIdVERSION_STORAGE_NODE_IDhardcoded 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 protectedRepositoryImpl(RepositoryConfig repConfig)Protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RepositoryImplcreate(RepositoryConfig config)Creates a newRepositoryImplinstance.protected ClusterNodecreateClusterNode()Creates the cluster node.GarbageCollectorcreateDataStoreGarbageCollector()Creates a data store garbage collector for this repository.protected SharedItemStateManagercreateItemStateManager(PersistenceManager persistMgr, boolean usesReferences, ISMLocking locking)Creates aSharedItemStateManageror derivative.protected NamespaceRegistryImplcreateNamespaceRegistry()Protected factory method for creating the namespace registry.protected NodeTypeRegistrycreateNodeTypeRegistry()Protected factory method for creating the node type registry.protected SessionImplcreateSession(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 SessionImplcreateSession(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 SessionImplcreateSessionInstance(Subject subject, WorkspaceConfig wspConfig)Creates an instance of theSessionImplclass representing a user represented by thesubjectinstance attached to the workspace configured by thewspConfig.protected SessionImplcreateSessionInstance(AuthContext loginContext, WorkspaceConfig wspConfig)Creates an instance of theSessionImplclass representing a user authenticated by theloginContextinstance attached to the workspace configured by thewspConfig.protected InternalVersionManagerImplcreateVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher)Creates the version manager.protected voidcreateWorkspace(String workspaceName)Creates a workspace with the given name.protected voidcreateWorkspace(String workspaceName, InputSource configTemplate)Creates a workspace with the given name and given workspace configuration template.protected RepositoryImpl.WorkspaceInfocreateWorkspaceInfo(WorkspaceConfig wspConfig)Creates a newRepositoryImpl.WorkspaceInfoinstance forwspConfig.protected voiddoShutdown()Protected method that performs the actual shutdown after the shutdown lock has been acquired by theshutdown()method.voidexternalWorkspaceCreated(String workspaceName, InputSource configTemplate)Workspace created on another cluster node.CacheManagergetCacheManager()Get the cache manager of this repository, useful for setting its memory parameters.RepositoryConfiggetConfig()Returns the configuration of this repository.protected PropertiesgetCustomRepositoryDescriptors()Returns aPropertiesobject containing custom repository descriptors ornullif none exist.StringgetDescriptor(String key)String[]getDescriptorKeys()ValuegetDescriptorValue(String key)Value[]getDescriptorValues(String key)protected SearchManagergetSystemSearchManager(String wspName)Returns the system search manager ornullif none is configured.protected RepositoryImpl.WorkspaceInfogetWorkspaceInfo(String workspaceName)Returns theRepositoryImpl.WorkspaceInfofor the named workspace.protected String[]getWorkspaceNames()Returns the names of all workspaces in this repository.protected voidinitRepositoryDescriptors()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 voidinitStartupWorkspaces()Initialize startup workspaces.booleanisSingleValueDescriptor(String key)voidloggedOut(SessionImpl session)Called when aSessionhas been 'closed' by calling.Session.logout()voidloggingOut(SessionImpl session)Called when aSessionis about to be 'closed' by calling.Session.logout()Sessionlogin(Credentials credentials, String workspaceName)protected voidonSessionCreated(SessionImpl session)Adds the given session to the list of active sessions and registers this repository as listener.protected voidsanityCheck()Performs a sanity check on this repository instance.protected voidsetDescriptor(String desc, String value)protected voidsetDescriptor(String desc, Value value)protected voidsetDescriptor(String desc, Value[] values)protected voidsetReferentialIntegrityChecking(String workspace, boolean enabled)Enables or disables referential integrity checking for given workspace.voidshutdown()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 astringdescriptor. 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 RepositoryExceptionInitialize 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 newRepositoryImplinstance.- Parameters:
config- the configuration of the repository- Returns:
- a new
RepositoryImplinstance - Throws:
RepositoryException- If an error occurs
-
sanityCheck
protected void sanityCheck() throws RepositoryExceptionPerforms 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 ornullif 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.WorkspaceInfofor the named workspace.- Parameters:
workspaceName- The name of the workspace whoseRepositoryImpl.WorkspaceInfois to be returned. This must not benull.- Returns:
- The
RepositoryImpl.WorkspaceInfofor 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:WorkspaceListenerWorkspace created on another cluster node.- Specified by:
externalWorkspaceCreatedin 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-trueto enable integrity checking (default),falseto 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 actualSessionImplinstance.- 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 actualSessionImplinstance.- 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:
shutdownin 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 RepositoryExceptionInitializes 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 aPropertiesobject containing custom repository descriptors ornullif 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
STRINGdescriptor values.This method tries to load the
Propertiesfrom theorg/apache/jackrabbit/core/repository.propertiesresource 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 aSharedItemStateManageror derivative.- Parameters:
persistMgr- persistence managerusesReferences-trueif the item state manager should use node references to verify integrity of its reference properties;falseotherwise- 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
RepositoryManagerinterface 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:
loginin interfaceRepository- Throws:
LoginExceptionNoSuchWorkspaceExceptionRepositoryException
-
getDescriptor
public String getDescriptor(String key)
- Specified by:
getDescriptorin interfaceRepository
-
getDescriptorKeys
public String[] getDescriptorKeys()
- Specified by:
getDescriptorKeysin interfaceRepository
-
getDescriptorValue
public Value getDescriptorValue(String key)
- Specified by:
getDescriptorValuein interfaceRepository
-
getDescriptorValues
public Value[] getDescriptorValues(String key)
- Specified by:
getDescriptorValuesin interfaceRepository
-
isSingleValueDescriptor
public boolean isSingleValueDescriptor(String key)
- Specified by:
isSingleValueDescriptorin interfaceRepository
-
loggingOut
public void loggingOut(SessionImpl session)
Called when aSessionis about to be 'closed' by calling. At this moment the session is still valid.Session.logout()- Specified by:
loggingOutin interfaceSessionListener- Parameters:
session- theSessionthat is about to be 'closed'
-
loggedOut
public void loggedOut(SessionImpl session)
Called when aSessionhas been 'closed' by calling.Session.logout()- Specified by:
loggedOutin interfaceSessionListener- Parameters:
session- theSessionthat has been 'closed'
-
createSessionInstance
protected SessionImpl createSessionInstance(AuthContext loginContext, WorkspaceConfig wspConfig) throws AccessDeniedException, RepositoryException
Creates an instance of theSessionImplclass representing a user authenticated by theloginContextinstance 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 theSessionImplclass representing a user represented by thesubjectinstance 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.WorkspaceInfoinstance forwspConfig.- Parameters:
wspConfig- the workspace configuration.- Returns:
- a new
WorkspaceInfoinstance.
-
-