Class LegacyResourceProviderFactoryAdapter
-
Field Summary
Fields inherited from class org.apache.sling.spi.resource.provider.ResourceProvider
AUTH_ADMIN, AUTH_CLONE, AUTH_SERVICE_BUNDLE, AUTHENTICATE_LAZY, AUTHENTICATE_NO, AUTHENTICATE_REQUIRED, MODE_OVERLAY, MODE_PASSTHROUGH, PROPERTY_ADAPTABLE, PROPERTY_ATTRIBUTABLE, PROPERTY_AUTHENTICATE, PROPERTY_MODE, PROPERTY_MODIFIABLE, PROPERTY_NAME, PROPERTY_REFRESHABLE, PROPERTY_ROOT, PROPERTY_USE_RESOURCE_ACCESS_SECURITY, RESOURCE_TYPE_SYNTHETIC
-
Constructor Summary
ConstructorsConstructorDescriptionLegacyResourceProviderFactoryAdapter
(ResourceProviderFactory rpFactory, String[] languages, boolean ownsRoot) -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeadaptTo
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull Class<AdapterType> type) Adapts the provider to another type.@NotNull LegacyResourceProviderAdapter
authenticate
(@NotNull Map<String, Object> authenticationInfo) Authenticate against the resource provider.void
commit
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Commit all transient changes: create, delete and updatescreate
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, String path, Map<String, Object> properties) Create a new resource at the given path.void
delete
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull Resource resource) Delete the resource at the given path.getAttribute
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull String name) Returns the value of the given resource provider attribute ornull
if the attribute is not set or not visible (as e.g. security sensitive attributes).getAttributeNames
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Returns a collection of attribute names whose value can be retrieved calling theResourceProvider.getAttribute(ResolveContext, String)
method.Get the optional query language provider.getResource
(ResolveContext<LegacyResourceProviderAdapter> ctx, String path, ResourceContext resourceContext, Resource parent) Returns a resource from this resource provider ornull
if the resource provider cannot find it.boolean
hasChanges
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Are there any transient changes?boolean
isLive
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Returnstrue
if this resource provider has not been closed yet and can still be used.listChildren
(ResolveContext<LegacyResourceProviderAdapter> ctx, Resource parent) void
logout
(@NotNull LegacyResourceProviderAdapter state) If the provider requires authentication, this method is called with the state of the user returned byResourceProvider.authenticate(Map)
once the resource resolver is closed.void
refresh
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) The provider is updated to reflect the latest state.void
revert
(@NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Revert all transient changes: create, delete and updates.Methods inherited from class org.apache.sling.spi.resource.provider.ResourceProvider
copy, getParent, getProviderContext, move, orderBefore, start, stop, update
-
Constructor Details
-
LegacyResourceProviderFactoryAdapter
public LegacyResourceProviderFactoryAdapter(ResourceProviderFactory rpFactory, String[] languages, boolean ownsRoot)
-
-
Method Details
-
authenticate
@NotNull public @NotNull LegacyResourceProviderAdapter authenticate(@NotNull @NotNull Map<String, Object> authenticationInfo) throws LoginExceptionDescription copied from class:ResourceProvider
Authenticate against the resource provider.Returns a provider context object if authentication is successful. The context object is passed to the resource provider in all messages through the
ResourceContext
. A valid implementation might returnnull
as the context information.If authentication fails a
LoginException
must be thrown.The returned context object grants access to the provided resources with privileges assigned to the service provided by the calling bundle.
The
authenticationInfo
map will in general contain the same information as provided to the respectiveResourceResolver
method. ForThe provided
authenticationInfo
map may be used to provide additional information such as theResourceProvider.AUTH_SERVICE_BUNDLE
. If this property is provided, additional information likeResourceResolverFactory.SUBSERVICE
might be provided, but theResourceResolverFactory.USER
andResourceResolverFactory.PASSWORD
properties provided in the map must be ignored.The
ResourceResolverFactory.USER_IMPERSONATION
property is obeyed but requires that the authenticated user has permission to impersonate as the requested user. If such permission is missing, aLoginException
is thrown.The resource resolver implementation will call the
ResourceProvider.logout(Object)
method once the resource resolver is closed. However, if the resource provider is already unregistered when the resource resolver is closed, logout can't be called. Therefore the returned state object might implementCloseable
. In this case close is called on the state object.- Overrides:
authenticate
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
authenticationInfo
- A map of further credential information which may be used by the implementation to parameterize how the resource resolver is created.- Returns:
- A context data object according to the
authenticationInfo
. - Throws:
LoginException
- If an error occurs authenticating with the provided credential data.- See Also:
-
logout
Description copied from class:ResourceProvider
If the provider requires authentication, this method is called with the state of the user returned byResourceProvider.authenticate(Map)
once the resource resolver is closed.- Overrides:
logout
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
state
- The provider state returned byResourceProvider.authenticate(Map)
.
-
getResource
public Resource getResource(ResolveContext<LegacyResourceProviderAdapter> ctx, String path, ResourceContext resourceContext, Resource parent) Description copied from class:ResourceProvider
Returns a resource from this resource provider ornull
if the resource provider cannot find it. The path must have theResourceProvider.PROPERTY_ROOT
strings as its prefix. The resource provider must not return cached instances for a resource as the resource resolver will update the resource meta data of the resource at the end of the resolution process and this meta data might be different depending on the full path of resource resolution passed into the resource resolver.- Specified by:
getResource
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.path
- The full path of the resource.resourceContext
- Additional information for resolving the resourceparent
- Optional parent resource- Returns:
null
If this provider does not have a resource for the path.
-
listChildren
public Iterator<Resource> listChildren(ResolveContext<LegacyResourceProviderAdapter> ctx, Resource parent) Description copied from class:ResourceProvider
Returns anIterator
ofResource
objects loaded from the children of the givenResource
. The returnedResource
instances are attached to the sameResourceResolver
as the givenparent
resource.This method may be called for resource providers whose root path list contains a path such that the resource path is a prefix of the list entry. This allows for the enumeration of deeply nested provided resources for which no actual parent hierarchy exists.
The returned iterator may in turn contain resources which do not actually exist but are required to traverse the resource tree. Such resources SHOULD be
SyntheticResource
objects whose resource type MUST be set toResourceProvider.RESOURCE_TYPE_SYNTHETIC
. As withResourceProvider.getResource(ResolveContext, String, ResourceContext, Resource)
the returned Resource objects must not be cached objects.- Specified by:
listChildren
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.parent
- TheResource
whose children are requested.- Returns:
- An
Iterator
ofResource
objects ornull
if the resource provider has no children for the given resource.
-
refresh
Description copied from class:ResourceProvider
The provider is updated to reflect the latest state. Resources which have changes pending are not discarded.ResourceProvider.revert(ResolveContext)
can be called to discard changes.This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_REFRESHABLE
to the valuetrue
.- Overrides:
refresh
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.
-
getQueryLanguageProvider
@Nullable public @Nullable QueryLanguageProvider<LegacyResourceProviderAdapter> getQueryLanguageProvider()Description copied from class:ResourceProvider
Get the optional query language provider. If the provider supports this kind of query, it must return a query provider implementation if the provider is active. It should not return a query provider if it is not active. This method is called for each query, therefore the provider implementation might cache the provider object.- Overrides:
getQueryLanguageProvider
in classResourceProvider<LegacyResourceProviderAdapter>
- Returns:
- A query language provider if this resource provider supports this type of querying.
-
getAttributeNames
public Collection<String> getAttributeNames(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) Description copied from class:ResourceProvider
Returns a collection of attribute names whose value can be retrieved calling theResourceProvider.getAttribute(ResolveContext, String)
method.This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_ATTRIBUTABLE
to the valuetrue
.- Overrides:
getAttributeNames
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.- Returns:
- A collection of attribute names or
null
-
getAttribute
public Object getAttribute(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull @NotNull String name) Description copied from class:ResourceProvider
Returns the value of the given resource provider attribute ornull
if the attribute is not set or not visible (as e.g. security sensitive attributes).This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_ATTRIBUTABLE
to the valuetrue
.- Overrides:
getAttribute
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.name
- The name of the attribute to access- Returns:
- The value of the attribute or
null
if the attribute is not set or not accessible.
-
isLive
Description copied from class:ResourceProvider
Returnstrue
if this resource provider has not been closed yet and can still be used.This method will never throw an exception even after the resource provider has been closed
This method is only called for resource providers which have a state and require authentication.
- Overrides:
isLive
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.- Returns:
true
if the resource provider has not been closed yet and is still active.. Once the resource provider has been closed or is not active anymore, this method returnsfalse
.
-
create
public Resource create(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, String path, Map<String, Object> properties) throws PersistenceExceptionDescription copied from class:ResourceProvider
Create a new resource at the given path. The new resource is put into the transient space of this provider untilResourceProvider.commit(ResolveContext)
is called.A resource provider must value
ResourceResolver.PROPERTY_RESOURCE_TYPE
to set the resource type of a resource.This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLE
to the valuetrue
.- Overrides:
create
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.path
- The resource path.properties
- Optional properties- Returns:
- The new resource.
- Throws:
PersistenceException
- If anything fails
-
delete
public void delete(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull @NotNull Resource resource) throws PersistenceException Description copied from class:ResourceProvider
Delete the resource at the given path. This change is kept in the transient space of this provider untilResourceProvider.commit(ResolveContext)
is called.This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLE
to the valuetrue
.- Overrides:
delete
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.resource
- The resource to delete.- Throws:
PersistenceException
- If anything fails
-
revert
Description copied from class:ResourceProvider
Revert all transient changes: create, delete and updates.This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLE
to the valuetrue
.- Overrides:
revert
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.
-
commit
public void commit(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx) throws PersistenceException Description copied from class:ResourceProvider
Commit all transient changes: create, delete and updatesThis method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLE
to the valuetrue
.- Overrides:
commit
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.- Throws:
PersistenceException
- If anything fails
-
hasChanges
Description copied from class:ResourceProvider
Are there any transient changes?This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLE
to the valuetrue
.- Overrides:
hasChanges
in classResourceProvider<LegacyResourceProviderAdapter>
- Parameters:
ctx
- TheResolveContext
.- Returns:
true
if there are pending changes.
-
adaptTo
public <AdapterType> AdapterType adaptTo(@NotNull @NotNull ResolveContext<LegacyResourceProviderAdapter> ctx, @NotNull @NotNull Class<AdapterType> type) Description copied from class:ResourceProvider
Adapts the provider to another type.Please not that it is explicitly left as an implementation detail whether each call to this method with the same
type
yields the same object or a new object on each call.Implementations of this method should document their adapted types as well as their behavior with respect to returning newly created or not instance on each call.
This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_ADAPTABLE
to the valuetrue
.- Overrides:
adaptTo
in classResourceProvider<LegacyResourceProviderAdapter>
- Type Parameters:
AdapterType
- The generic type to which this resource is adapted to.- Parameters:
ctx
- TheResolveContext
.type
- The generic type to which this resource is adapted to.- Returns:
- The adapter target or
null
if the provider cannot be adapt to the requested type.
-