Class LegacyResourceProviderAdapter
- All Implemented Interfaces:
Closeable,AutoCloseable
-
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
ConstructorsConstructorDescriptionLegacyResourceProviderAdapter(ResourceProvider rp, String[] languages, boolean ownsRoot) -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeadaptTo(@NotNull ResolveContext<Object> ctx, @NotNull Class<AdapterType> type) Adapts the provider to another type.voidclose()voidcommit(@NotNull ResolveContext<Object> ctx) Commit all transient changes: create, delete and updatesCreate a new resource at the given path.voiddelete(@NotNull ResolveContext<Object> ctx, @NotNull Resource resource) Delete the resource at the given path.getAttribute(@NotNull ResolveContext<Object> ctx, @NotNull String name) Returns the value of the given resource provider attribute ornullif the attribute is not set or not visible (as e.g. security sensitive attributes).getAttributeNames(@NotNull ResolveContext<Object> ctx) Returns a collection of attribute names whose value can be retrieved calling theResourceProvider.getAttribute(ResolveContext, String)method.@Nullable QueryLanguageProvider<Object>Get the optional query language provider.getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) Returns a resource from this resource provider ornullif the resource provider cannot find it.booleanhasChanges(@NotNull ResolveContext<Object> ctx) Are there any transient changes?booleanisLive(@NotNull ResolveContext<Object> ctx) Returnstrueif this resource provider has not been closed yet and can still be used.listChildren(ResolveContext<Object> ctx, Resource parent) voidIf the provider requires authentication, this method is called with the state of the user returned byResourceProvider.authenticate(Map)once the resource resolver is closed.voidrefresh(@NotNull ResolveContext<Object> ctx) The provider is updated to reflect the latest state.voidrevert(@NotNull ResolveContext<Object> ctx) Revert all transient changes: create, delete and updates.toString()Methods inherited from class org.apache.sling.spi.resource.provider.ResourceProvider
authenticate, copy, getParent, getProviderContext, move, orderBefore, start, stop, update
-
Constructor Details
-
LegacyResourceProviderAdapter
-
-
Method Details
-
getResource
public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) Description copied from class:ResourceProviderReturns a resource from this resource provider ornullif the resource provider cannot find it. The path must have theResourceProvider.PROPERTY_ROOTstrings 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:
getResourcein classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.path- The full path of the resource.resourceContext- Additional information for resolving the resourceparent- Optional parent resource- Returns:
nullIf this provider does not have a resource for the path.
-
listChildren
Description copied from class:ResourceProviderReturns anIteratorofResourceobjects loaded from the children of the givenResource. The returnedResourceinstances are attached to the sameResourceResolveras the givenparentresource.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
SyntheticResourceobjects 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:
listChildrenin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.parent- TheResourcewhose children are requested.- Returns:
- An
IteratorofResourceobjects ornullif the resource provider has no children for the given resource.
-
refresh
Description copied from class:ResourceProviderThe 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_REFRESHABLEto the valuetrue.- Overrides:
refreshin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.
-
getQueryLanguageProvider
Description copied from class:ResourceProviderGet 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:
getQueryLanguageProviderin classResourceProvider<Object>- Returns:
- A query language provider if this resource provider supports this type of querying.
-
getAttributeNames
Description copied from class:ResourceProviderReturns 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_ATTRIBUTABLEto the valuetrue.- Overrides:
getAttributeNamesin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.- Returns:
- A collection of attribute names or
null
-
getAttribute
public Object getAttribute(@NotNull @NotNull ResolveContext<Object> ctx, @NotNull @NotNull String name) Description copied from class:ResourceProviderReturns the value of the given resource provider attribute ornullif 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_ATTRIBUTABLEto the valuetrue.- Overrides:
getAttributein classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.name- The name of the attribute to access- Returns:
- The value of the attribute or
nullif the attribute is not set or not accessible.
-
isLive
Description copied from class:ResourceProviderReturnstrueif 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:
isLivein classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.- Returns:
trueif 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.
-
logout
Description copied from class:ResourceProviderIf 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:
logoutin classResourceProvider<Object>- Parameters:
state- The provider state returned byResourceProvider.authenticate(Map).
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
create
public Resource create(@NotNull @NotNull ResolveContext<Object> ctx, String path, Map<String, Object> properties) throws PersistenceExceptionDescription copied from class:ResourceProviderCreate 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_TYPEto 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_MODIFIABLEto the valuetrue.- Overrides:
createin classResourceProvider<Object>- 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<Object> ctx, @NotNull @NotNull Resource resource) throws PersistenceException Description copied from class:ResourceProviderDelete 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_MODIFIABLEto the valuetrue.- Overrides:
deletein classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.resource- The resource to delete.- Throws:
PersistenceException- If anything fails
-
revert
Description copied from class:ResourceProviderRevert 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_MODIFIABLEto the valuetrue.- Overrides:
revertin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.
-
commit
Description copied from class:ResourceProviderCommit all transient changes: create, delete and updatesThis method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLEto the valuetrue.- Overrides:
commitin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.- Throws:
PersistenceException- If anything fails
-
hasChanges
Description copied from class:ResourceProviderAre there any transient changes?This method is only called if the provider supports this and indicates it by setting the
ResourceProvider.PROPERTY_MODIFIABLEto the valuetrue.- Overrides:
hasChangesin classResourceProvider<Object>- Parameters:
ctx- TheResolveContext.- Returns:
trueif there are pending changes.
-
adaptTo
public <AdapterType> AdapterType adaptTo(@NotNull @NotNull ResolveContext<Object> ctx, @NotNull @NotNull Class<AdapterType> type) Description copied from class:ResourceProviderAdapts 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
typeyields 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_ADAPTABLEto the valuetrue.- Overrides:
adaptToin classResourceProvider<Object>- 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
nullif the provider cannot be adapt to the requested type.
-
toString
-