Class ResourceProvider<T>
- java.lang.Object
-
- org.apache.sling.spi.resource.provider.ResourceProvider<T>
-
@ConsumerType public abstract class ResourceProvider<T> extends java.lang.Object
API for providers of resources. Used by theResourceResolver
to transparently access resources from different locations such as a JCR repository, a database, or bundle resources.This extension point is defined by an abstract class (in contrast to an interface) as this allows to add new functionality in new versions without breaking any implementation.
This service is intended to be implemented by providers of resource instances on behalf of the
ResourceResolver
. It is not intended to be used by client applications directly. A resource provider implements this service by extending this class.A resource provider must set the
PROPERTY_ROOT
property with an absolute path. This is the mount point of the resource provider. If there is more than one provider registering for the same root, only the one with the highest service ranking is used.If a provider is used in the resource tree, it gets activated through a call of the
start(ProviderContext)
method. If the provider is not used anymore within the resource tree, thestop()
method is called. Whenever information concerning the provider is changed while the provider is used, theupdate(long)
method is called. The provider context instance which is passed to thestart(ProviderContext)
method contains the updated state.Some resource providers might require (user) authentication. For example the JCR resource provider uses authenticated sessions. If a provider requires authentication it must indicate this by setting the service registration property
PROPERTY_AUTHENTICATE
to eitherAUTHENTICATE_LAZY
orAUTHENTICATE_REQUIRED
. In these cases, the resource resolver callsauthenticate(Map)
and on successful authentication the provider returns a state object for the current user. This object is passed into the provider with every method throughResolveContext.getProviderState()
. If a provider requires authentication, thelogout(Object)
method is called, when the resource resolver is closed. If the provider does not set this service property or sets it toAUTHENTICATE_NO
theauthenticate(Map)
andlogout(Object)
method are never called and thereforeResolveContext.getProviderState()
will returnnull
.Each method gets the
ResourceContext
which gives access to further functionality.- Since:
- 1.0.0 (Sling API Bundle 2.11.0)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTH_ADMIN
The authentication information property indicating to use an administrative login.static java.lang.String
AUTH_CLONE
The authentication information property indicating that an existing resource resolver is being cloned.static java.lang.String
AUTH_SERVICE_BUNDLE
The authentication information property referring to the bundle providing a service for which a resource provider is to be retrieved.static java.lang.String
AUTHENTICATE_LAZY
Value forPROPERTY_AUTHENTICATE
indicating authentication is needed and will be done on demand.static java.lang.String
AUTHENTICATE_NO
Default value forPROPERTY_AUTHENTICATE
static java.lang.String
AUTHENTICATE_REQUIRED
Value forPROPERTY_AUTHENTICATE
indicating authentication is required.static java.lang.String
MODE_OVERLAY
Default mode.static java.lang.String
MODE_PASSTHROUGH
Passthrough mode.static java.lang.String
PROPERTY_ADAPTABLE
If this flag is set totrue
, the resource resolver will use this provider for the adaptTo() operation.static java.lang.String
PROPERTY_ATTRIBUTABLE
If this flag is set totrue
, the resource resolver will try to get the attribute names and the attribute values from this provider.static java.lang.String
PROPERTY_AUTHENTICATE
If a resource provider needs the user to be authenticated this property must be set to eitherAUTHENTICATE_LAZY
orAUTHENTICATE_REQUIRED
.static java.lang.String
PROPERTY_MODE
Mode for the resource provide The value is eitherMODE_OVERLAY
(default) orMODE_PASSTHROUGH
.static java.lang.String
PROPERTY_MODIFIABLE
A modifiable resource provider is capable of creating, changing and deleting resources.static java.lang.String
PROPERTY_NAME
Optional service registration property setting a name for the provider.static java.lang.String
PROPERTY_REFRESHABLE
If this flag is set totrue
, the resource resolver will callrefresh(ResolveContext)
when it's refreshed itself.static java.lang.String
PROPERTY_ROOT
The name of the service registration property containing the root path of the resources provided by this provider.static java.lang.String
PROPERTY_USE_RESOURCE_ACCESS_SECURITY
The name of the service registration property containing a boolean flag indicating if the ResourceAccessSecurity service should be used for this provider or not.static java.lang.String
RESOURCE_TYPE_SYNTHETIC
The resource type be set on resources returned by thelistChildren(ResolveContext, Resource)
method to enable traversing the resource tree down to a deeply nested provided resource which has no concrete parent hierarchy (value is"sling:syntheticResourceProviderResource").
-
Constructor Summary
Constructors Constructor Description ResourceProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <AdapterType>
AdapterTypeadaptTo(@NotNull ResolveContext<T> ctx, @NotNull java.lang.Class<AdapterType> type)
Adapts the provider to another type.T
authenticate(@NotNull java.util.Map<java.lang.String,java.lang.Object> authenticationInfo)
Authenticate against the resource provider.void
commit(@NotNull ResolveContext<T> ctx)
Commit all transient changes: create, delete and updatesboolean
copy(@NotNull ResolveContext<T> ctx, @NotNull java.lang.String srcAbsPath, @NotNull java.lang.String destAbsPath)
This method copies the subgraph rooted at, and including, the resource atsrcAbsPath
to the new location atdestAbsPath
and adds it as a child node of the resource atdestAbsPath
.@NotNull Resource
create(@NotNull ResolveContext<T> ctx, java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> properties)
Create a new resource at the given path.void
delete(@NotNull ResolveContext<T> ctx, @NotNull Resource resource)
Delete the resource at the given path.@Nullable java.lang.Object
getAttribute(@NotNull ResolveContext<T> ctx, @NotNull java.lang.String name)
Returns the value of the given resource provider attribute ornull
if the attribute is not set or not visible (as e.g.@Nullable java.util.Collection<java.lang.String>
getAttributeNames(@NotNull ResolveContext<T> ctx)
Returns a collection of attribute names whose value can be retrieved calling thegetAttribute(ResolveContext, String)
method.@Nullable Resource
getParent(@NotNull ResolveContext<T> ctx, @NotNull Resource child)
Returns the parent resource from this resource provider ornull
if the resource provider cannot find it.@Nullable QueryLanguageProvider<T>
getQueryLanguageProvider()
Get the optional query language provider.abstract @Nullable Resource
getResource(@NotNull ResolveContext<T> ctx, @NotNull java.lang.String path, @NotNull ResourceContext resourceContext, @Nullable Resource parent)
Returns a resource from this resource provider ornull
if the resource provider cannot find it.boolean
hasChanges(@NotNull ResolveContext<T> ctx)
Are there any transient changes?boolean
isLive(@NotNull ResolveContext<T> ctx)
Returnstrue
if this resource provider has not been closed yet and can still be used.abstract @Nullable java.util.Iterator<Resource>
listChildren(@NotNull ResolveContext<T> ctx, @NotNull Resource parent)
void
logout(T state)
If the provider requires authentication, this method is called with the state of the user returned byauthenticate(Map)
once the resource resolver is closed.boolean
move(@NotNull ResolveContext<T> ctx, @NotNull java.lang.String srcAbsPath, @NotNull java.lang.String destAbsPath)
This method moves the subgraph rooted at, and including, the resource atsrcAbsPath
to the new location atdestAbsPath
and adds it as a child node of the resource atdestAbsPath
.boolean
orderBefore(@NotNull ResolveContext<T> ctx, @NotNull Resource parent, @NotNull java.lang.String name, @Nullable java.lang.String followingSiblingName)
Orders the child resources returned bylistChildren(ResolveContext, Resource)
so that a given resource is listed before the given sibling resource.void
refresh(@NotNull ResolveContext<T> ctx)
The provider is updated to reflect the latest state.void
revert(@NotNull ResolveContext<T> ctx)
Revert all transient changes: create, delete and updates.void
start(@NotNull ProviderContext ctx)
With a call to this method, the provider implementation is notified that it is used in the resource tree.void
stop()
With a call to this method, the provider implementation is notified that it is not used anymore in the resource tree.void
update(long changeSet)
With a call to this method, the provider implementation is notified that any information regarding the registration of the provider has changed.
-
-
-
Field Detail
-
PROPERTY_ROOT
public static final java.lang.String PROPERTY_ROOT
The name of the service registration property containing the root path of the resources provided by this provider. If this property is missing, empty or invalid, the provider is ignored. (value is "provider.root")- See Also:
- Constant Field Values
-
PROPERTY_NAME
public static final java.lang.String PROPERTY_NAME
Optional service registration property setting a name for the provider. The name must not be unique. The name in combination with the root can be used to identify a resource provider.- See Also:
- Constant Field Values
-
PROPERTY_USE_RESOURCE_ACCESS_SECURITY
public static final java.lang.String PROPERTY_USE_RESOURCE_ACCESS_SECURITY
The name of the service registration property containing a boolean flag indicating if the ResourceAccessSecurity service should be used for this provider or not. ResourceAccessSecurity should only be used if the underlying storage does not provide access control The default for this value isfalse
. (value is "provider.useResourceAccessSecurity")- See Also:
- Constant Field Values
-
AUTHENTICATE_NO
public static final java.lang.String AUTHENTICATE_NO
Default value forPROPERTY_AUTHENTICATE
- See Also:
PROPERTY_AUTHENTICATE
, Constant Field Values
-
AUTHENTICATE_REQUIRED
public static final java.lang.String AUTHENTICATE_REQUIRED
Value forPROPERTY_AUTHENTICATE
indicating authentication is required.- See Also:
PROPERTY_AUTHENTICATE
, Constant Field Values
-
AUTHENTICATE_LAZY
public static final java.lang.String AUTHENTICATE_LAZY
Value forPROPERTY_AUTHENTICATE
indicating authentication is needed and will be done on demand.- See Also:
PROPERTY_AUTHENTICATE
, Constant Field Values
-
PROPERTY_AUTHENTICATE
public static final java.lang.String PROPERTY_AUTHENTICATE
If a resource provider needs the user to be authenticated this property must be set to eitherAUTHENTICATE_LAZY
orAUTHENTICATE_REQUIRED
. If it is set toAUTHENTICATE_REQUIRED
, theauthenticate(Map)
method is called when the resource resolver is created and only if authentication against all resource providers marked as required is successful, a resource resolver is created. Otherwise the creation fails. If a provider sets this property toAUTHENTICATE_LAZY
, the authenticate method is only invoked if a resource from this provider is requested. This might also happen for traversal or queries. If the authentication fails, resources from this provider are not accessible. If this property is not set or set toAUTHENTICATE_NO
, no authentication is required for this provider and theauthenticate(Map)
is never invoked. String service property, default value isAUTHENTICATE_NO
. (value is "provider.authenticate")- See Also:
- Constant Field Values
-
PROPERTY_MODIFIABLE
public static final java.lang.String PROPERTY_MODIFIABLE
A modifiable resource provider is capable of creating, changing and deleting resources. This means the methodscreate(ResolveContext, String, Map)
,delete(ResolveContext, Resource)
and adapting a resource to a modifiable value map is supported. If this flag is set tofalse
, the resource resolver does not take this provider into account for modifications and modification operations to this provider always result in an exception. If this is set totrue
, the propertyPROPERTY_AUTHENTICATE
must require authentication, otherwise this provider registration is considered invalid and the provider is not used. Boolean service property, default value isfalse
. (value is "provider.modifiable")- See Also:
- Constant Field Values
-
PROPERTY_ADAPTABLE
public static final java.lang.String PROPERTY_ADAPTABLE
If this flag is set totrue
, the resource resolver will use this provider for the adaptTo() operation. Boolean service property, default value isfalse
. (value is "provider.adaptable")- See Also:
- Constant Field Values
-
PROPERTY_REFRESHABLE
public static final java.lang.String PROPERTY_REFRESHABLE
If this flag is set totrue
, the resource resolver will callrefresh(ResolveContext)
when it's refreshed itself. Boolean service property, default value isfalse
. (value is "provider.refreshable")- See Also:
- Constant Field Values
-
PROPERTY_ATTRIBUTABLE
public static final java.lang.String PROPERTY_ATTRIBUTABLE
If this flag is set totrue
, the resource resolver will try to get the attribute names and the attribute values from this provider. Boolean service property, default value isfalse
. (value is "provider.attributable")- See Also:
- Constant Field Values
-
AUTH_SERVICE_BUNDLE
public static final java.lang.String AUTH_SERVICE_BUNDLE
The authentication information property referring to the bundle providing a service for which a resource provider is to be retrieved. If this property is provided, theResourceResolverFactory.SUBSERVICE
property may also be present.ResourceResolverFactory
implementations must provide this property if their implementation of theResourceResolverFactory.getServiceResourceResolver(Map)
method use a resource provider factory.The type of this property, if present, is
org.osgi.framework.Bundle
.- See Also:
- Constant Field Values
-
AUTH_ADMIN
public static final java.lang.String AUTH_ADMIN
The authentication information property indicating to use an administrative login. This property must be set if the resource resolver is created throughResourceResolverFactory.getAdministrativeResourceResolver(Map)
.- See Also:
- Constant Field Values
-
AUTH_CLONE
public static final java.lang.String AUTH_CLONE
The authentication information property indicating that an existing resource resolver is being cloned. Providers that receive stateful objects as authentication information must deep-clone those objects when this property is present, to avoid inadvertent state sharing with the existing resolver.- Since:
- 1.2.0
- See Also:
- Constant Field Values
-
RESOURCE_TYPE_SYNTHETIC
public static final java.lang.String RESOURCE_TYPE_SYNTHETIC
The resource type be set on resources returned by thelistChildren(ResolveContext, Resource)
method to enable traversing the resource tree down to a deeply nested provided resource which has no concrete parent hierarchy (value is"sling:syntheticResourceProviderResource").
-
PROPERTY_MODE
public static final java.lang.String PROPERTY_MODE
Mode for the resource provide The value is eitherMODE_OVERLAY
(default) orMODE_PASSTHROUGH
. The overlay mode is the default. With this mode a resource provider is completely overlaying a potential parent provider. Events and query results from a parent provider are filtered based on the child providers. When a provider specifies the passthrough mode, the resoource provider specifying this mode will be used to get resources. However, for modifications, the parent provider is queried. Similar events and query results from the parent are not filtered. This allows a child resource provider to decorate resources from a parent provider without needing to reimplement all the other functionality.- Since:
- 1.4
- See Also:
- Constant Field Values
-
MODE_OVERLAY
public static final java.lang.String MODE_OVERLAY
Default mode. The resource provider overlays everything from the parent provider.- Since:
- 1.4
- See Also:
- Constant Field Values
-
MODE_PASSTHROUGH
public static final java.lang.String MODE_PASSTHROUGH
Passthrough mode. The implementation passes certain functionality through to the parent resource provider.- Since:
- 1.4
- See Also:
- Constant Field Values
-
-
Method Detail
-
start
public void start(@NotNull @NotNull ProviderContext ctx)
With a call to this method, the provider implementation is notified that it is used in the resource tree.- Parameters:
ctx
- The context for this provider.
-
stop
public void stop()
With a call to this method, the provider implementation is notified that it is not used anymore in the resource tree.
-
update
public void update(long changeSet)
With a call to this method, the provider implementation is notified that any information regarding the registration of the provider has changed. For example, observation listeners might have changed. This method is only called while the provider is used in the resource tree.- Parameters:
changeSet
- A bit set of provider info that has changed.- See Also:
ProviderContext.OBSERVATION_LISTENER_CHANGED
,ProviderContext.EXCLUDED_PATHS_CHANGED
-
authenticate
@Nullable public T authenticate(@NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> authenticationInfo) throws LoginException
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 theAUTH_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
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.- 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:
- Service Authentication
-
logout
public void logout(@Nullable T state)
If the provider requires authentication, this method is called with the state of the user returned byauthenticate(Map)
once the resource resolver is closed.- Parameters:
state
- The provider state returned byauthenticate(Map)
.
-
refresh
public void refresh(@NotNull @NotNull ResolveContext<T> ctx)
The provider is updated to reflect the latest state. Resources which have changes pending are not discarded.revert(ResolveContext)
can be called to discard changes.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_REFRESHABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.
-
isLive
public boolean isLive(@NotNull @NotNull ResolveContext<T> ctx)
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.
- 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
.
-
getParent
@Nullable public @Nullable Resource getParent(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull Resource child)
Returns the parent resource from this resource provider ornull
if the resource provider cannot find it. 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.- Parameters:
ctx
- TheResolveContext
.child
- The child resource.- Returns:
null
if this provider does not have a resource for the parent.- Throws:
SlingException
- may be thrown in case of any problem creating theResource
instance.
-
getResource
@Nullable public abstract @Nullable Resource getResource(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull java.lang.String path, @NotNull @NotNull ResourceContext resourceContext, @Nullable @Nullable Resource parent)
Returns a resource from this resource provider ornull
if the resource provider cannot find it. The path must have thePROPERTY_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.- 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.- Throws:
SlingException
- may be thrown in case of any problem creating theResource
instance.
-
listChildren
@Nullable public abstract @Nullable java.util.Iterator<Resource> listChildren(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull Resource parent)
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 toRESOURCE_TYPE_SYNTHETIC
. As withgetResource(ResolveContext, String, ResourceContext, Resource)
the returned Resource objects must not be cached objects.- 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. - Throws:
java.lang.NullPointerException
- Ifparent
isnull
.SlingException
- If any error occurs acquiring the child resource iterator.
-
getAttributeNames
@Nullable public @Nullable java.util.Collection<java.lang.String> getAttributeNames(@NotNull @NotNull ResolveContext<T> ctx)
Returns a collection of attribute names whose value can be retrieved calling thegetAttribute(ResolveContext, String)
method.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_ATTRIBUTABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.- Returns:
- A collection of attribute names or
null
- Throws:
java.lang.IllegalStateException
- if this resource provider has already been closed.
-
getAttribute
@Nullable public @Nullable java.lang.Object getAttribute(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull java.lang.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).This method is only called if the provider supports this and indicates it by setting the
PROPERTY_ATTRIBUTABLE
to the valuetrue
.- 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. - Throws:
java.lang.IllegalStateException
- if this resource provider has already been closed.
-
create
@NotNull public @NotNull Resource create(@NotNull @NotNull ResolveContext<T> ctx, java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> properties) throws PersistenceException
Create a new resource at the given path. The new resource is put into the transient space of this provider untilcommit(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
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.path
- The resource path.properties
- Optional properties- Returns:
- The new resource.
- Throws:
PersistenceException
- If anything fails
-
orderBefore
public boolean orderBefore(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull Resource parent, @NotNull @NotNull java.lang.String name, @Nullable @Nullable java.lang.String followingSiblingName) throws PersistenceException
Orders the child resources returned bylistChildren(ResolveContext, Resource)
so that a given resource is listed before the given sibling resource. The changes are transient untilcommit(ResolveContext)
is called..- Parameters:
ctx
- TheResolveContext
.parent
- the parent resource containing the child resources to order.name
- the name of the child resource inparent
to order. Must be an existing child name.followingSiblingName
- the name of the resource child inparent
which should come after the reordered resource. Ifnull
is given the resource is ordered as last among all sibling resources.- Returns:
true
in case the order of the child resources inparent
has been changed,false
if the given resource were already in the desired order.- Throws:
java.lang.UnsupportedOperationException
- in case the underlying resource provider does not support ordering or the child resources ofparent
are provided by different providers.java.lang.IllegalArgumentException
- if eithername
orfollowingSiblingName
are not existing child resource names ofparent
.PersistenceException
- If the operation fails in the underlying resource provider, e.g. in case the parent resource does not support orderable children.- Since:
- 1.3.0 (Sling API Bundle 2.24.0)
- See Also:
listChildren(ResolveContext, Resource)
-
delete
public void delete(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull Resource resource) throws PersistenceException
Delete the resource at the given path. This change is kept in the transient space of this provider untilcommit(ResolveContext)
is called.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.resource
- The resource to delete.- Throws:
PersistenceException
- If anything fails
-
revert
public void revert(@NotNull @NotNull ResolveContext<T> ctx)
Revert all transient changes: create, delete and updates.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.
-
commit
public void commit(@NotNull @NotNull ResolveContext<T> ctx) throws PersistenceException
Commit all transient changes: create, delete and updatesThis method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.- Throws:
PersistenceException
- If anything fails
-
hasChanges
public boolean hasChanges(@NotNull @NotNull ResolveContext<T> ctx)
Are there any transient changes?This method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.- Returns:
true
if there are pending changes.
-
getQueryLanguageProvider
@Nullable public @Nullable QueryLanguageProvider<T> getQueryLanguageProvider()
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.- Returns:
- A query language provider if this resource provider supports this type of querying.
-
adaptTo
@Nullable public <AdapterType> AdapterType adaptTo(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull java.lang.Class<AdapterType> type)
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
PROPERTY_ADAPTABLE
to the valuetrue
.- 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.
-
copy
public boolean copy(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull java.lang.String srcAbsPath, @NotNull @NotNull java.lang.String destAbsPath) throws PersistenceException
This method copies the subgraph rooted at, and including, the resource atsrcAbsPath
to the new location atdestAbsPath
and adds it as a child node of the resource atdestAbsPath
.Both resources are resources from this provider and the full tree is provided by this provider as well.
The resource at
destAbsPath
needs to exist, if not aPersistenceException
is thrown. If a child resource with the same name already exists atdestAbsPath
aPersistenceException
is thrown.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.srcAbsPath
- the path of the resource to be copied.destAbsPath
- the location to which the resource atsrcAbsPath
is to be copied.- Returns:
true
if the provider can perform the copy- Throws:
PersistenceException
- If an error occurs.
-
move
public boolean move(@NotNull @NotNull ResolveContext<T> ctx, @NotNull @NotNull java.lang.String srcAbsPath, @NotNull @NotNull java.lang.String destAbsPath) throws PersistenceException
This method moves the subgraph rooted at, and including, the resource atsrcAbsPath
to the new location atdestAbsPath
and adds it as a child node of the resource atdestAbsPath
.Both resources are resources from this provider and the full tree is provided by this provider as well.
The resource at
destAbsPath
needs to exist, if not aPersistenceException
is thrown. If a child resource with the same name already exists atdestAbsPath
aPersistenceException
is thrown.This method is only called if the provider supports this and indicates it by setting the
PROPERTY_MODIFIABLE
to the valuetrue
.- Parameters:
ctx
- TheResolveContext
.srcAbsPath
- the path of the resource to be copied.destAbsPath
- the location to which the resource atsrcAbsPath
is to be moved.- Returns:
true
if the provider can perform the move- Throws:
PersistenceException
- If an error occurs.
-
-