Class OnDeployScriptBase

  • All Implemented Interfaces:
    OnDeployScript

    @ConsumerType
    public abstract class OnDeployScriptBase
    extends Object
    implements OnDeployScript
    Base on-deploy script implementation.
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

      • OnDeployScriptBase

        public OnDeployScriptBase()
    • Method Detail

      • 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()