Interface ActionManager


  • @ProviderType
    public interface ActionManager
    • Method Detail

      • withQueryResults

        int withQueryResults​(String queryStatement,
                             String language,
                             CheckedBiConsumer<org.apache.sling.api.resource.ResourceResolver,​String> callback,
                             CheckedBiFunction<org.apache.sling.api.resource.ResourceResolver,​String,​Boolean>... filters)
                      throws javax.jcr.RepositoryException,
                             org.apache.sling.api.resource.PersistenceException,
                             Exception
        Schedule an activity to occur for every node found by a given query. Optionally, programmatic filters can be used to ignore query results that are not of interest to the activity. These filters can usually take on more complex logic perform faster than having the query engine do the same.
        Parameters:
        queryStatement - Query string
        language - Query language to use
        callback - Callback action to perform for every query result
        filters - Optional filters return true if action should be taken
        Returns:
        Count of items found in query
        Throws:
        javax.jcr.RepositoryException
        org.apache.sling.api.resource.PersistenceException
        Exception
      • deferredWithResolver

        void deferredWithResolver​(CheckedConsumer<org.apache.sling.api.resource.ResourceResolver> action)
        Perform action at some later time using a provided pooled resolver
        Parameters:
        action - Action to perform
      • withResolver

        void withResolver​(CheckedConsumer<org.apache.sling.api.resource.ResourceResolver> action)
                   throws Exception
        Perform action right now using a provided pooled resolver
        Parameters:
        action - Action to perform
        Throws:
        Exception
      • cancel

        void cancel​(boolean useForce)
        Cancel all work scheduled using this action manager.
        Parameters:
        useForce - If true, forces active work to be interrupted.
      • onSuccess

        void onSuccess​(CheckedConsumer<org.apache.sling.api.resource.ResourceResolver> successTask)
        Register a handler to be fired when the work has completed with no errors.
        Parameters:
        successTask -
      • onFailure

        void onFailure​(CheckedBiConsumer<List<Failure>,​org.apache.sling.api.resource.ResourceResolver> failureTask)
        Register a handler to be fired when the work has completed and there was at least one error.
        Parameters:
        failureTask -
      • onFinish

        void onFinish​(Runnable finishHandler)
        Register a handler to be fired when the work is completed, successfully or not. Note: These handlers are called after the success/fail handlers.
        Parameters:
        finishHandler -
      • isComplete

        boolean isComplete()
        Have all actions completed?
        Returns:
        True if all scheduled work has been completed
      • closeAllResolvers

        void closeAllResolvers()
        Forcefully terminate open resolvers, should only be performed by the factory If using withQueryResults or deferredWithResolvers, use addCleanupTask instead.
      • getFailureList

        List<Failure> getFailureList()
        List all failed actions
        Returns:
        List of failures
      • setCurrentItem

        void setCurrentItem​(String item)
        Note the name or path of the item currently being processed This is particularly useful for error reporting
        Parameters:
        item - Item name or path being processed currently
      • getName

        String getName()
        Returns:
        The name set on this action manager at the time of its creation
      • getAddedCount

        int getAddedCount()
        Returns:
        The number of items of work added for processing.
      • getSuccessCount

        int getSuccessCount()
        Returns:
        The number of items of work that were successfully processed.
      • getErrorCount

        int getErrorCount()
        Returns:
        The number of items of work that were unsuccessfully processed.
      • getCompletedCount

        int getCompletedCount()
        Returns:
        The number of items of work that were processed.
      • getRemainingCount

        int getRemainingCount()
        Returns:
        The number of items of work that have been added but have not yet been processed.