Class RemoteResolver
- java.lang.Object
-
- org.apache.sling.api.wrappers.ResourceResolverWrapper
-
- com.composum.sling.nodes.mount.remote.RemoteResolver
-
- All Implemented Interfaces:
ExtendedResolver
,Closeable
,AutoCloseable
,org.apache.sling.api.adapter.Adaptable
,org.apache.sling.api.resource.ResourceResolver
public class RemoteResolver extends org.apache.sling.api.wrappers.ResourceResolverWrapper implements ExtendedResolver
the resolver of the remote Sling instance resources mounted by the resource provider; supports extended CRUD operations for resource ordering and file uploads (updates)
-
-
Field Summary
Fields Modifier and Type Field Description protected RemoteWriter.ChangeSet
changeSet
protected org.apache.sling.api.resource.ResourceResolver
parentDelegate
protected RemoteProvider
provider
protected org.apache.commons.collections4.map.LRUMap
resourceCache
-
Constructor Summary
Constructors Constructor Description RemoteResolver(@NotNull RemoteProvider provider, @NotNull org.apache.sling.api.resource.ResourceResolver parentDelegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RemoteResource
_discard(RemoteResource resource)
protected @Nullable String
_parentPath(@NotNull String path)
protected @NotNull String
_pathName(@NotNull String path)
protected @Nullable org.apache.sling.api.resource.Resource
_resolve(@NotNull String path)
Resolves the resource specified by the path and caches the result.<AdapterType>
AdapterTypeadaptTo(@NotNull Class<AdapterType> type)
@NotNull org.apache.sling.api.resource.ResourceResolver
clone(Map<String,Object> authenticationInfo)
void
close()
void
commit()
org.apache.sling.api.resource.Resource
copy(String srcAbsPath, String destAbsPath)
@NotNull org.apache.sling.api.resource.Resource
create(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, Map<String,Object> properties)
void
delete(@NotNull org.apache.sling.api.resource.Resource resource)
@NotNull Iterator<org.apache.sling.api.resource.Resource>
findResources(@NotNull String query, String language)
@Nullable Object
getAttribute(@NotNull String name)
@NotNull Iterator<String>
getAttributeNames()
protected RemoteWriter.ChangeSet
getChangeSet()
@NotNull Iterable<org.apache.sling.api.resource.Resource>
getChildren(@NotNull org.apache.sling.api.resource.Resource parent)
@Nullable org.apache.sling.api.resource.Resource
getParent(@NotNull org.apache.sling.api.resource.Resource child)
protected @Nullable org.apache.sling.api.resource.ResourceResolver
getParentDelegate()
@Nullable String
getParentResourceType(String resourceType)
@Nullable String
getParentResourceType(org.apache.sling.api.resource.Resource resource)
@Nullable String
getResolverRootPath()
@Nullable org.apache.sling.api.resource.Resource
getResource(@NotNull String path)
@Nullable org.apache.sling.api.resource.Resource
getResource(org.apache.sling.api.resource.Resource base, @NotNull String path)
@NotNull String[]
getSearchPath()
@Nullable String
getUserID()
boolean
hasChanges()
boolean
hasChildren(@NotNull org.apache.sling.api.resource.Resource resource)
boolean
isLive()
boolean
isResourceType(org.apache.sling.api.resource.Resource resource, String resourceType)
@NotNull Iterator<org.apache.sling.api.resource.Resource>
listChildren(@NotNull org.apache.sling.api.resource.Resource parent)
@NotNull String
map(@NotNull String resourcePath)
@Nullable String
map(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String resourcePath)
org.apache.sling.api.resource.Resource
move(@NotNull String srcAbsPath, @NotNull String destParentAbsPath, @Nullable String destChildName, @Nullable String order)
move with optional rename and orderingorg.apache.sling.api.resource.Resource
move(String srcAbsPath, String destAbsPath)
@NotNull Iterator<Map<String,Object>>
queryResources(@NotNull String query, String language)
void
refresh()
@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull String absPath)
@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull javax.servlet.http.HttpServletRequest request)
@NotNull org.apache.sling.api.resource.Resource
resolve(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String absPath)
void
revert()
org.apache.sling.api.resource.Resource
upload(@NotNull String absPath, @NotNull InputStream content, @Nullable String filename, @Nullable String mimeType, @Nullable String charset)
uploads the content of a file to update or create a file resource
-
-
-
Field Detail
-
resourceCache
protected final org.apache.commons.collections4.map.LRUMap resourceCache
-
provider
protected final RemoteProvider provider
-
parentDelegate
protected final org.apache.sling.api.resource.ResourceResolver parentDelegate
-
changeSet
protected RemoteWriter.ChangeSet changeSet
-
-
Constructor Detail
-
RemoteResolver
public RemoteResolver(@NotNull @NotNull RemoteProvider provider, @NotNull @NotNull org.apache.sling.api.resource.ResourceResolver parentDelegate)
-
-
Method Detail
-
getParentDelegate
@Nullable protected @Nullable org.apache.sling.api.resource.ResourceResolver getParentDelegate()
- Returns:
- the 'parent' resource resolver (from the ResolveContext)
-
getChangeSet
protected RemoteWriter.ChangeSet getChangeSet()
- Returns:
- the current set of CRUD changes
-
_resolve
@Nullable protected @Nullable org.apache.sling.api.resource.Resource _resolve(@NotNull @NotNull String path)
Resolves the resource specified by the path and caches the result.- Parameters:
path
- the path (the local path) of the mounted remote resource- Returns:
- the resource, maybe a 'non existing' instance if the resource can't be read
-
_discard
protected RemoteResource _discard(RemoteResource resource)
- Returns:
- the 'non existing' replacement of the discarded resource
-
getResolverRootPath
@Nullable public @Nullable String getResolverRootPath()
- Specified by:
getResolverRootPath
in interfaceExtendedResolver
- Returns:
- the local root path of the resolver (mount point) if useful
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String absPath)
- Specified by:
resolve
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
resolve
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull String absPath)
- Specified by:
resolve
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
resolve
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull javax.servlet.http.HttpServletRequest request)
- Specified by:
resolve
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
resolve
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
map
@NotNull public @NotNull String map(@NotNull @NotNull String resourcePath)
- Specified by:
map
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
map
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
map
@Nullable public @Nullable String map(@NotNull @NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String resourcePath)
- Specified by:
map
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
map
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(@NotNull @NotNull String path)
- Specified by:
getResource
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getResource
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(org.apache.sling.api.resource.Resource base, @NotNull @NotNull String path)
- Specified by:
getResource
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getResource
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getSearchPath
@NotNull public @NotNull String[] getSearchPath()
- Specified by:
getSearchPath
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getSearchPath
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getParent
@Nullable public @Nullable org.apache.sling.api.resource.Resource getParent(@NotNull @NotNull org.apache.sling.api.resource.Resource child)
- Specified by:
getParent
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getParent
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
listChildren
@NotNull public @NotNull Iterator<org.apache.sling.api.resource.Resource> listChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource parent)
- Specified by:
listChildren
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
listChildren
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getChildren
@NotNull public @NotNull Iterable<org.apache.sling.api.resource.Resource> getChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource parent)
- Specified by:
getChildren
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getChildren
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
findResources
@NotNull public @NotNull Iterator<org.apache.sling.api.resource.Resource> findResources(@NotNull @NotNull String query, String language)
- Specified by:
findResources
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
findResources
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
queryResources
@NotNull public @NotNull Iterator<Map<String,Object>> queryResources(@NotNull @NotNull String query, String language)
- Specified by:
queryResources
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
queryResources
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
hasChildren
public boolean hasChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
- Specified by:
hasChildren
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
hasChildren
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
clone
@NotNull public @NotNull org.apache.sling.api.resource.ResourceResolver clone(Map<String,Object> authenticationInfo) throws org.apache.sling.api.resource.LoginException
- Specified by:
clone
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
clone
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.LoginException
-
isLive
public boolean isLive()
- Specified by:
isLive
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
isLive
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
close
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getUserID
@Nullable public @Nullable String getUserID()
- Specified by:
getUserID
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getUserID
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getAttributeNames
@NotNull public @NotNull Iterator<String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getAttributeNames
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getAttribute
@Nullable public @Nullable Object getAttribute(@NotNull @NotNull String name)
- Specified by:
getAttribute
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getAttribute
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
delete
public void delete(@NotNull @NotNull org.apache.sling.api.resource.Resource resource) throws org.apache.sling.api.resource.PersistenceException
- Specified by:
delete
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
delete
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.PersistenceException
-
create
@NotNull public @NotNull org.apache.sling.api.resource.Resource create(@NotNull @NotNull org.apache.sling.api.resource.Resource parent, @NotNull @NotNull String name, Map<String,Object> properties) throws org.apache.sling.api.resource.PersistenceException
- Specified by:
create
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
create
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.PersistenceException
-
revert
public void revert()
- Specified by:
revert
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
revert
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
commit
public void commit() throws org.apache.sling.api.resource.PersistenceException
- Specified by:
commit
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
commit
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.PersistenceException
-
hasChanges
public boolean hasChanges()
- Specified by:
hasChanges
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
hasChanges
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getParentResourceType
@Nullable public @Nullable String getParentResourceType(org.apache.sling.api.resource.Resource resource)
- Specified by:
getParentResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getParentResourceType
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getParentResourceType
@Nullable public @Nullable String getParentResourceType(String resourceType)
- Specified by:
getParentResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
getParentResourceType
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
isResourceType
public boolean isResourceType(org.apache.sling.api.resource.Resource resource, String resourceType)
- Specified by:
isResourceType
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
isResourceType
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
refresh
public void refresh()
- Specified by:
refresh
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
refresh
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
copy
public org.apache.sling.api.resource.Resource copy(String srcAbsPath, String destAbsPath) throws org.apache.sling.api.resource.PersistenceException
- Specified by:
copy
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
copy
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.PersistenceException
-
move
public org.apache.sling.api.resource.Resource move(String srcAbsPath, String destAbsPath) throws org.apache.sling.api.resource.PersistenceException
- Specified by:
move
in interfaceorg.apache.sling.api.resource.ResourceResolver
- Overrides:
move
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
- Throws:
org.apache.sling.api.resource.PersistenceException
-
move
public org.apache.sling.api.resource.Resource move(@NotNull @NotNull String srcAbsPath, @NotNull @NotNull String destParentAbsPath, @Nullable @Nullable String destChildName, @Nullable @Nullable String order) throws org.apache.sling.api.resource.PersistenceException
Description copied from interface:ExtendedResolver
move with optional rename and ordering- Specified by:
move
in interfaceExtendedResolver
- Parameters:
srcAbsPath
- the absolute path of th resource to movedestParentAbsPath
- the absolute path of the designated parent resourcedestChildName
- the designated name of the new resourceorder
- an ordering rule as described for the SlingPostServlet- Throws:
org.apache.sling.api.resource.PersistenceException
-
upload
public org.apache.sling.api.resource.Resource upload(@NotNull @NotNull String absPath, @NotNull @NotNull InputStream content, @Nullable @Nullable String filename, @Nullable @Nullable String mimeType, @Nullable @Nullable String charset) throws org.apache.sling.api.resource.PersistenceException
Description copied from interface:ExtendedResolver
uploads the content of a file to update or create a file resource- Specified by:
upload
in interfaceExtendedResolver
- Parameters:
absPath
- the absolute path oof the file resource to updatecontent
- the new file contentfilename
- the name of the uploaded filemimeType
- the mime type of the content if knowncharset
- the charset of the content- Throws:
org.apache.sling.api.resource.PersistenceException
-
adaptTo
@Nullable public <AdapterType> AdapterType adaptTo(@NotNull @NotNull Class<AdapterType> type)
- Specified by:
adaptTo
in interfaceorg.apache.sling.api.adapter.Adaptable
- Overrides:
adaptTo
in classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
-