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.ChangeSetchangeSetprotected org.apache.sling.api.resource.ResourceResolverparentDelegateprotected RemoteProviderproviderprotected org.apache.commons.collections4.map.LRUMapresourceCache
-
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.ResourceResolverclone(Map<String,Object> authenticationInfo)voidclose()voidcommit()org.apache.sling.api.resource.Resourcecopy(String srcAbsPath, String destAbsPath)@NotNull org.apache.sling.api.resource.Resourcecreate(@NotNull org.apache.sling.api.resource.Resource parent, @NotNull String name, Map<String,Object> properties)voiddelete(@NotNull org.apache.sling.api.resource.Resource resource)@NotNull Iterator<org.apache.sling.api.resource.Resource>findResources(@NotNull String query, String language)@Nullable ObjectgetAttribute(@NotNull String name)@NotNull Iterator<String>getAttributeNames()protected RemoteWriter.ChangeSetgetChangeSet()@NotNull Iterable<org.apache.sling.api.resource.Resource>getChildren(@NotNull org.apache.sling.api.resource.Resource parent)@Nullable org.apache.sling.api.resource.ResourcegetParent(@NotNull org.apache.sling.api.resource.Resource child)protected @Nullable org.apache.sling.api.resource.ResourceResolvergetParentDelegate()@Nullable StringgetParentResourceType(String resourceType)@Nullable StringgetParentResourceType(org.apache.sling.api.resource.Resource resource)@Nullable StringgetResolverRootPath()@Nullable org.apache.sling.api.resource.ResourcegetResource(@NotNull String path)@Nullable org.apache.sling.api.resource.ResourcegetResource(org.apache.sling.api.resource.Resource base, @NotNull String path)@NotNull String[]getSearchPath()@Nullable StringgetUserID()booleanhasChanges()booleanhasChildren(@NotNull org.apache.sling.api.resource.Resource resource)booleanisLive()booleanisResourceType(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 Stringmap(@NotNull String resourcePath)@Nullable Stringmap(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String resourcePath)org.apache.sling.api.resource.Resourcemove(@NotNull String srcAbsPath, @NotNull String destParentAbsPath, @Nullable String destChildName, @Nullable String order)move with optional rename and orderingorg.apache.sling.api.resource.Resourcemove(String srcAbsPath, String destAbsPath)@NotNull Iterator<Map<String,Object>>queryResources(@NotNull String query, String language)voidrefresh()@NotNull org.apache.sling.api.resource.Resourceresolve(@NotNull String absPath)@NotNull org.apache.sling.api.resource.Resourceresolve(@NotNull javax.servlet.http.HttpServletRequest request)@NotNull org.apache.sling.api.resource.Resourceresolve(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String absPath)voidrevert()org.apache.sling.api.resource.Resourceupload(@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:
getResolverRootPathin 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:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
resolvein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
resolve
@NotNull public @NotNull org.apache.sling.api.resource.Resource resolve(@NotNull @NotNull String absPath)- Specified by:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
resolvein 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:
resolvein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
resolvein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
map
@NotNull public @NotNull String map(@NotNull @NotNull String resourcePath)
- Specified by:
mapin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
mapin 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:
mapin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
mapin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(@NotNull @NotNull String path)- Specified by:
getResourcein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getResourcein 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:
getResourcein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getResourcein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getSearchPath
@NotNull public @NotNull String[] getSearchPath()
- Specified by:
getSearchPathin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getSearchPathin 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:
getParentin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getParentin 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:
listChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
listChildrenin 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:
getChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getChildrenin 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:
findResourcesin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
findResourcesin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
queryResources
@NotNull public @NotNull Iterator<Map<String,Object>> queryResources(@NotNull @NotNull String query, String language)
- Specified by:
queryResourcesin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
queryResourcesin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
hasChildren
public boolean hasChildren(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)- Specified by:
hasChildrenin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
hasChildrenin 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:
clonein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
clonein classorg.apache.sling.api.wrappers.ResourceResolverWrapper- Throws:
org.apache.sling.api.resource.LoginException
-
isLive
public boolean isLive()
- Specified by:
isLivein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
isLivein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
closein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getUserID
@Nullable public @Nullable String getUserID()
- Specified by:
getUserIDin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getUserIDin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getAttributeNames
@NotNull public @NotNull Iterator<String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getAttributeNamesin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getAttribute
@Nullable public @Nullable Object getAttribute(@NotNull @NotNull String name)
- Specified by:
getAttributein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getAttributein 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:
deletein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
deletein 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:
createin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
createin classorg.apache.sling.api.wrappers.ResourceResolverWrapper- Throws:
org.apache.sling.api.resource.PersistenceException
-
revert
public void revert()
- Specified by:
revertin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
revertin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
commit
public void commit() throws org.apache.sling.api.resource.PersistenceException- Specified by:
commitin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
commitin classorg.apache.sling.api.wrappers.ResourceResolverWrapper- Throws:
org.apache.sling.api.resource.PersistenceException
-
hasChanges
public boolean hasChanges()
- Specified by:
hasChangesin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
hasChangesin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getParentResourceType
@Nullable public @Nullable String getParentResourceType(org.apache.sling.api.resource.Resource resource)
- Specified by:
getParentResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getParentResourceTypein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
getParentResourceType
@Nullable public @Nullable String getParentResourceType(String resourceType)
- Specified by:
getParentResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
getParentResourceTypein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
isResourceType
public boolean isResourceType(org.apache.sling.api.resource.Resource resource, String resourceType)- Specified by:
isResourceTypein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
isResourceTypein classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
refresh
public void refresh()
- Specified by:
refreshin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
refreshin 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:
copyin interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
copyin 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:
movein interfaceorg.apache.sling.api.resource.ResourceResolver- Overrides:
movein 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.PersistenceExceptionDescription copied from interface:ExtendedResolvermove with optional rename and ordering- Specified by:
movein 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.PersistenceExceptionDescription copied from interface:ExtendedResolveruploads the content of a file to update or create a file resource- Specified by:
uploadin 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:
adaptToin interfaceorg.apache.sling.api.adapter.Adaptable- Overrides:
adaptToin classorg.apache.sling.api.wrappers.ResourceResolverWrapper
-
-