aem-plugin / com.cognifide.gradle.aem.common.instance.service.repository / Node

Node

class Node : Serializable

Represents node stored in JCR content repository.

Types

Property

enum class Property

Constructors

<init>

Represents node stored in JCR content repository.

Node(repository: Repository, path: String, props: Map<String, Any>? = null)

Properties

baseName

File node base name.

val baseName: String

children

Get all child nodes.

val children: List<Node>

exists

Check if node exists.

val exists: Boolean

extension

File node extension.

val extension: String

json

val json: String

name

Node name

val name: String

parent

Parent node.

val parent: Node

parents

val parents: List<Node>

path

val path: String

properties

JCR node properties.

val properties: Properties

repository

val repository: Repository

root

val root: Boolean

siblings

val siblings: List<Node>

type

JCR primary type of node.

val type: String

Functions

child

Get child node by name.

fun child(name: String): Node

children

Loop over all node child nodes.

fun children(): Sequence<Node>

copy

Copy node to from source path to destination path.

fun copy(targetPath: String): Node

copyFrom

Copy node from other path to current path.

fun copyFrom(sourcePath: String): Node

copyTo

Copy node to path pointing to folder with preserving original node name.

fun copyTo(targetDir: String): Node

delete

Delete node and all children from repository.

fun delete(): RepositoryResult

deleteProperties

Delete multiple properties from node.

fun deleteProperties(vararg names: String): RepositoryResult
fun deleteProperties(names: Iterable<String>): RepositoryResult

deleteProperty

Delete single property from node.

fun deleteProperty(name: String): RepositoryResult

download

Download file stored in node to specified local file.

fun download(targetFilePath: String): Unit
fun download(targetFile: File): Unit

Download file stored in node to temporary directory with preserving file name.

fun download(): File

downloadPackage

Download node as CRX package.

fun downloadPackage(options: PackageDefinition.() -> Unit = {}): File

downloadTo

Download file stored in node to specified local directory with preserving file name.

fun downloadTo(targetDirPath: String): File
fun downloadTo(targetDir: File): File

equals

fun equals(other: Any?): Boolean

exists

Check if node exists.

fun exists(recheck: Boolean = false): Boolean

hashCode

fun hashCode(): Int

hasProperties

Check if node has properties.

fun hasProperties(vararg names: String): Boolean
fun hasProperties(names: Iterable<String>): Boolean

hasProperty

Check if node has property.

fun hasProperty(name: String): Boolean

import

Import node into repository.

fun import(properties: Map<String, Any?>, name: String? = null, replace: Boolean = false, replaceProperties: Boolean = false): RepositoryResult

Import content structure defined in JSON file into repository.

fun import(file: File, name: String? = null, replace: Boolean = false, replaceProperties: Boolean = false): RepositoryResult

move

Move node from source path to destination path.

fun move(targetPath: String, replace: Boolean = false): Node

parents

Get all parent nodes.

fun parents(): Sequence<Node>

query

Search nodes by querying repository under node path.

fun query(criteria: QueryCriteria.() -> Unit): Sequence<Node>
fun query(criteria: QueryCriteria): Sequence<Node>

read

Read file stored in node.

fun <T> read(reader: (InputStream) -> T): T

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).

fun reload(): Unit

replace

Delete node and creates it again. Use with caution!

fun replace(properties: Map<String, Any?>): RepositoryResult

save

Create or update node in repository.

fun save(properties: Map<String, Any?>): RepositoryResult

saveProperty

Update only single property of node.

fun saveProperty(name: String, value: Any?): RepositoryResult

sibling

fun sibling(name: String): Node

siblings

fun siblings(): Sequence<Node>

toString

fun toString(): String

traverse

Search nodes by traversing a node tree. Use sequence filter method to find desired nodes.

fun traverse(self: Boolean = false): Sequence<Node>

upload

Upload file to node.

fun upload(file: File): Unit

uploadDamAsset

Upload asset using dedicated DAM endpoint.

fun uploadDamAsset(file: File): Unit

uploadFile

Upload asset using default Sling endpoint.

fun uploadFile(file: File): Unit

uploadTo

Upload file to current folder node with preserving original file name.

fun uploadTo(file: File): Node

Companion Object Properties

DAM_PATH

const val DAM_PATH: String

DAM_UPLOAD_SUFFIX

const val DAM_UPLOAD_SUFFIX: String

TYPE_UNSTRUCTURED

val TYPE_UNSTRUCTURED: Pair<String, String>