public class Node
Represents a node stored in JCR content repository.
@NotNull public static java.lang.String DAM_PATH
@NotNull public static java.lang.String DAM_UPLOAD_SUFFIX
public static com.cognifide.gradle.aem.common.instance.service.repository.Node.Companion Companion
public Node(@NotNull
Repository repository,
@NotNull
java.lang.String path,
@Nullable
java.util.Map<java.lang.String,? extends java.lang.Object> props)
Represents a node stored in JCR content repository.
@NotNull public java.lang.String getName()
Node name
@NotNull public java.lang.String getBaseName()
File node base name.
@NotNull public java.lang.String getExtension()
File node extension.
@NotNull public Properties getProperties()
JCR node properties.
Keep in mind that these values are loaded lazily and sometimes it is needed to reload them using dedicated method.
@NotNull public java.lang.String getType()
JCR primary type of node.
@NotNull public Node getParent()
Parent node.
public boolean getRoot()
@NotNull public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> parents()
Get all parent nodes.
@NotNull public java.util.List<com.cognifide.gradle.aem.common.instance.service.repository.Node> getParents()
@NotNull public Node child(@NotNull java.lang.String name)
Get child node by name.
public boolean hasChild(@NotNull
java.lang.String name)
Check if child node exists.
@NotNull public java.util.List<com.cognifide.gradle.aem.common.instance.service.repository.Node> getChildren()
Get all child nodes.
Because of performance issues, using method is more preferred.
@NotNull public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> children()
Loop over all node child nodes.
@NotNull public java.util.List<com.cognifide.gradle.aem.common.instance.service.repository.Node> getSiblings()
@NotNull public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> siblings()
@NotNull public Node sibling(@NotNull java.lang.String name)
public boolean getExists()
Check if node exists.
Not checks again if properties of node are already loaded (skips extra HTTP request / optimization).
public boolean exists(boolean recheck)
Check if node exists.
@NotNull public RepositoryResult save(@NotNull java.util.Map<java.lang.String,? extends java.lang.Object> properties)
Create or update node in repository.
@NotNull public RepositoryResult import(@NotNull java.util.Map<java.lang.String,? extends java.lang.Object> properties, @Nullable java.lang.String name, boolean replace, boolean replaceProperties)
Import node into repository.
Effectively it is an alternative method for saving node supporting dots in node names.
@NotNull public RepositoryResult import(@NotNull java.io.File file, @Nullable java.lang.String name, boolean replace, boolean replaceProperties)
Import content structure defined in JSON file into repository.
@NotNull public RepositoryResult delete()
Delete node and all children from repository.
@NotNull public RepositoryResult replace(@NotNull java.util.Map<java.lang.String,? extends java.lang.Object> properties)
Delete node and creates it again. Use with caution!
public void reload()
Synchronize on demand previously loaded properties of node (by default properties are loaded lazily). Useful when saving and working on same node again (without instantiating separate variable).
@NotNull public Node copy(@NotNull java.lang.String targetPath)
Copy node to from source path to destination path.
@NotNull public Node move(@NotNull java.lang.String targetPath, boolean replace)
Move node from source path to destination path.
@NotNull public Node copyTo(@NotNull java.lang.String targetDir)
Copy node to path pointing to folder with preserving original node name.
@NotNull public Node copyFrom(@NotNull java.lang.String sourcePath)
Copy node from other path to current path.
@NotNull public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> traverse(boolean self)
Search nodes by traversing a node tree. Use sequence filter method to find desired nodes.
@NotNull
public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> query(@NotNull
kotlin.jvm.functions.Function1<? super com.cognifide.gradle.aem.common.instance.service.repository.QueryCriteria,kotlin.Unit> criteria)
Search nodes by querying repository under node path.
@NotNull
public kotlin.sequences.Sequence<com.cognifide.gradle.aem.common.instance.service.repository.Node> query(@NotNull
QueryCriteria criteria)
Search nodes by querying repository under node path.
Note that this method is automatically querying more results (incrementing offset internally).
@NotNull public RepositoryResult saveProperty(@NotNull java.lang.String name, @Nullable java.lang.Object value)
Update only single property of node.
@NotNull public RepositoryResult deleteProperty(@NotNull java.lang.String name)
Delete single property from node.
@NotNull public RepositoryResult deleteProperties(@NotNull java.lang.String... names)
Delete multiple properties from node.
@NotNull public RepositoryResult deleteProperties(@NotNull java.lang.Iterable<java.lang.String> names)
Delete multiple properties from node.
public boolean hasProperty(@NotNull
java.lang.String name)
Check if node has property.
public boolean hasProperties(@NotNull
java.lang.String... names)
Check if node has properties.
public boolean hasProperties(@NotNull
java.lang.Iterable<java.lang.String> names)
Check if node has properties.
@NotNull public java.lang.String getJson()
public void upload(@NotNull
java.io.File file)
Upload file to node.
If node path points to DAM, separate / dedicated endpoint is used automatically, so that metadata and renditions are generated immediately.
public void uploadFile(@NotNull
java.io.File file)
Upload asset using default Sling endpoint.
public void uploadDamAsset(@NotNull
java.io.File file)
Upload asset using dedicated DAM endpoint.
@NotNull public Node uploadTo(@NotNull java.io.File file)
Upload file to current folder node with preserving original file name.
public <T> T read(@NotNull
kotlin.jvm.functions.Function1<? super java.io.InputStream,? extends T> reader)
Read file stored in node.
public void download(@NotNull
java.lang.String targetFilePath)
Download file stored in node to specified local file.
public void download(@NotNull
java.io.File targetFile)
Download file stored in node to specified local file.
@NotNull public java.io.File download()
Download file stored in node to temporary directory with preserving file name.
@NotNull
public java.io.File downloadTo(@NotNull
java.lang.String targetDirPath)
Download file stored in node to specified local directory with preserving file name.
@NotNull
public java.io.File downloadTo(@NotNull
java.io.File targetDir)
Download file stored in node to specified local directory with preserving file name.
@NotNull
public java.io.File downloadPackage(@NotNull
kotlin.jvm.functions.Function1<? super com.cognifide.gradle.aem.common.pkg.PackageDefinition,kotlin.Unit> options)
Download node as CRX package.
public boolean equals(@Nullable
java.lang.Object other)
public int hashCode()
@NotNull public java.lang.String toString()
@NotNull public Repository getRepository()
@NotNull public java.lang.String getPath()