Interface WorkflowHelper


  • @ProviderType
    public interface WorkflowHelper
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  WorkflowHelper.AssetResourceResolverPair
      A simple tuple which contains a resolved asset and a resource resolver, so that the resource resolver can later be closed.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String[] buildArguments​(com.day.cq.workflow.metadata.MetaDataMap metaData)
      Build an arguments array from the metadata map.
      WorkflowHelper.AssetResourceResolverPair getAssetFromPayload​(com.day.cq.workflow.exec.WorkItem item, com.day.cq.workflow.WorkflowSession workflowSession)
      Resolve the asset for the workflow's payload and return it, along with a resolved resource resolver.
      String getExtension​(String mimetype)
      Return the extension corresponding to the mime type.
      org.apache.sling.api.resource.Resource getPageOrAssetResource​(org.apache.sling.api.resource.ResourceResolver resourceResolver, String path)
      Derives either an Asset or Page resource (dam:Asset or cq:Page) that the provided path belongs to.
      double getQuality​(double base, String qualityStr)
      Parse the provided quality string, from 1 to 100, and apply it to the base.
      org.apache.sling.api.resource.ResourceResolver getResourceResolver​(com.adobe.granite.workflow.WorkflowSession workflowSession)
      Convenience method for getting a ResourceResolver object from a Granite based Workflow Process.
      org.apache.sling.api.resource.ResourceResolver getResourceResolver​(com.day.cq.workflow.WorkflowSession workflowSession)
      Convenience method for getting a ResourceResolver object from a CQ based Workflow Process.
      List<String> getValuesFromArgs​(String name, String[] args)
      Parse a workflow args string in the formaat >name<:>value<,>name<:>value< and extract the values with the specified name.
      boolean isPathTypedPayload​(com.adobe.granite.workflow.exec.WorkflowData workflowData)
      Method for Granite Workflow APIs.
      boolean isPathTypedPayload​(com.day.cq.workflow.exec.WorkflowData workflowData)
      Method for CQ Workflow APIs.
    • Method Detail

      • getResourceResolver

        org.apache.sling.api.resource.ResourceResolver getResourceResolver​(com.adobe.granite.workflow.WorkflowSession workflowSession)
        Convenience method for getting a ResourceResolver object from a Granite based Workflow Process.
        Parameters:
        workflowSession - the granite workflow session
        Returns:
        the associated ResourceResolver object
      • getResourceResolver

        org.apache.sling.api.resource.ResourceResolver getResourceResolver​(com.day.cq.workflow.WorkflowSession workflowSession)
                                                                    throws org.apache.sling.api.resource.LoginException
        Convenience method for getting a ResourceResolver object from a CQ based Workflow Process.
        Parameters:
        workflowSession - the CQ workflow session
        Returns:
        the associated ResourceResolver object
        Throws:
        org.apache.sling.api.resource.LoginException
      • getAssetFromPayload

        WorkflowHelper.AssetResourceResolverPair getAssetFromPayload​(com.day.cq.workflow.exec.WorkItem item,
                                                                     com.day.cq.workflow.WorkflowSession workflowSession)
        Resolve the asset for the workflow's payload and return it, along with a resolved resource resolver.
        Parameters:
        item - the workflow workitem
        workflowSession - the workflow session
        Returns:
        a tuple containing the asset and resource resolver or null if the asset cannot be resolved
      • getExtension

        String getExtension​(String mimetype)
        Return the extension corresponding to the mime type.
        Parameters:
        mimetype - the mimetype
        Returns:
        the corresponding extension
      • buildArguments

        String[] buildArguments​(com.day.cq.workflow.metadata.MetaDataMap metaData)
        Build an arguments array from the metadata map.
        Parameters:
        metaData - the metadata maps
        Returns:
        the values array
      • getValuesFromArgs

        List<String> getValuesFromArgs​(String name,
                                       String[] args)
        Parse a workflow args string in the formaat >name<:>value<,>name<:>value< and extract the values with the specified name.
        Parameters:
        name - the argument name
        args - the arguments array
        Returns:
        the values list
      • getQuality

        double getQuality​(double base,
                          String qualityStr)
        Parse the provided quality string, from 1 to 100, and apply it to the base. Allows for a constant scale to be used and applied to different image types which support different quality scales.
        Parameters:
        base - the maximal quality value
        qualityStr - the string to parse
        Returns:
        a usable quality value
      • getPageOrAssetResource

        org.apache.sling.api.resource.Resource getPageOrAssetResource​(org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                      String path)
        Derives either an Asset or Page resource (dam:Asset or cq:Page) that the provided path belongs to. Example: When path = /content/dam/foo.png/jcr:content/renditions/original, this method will return the resource at /content/dam/foo.png Example: When path = /content/site/bar/jcr:content/root/text, this method will return the resource at /content/site/bar
        Parameters:
        resourceResolver - the resourceResolver to resolve the path to the appropriate resource
        path - the path to resolve to an Asset or Page
        Returns:
        the resource representing the resolver dam:Asset or cq:Page, if neither can be resolved, null is returned.
      • isPathTypedPayload

        boolean isPathTypedPayload​(com.day.cq.workflow.exec.WorkflowData workflowData)
        Method for CQ Workflow APIs.
        Parameters:
        workflowData - the Workflow data
        Returns:
        true of the WorkflowData payload is of type JCR_PATH
      • isPathTypedPayload

        boolean isPathTypedPayload​(com.adobe.granite.workflow.exec.WorkflowData workflowData)
        Method for Granite Workflow APIs.
        Parameters:
        workflowData - the Workflow data
        Returns:
        true of the WorkflowData payload is of type JCR_PATH