public abstract class AbstractSlingRepository2 extends java.lang.Object implements SlingRepository
AbstractSlingRepository2
is an abstract implementation of
the SlingRepository
version 2.3 interface (phasing
loginAdministrative(String)
out in favor of
loginService(String, String)
) which provides default support for
attached repositories.
Implementations of the SlingRepository
interface may wish to
extend this class to benefit from default implementations of most methods.
loginService(String, String)
method the bundle using the repository
service has to be provided in the
constructor
.
The premise of this abstract class is that an instance of an implementation
of this abstract class is handed out to each consumer of the
SlingRepository
service. Each instance is generally based on the same
delegated repository
instance and also makes use of
a single system wide namespace
session support
.
AbstractSlingRepositoryManager
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDefaultWorkspace()
Returns the default workspace to login to if any of the
login and
createSession methods is called without an explicit workspace
name. |
java.lang.String |
getDescriptor(java.lang.String name) |
java.lang.String[] |
getDescriptorKeys() |
Value |
getDescriptorValue(java.lang.String key) |
Value[] |
getDescriptorValues(java.lang.String key) |
Session |
impersonateFromService(java.lang.String subServiceName,
Credentials credentials,
java.lang.String workspaceName)
Default implementation of the
#impersonateFromService(Credentials, String, String)
method taking into account the bundle calling this method. |
boolean |
isSingleValueDescriptor(java.lang.String key) |
boolean |
isStandardDescriptor(java.lang.String key) |
Session |
login()
Same as calling
login(null, null) . |
Session |
login(Credentials credentials)
Same as calling
login(credentials, null) . |
Session |
login(Credentials credentials,
java.lang.String workspace)
Logs into the repository at the given
workspace with the given
credentials and returns the session returned from
the repository. |
Session |
login(java.lang.String workspace)
Same as calling
login(null, workspace) . |
Session |
loginAdministrative(java.lang.String workspace)
Login as an administrative user.
|
Session |
loginService(java.lang.String subServiceName,
java.lang.String workspace)
Actual implementation of the
loginService(String, String) method
taking into account the bundle calling this method. |
public final java.lang.String getDefaultWorkspace()
login
and
createSession
methods is called without an explicit workspace
name.
This method may return null
in which case the actual default
workspace used depends on the underlying JCR Repository implementation.
getDefaultWorkspace
in interface SlingRepository
public Session login() throws LoginException, RepositoryException
login(null, null)
.
This method may be overwritten.
login(null, null)
.LoginException
- If login is not possibleRepositoryException
- If another error occurrs during loginlogin(Credentials, String)
,
#getNamespaceAwareSession(Session)
public Session login(Credentials credentials) throws LoginException, RepositoryException
login(credentials, null)
.
This method may be overwritten.
credentials
- The Credentials
to use to login.login(credentials, null)
.LoginException
- If login is not possibleRepositoryException
- If another error occurrs during loginlogin(Credentials, String)
,
#getNamespaceAwareSession(Session)
public Session login(java.lang.String workspace) throws LoginException, NoSuchWorkspaceException, RepositoryException
login(null, workspace)
.
This method may be overwritten.
workspace
- The workspace to access or null
to access the
default workspace
login(null, workspace)
.LoginException
- If login is not possibleRepositoryException
- If another error occurrs during loginNoSuchWorkspaceException
login(Credentials, String)
,
#getNamespaceAwareSession(Session)
public Session login(Credentials credentials, java.lang.String workspace) throws LoginException, NoSuchWorkspaceException, RepositoryException
workspace
with the given
credentials
and returns the session returned from
the repository.
This method logs in as a guest if null
credentials are provided.
The method may be overwritten to implement a different behaviour as
indicated by the JCR specification for this method to use external
mechanisms to login instead of leveraging provided credentials.
This method may be overwritten.
credentials
- The Credentials
to use to login. If this is
null
JCR GuestCredentials
are used to login.workspace
- The workspace to access or null
to access the
default workspace
LoginException
- If login is not possibleNoSuchWorkspaceException
- if the desired workspace is not
availableRepositoryException
- If another error occurrs during login#getNamespaceAwareSession(Session)
public final Session loginService(java.lang.String subServiceName, java.lang.String workspace) throws LoginException, RepositoryException
loginService(String, String)
method
taking into account the bundle calling this method.
This method uses the
ServiceUserMapper
service to map the named service to a user and then
calls the createServiceSession(String, String)
method actually
create a session for that user.loginService
in interface SlingRepository
subServiceName
- An optional subService identifier (may be
null
)workspace
- The workspace to access or null
to access the
default workspace
LoginException
- if the service name cannot be derived or if
logging is as the user to which the service name maps is not
allowedRepositoryException
- If a general error occurs while creating the
sessionpublic Session impersonateFromService(java.lang.String subServiceName, Credentials credentials, java.lang.String workspaceName) throws LoginException, RepositoryException
#impersonateFromService(Credentials, String, String)
method taking into account the bundle calling this method.
This method uses the
ServiceUserMapper
service to map the named service to a user and then
calls the createServiceSession(String, String)
method actually
create a session for that user. This service session is then impersonated
to the subject identified by the specified credentials
.impersonateFromService
in interface SlingRepository
subServiceName
- An optional subService identifier (may be null
)credentials
- A valid non-null Credentials
objectworkspaceName
- The workspace to access or null
to access the
default workspace
Session
objectLoginException
- If the current session does not have sufficient access to perform the operation.RepositoryException
- If another error occurs.public final Session loginAdministrative(java.lang.String workspace) throws RepositoryException
disableLoginAdministrative
to true
.
This implementation cannot be overwritten but, unless disabled, forwards
to the createAdministrativeSession(String)
method.
loginAdministrative
in interface SlingRepository
workspace
- The workspace to access or null
to access the
default workspace
RepositoryException
- If the login fails or has been disabledpublic java.lang.String getDescriptor(java.lang.String name)
public java.lang.String[] getDescriptorKeys()
public Value getDescriptorValue(java.lang.String key)
public Value[] getDescriptorValues(java.lang.String key)
public boolean isSingleValueDescriptor(java.lang.String key)
public boolean isStandardDescriptor(java.lang.String key)
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"