Class 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 Detail

      • resourceCache

        protected final org.apache.commons.collections4.map.LRUMap resourceCache
      • parentDelegate

        protected final org.apache.sling.api.resource.ResourceResolver parentDelegate
    • 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)
      • _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
      • _parentPath

        @Nullable
        protected @Nullable String _parentPath​(@NotNull
                                               @NotNull String path)
      • _pathName

        @NotNull
        protected @NotNull String _pathName​(@NotNull
                                            @NotNull String path)
      • getResolverRootPath

        @Nullable
        public @Nullable String getResolverRootPath()
        Specified by:
        getResolverRootPath in interface ExtendedResolver
        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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        resolve in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • resolve

        @NotNull
        public @NotNull org.apache.sling.api.resource.Resource resolve​(@NotNull
                                                                       @NotNull String absPath)
        Specified by:
        resolve in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        resolve in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        resolve in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • map

        @NotNull
        public @NotNull String map​(@NotNull
                                   @NotNull String resourcePath)
        Specified by:
        map in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        map in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        map in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getResource

        @Nullable
        public @Nullable org.apache.sling.api.resource.Resource getResource​(@NotNull
                                                                            @NotNull String path)
        Specified by:
        getResource in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getResource in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getResource in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getSearchPath

        @NotNull
        public @NotNull String[] getSearchPath()
        Specified by:
        getSearchPath in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getSearchPath in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getParent in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        listChildren in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getChildren in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        findResources in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • queryResources

        @NotNull
        public @NotNull Iterator<Map<String,​Object>> queryResources​(@NotNull
                                                                          @NotNull String query,
                                                                          String language)
        Specified by:
        queryResources in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        queryResources in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • hasChildren

        public boolean hasChildren​(@NotNull
                                   @NotNull org.apache.sling.api.resource.Resource resource)
        Specified by:
        hasChildren in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        hasChildren in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        clone in class org.apache.sling.api.wrappers.ResourceResolverWrapper
        Throws:
        org.apache.sling.api.resource.LoginException
      • isLive

        public boolean isLive()
        Specified by:
        isLive in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        isLive in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        close in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getUserID

        @Nullable
        public @Nullable String getUserID()
        Specified by:
        getUserID in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getUserID in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getAttributeNames

        @NotNull
        public @NotNull Iterator<String> getAttributeNames()
        Specified by:
        getAttributeNames in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getAttributeNames in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getAttribute

        @Nullable
        public @Nullable Object getAttribute​(@NotNull
                                             @NotNull String name)
        Specified by:
        getAttribute in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getAttribute in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        delete in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        create in class org.apache.sling.api.wrappers.ResourceResolverWrapper
        Throws:
        org.apache.sling.api.resource.PersistenceException
      • revert

        public void revert()
        Specified by:
        revert in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        revert in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • commit

        public void commit()
                    throws org.apache.sling.api.resource.PersistenceException
        Specified by:
        commit in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        commit in class org.apache.sling.api.wrappers.ResourceResolverWrapper
        Throws:
        org.apache.sling.api.resource.PersistenceException
      • hasChanges

        public boolean hasChanges()
        Specified by:
        hasChanges in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        hasChanges in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getParentResourceType

        @Nullable
        public @Nullable String getParentResourceType​(org.apache.sling.api.resource.Resource resource)
        Specified by:
        getParentResourceType in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getParentResourceType in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • getParentResourceType

        @Nullable
        public @Nullable String getParentResourceType​(String resourceType)
        Specified by:
        getParentResourceType in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        getParentResourceType in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • isResourceType

        public boolean isResourceType​(org.apache.sling.api.resource.Resource resource,
                                      String resourceType)
        Specified by:
        isResourceType in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        isResourceType in class org.apache.sling.api.wrappers.ResourceResolverWrapper
      • refresh

        public void refresh()
        Specified by:
        refresh in interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        refresh in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        copy in class org.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 interface org.apache.sling.api.resource.ResourceResolver
        Overrides:
        move in class org.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 interface ExtendedResolver
        Parameters:
        srcAbsPath - the absolute path of th resource to move
        destParentAbsPath - the absolute path of the designated parent resource
        destChildName - the designated name of the new resource
        order - 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 interface ExtendedResolver
        Parameters:
        absPath - the absolute path oof the file resource to update
        content - the new file content
        filename - the name of the uploaded file
        mimeType - the mime type of the content if known
        charset - 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 interface org.apache.sling.api.adapter.Adaptable
        Overrides:
        adaptTo in class org.apache.sling.api.wrappers.ResourceResolverWrapper