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 final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Execute the script.
    final void
    execute(org.apache.sling.api.resource.ResourceResolver resourceResolver)
    Execute the script, passing in a resourceResolver instance.
    protected final javax.jcr.Node
    getOrCreateNode(String absolutePath)
    Retrieve a node, or create it if not present.
    protected final javax.jcr.Node
    getOrCreateNode(String absolutePath, String nodeType)
    Retrieve a node, or create it if not present.
    protected final javax.jcr.Node
    getOrCreateNode(String absolutePath, String intermediateNodeType, String nodeType)
    Retrieve a node, or create it if not present.
    protected final com.day.cq.wcm.api.PageManager
     
    protected final org.apache.sling.api.resource.ResourceResolver
     
    protected final javax.jcr.Session
     
    protected final javax.jcr.Workspace
     
    protected final void
    Remove node at a given path.
    protected final void
    renameProperty(javax.jcr.Node node, String oldPropertyName, String newPropertyName)
    Rename a property on a node.
    protected final void
    renameProperty(org.apache.sling.api.resource.Resource resource, String oldPropertyName, String newPropertyName)
    Rename a property on a resource.
    protected final void
    searchAndUpdateResourceType(String oldResourceType, String newResourceType)
    Searches for the current sling:resourceType under /content and replaces any nodes it finds with the newResourceType.
    protected final void
    updateResourceType(javax.jcr.Node node, String resourceType)
    Update the sling:resourceType of a node.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

    • OnDeployScriptBase

      public OnDeployScriptBase()
  • Method Details

    • execute

      public final void execute(org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Description copied from interface: OnDeployScript
      Execute the script, passing in a resourceResolver instance.
      Specified by:
      execute in interface OnDeployScript
      Parameters:
      resourceResolver - Resource resolver.
      See Also:
    • execute

      protected abstract void execute() throws Exception
      Execute 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.RepositoryException
      Rename 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.RepositoryException
      Update 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()