Class RemoteReader
- java.lang.Object
-
- com.composum.sling.nodes.mount.remote.RemoteReader
-
public class RemoteReader extends Object
reads the resource data using default Sling GET servlet JSON requests
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
RemoteReader.RemoteBinary
-
Field Summary
Fields Modifier and Type Field Description static Map<String,Boolean>
BOOLEAN_VALUES
static String[]
DATE_FORMATS
static Pattern
DAV_HREF
static String
DAV_NS
static String
DAV_TYPE_FOLDER
static String
DAV_TYPE_UNKNOWN
static String
NS_PREFIX_JCR
protected RemoteProvider
provider
static Pattern
STRING_TYPE_PREFIX
-
Constructor Summary
Constructors Constructor Description RemoteReader(@NotNull RemoteProvider provider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDavProperty(@NotNull RemoteResource resource, @NotNull org.apache.jackrabbit.webdav.property.DavProperty<?> property)
protected void
addDavProperty(@NotNull RemoteResource resource, @Nullable String ns, @NotNull org.apache.jackrabbit.webdav.property.DavProperty<?> property)
protected void
adjustDavType(@NotNull RemoteResource resource, boolean isFolder)
@NotNull String
getDavUrl(@NotNull RemoteResource resource)
@NotNull String
getDavUrl(@NotNull String resourcePath)
@NotNull String
getJsonUrl(@NotNull RemoteResource resource)
@NotNull String
getJsonUrl(@NotNull String path)
protected int
loadDavResource(@NotNull RemoteResource resource, @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.protected void
loadDavResource(@NotNull RemoteResource resource, @NotNull org.apache.jackrabbit.webdav.MultiStatusResponse response)
protected void
loadJsonResource(@NotNull RemoteResource resource, @NotNull com.google.gson.stream.JsonReader jsonReader)
protected int
loadJsonResource(@NotNull RemoteResource resource, @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.@Nullable RemoteResource
loadResource(@NotNull RemoteResource resource, boolean isKnownChild)
Loads the properties and children into the given resource@NotNull String
remotePath(@NotNull RemoteResource resource)
static @Nullable Boolean
toBoolean(@NotNull String string)
static @Nullable Calendar
toDate(@NotNull String string)
Object
transform(String string)
-
-
-
Field Detail
-
NS_PREFIX_JCR
public static final String NS_PREFIX_JCR
- See Also:
- Constant Field Values
-
DAV_HREF
public static final Pattern DAV_HREF
-
provider
protected final RemoteProvider provider
-
DAV_NS
public static final String DAV_NS
- See Also:
- Constant Field Values
-
DAV_TYPE_FOLDER
public static final String DAV_TYPE_FOLDER
- See Also:
- Constant Field Values
-
DAV_TYPE_UNKNOWN
public static final String DAV_TYPE_UNKNOWN
- See Also:
- Constant Field Values
-
STRING_TYPE_PREFIX
public static final Pattern STRING_TYPE_PREFIX
-
DATE_FORMATS
public static final String[] DATE_FORMATS
-
-
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 / updateisKnownChild
- '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)
-
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 / updatehttpClient
- 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)
-
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 / updatehttpClient
- 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
-
-