SlingPost

A class for interacting with the Sling Post Servlet.

Kind: global class

new SlingPost(config)

Construct a new SlingPost instance

ParamTypeDescription
config*
[config.url]stringthe url of the Apache Sling instance to connect to
[config.username]stringthe username to authenticate with Apache Sling
[config.password]stringthe password to authenticate with Apache Sling
[config.base]stringthe base directory to use when creating file paths
[config.level]stringthe logging level for configuring the logger

slingPost.repositoryPath(file)

Calculates the Sling repository path for a file based on the configured base path

Kind: instance method of SlingPost

ParamTypeDescription
filestringthe file for which to calculate the repository path

slingPost.copy(fromPath, toPath)

Copies the item addressed by the fromPath parameter to a new location indicated by the toPath parameter

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#copying-content-1

ParamTypeDescription
fromPathstringthe absolute path to the item to move
toPathstringthe absolute or relative path to which the resource is copied. If the path is relative it is assumed to be below the same parent as the request resource. If it is terminated with a / character the request resource is copied to an item of the same name under the destination path.

slingPost.delete(path)

Remove existing content

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#content-removal-1

ParamTypeDescription
pathstringThe absolute path of the item to delete

slingPost.importContent(content, path, [contentType], [replace], [replaceProperties])

Import content into the Sling repository from a string.

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#importing-content-structures-1

ParamTypeDefaultDescription
contentstringSpecifies content string to import. The format of the import content is the same as is used by the jcr.contentloader bundle.
pathstringThe absolute path of the parent item under which to import the content
[contentType]string"json"Specifies the type of content being imported. Possible values are: xml, jcr.xml, json, jar, zip
[replace]booleantrueSpecifies whether the import should replace any existing nodes at the same path. Note: When true, the existing nodes will be deleted and a new node is created in the same place.
[replaceProperties]booleantrueSpecifies whether the import should replace properties if they already exist.

slingPost.importFile(file, path, contentType, replace, replaceProperties)

Import content into the Sling repository from a file.

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#importing-content-structures-1

ParamTypeDefaultDescription
filestringSpecifies a file uploaded for import. The format of the import content is the same as is used by the jcr.contentloader bundle.
pathstringThe absolute path of the parent item under which to import the content. If not specified, the base path will be used to calculate the repository path.
contentTypestring"json"Specifies the type of content being imported. Possible values are: xml, jcr.xml, json, jar, zip
replacebooleantrueSpecifies whether the import should replace any existing nodes at the same path. Note: When true, the existing nodes will be deleted and a new node is created in the same place.
replacePropertiesbooleantrueSpecifies whether the import should replace properties if they already exist.

slingPost.move(fromPath, toPath)

Moves the item addressed by the fromPath to a new location indicated by the toPath parameter.

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#moving-content

ParamTypeDescription
fromPathstringthe absolute path to the item to move
toPathstringthe absolute or relative path to which the resource is moved. If the path is relative it is assumed to be below the same parent as the request resource. If it is terminated with a / character the request resource is moved to an item of the same name under the destination path.

slingPost.post(path, params)

Sends a POST request to the Apache Sling Post Servlet

Kind: instance method of SlingPost

ParamTypeDescription
pathstringthe path to execute the command
paramsObjectthe paramters to send to the Apache Sling Post API

slingPost.uploadFile(file, [path], [params])

Upload a file into the Apache Sling repository

Kind: instance method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#file-uploads

ParamTypeDescription
filestringThe file or glob of files to upload into the Apache Sling repository
[path]stringThe path under which to upload the file. If not specified, the base path will be used to calculate the repository path.
[params]ObjectAdditional parameters to send to the Apache Sling Post API

SlingPost.addAutomaticProperties(params)

Add the automatic properties into the params

Kind: static method of SlingPost
See: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#automatic-property-values-last-modified-and-created-by

ParamType
paramsObject