Class RemoteReader


  • public class RemoteReader
    extends Object
    reads the resource data using default Sling GET servlet JSON requests
    • Constructor Detail

      • RemoteReader

        public RemoteReader​(@NotNull
                            @NotNull RemoteProvider provider)
    • Method Detail

      • remotePath

        @NotNull
        public @NotNull String remotePath​(@NotNull
                                          @NotNull RemoteResource resource)
        Returns:
        the resoures repository path on the remote system
      • loadResource

        @Nullable
        public @Nullable RemoteResource loadResource​(@NotNull
                                                     @NotNull RemoteResource resource,
                                                     boolean isKnownChild)
        Loads the properties and children into the given resource
        Parameters:
        resource - the resource to load / update
        isKnownChild - 'true' if the resource is cached already (as a child of another resource) and cannot be ignored
        Returns:
        the loaded resource; 'null' if the resource couldn't be loaded
      • getDavUrl

        @NotNull
        public @NotNull String getDavUrl​(@NotNull
                                         @NotNull RemoteResource resource)
      • getDavUrl

        @NotNull
        public @NotNull String getDavUrl​(@NotNull
                                         @NotNull String resourcePath)
      • loadDavResource

        protected int loadDavResource​(@NotNull
                                      @NotNull RemoteResource resource,
                                      @NotNull
                                      @NotNull org.apache.http.client.HttpClient httpClient)
        In the case that a servlet at the remote system blocks the JSON access a WebDAV request is used as fallback to retrieve the resources properties and children.
        Parameters:
        resource - the resource to load / update
        httpClient - the client instance to execute the request
        Returns:
        the status code of the request response
      • adjustDavType

        protected void adjustDavType​(@NotNull
                                     @NotNull RemoteResource resource,
                                     boolean isFolder)
      • loadDavResource

        protected void loadDavResource​(@NotNull
                                       @NotNull RemoteResource resource,
                                       @NotNull
                                       @NotNull org.apache.jackrabbit.webdav.MultiStatusResponse response)
      • addDavProperty

        protected void addDavProperty​(@NotNull
                                      @NotNull RemoteResource resource,
                                      @NotNull
                                      @NotNull org.apache.jackrabbit.webdav.property.DavProperty<?> property)
      • addDavProperty

        protected void addDavProperty​(@NotNull
                                      @NotNull RemoteResource resource,
                                      @Nullable
                                      @Nullable String ns,
                                      @NotNull
                                      @NotNull org.apache.jackrabbit.webdav.property.DavProperty<?> property)
      • getJsonUrl

        @NotNull
        public @NotNull String getJsonUrl​(@NotNull
                                          @NotNull RemoteResource resource)
      • getJsonUrl

        @NotNull
        public @NotNull String getJsonUrl​(@NotNull
                                          @NotNull String path)
      • loadJsonResource

        protected int loadJsonResource​(@NotNull
                                       @NotNull RemoteResource resource,
                                       @NotNull
                                       @NotNull org.apache.http.client.HttpClient httpClient)
        The preferred resource loading using the default Sling GET servlet to read the properties and children of the resource to load.
        Parameters:
        resource - the resource to load / update
        httpClient - the client instance to execute the request
        Returns:
        the status code of the request response
      • loadJsonResource

        protected void loadJsonResource​(@NotNull
                                        @NotNull RemoteResource resource,
                                        @NotNull
                                        @NotNull com.google.gson.stream.JsonReader jsonReader)
                                 throws IOException
        Throws:
        IOException
      • toBoolean

        @Nullable
        public static @Nullable Boolean toBoolean​(@NotNull
                                                  @NotNull String string)
      • toDate

        @Nullable
        public static @Nullable Calendar toDate​(@NotNull
                                                @NotNull String string)