Class OnDeployScriptBase
- java.lang.Object
-
- com.adobe.acs.commons.ondeploy.scripts.OnDeployScriptBase
-
- All Implemented Interfaces:
OnDeployScript
@ConsumerType public abstract class OnDeployScriptBase extends Object implements OnDeployScript
Base on-deploy script implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description OnDeployScriptBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidexecute()Execute the script.voidexecute(org.apache.sling.api.resource.ResourceResolver resourceResolver)Execute the script, passing in a resourceResolver instance.protected javax.jcr.NodegetOrCreateNode(String absolutePath)Retrieve a node, or create it if not present.protected javax.jcr.NodegetOrCreateNode(String absolutePath, String nodeType)Retrieve a node, or create it if not present.protected javax.jcr.NodegetOrCreateNode(String absolutePath, String intermediateNodeType, String nodeType)Retrieve a node, or create it if not present.protected com.day.cq.wcm.api.PageManagergetPageManager()protected org.apache.sling.api.resource.ResourceResolvergetResourceResolver()protected javax.jcr.SessiongetSession()protected javax.jcr.WorkspacegetWorkspace()protected voidremoveResource(String path)Remove node at a given path.protected voidrenameProperty(javax.jcr.Node node, String oldPropertyName, String newPropertyName)Rename a property on a node.protected voidrenameProperty(org.apache.sling.api.resource.Resource resource, String oldPropertyName, String newPropertyName)Rename a property on a resource.protected voidsearchAndUpdateResourceType(String oldResourceType, String newResourceType)Searches for the current sling:resourceType under /content and replaces any nodes it finds with the newResourceType.protected voidupdateResourceType(javax.jcr.Node node, String resourceType)Update the sling:resourceType of a node.
-
-
-
Method Detail
-
execute
public final void execute(org.apache.sling.api.resource.ResourceResolver resourceResolver)
Description copied from interface:OnDeployScriptExecute the script, passing in a resourceResolver instance.- Specified by:
executein interfaceOnDeployScript- Parameters:
resourceResolver- Resource resolver.- See Also:
OnDeployScript.execute(ResourceResolver)
-
execute
protected abstract void execute() throws ExceptionExecute the script. This function must be implemented by all scripts.- Throws:
Exception
-
getOrCreateNode
protected final javax.jcr.Node getOrCreateNode(String absolutePath) throws javax.jcr.RepositoryException
Retrieve a node, or create it if not present. The node, as well as non-existent parent nodes, are created as type nt:unstructured.- Parameters:
absolutePath- Path to fetch or create.- Returns:
- The fetched or created node.
- Throws:
javax.jcr.RepositoryException
-
getOrCreateNode
protected final javax.jcr.Node getOrCreateNode(String absolutePath, String nodeType) throws javax.jcr.RepositoryException
Retrieve a node, or create it if not present. If the node does not exist, it is created as the specified nodeType. Non-existent parent nodes are created as type nt:unstructured.- Parameters:
absolutePath- Path to fetch or create.nodeType- The type of node to create.- Returns:
- The fetched or created node.
- Throws:
javax.jcr.RepositoryException
-
getOrCreateNode
protected final javax.jcr.Node getOrCreateNode(String absolutePath, String intermediateNodeType, String nodeType) throws javax.jcr.RepositoryException
Retrieve a node, or create it if not present. If the node does not exist, it is created as the specified nodeType. Non-existent parent nodes are created as the type specified by intermediateNodeType.- Parameters:
absolutePath- Path to fetch or create.intermediateNodeType- The type of intermediate nodes to create.nodeType- The type of node to create.- Returns:
- The fetched or created node.
- Throws:
javax.jcr.RepositoryException
-
renameProperty
protected final void renameProperty(javax.jcr.Node node, String oldPropertyName, String newPropertyName) throws javax.jcr.RepositoryExceptionRename a property on a node.- Parameters:
node- Node to update the property name on.oldPropertyName- Old property name.newPropertyName- New property name.- Throws:
javax.jcr.RepositoryException
-
renameProperty
protected final void renameProperty(org.apache.sling.api.resource.Resource resource, String oldPropertyName, String newPropertyName)Rename a property on a resource.- Parameters:
resource- Resource to update the property name on.oldPropertyName- Old property name.newPropertyName- New property name.
-
removeResource
protected final void removeResource(String path) throws javax.jcr.RepositoryException
Remove node at a given path.- Parameters:
path- Path to the node to remove.- Throws:
javax.jcr.RepositoryException
-
searchAndUpdateResourceType
protected final void searchAndUpdateResourceType(String oldResourceType, String newResourceType) throws javax.jcr.RepositoryException
Searches for the current sling:resourceType under /content and replaces any nodes it finds with the newResourceType.- Parameters:
oldResourceType- The current sling:resourceType.newResourceType- The new sling:resourceType to be used.- Throws:
javax.jcr.RepositoryException
-
updateResourceType
protected final void updateResourceType(javax.jcr.Node node, String resourceType) throws javax.jcr.RepositoryExceptionUpdate the sling:resourceType of a node.- Parameters:
node- The node to update.resourceType- The new sling:resourceType to be used.- Throws:
javax.jcr.RepositoryException
-
getResourceResolver
protected final org.apache.sling.api.resource.ResourceResolver getResourceResolver()
-
getPageManager
protected final com.day.cq.wcm.api.PageManager getPageManager()
-
getSession
protected final javax.jcr.Session getSession()
-
getWorkspace
protected final javax.jcr.Workspace getWorkspace()
-
-