Class AbstractReadableRepositoryService
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.AbstractRepositoryService
-
- org.apache.jackrabbit.spi.commons.AbstractReadableRepositoryService
-
- All Implemented Interfaces:
RepositoryService
public abstract class AbstractReadableRepositoryService extends AbstractRepositoryService
AbstractReadableRepositoryService
provides an abstract base class where all methods that attempt to write throw anUnsupportedRepositoryOperationException
. This class useful for repository service implementation that only provide read access to the underlying content.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
defaulWsp
The name of the default workspaceprotected static Set<String>
WRITE_ACTIONS
protected List<String>
wspNames
The list of workspaces that this repository service exposes.-
Fields inherited from class org.apache.jackrabbit.spi.commons.AbstractRepositoryService
descriptors, namespaces, nodeTypeDefs, rootNodeDefinition
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkWorkspace(String workspaceName)
Checks whether theworkspaceName
is valid.protected SessionInfo
createSessionInfo(Credentials credentials, String workspaceName)
Creates a session info instance for the givencredentials
andworkspaceName
.ItemInfoCache
getItemInfoCache(SessionInfo sessionInfo)
Returns aItemInfoCache
for the givenSessionInfo
.NodeInfo
getNodeInfo(SessionInfo sessionInfo, NodeId nodeId)
This default implementation returns the first item returned by the call toRepositoryService.getItemInfos(SessionInfo, ItemId)
.String[]
getWorkspaceNames(SessionInfo sessionInfo)
This default implementation first callsAbstractRepositoryService.checkSessionInfo(SessionInfo)
with thesessionInfo
, then returns the workspaces that were passed to the constructor of this repository service.boolean
isGranted(SessionInfo sessionInfo, ItemId itemId, String[] actions)
This default implementation first callsAbstractRepositoryService.checkSessionInfo(SessionInfo)
with thesessionInfo
, then returnsfalse
if the any of theactions
are inWRITE_ACTIONS
; otherwise returnstrue
.-
Methods inherited from class org.apache.jackrabbit.spi.commons.AbstractRepositoryService
addVersionLabel, checkCredentials, checkin, checkout, checkout, checkpoint, checkpoint, checkQueryStatement, checkSessionInfo, clone, copy, createActivity, createBatch, createConfiguration, createEventFilter, createRootNodeDefinition, createSessionInfo, createSubscription, createTree, createWorkspace, deleteWorkspace, dispose, dispose, executeQuery, getEvents, getEvents, getIdFactory, getLockInfo, getNameFactory, getNamespacePrefix, getNamespaceURI, getNodeDefinition, getPathFactory, getPropertyDefinition, getQNodeTypeDefinitions, getQNodeTypeDefinitions, getQValueFactory, getRegisteredNamespaces, getRepositoryDescriptors, getSupportedQueryLanguages, impersonate, importXml, lock, lock, merge, merge, mergeActivity, move, obtain, obtain, refreshLock, registerNamespace, registerNodeTypes, removeActivity, removeVersion, removeVersionLabel, resolveMergeConflict, restore, restore, submit, unlock, unregisterNamespace, unregisterNodeTypes, update, updateEventFilters
-
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.spi.RepositoryService
getChildInfos, getItemInfos, getPrivilegeDefinitions, getPrivilegeNames, getPropertyInfo, getReferences, getSupportedPrivileges
-
-
-
-
Constructor Detail
-
AbstractReadableRepositoryService
public AbstractReadableRepositoryService(Map<String,QValue[]> descriptors, Map<String,String> namespaces, Reader cnd, List<String> wspNames, String defaultWsp) throws RepositoryException, ParseException, IllegalArgumentException
Creates a newAbstractReadableRepositoryService
.- Parameters:
descriptors
- the repository descriptors. Maps descriptor keys to descriptor values.namespaces
- the namespaces. Maps namespace prefixes to namespace URIs.cnd
- a reader on the compact node type definition.wspNames
- a list of workspace names.defaultWsp
- name of the default workspace- Throws:
RepositoryException
- if the namespace mappings are invalid.ParseException
- if an error occurs while parsing the CND.IllegalArgumentException
- ifdefaultWsp
isnull
-
-
Method Detail
-
checkWorkspace
protected void checkWorkspace(String workspaceName) throws NoSuchWorkspaceException
Checks whether theworkspaceName
is valid.- Overrides:
checkWorkspace
in classAbstractRepositoryService
- Parameters:
workspaceName
- name of the workspace to check- Throws:
NoSuchWorkspaceException
- ifworkspaceName
is neither in the list of workspace nor null (i.e. default workspace).
-
createSessionInfo
protected SessionInfo createSessionInfo(Credentials credentials, String workspaceName) throws RepositoryException
Description copied from class:AbstractRepositoryService
Creates a session info instance for the givencredentials
andworkspaceName
. This default implementation creates aSessionInfoImpl
instance and sets theuserId
and workspaceName. The useruserId
isnull
or theuserId
fromcredentials
if it is of typeSimpleCredentials
.- Overrides:
createSessionInfo
in classAbstractRepositoryService
- Parameters:
credentials
- the credentials.workspaceName
- the name of the workspace to access ornull
for the default workspace.- Returns:
- a session info instance for the given
credentials
andworkspaceName
. - Throws:
RepositoryException
-
getItemInfoCache
public ItemInfoCache getItemInfoCache(SessionInfo sessionInfo)
Description copied from interface:RepositoryService
Returns aItemInfoCache
for the givenSessionInfo
.- Parameters:
sessionInfo
-- Returns:
- a new instance of
ItemInfoCacheImpl
-
getNodeInfo
public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws ItemNotFoundException, RepositoryException
This default implementation returns the first item returned by the call toRepositoryService.getItemInfos(SessionInfo, ItemId)
. The underlying assumption here is that the implementation and the persistence layer are optimized for batch reading. That is, a call togetItemInfos
is no more expensive than retrieving the singleNodeInfo
only. If this assumption does not hold, subclasses should override this method.- Returns:
- The
NodeInfo
for the node identified by the given id. - Throws:
ItemNotFoundException
RepositoryException
- See Also:
Session.getItem(String)
,Node.getNode(String)
,VersionHistory.getAllVersions()
,VersionHistory.getVersion(String)
,VersionHistory.getVersionByLabel(String)
,VersionHistory.getRootVersion()
,Node.getBaseVersion()
,Node.getVersionHistory()
,Version.getContainingHistory()
-
getWorkspaceNames
public String[] getWorkspaceNames(SessionInfo sessionInfo) throws RepositoryException
This default implementation first callsAbstractRepositoryService.checkSessionInfo(SessionInfo)
with thesessionInfo
, then returns the workspaces that were passed to the constructor of this repository service.- Returns:
- An array of workspace names.
- Throws:
RepositoryException
- See Also:
Workspace.getAccessibleWorkspaceNames()
,Workspace.getName()
-
isGranted
public boolean isGranted(SessionInfo sessionInfo, ItemId itemId, String[] actions) throws RepositoryException
This default implementation first callsAbstractRepositoryService.checkSessionInfo(SessionInfo)
with thesessionInfo
, then returnsfalse
if the any of theactions
are inWRITE_ACTIONS
; otherwise returnstrue
.- Returns:
- true if the session with the given
SessionInfo
has the specified rights for the given item. - Throws:
RepositoryException
- See Also:
Session.checkPermission(String, String)
,Session.hasPermission(String, String)
-
-