Package org.apache.jackrabbit.jcr2spi
Class WorkspaceManager
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.WorkspaceManager
-
- All Implemented Interfaces:
NamespaceStorage
,AccessManager
,UpdatableItemStateManager
public class WorkspaceManager extends Object implements UpdatableItemStateManager, NamespaceStorage, AccessManager
WorkspaceManager
...
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.jcr2spi.security.AccessManager
ADD_NODE_ACTION, READ, READ_ACTION, REMOVE, REMOVE_ACTION, SET_PROPERTY_ACTION
-
-
Constructor Summary
Constructors Constructor Description WorkspaceManager(RepositoryConfig config, SessionInfo sessionInfo, boolean observationSupported)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(InternalEventListener listener)
Sets theInternalEventListener
that gets notifications about local and external changes.void
addLockToken(String lt)
This method succeeds if the lock tokens could be added to theSessionInfo
.boolean
canAccess(String workspaceName)
Determines whether the subject of the current context is granted access to the given workspace.boolean
canRead(ItemState itemState)
Returns true if the existing item with the givenItemId
can be read.boolean
canRemove(ItemState itemState)
Returns true if the existing item state can be removed.String[]
checkQueryStatement(String statement, String language, Map<String,String> namespaces)
Checks if the query statement is valid.EventFilter
createEventFilter(int eventTypes, Path path, boolean isDeep, String[] uuids, Name[] nodeTypes, boolean noLocal)
Creates an event filter based on the parameters available inObservationManager.addEventListener(javax.jcr.observation.EventListener, int, java.lang.String, boolean, java.lang.String[], java.lang.String[], boolean)
.void
dispose()
Dispose thisWorkspaceManager
void
execute(Operation operation)
Creates a new batch from the single workspace operation and executes it.void
execute(ChangeLog changes)
Creates a new batch from the givenChangeLog
and executes it.QueryInfo
executeQuery(String statement, String language, Map<String,String> namespaces, long limit, long offset, Map<String,QValue> boundValues)
AccessControlProvider
getAccessControlProvider()
Locates and instantiates an AccessControlProvider implementation.EffectiveNodeTypeProvider
getEffectiveNodeTypeProvider()
EventBundle
getEvents(EventFilter filter, long after)
Returns the events from the journal that occurred after a given date.HierarchyManager
getHierarchyManager()
IdFactory
getIdFactory()
ItemDefinitionProvider
getItemDefinitionProvider()
ItemStateFactory
getItemStateFactory()
LockInfo
getLockInfo(NodeId nodeId)
String[]
getLockTokens()
Returns the lock tokens present with theSessionInfo
.NameFactory
getNameFactory()
NamespaceRegistryImpl
getNamespaceRegistryImpl()
NodeTypeRegistry
getNodeTypeRegistry()
PathFactory
getPathFactory()
String
getPrefix(String uri)
Map<String,String>
getRegisteredNamespaces()
String[]
getSupportedQueryLanguages()
String
getURI(String prefix)
String[]
getWorkspaceNames()
boolean
isGranted(ItemState itemState, String[] actions)
Determines whether the specifiedpermissions
are granted on the item with the specified path.boolean
isGranted(NodeState parentState, Path relPath, String[] actions)
Determines whether the specifiedpermissions
are granted on the item with the specified path.void
registerNamespace(String prefix, String uri)
void
removeEventListener(InternalEventListener listener)
void
removeLockToken(String lt)
Tries to remove the given token from theSessionInfo
.void
setUserData(String userData)
void
unregisterNamespace(String uri)
void
updateEventFilters()
Updates the event filters on the subscription.
-
-
-
Constructor Detail
-
WorkspaceManager
public WorkspaceManager(RepositoryConfig config, SessionInfo sessionInfo, boolean observationSupported) throws RepositoryException
- Throws:
RepositoryException
-
-
Method Detail
-
getNamespaceRegistryImpl
public NamespaceRegistryImpl getNamespaceRegistryImpl()
-
getNodeTypeRegistry
public NodeTypeRegistry getNodeTypeRegistry()
-
getItemDefinitionProvider
public ItemDefinitionProvider getItemDefinitionProvider()
-
getEffectiveNodeTypeProvider
public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider()
-
getHierarchyManager
public HierarchyManager getHierarchyManager()
-
getWorkspaceNames
public String[] getWorkspaceNames() throws RepositoryException
- Throws:
RepositoryException
-
getIdFactory
public IdFactory getIdFactory()
-
getNameFactory
public NameFactory getNameFactory()
-
getPathFactory
public PathFactory getPathFactory()
-
getItemStateFactory
public ItemStateFactory getItemStateFactory()
-
getAccessControlProvider
public AccessControlProvider getAccessControlProvider() throws RepositoryException
Locates and instantiates an AccessControlProvider implementation.- Returns:
- an access control manager provider.
- Throws:
RepositoryException
-
getLockInfo
public LockInfo getLockInfo(NodeId nodeId) throws RepositoryException
- Throws:
RepositoryException
-
getLockTokens
public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException
Returns the lock tokens present with theSessionInfo
.- Returns:
- lock tokens present with the
SessionInfo
. - Throws:
UnsupportedRepositoryOperationException
- If not supported.RepositoryException
- If another error occurs.- See Also:
SessionInfo.getLockTokens()
-
addLockToken
public void addLockToken(String lt) throws UnsupportedRepositoryOperationException, LockException, RepositoryException
This method succeeds if the lock tokens could be added to theSessionInfo
.- Parameters:
lt
- The lock token to be added.- Throws:
UnsupportedRepositoryOperationException
- If not supported.LockException
- If a lock related exception occurs.RepositoryException
- If another exception occurs.- See Also:
SessionInfo.addLockToken(String)
-
removeLockToken
public void removeLockToken(String lt) throws UnsupportedRepositoryOperationException, LockException, RepositoryException
Tries to remove the given token from theSessionInfo
.- Parameters:
lt
- The lock token to be removed.- Throws:
UnsupportedRepositoryOperationException
- If not supported.LockException
- If a lock related exception occurs, e.g if the session info does not contain the specified lock token.RepositoryException
- If another exception occurs.- See Also:
SessionInfo.removeLockToken(String)
-
getSupportedQueryLanguages
public String[] getSupportedQueryLanguages() throws RepositoryException
- Returns:
- The names of the supported query languages.
- Throws:
RepositoryException
- If an error occurs.
-
checkQueryStatement
public String[] checkQueryStatement(String statement, String language, Map<String,String> namespaces) throws InvalidQueryException, RepositoryException
Checks if the query statement is valid.- Parameters:
statement
- the query statement.language
- the query language.namespaces
- the locally remapped namespaces which might be used in the query statement.- Returns:
- the bind variable names.
- Throws:
InvalidQueryException
- if the query statement is invalid.RepositoryException
- if an error occurs while checking the query statement.
-
executeQuery
public QueryInfo executeQuery(String statement, String language, Map<String,String> namespaces, long limit, long offset, Map<String,QValue> boundValues) throws RepositoryException
- Parameters:
statement
- the query statement.language
- the query language.namespaces
- the locally remapped namespaces which might be used in the query statement.limit
- The result size limit as specified byQuery.setLimit(long)
.offset
- The result offset as specified byQuery.setOffset(long)
boundValues
- The bound values as specified byQuery.bindValue(String, javax.jcr.Value)
- Returns:
- the QueryInfo created by
RepositoryService.executeQuery(org.apache.jackrabbit.spi.SessionInfo, String, String, java.util.Map, long, long, java.util.Map)
. - Throws:
RepositoryException
- If an error occurs.
-
addEventListener
public void addEventListener(InternalEventListener listener) throws RepositoryException
Sets theInternalEventListener
that gets notifications about local and external changes.- Parameters:
listener
- the new listener.- Throws:
RepositoryException
- if the listener cannot be registered.
-
updateEventFilters
public void updateEventFilters() throws RepositoryException
Updates the event filters on the subscription. The filters are retrieved from the current list of internal event listeners.- Throws:
RepositoryException
- If an error occurs.
-
removeEventListener
public void removeEventListener(InternalEventListener listener) throws RepositoryException
- Parameters:
listener
- The listener to be removed.- Throws:
RepositoryException
- If an error occurs.
-
createEventFilter
public EventFilter createEventFilter(int eventTypes, Path path, boolean isDeep, String[] uuids, Name[] nodeTypes, boolean noLocal) throws UnsupportedRepositoryOperationException, RepositoryException
Creates an event filter based on the parameters available inObservationManager.addEventListener(javax.jcr.observation.EventListener, int, java.lang.String, boolean, java.lang.String[], java.lang.String[], boolean)
.- Parameters:
eventTypes
- A combination of one or more event type constants encoded as a bitmask.path
- an absolute path.isDeep
- aboolean
.uuids
- array of UUIDs.nodeTypes
- array of node type names.noLocal
- aboolean
.- Returns:
- the event filter instance with the given parameters.
- Throws:
UnsupportedRepositoryOperationException
- if this implementation does not support observation.RepositoryException
-
getEvents
public EventBundle getEvents(EventFilter filter, long after) throws RepositoryException, UnsupportedRepositoryOperationException
Returns the events from the journal that occurred after a given date.- Parameters:
filter
- the event filter to apply.after
- a date in milliseconds.- Returns:
- the events as a bundle.
- Throws:
RepositoryException
- if an error occurs.UnsupportedRepositoryOperationException
- if the implementation does not support journaled observation.
-
setUserData
public void setUserData(String userData) throws RepositoryException
- Parameters:
userData
- The user data used for the event processing.- Throws:
RepositoryException
- If an error occurs.
-
execute
public void execute(Operation operation) throws RepositoryException
Creates a new batch from the single workspace operation and executes it.- Specified by:
execute
in interfaceUpdatableItemStateManager
- Throws:
RepositoryException
- See Also:
UpdatableItemStateManager.execute(Operation)
-
execute
public void execute(ChangeLog changes) throws RepositoryException
Creates a new batch from the givenChangeLog
and executes it.- Specified by:
execute
in interfaceUpdatableItemStateManager
- Parameters:
changes
- The set of transient changes to be executed.- Throws:
RepositoryException
-
dispose
public void dispose()
Dispose thisWorkspaceManager
- Specified by:
dispose
in interfaceUpdatableItemStateManager
-
isGranted
public boolean isGranted(NodeState parentState, Path relPath, String[] actions) throws ItemNotFoundException, RepositoryException
Description copied from interface:AccessManager
Determines whether the specifiedpermissions
are granted on the item with the specified path.- Specified by:
isGranted
in interfaceAccessManager
- Parameters:
parentState
- The node state of the next existing ancestor.relPath
- The relative path pointing to the non-existing target item.actions
- An array of actions that need to be checked.- Returns:
true
if the actions are granted; otherwisefalse
- Throws:
ItemNotFoundException
- if the target item does not existRepositoryException
- if another error occurs- See Also:
AccessManager.isGranted(NodeState, Path, String[])
-
isGranted
public boolean isGranted(ItemState itemState, String[] actions) throws ItemNotFoundException, RepositoryException
Description copied from interface:AccessManager
Determines whether the specifiedpermissions
are granted on the item with the specified path.- Specified by:
isGranted
in interfaceAccessManager
actions
- An array of actions that need to be checked.- Returns:
true
if the actions are granted; otherwisefalse
- Throws:
ItemNotFoundException
- if the target item does not existRepositoryException
- if another error occurs- See Also:
AccessManager.isGranted(ItemState, String[])
-
canRead
public boolean canRead(ItemState itemState) throws ItemNotFoundException, RepositoryException
Description copied from interface:AccessManager
Returns true if the existing item with the givenItemId
can be read.- Specified by:
canRead
in interfaceAccessManager
- Returns:
- Throws:
ItemNotFoundException
RepositoryException
- See Also:
AccessManager.canRead(ItemState)
-
canRemove
public boolean canRemove(ItemState itemState) throws ItemNotFoundException, RepositoryException
Description copied from interface:AccessManager
Returns true if the existing item state can be removed.- Specified by:
canRemove
in interfaceAccessManager
- Returns:
- Throws:
ItemNotFoundException
RepositoryException
- See Also:
AccessManager.canRemove(ItemState)
-
canAccess
public boolean canAccess(String workspaceName) throws NoSuchWorkspaceException, RepositoryException
Description copied from interface:AccessManager
Determines whether the subject of the current context is granted access to the given workspace.- Specified by:
canAccess
in interfaceAccessManager
- Parameters:
workspaceName
- name of workspace- Returns:
true
if the subject of the current context is granted access to the given workspace; otherwisefalse
.- Throws:
NoSuchWorkspaceException
- if a workspace with the given name does not exist.RepositoryException
- if another error occurs- See Also:
AccessManager.canAccess(String)
-
getRegisteredNamespaces
public Map<String,String> getRegisteredNamespaces() throws RepositoryException
- Specified by:
getRegisteredNamespaces
in interfaceNamespaceStorage
- Throws:
RepositoryException
-
getPrefix
public String getPrefix(String uri) throws NamespaceException, RepositoryException
- Specified by:
getPrefix
in interfaceNamespaceStorage
- Throws:
NamespaceException
RepositoryException
-
getURI
public String getURI(String prefix) throws NamespaceException, RepositoryException
- Specified by:
getURI
in interfaceNamespaceStorage
- Throws:
NamespaceException
RepositoryException
-
registerNamespace
public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException
- Specified by:
registerNamespace
in interfaceNamespaceStorage
- Throws:
NamespaceException
UnsupportedRepositoryOperationException
AccessDeniedException
RepositoryException
-
unregisterNamespace
public void unregisterNamespace(String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException
- Specified by:
unregisterNamespace
in interfaceNamespaceStorage
- Throws:
NamespaceException
UnsupportedRepositoryOperationException
AccessDeniedException
RepositoryException
-
-