A class for interacting with the Sling Post Servlet.
Kind: global class
Construct a new SlingPost instance
Param | Type | Description |
---|---|---|
config | * | |
[config.url] | string | the url of the Apache Sling instance to connect to |
[config.username] | string | the username to authenticate with Apache Sling |
[config.password] | string | the password to authenticate with Apache Sling |
[config.base] | string | the base directory to use when creating file paths |
[config.level] | string | the logging level for configuring the logger |
Calculates the Sling repository path for a file based on the configured base path
Kind: instance method of SlingPost
Param | Type | Description |
---|---|---|
file | string | the file for which to calculate the repository path |
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
Param | Type | Description |
---|---|---|
fromPath | string | the absolute path to the item to move |
toPath | string | the 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. |
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
Param | Type | Description |
---|---|---|
path | string | The absolute path of the item to delete |
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
Param | Type | Default | Description |
---|---|---|---|
content | string | Specifies content string to import. The format of the import content is the same as is used by the jcr.contentloader bundle. | |
path | string | The 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] | boolean | true | Specifies 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] | boolean | true | Specifies whether the import should replace properties if they already exist. |
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
Param | Type | Default | Description |
---|---|---|---|
file | string | Specifies a file uploaded for import. The format of the import content is the same as is used by the jcr.contentloader bundle. | |
path | string | The 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. | |
contentType | string | "json" | Specifies the type of content being imported. Possible values are: xml, jcr.xml, json, jar, zip |
replace | boolean | true | Specifies 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 | boolean | true | Specifies whether the import should replace properties if they already exist. |
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
Param | Type | Description |
---|---|---|
fromPath | string | the absolute path to the item to move |
toPath | string | the 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. |
Sends a POST request to the Apache Sling Post Servlet
Kind: instance method of SlingPost
Param | Type | Description |
---|---|---|
path | string | the path to execute the command |
params | Object | the paramters to send to the Apache Sling Post API |
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
Param | Type | Description |
---|---|---|
file | string | The file or glob of files to upload into the Apache Sling repository |
[path] | string | The path under which to upload the file. If not specified, the base path will be used to calculate the repository path. |
[params] | Object | Additional parameters to send to the Apache Sling Post API |
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
Param | Type |
---|---|
params | Object |