Interface ContentUpgrade


  • @ProviderType
    public interface ContentUpgrade
    This class provides the builder methods to perform a content upgrade.
    Author:
    Roxana Muresan, Roland Gruber
    • Method Detail

      • forResources

        ContentUpgrade forResources​(String[] paths)
        Loops for given list of resources.
        Parameters:
        paths - list of paths
        Returns:
        upgrade object
      • forChildResourcesOf

        ContentUpgrade forChildResourcesOf​(String path)
        Loops for all child resources of the given path. The path itself is not included.
        Parameters:
        path - path
        Returns:
        upgrade object
      • forDescendantResourcesOf

        ContentUpgrade forDescendantResourcesOf​(String path)
        Loops recursive for all child resources of the given path. The path itself is not included.
        Parameters:
        path - path
        Returns:
        upgrade object
      • forResourcesInSubtree

        ContentUpgrade forResourcesInSubtree​(String path)
        Loops recursive over all resources contained in the subtree at the given path.
        Parameters:
        path - path
        Returns:
        upgrade object
      • forResourcesBySql2Query

        ContentUpgrade forResourcesBySql2Query​(String query)
        Loops over resources found by SQL2 query.
        Parameters:
        query - query string
        Returns:
        upgrade object
      • forResourcesByPropertyQuery

        ContentUpgrade forResourcesByPropertyQuery​(String path,
                                                   Map<String,​String> conditionProperties)
        Loops over resources found by the SQL2 query generated by the path and properties and the default node type "nt:base".
        Parameters:
        path - search path
        conditionProperties - properties to generate AND conditions (values containing % will be matched using LIKE)
        Returns:
        upgrade object
      • forResourcesByPropertyQuery

        ContentUpgrade forResourcesByPropertyQuery​(String path,
                                                   Map<String,​String> conditionProperties,
                                                   String nodeType)
        Loops over resources found by the SQL2 query generated by the nodeType, path and properties.
        Parameters:
        path - search path
        conditionProperties - properties to generate AND conditions (values containing % will be matched using LIKE)
        nodeType - node type (e.g. "nt:base")
        Returns:
        upgrade object
      • filterByHasProperty

        ContentUpgrade filterByHasProperty​(String name)
        Filters by existence of a single property.
        Parameters:
        name - property name
        Returns:
        upgrade object
      • filterByNotHasProperty

        ContentUpgrade filterByNotHasProperty​(String name)
        Filters by non-existence of a single property.
        Parameters:
        name - property name
        Returns:
        upgrade object
      • filterByProperty

        ContentUpgrade filterByProperty​(String name,
                                        Object value)
        Filters by matching a single property.
        Parameters:
        name - property name
        value - property value
        Returns:
        upgrade object
      • filterByNotProperty

        ContentUpgrade filterByNotProperty​(String name,
                                           Object value)
        Filters by not matching a single property.
        Parameters:
        name - property name
        value - property value
        Returns:
        upgrade object
      • filterByPropertyIsMultiple

        ContentUpgrade filterByPropertyIsMultiple​(String name,
                                                  Object value)
        Filters by matching a single property using a regular expression for the value. This is intended for single value properties.
        Parameters:
        name - property name
        value - attribute value
        Returns:
        upgrade object
      • filterByPropertyRegex

        ContentUpgrade filterByPropertyRegex​(String name,
                                             String regex)
        Filters by matching a single property using a regular expression for the value. This is intended for single value properties.
        Parameters:
        name - property name
        regex - regular expression to match value
        Returns:
        upgrade object
      • filterByNotPropertyRegex

        ContentUpgrade filterByNotPropertyRegex​(String name,
                                                String regex)
        Filters by not matching a single property using a regular expression for the value. This is intended for single value properties.
        Parameters:
        name - property name
        regex - regular expression to match value
        Returns:
        upgrade object
      • filterByAnyPropertyRegex

        ContentUpgrade filterByAnyPropertyRegex​(String regex)
        Filters by checking if any property matches the given regular expression for the value. This is intended for single value properties.
        Parameters:
        regex - regular expression to match value
        Returns:
        upgrade object
      • filterByNoPropertyRegex

        ContentUpgrade filterByNoPropertyRegex​(String regex)
        Filters by checking if any property does not match the given regular expression for the value. This is intended for single value properties.
        Parameters:
        regex - regular expression to match value
        Returns:
        upgrade object
      • filterByProperties

        ContentUpgrade filterByProperties​(Map<String,​Object> conditionProperties)
        Filters by matching multiple properties. Can be used also for Multi-value properties.
        Parameters:
        conditionProperties - properties to filter
        Returns:
        upgrade object
      • filterByNotProperties

        ContentUpgrade filterByNotProperties​(Map<String,​Object> conditionProperties)
        Filters by not matching multiple properties. Can be used also for Multi-value properties.
        Parameters:
        conditionProperties - properties to filter
        Returns:
        upgrade object
      • filterByMultiValuePropContains

        ContentUpgrade filterByMultiValuePropContains​(String name,
                                                      Object[] conditionValues)
        Filters by multi-value with the given name containing the given condition values.
        Parameters:
        name - name of the multi-value property
        conditionValues - values to search for
        Returns:
        upgrade object
      • filterByNotMultiValuePropContains

        ContentUpgrade filterByNotMultiValuePropContains​(String name,
                                                         Object[] conditionValues)
        Filters by multi-value with the given name not containing the given condition values.
        Parameters:
        name - name of the multi-value property
        conditionValues - values to search for
        Returns:
        upgrade object
      • filterByNodeName

        ContentUpgrade filterByNodeName​(String nodeName)
        Filters by node name exact match.
        Parameters:
        nodeName - node name
        Returns:
        upgrade object
      • filterByNotNodeName

        ContentUpgrade filterByNotNodeName​(String nodeName)
        Filters by node name no exact match.
        Parameters:
        nodeName - node name
        Returns:
        upgrade object
      • filterByNodeExists

        ContentUpgrade filterByNodeExists​(String path)
        Filters by node/subNode exists.
        Parameters:
        path - absolute or relative resource path
        Returns:
        upgrade object
      • filterByNodeNotExists

        ContentUpgrade filterByNodeNotExists​(String path)
        Filters by node/subNode not exists.
        Parameters:
        path - absolute or relative resource path
        Returns:
        upgrade object
      • filterByNodeNameRegex

        ContentUpgrade filterByNodeNameRegex​(String regex)
        Filters by matching node name using regular expression.
        Parameters:
        regex - regular expression (Java standard pattern)
        Returns:
        upgrade object
      • filterByNotNodeNameRegex

        ContentUpgrade filterByNotNodeNameRegex​(String regex)
        Filters by not matching node name using regular expression.
        Parameters:
        regex - regular expression (Java standard pattern)
        Returns:
        upgrade object
      • filterByPathRegex

        ContentUpgrade filterByPathRegex​(String regex)
        Filters by matching node path using regular expression.
        Parameters:
        regex - regular expression (Java standard pattern)
        Returns:
        upgrade object
      • filterByNotPathRegex

        ContentUpgrade filterByNotPathRegex​(String regex)
        Filters by not matching node path using regular expression.
        Parameters:
        regex - regular expression (Java standard pattern)
        Returns:
        upgrade object
      • filterByNodeRootPaths

        ContentUpgrade filterByNodeRootPaths​(List<String> rootPaths)
        Filters by matching the resource path with the rootpaths
        Parameters:
        rootPaths - List of rootPaths to be matched
        Returns:
        upgrade object
      • filterWith

        ContentUpgrade filterWith​(FilterBy filter)
        Filters by matching the given filter.
        Parameters:
        filter - filter
        Returns:
        upgrade object
      • filterNotWith

        ContentUpgrade filterNotWith​(FilterBy filter)
        Filters by not matching the given filter.
        Parameters:
        filter - filter
        Returns:
        upgrade object
      • doSetProperty

        ContentUpgrade doSetProperty​(String name,
                                     Object value)
        Sets a property value.
        Parameters:
        name - property name
        value - property value
        Returns:
        upgrade object
      • doSetProperty

        ContentUpgrade doSetProperty​(String name,
                                     Object value,
                                     String pathToSubnode)
        Sets a property value on a subnode.
        Parameters:
        name - property name
        value - property value
        pathToSubnode - path to subnode where property will be set
        Returns:
        upgrade object
      • doSetProperty

        ContentUpgrade doSetProperty​(String name,
                                     Object value,
                                     String pathToSubnode,
                                     String primaryType)
        Sets a property value on a subnode.
        Parameters:
        name - property name
        value - property value
        pathToSubnode - path to subnode where property will be set
        primaryType - primary type if subnode or intermediate nodes need to be created
        Returns:
        upgrade object
      • doJoinProperty

        ContentUpgrade doJoinProperty​(String name)
        Joins a property value into a single value. Uses "," to join multiple values. Deletes properties with empty array values.
        Parameters:
        name - property name
        Returns:
        upgrade object
      • doJoinProperty

        ContentUpgrade doJoinProperty​(String name,
                                      Object value)
        Joins a property value into a single value. Uses "," to join multiple values.
        Parameters:
        name - property name
        value - property value fall back for empty arrays. Use null to delete the property.
        Returns:
        upgrade object
      • doJoinProperty

        ContentUpgrade doJoinProperty​(String name,
                                      Object value,
                                      String separator)
        Joins a property value into a single value using the given separator.
        Parameters:
        name - property name
        value - property value fall back for empty arrays. Use null to delete the property.
        separator - separator (e.g. ",")
        Returns:
        upgrade object
      • doDeleteProperty

        ContentUpgrade doDeleteProperty​(String name)
        Deletes a property if existing.
        Parameters:
        name - property name
        Returns:
        upgrade object
      • doDeleteProperty

        ContentUpgrade doDeleteProperty​(String name,
                                        String pathToSubnode)
        Deletes a property if existing.
        Parameters:
        name - property name
        pathToSubnode - path to subnode where property will be set
        Returns:
        upgrade object
      • doRenameProperty

        ContentUpgrade doRenameProperty​(String oldName,
                                        String newName)
        Renames a property if existing.
        Parameters:
        oldName - old property name
        newName - new property name
        Returns:
        upgrade object
      • doRenameProperty

        ContentUpgrade doRenameProperty​(String oldName,
                                        String newName,
                                        String pathToSubnode)
        Renames a property if existing.
        Parameters:
        oldName - old property name
        newName - new property name
        pathToSubnode - path to subnode where property will be set
        Returns:
        upgrade object
      • doCopyPropertyToRelativePath

        ContentUpgrade doCopyPropertyToRelativePath​(String name,
                                                    String newName,
                                                    String relativeResourcePath)
        Copies a property to a relative path.
        Parameters:
        name - property name
        newName - new property name
        relativeResourcePath - relative path
        Returns:
        upgrade object
      • doMovePropertyToRelativePath

        ContentUpgrade doMovePropertyToRelativePath​(String name,
                                                    String newName,
                                                    String relativeResourcePath)
        Moves a property to a relative path.
        Parameters:
        name - property name
        newName - new property name
        relativeResourcePath - relative path
        Returns:
        upgrade object
      • doAddValuesToMultiValueProperty

        ContentUpgrade doAddValuesToMultiValueProperty​(String name,
                                                       String[] values)
        Adds values to a multivalue property.
        Parameters:
        name - property name
        values - values
        Returns:
        upgrade object
      • doRemoveValuesOfMultiValueProperty

        ContentUpgrade doRemoveValuesOfMultiValueProperty​(String name,
                                                          String[] values)
        Removes values of a multivalue property.
        Parameters:
        name - property name
        values - values to remove
        Returns:
        upgrade object
      • doReplaceValuesOfMultiValueProperty

        ContentUpgrade doReplaceValuesOfMultiValueProperty​(String name,
                                                           String[] oldValues,
                                                           String[] newValues)
        Replaces values in a multivalue property.
        Parameters:
        name - property name
        oldValues - values to remove
        newValues - values to add
        Returns:
        upgrade object
      • doReplaceValueInAllProperties

        ContentUpgrade doReplaceValueInAllProperties​(String oldValue,
                                                     String newValue)
        Replaces a substring in all properties of the matching resource. Only applies to String properties.
        Parameters:
        oldValue - old value
        newValue - new value
        Returns:
        upgrade object
      • doReplaceValueInProperties

        ContentUpgrade doReplaceValueInProperties​(String oldValue,
                                                  String newValue,
                                                  String[] propertyNames)
        Replaces a substring in specific properties of the matching resource. Only applies to String properties.
        Parameters:
        oldValue - old value
        newValue - new value
        propertyNames - property names that should be checked
        Returns:
        upgrade object
      • doReplaceValueInAllPropertiesRegex

        ContentUpgrade doReplaceValueInAllPropertiesRegex​(String searchRegex,
                                                          String replacement)
        Replaces a substring in all properties of the matching resource using a regular expression. Only applies to String properties.
        Parameters:
        searchRegex - regex to match old value
        replacement - new value, may contain matcher groups (e.g. $1)
        Returns:
        upgrade object
      • doReplaceValueInPropertiesRegex

        ContentUpgrade doReplaceValueInPropertiesRegex​(String searchRegex,
                                                       String replacement,
                                                       String[] propertyNames)
        Replaces a substring in specific properties of the matching resource using a regular expression. Only applies to String properties.
        Parameters:
        searchRegex - regex to match old value
        replacement - new value, may contain matcher groups (e.g. $1)
        propertyNames - property names that should be checked
        Returns:
        upgrade object
      • doChangePrimaryType

        ContentUpgrade doChangePrimaryType​(String newPrimaryType)
        Changes jcr:primaryType.
        Parameters:
        newPrimaryType - jcr:primaryType value
        Returns:
        upgrade object
      • doRename

        ContentUpgrade doRename​(String newName)
        Renames a resource to the given name.
        Parameters:
        newName - path
        Returns:
        newName new name
      • doCopyResourceToRelativePath

        ContentUpgrade doCopyResourceToRelativePath​(String relativePath)
        Copies a resource to a relative path.
        Parameters:
        relativePath - path
        Returns:
        upgrade object
      • doCopyResourceToRelativePath

        ContentUpgrade doCopyResourceToRelativePath​(String relativePath,
                                                    String newName)
        Copies a resource to a relative path.
        Parameters:
        relativePath - path
        newName - name for the new resource. If not provided the name of the source resource will be used.
        Returns:
        upgrade object
      • doMoveResourceToRelativePath

        ContentUpgrade doMoveResourceToRelativePath​(String relativePath)
        Moves a resource to a relative path.
        Parameters:
        relativePath - path
        Returns:
        upgrade object
      • doMoveResourceToPathRegex

        ContentUpgrade doMoveResourceToPathRegex​(String matchPattern,
                                                 String targetPathExpr)
        Moves a resource if its path matches the pattern to the path obtained by applying the replacement expression
        Parameters:
        matchPattern - regular expression for matching the resource path
        targetPathExpr - expression to calculate the target path, can contain matched group references $1, $2, ...
        Returns:
        upgrade object
      • doReorderNode

        ContentUpgrade doReorderNode​(String nameOfNodeToMove,
                                     String newSuccessor)
        Reorders a resource.
        Parameters:
        nameOfNodeToMove - entry name to move
        newSuccessor - entry will be put before this node (null to move at the end)
        Returns:
        upgrade object
      • doDeleteResource

        ContentUpgrade doDeleteResource​(String... children)
        Deletes the child resources if supplied. If no children are specified it deletes the resource itself.
        Parameters:
        children - delete children (resource itself if empty)
        Returns:
        upgrade object
      • doCreateResource

        ContentUpgrade doCreateResource​(String name,
                                        String primaryType)
        Creates a new resource under the current one.
        Parameters:
        name - resource name
        primaryType - jcr:primaryType
        Returns:
        upgrade object
      • doCreateResource

        ContentUpgrade doCreateResource​(String name,
                                        String primaryType,
                                        Map<String,​Object> properties)
        Creates a new resource under the current one.
        Parameters:
        name - resource name
        primaryType - jcr:primaryType
        properties - properties excl. jcr:primaryType
        Returns:
        upgrade object
      • doCreateResource

        ContentUpgrade doCreateResource​(String name,
                                        String primaryType,
                                        String relativePath)
        Creates a new resource under the current one.
        Parameters:
        name - resource name
        primaryType - jcr:primaryType
        relativePath - relative path
        Returns:
        upgrade object
      • doCreateResource

        ContentUpgrade doCreateResource​(String name,
                                        String primaryType,
                                        Map<String,​Object> properties,
                                        String relativePath)
        Creates a new resource under the current one.
        Parameters:
        name - resource name
        primaryType - jcr:primaryType
        properties - properties excl. jcr:primaryType
        relativePath - relative path
        Returns:
        upgrade object
      • doActivateResource

        ContentUpgrade doActivateResource()
        Activates the resource.
        Returns:
        upgrade object
      • doDeactivateResource

        ContentUpgrade doDeactivateResource()
        Deactivates the resource.
        Returns:
        upgrade object
      • doCustomResourceBasedAction

        ContentUpgrade doCustomResourceBasedAction​(CustomResourceAction action)
        Performs a custom action with providing a function.
        Parameters:
        action - action to perform on resource
        Returns:
        upgrade object
      • doActivateContainingPage

        ContentUpgrade doActivateContainingPage()
        Activates the page where the resource is located.
        Returns:
        upgrade object
      • doTreeActivateContainingPage

        ContentUpgrade doTreeActivateContainingPage()
        Activates the page tree where the resource is located.
        Returns:
        upgrade object
      • doTreeActivateContainingPage

        ContentUpgrade doTreeActivateContainingPage​(boolean skipDeactivated)
        Activates the page tree where the resource is located.
        Parameters:
        skipDeactivated - skip pages that are deactivated
        Returns:
        upgrade object
      • doDeactivateContainingPage

        ContentUpgrade doDeactivateContainingPage()
        Deactivates the page where the resource is located.
        Returns:
        upgrade object
      • doDeleteContainingPage

        ContentUpgrade doDeleteContainingPage()
        Deletes the page where the resource is located. This will not work if called multiple times for the same page.
        Returns:
        upgrade object
      • doAddTagsToContainingPage

        ContentUpgrade doAddTagsToContainingPage​(String... tags)
        Adds tags to the containing page of the matching resource.
        Parameters:
        tags - tag IDs or paths
        Returns:
        upgrade object
      • doSetTagsForContainingPage

        ContentUpgrade doSetTagsForContainingPage​(String... tags)
        Sets tags for the containing page of the matching resource. All existing tags are overwritten.
        Parameters:
        tags - tag IDs or paths
        Returns:
        upgrade object
      • doRemoveTagsFromContainingPage

        ContentUpgrade doRemoveTagsFromContainingPage​(String... tags)
        Removes tags from the containing page of the matching resource.
        Parameters:
        tags - tag IDs or paths
        Returns:
        upgrade object
      • doCheckPageRendering

        ContentUpgrade doCheckPageRendering()
        Checks if the containing page renders with status code 200.
        Returns:
        upgrade object
      • doCheckPageRendering

        ContentUpgrade doCheckPageRendering​(int code)
        Checks if the containing page renders with given status code.
        Parameters:
        code - status code
        Returns:
        upgrade object
      • doCheckPageRendering

        ContentUpgrade doCheckPageRendering​(String textPresent)
        Checks if the containing page renders with status code 200 and contains given text.
        Parameters:
        textPresent - page content must include this text
        Returns:
        upgrade object
      • doCheckPageRendering

        ContentUpgrade doCheckPageRendering​(String textPresent,
                                            String textNotPresent)
        Checks if the containing page renders with status code 200 and (not) contains given text.
        Parameters:
        textPresent - page content must include this text (can be null)
        textNotPresent - page content must not include this text (can be null)
        Returns:
        upgrade object
      • doAddMixin

        ContentUpgrade doAddMixin​(String mixinName)
        Adds a mixin
        Parameters:
        mixinName - valid mixin name
        Returns:
        upgrade object
      • doRemoveMixin

        ContentUpgrade doRemoveMixin​(String mixinName)
        Removes a mixin
        Parameters:
        mixinName - valid mixin name present on the node
        Returns:
        upgrade object
      • printPath

        ContentUpgrade printPath()
        Print path
        Returns:
        upgrade object
      • printProperty

        ContentUpgrade printProperty​(String property)
        Print property
        Parameters:
        property - property name
        Returns:
        upgrade object
      • printJson

        ContentUpgrade printJson()
        Prints the properties json
        Returns:
        upgrade object
      • run

        void run()
          throws org.apache.sling.api.resource.PersistenceException,
                 AecuException
        Saves all changes to repository.
        Throws:
        org.apache.sling.api.resource.PersistenceException - error during execution
        AecuException - other error
      • dryRun

        void dryRun()
             throws org.apache.sling.api.resource.PersistenceException,
                    AecuException
        Performs a dry-run. No changes are written to CRX.
        Throws:
        org.apache.sling.api.resource.PersistenceException - error doing dry-run
        AecuException - other error
      • run

        void run​(boolean dryRun)
          throws org.apache.sling.api.resource.PersistenceException,
                 AecuException
        Executes a run or a dryRun depending on the dryRun parameter value.
        Parameters:
        dryRun - dryRun option
        Throws:
        org.apache.sling.api.resource.PersistenceException - error during execution
        AecuException - other error