public class WorkflowClient extends CQClient
Modifier and Type | Class and Description |
---|---|
static class |
WorkflowClient.Status
Enumeration of the different Workflow Statuses
|
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
Modifier and Type | Field and Description |
---|---|
static String |
MANAGE_WF_ENGINE_PATH
Request Path to manage workflow engine
|
static String |
MANAGE_WF_INBOX_PATH
Request Path to manage users workflow inbox
|
static String |
MANAGE_WF_INSTANCES_PATH
Request Path to manage workflow instances
|
static String |
MANAGE_WF_MODELS_PATH
Request Path to manage workflow models
|
static String |
MODEL_DESCR_TYPE_JSON
Defines what type of model definition gets passed, currently only JSON
format is implemented
|
static String |
MODEL_LIST_TYPE_ID
Type of model list to return, model id = model node handle
|
static String |
MODEL_LIST_TYPE_URI
Type of models list to return, uri = root context + model id
|
static String |
PAYLOAD_TYPE_JCR
Type of payload referencing used when starting a workflow, in this case a
JCR Path
|
static String |
PAYLOAD_TYPE_URL
Type of payload referencing used when starting a workflow, in this case a
URL Path
|
LOG, STATISTICS_ROOT, wcmCommands
Constructor and Description |
---|
WorkflowClient(org.apache.http.impl.client.CloseableHttpClient http,
org.apache.sling.testing.clients.SlingClientConfig config) |
WorkflowClient(URI serverUrl,
String user,
String password) |
Modifier and Type | Method and Description |
---|---|
org.apache.sling.testing.clients.SlingHttpResponse |
abortWorkflow(String instanceId,
int... expectedStatus)
Aborts/Terminates a running workflow instance.
|
org.apache.sling.testing.clients.SlingHttpResponse |
advanceWorkItem(String workItemId,
String routeId,
int... expectedStatus)
Advances a workflow item trough the next step.
|
org.apache.sling.testing.clients.SlingHttpResponse |
approveAndAdvanceWorkItem(WorkItem workItem,
String routeId,
int... expectedStatus)
Approves a workflow item and advanced to another node.
|
org.apache.sling.testing.clients.SlingHttpResponse |
approveComment(String workItemId,
String routeId,
int... expectedStatus) |
List<org.apache.sling.testing.clients.SlingHttpResponse> |
chooseRouteAndAdvance(String workflowInstancePath,
int chooseRoute)
Choose the route and advance with it
|
org.apache.sling.testing.clients.SlingHttpResponse |
delegateWorkItem(String workItemId,
String delegatee,
int... expectedStatus)
Delegates a workflow item to an other user
Handled by:
granite\bundles\workflow\console\src\main\java\com\adobe\granite
\workflow\console\servlet\InboxServlet.java
|
org.apache.sling.testing.clients.SlingHttpResponse |
deleteModel(String modelId,
int... expectedStatus)
Deletes a workflow model definition.
|
String |
deployModel(String modelSourcePath,
String modelType,
int... expectedStatus)
Creates a new workflow model in the repository by sending a model
definition.
Handled by: granite\bundles\workflow\console\src\main\java\com\adobe\granite\workflow \console\servlet\ModelsServlet.java |
String |
deployModel(String modelSourcePath,
String modelType,
List<org.apache.http.NameValuePair> replaces,
int... expectedStatus)
same as
deployModel(String, String, int...) , but with a list of strings to replace in the model |
Map<String,InboxItem> |
getInboxItems(int... expectedStatus)
Returns the list of work item that are currently in the inbox of this
client's user.
|
WorkflowEngine |
getWorkflowEngineInfo(int... expectedStatus)
Gets the workflow engine info from "/etc/workflow".
Handled by: granite\bundles\workflow\content\src\main\content\jcr_root \libs\cq\workflow\components\engine\json.jsp |
WorkflowInstance |
getWorkflowInstance(String instanceURI,
int... expectedStatus)
Returns all the information about a workflow instance in JSON format.
|
List<HistoryItem> |
getWorkflowInstanceHistory(String instanceURI,
int... expectedStatus)
Retrieve the workflow history of a specific workflow instance
|
List<WorkflowInstance> |
getWorkflowInstances() |
List<WorkflowInstance> |
getWorkflowInstances(WorkflowClient.Status wfStatus) |
List<WorkflowInstance> |
getWorkflowInstances(WorkflowClient.Status wfStatus,
org.joda.time.DateTime startTimeLimit,
org.joda.time.DateTime endTimeLimit) |
List<WorkflowInstance> |
getWorkflowInstances(WorkflowClient.Status wfStatus,
String model,
String payload,
org.joda.time.DateTime startTimeLimit,
org.joda.time.DateTime endTimeLimit) |
List<URI> |
getWorkflowInstanceURLs(WorkflowClient.Status wfStatus,
int... expectedStatus)
Returns a list of workflow instance URI's that are visible for the user.
|
WorkflowModel |
getWorkflowModel(String modelId,
String version,
int... expectedStatus)
Returns the model definition (metadata, nodes, transitions,title
,description etc) in a wrapper class.
|
String |
getWorkflowModelAsJSON(String modelId,
String version,
int... expectedStatus)
Returns the model definition (metadata, nodes, transitions,title
,description etc)
handled by:
\granite\bundles\workflow\console\src\main\java\com\adobe\granite
\workflow\console\servlet\ModelServlet.java
|
ArrayList<String> |
getWorkflowModels(String listType,
int... expectedStatus)
Returns a list of all available workflow models for this user.
|
List<String> |
getWorkItemBackRouteIds(String uri,
int... expectedStatus) |
WorkItem |
getWorkItemByURI(String uri,
int... expectedStatus)
Returns all available information about a work item.
|
boolean |
isWorkflowEngineActive()
Checks if the workflow engine is in an active state (actually its the
workflow OSGi service that gets tested).
|
static Date |
parseJSONDate(String date)
Turns a string date returned by JSON into a Date object.
|
org.apache.sling.testing.clients.SlingHttpResponse |
setWorkflowInstanceStatus(String instanceURI,
WorkflowClient.Status status,
int... expectedStatus)
Set the status of an running workflow instance.
|
String |
startWorkflow(String modelId,
String payload,
int... expectedStatus)
Convenience function for the most common case , using JCR path to
reference the payload.
|
String |
startWorkflow(String modelId,
String payloadType,
String payload,
Map<String,String> metaData,
String title,
String comment,
int... expectedStatus)
Starts a new workflow using the given model id, with the payload
specified.
|
org.apache.sling.testing.clients.SlingHttpResponse |
startWorkflowEngine(int... expectedStatus)
Starts the Workflow Engine, equals to starting the Workflow service.
|
org.apache.sling.testing.clients.SlingHttpResponse |
stepBackWorkItem(String workItemId,
String backrouteId,
int... expectedStatus)
Advances a workflow item back to a previous step.
|
org.apache.sling.testing.clients.SlingHttpResponse |
stopWorkflowEngine(int... expectedStatus)
Stops the Workflow Engine, equals to stopping the Workflow service.
|
org.apache.sling.testing.clients.SlingHttpResponse |
updateModel(String modelSourcePath,
String modelType,
String modelId,
int... expectedStatus)
updates an existing workflow model in the repository by sending a updated
model definition.
Handled by: granite\bundles\workflow\console\src\main\java\com\adobe\granite\workflow \console\servlet\ModelServlet.java |
org.apache.sling.testing.clients.SlingHttpResponse |
updateWfInstanceComment(String instanceURI,
String comment,
int... expectedStatus)
Convenience functions to update/set the comment in the workflow instance
metadata.
|
org.apache.sling.testing.clients.SlingHttpResponse |
updateWfInstanceMetaData(String instanceURI,
Map<String,String> metaData,
int... expectedStatus)
Sends an update request to a workflow instance to update/add metadata
|
org.apache.sling.testing.clients.SlingHttpResponse |
updateWfInstanceTitle(String instanceURI,
String title,
int... expectedStatus)
Convenience function to set edit/set the title of a workflow instance in
its meta data.
|
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, lockPage, movePage, movePage, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadAsset, uploadFileCQStyle
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUUId, getUUID, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getUser, getValue, getValues, hasValue
public static final String MANAGE_WF_INSTANCES_PATH
public static final String MANAGE_WF_MODELS_PATH
public static final String MANAGE_WF_INBOX_PATH
public static final String MANAGE_WF_ENGINE_PATH
public static final String MODEL_LIST_TYPE_ID
public static final String MODEL_LIST_TYPE_URI
public static final String MODEL_DESCR_TYPE_JSON
public static final String PAYLOAD_TYPE_JCR
public static final String PAYLOAD_TYPE_URL
public WorkflowClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public String deployModel(String modelSourcePath, String modelType, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, IOException
modelSourcePath
- path to modelmodelType
- if null or MODEL_DESCR_TYPE_JSON, the model description should
be in JSON format.expectedStatus
- list of allowed HTTP Status to be returned. if not set, http
status 201 (CREATED) is assumed.org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleIOException
- if access to to the JSON resource failspublic String deployModel(String modelSourcePath, String modelType, List<org.apache.http.NameValuePair> replaces, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, IOException
deployModel(String, String, int...)
, but with a list of strings to replace in the modelmodelSourcePath
- resource path of the modelmodelType
- model typereplaces
- list of strings pairs to replaceexpectedStatus
- expected status of the http responseorg.apache.sling.testing.clients.ClientException
- of the request failedIOException
- if the model cannot be readpublic org.apache.sling.testing.clients.SlingHttpResponse advanceWorkItem(String workItemId, String routeId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
workItemId
- the work item to advancerouteId
- the route it should takeexpectedStatus
- The HTTP status that should be returned, otherwise 200 is
assumed.org.apache.sling.testing.clients.ClientException
- if HTTP request fails for any reason.public List<org.apache.sling.testing.clients.SlingHttpResponse> chooseRouteAndAdvance(String workflowInstancePath, int chooseRoute) throws org.apache.sling.testing.clients.ClientException
workflowInstancePath
- the source of the workflow instancechooseRoute
- based on the model at the expected step, the route that should
be used (0, 1, 2, etc..)org.apache.sling.testing.clients.ClientException
- if HTTP request fails for any reason.public org.apache.sling.testing.clients.SlingHttpResponse stepBackWorkItem(String workItemId, String backrouteId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
workItemId
- the work item to advancebackrouteId
- the route it should takeexpectedStatus
- The HTTP status that should be returned, otherwise 200 is
assumed.org.apache.sling.testing.clients.ClientException
- if HTTP request fails for any reason.public org.apache.sling.testing.clients.SlingHttpResponse delegateWorkItem(String workItemId, String delegatee, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
workItemId
- the work item to delegatedelegatee
- the user/group this work item gets delegated toexpectedStatus
- The HTTP status that should be returned, otherwise 200 is
assumed.org.apache.sling.testing.clients.ClientException
- if HTTP request fails for any reason.public org.apache.sling.testing.clients.SlingHttpResponse approveAndAdvanceWorkItem(WorkItem workItem, String routeId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
workItem
- the work item to delegaterouteId
- the user/group this work item gets delegated toexpectedStatus
- The HTTP status that should be returned, otherwise 200 is
assumed.org.apache.sling.testing.clients.ClientException
- if HTTP request fails for any reason.public org.apache.sling.testing.clients.SlingHttpResponse approveComment(String workItemId, String routeId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public Map<String,InboxItem> getInboxItems(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
expectedStatus
- The HTTP status that should returned, othewise 200 is assumed.org.apache.sling.testing.clients.ClientException
- if requesting the JSON failspublic WorkItem getWorkItemByURI(String uri, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
uri
- the URI pointing to the work item nodeexpectedStatus
- the HTTP status that should be returned, otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if requesting the JSON fails for any reasonpublic List<String> getWorkItemBackRouteIds(String uri, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public org.apache.sling.testing.clients.SlingHttpResponse deleteModel(String modelId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
POST
that contains a
X-HTTP-Method-Override
header entry with value DELETE
is
sent instead of the proper HTTP DELETE
.modelId
- the id of the model to deleteexpectedStatus
- HTTP status to be returned, otherwise 20 (NO CONTENT) is
assumedorg.apache.sling.testing.clients.ClientException
- if POST request fails for any reasonpublic org.apache.sling.testing.clients.SlingHttpResponse abortWorkflow(String instanceId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceId
- instanceId (nodepath) of the running workflow instanceexpectedStatus
- if not set it defaults to 200org.apache.sling.testing.clients.ClientException
- if POST fails for any reasonspublic org.apache.sling.testing.clients.SlingHttpResponse updateModel(String modelSourcePath, String modelType, String modelId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, IOException
modelSourcePath
- path to modelmodelType
- if null or MODEL_DESCR_TYPE_JSON, the model description should
bE in JSON format.modelId
- the model to be updatedexpectedStatus
- list of allowed HTTP Status to be returned. if not set, http
status 200 (ok) is assumed.org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleIOException
- if access to to the JSON resource failspublic WorkflowEngine getWorkflowEngineInfo(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
expectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the request for the JSON data fails.public org.apache.sling.testing.clients.SlingHttpResponse stopWorkflowEngine(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
expectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request fails.public org.apache.sling.testing.clients.SlingHttpResponse startWorkflowEngine(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
expectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request fails.public boolean isWorkflowEngineActive() throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
- if requesting Workflow Info failspublic String startWorkflow(String modelId, String payload, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
modelId
- the workflow model id to be used.payload
- the payload JCR path to be set.expectedStatus
- The HTTP Status to be returned otherwise 201 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request failspublic String startWorkflow(String modelId, String payloadType, String payload, Map<String,String> metaData, String title, String comment, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
modelId
- The workflow model Id to be used.payloadType
- The type of payload referencing, either
PAYLOAD_TYPE_JCR
or PAYLOAD_TYPE_URL
. if
set to null , {#PAYLOAD_TYPE_JCR} is used as defaultmetaData
- any meta data that needs to be passed when starting the
workflowtitle
- title to be set for this workflow instancecomment
- comment to be set when starting the workflowexpectedStatus
- The HTTP Status to be returned otherwise 201 is assumedpayload
- the JCR path(s) or URL(s) pointing to the server resource that
act as payload. each payload entry will start a new workflow
instanceorg.apache.sling.testing.clients.ClientException
- if the POST request failspublic org.apache.sling.testing.clients.SlingHttpResponse updateWfInstanceComment(String instanceURI, String comment, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- the workflow instance to be updatedcomment
- the comment of the workflow instance to be setexpectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request fails.public org.apache.sling.testing.clients.SlingHttpResponse updateWfInstanceTitle(String instanceURI, String title, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- the workflow instance to be updatedtitle
- the title of the workflow instance to be setexpectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request fails.public org.apache.sling.testing.clients.SlingHttpResponse updateWfInstanceMetaData(String instanceURI, Map<String,String> metaData, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- the workflow instance to be updatedmetaData
- the metadata to be added /updatedexpectedStatus
- The HTTP Status to be returned otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if the POST request fails.public List<URI> getWorkflowInstanceURLs(WorkflowClient.Status wfStatus, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
wfStatus
- Only returns workflows that are in one of the possible States
( WorkflowClient.Status.RUNNING
, WorkflowClient.Status.ABORTED
,
WorkflowClient.Status.COMPLETED
or WorkflowClient.Status.SUSPENDED
), or, if
set to null, returns all workflow instances.expectedStatus
- HTTP Status to check for or, if not set, 200 is assumedwfStatus
.org.apache.sling.testing.clients.ClientException
- if the call to the backend requesting the JSON failspublic ArrayList<String> getWorkflowModels(String listType, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
listType
- if set to MODEL_LIST_TYPE_ID , a list of model ID's gets
returned (model ID = model Handle) if set to null or
MODEL_LIST_TYPE_URI, a list of model URI's gets returned (URI
= context path + model ID)expectedStatus
- HTTP Status to check for or, if not set, 200 is assumedorg.apache.sling.testing.clients.ClientException
- if requesting the JSON fails for any reasonpublic String getWorkflowModelAsJSON(String modelId, String version, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
modelId
- the model id to requestversion
- the version to retrieve. Either 'HEAD' or null to get the
latest version or in the format major.minor e.g. '1.2'.expectedStatus
- the expected HTTP Status, if not set 200 is assumedorg.apache.sling.testing.clients.ClientException
- If requesting the JSON fails for any reasonpublic WorkflowModel getWorkflowModel(String modelId, String version, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
modelId
- the model id to requestversion
- the version to retrieve. Either 'HEAD' or null to get the
latest version or in the format major.minor e.g. '1.2'.expectedStatus
- the expected HTTP Status, if not set 200 is assumedorg.apache.sling.testing.clients.ClientException
- If requesting the JSON fails for any reasonpublic WorkflowInstance getWorkflowInstance(String instanceURI, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- the path to the workflow instanceexpectedStatus
- the expected HTTP status, otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if requesting the JSON failspublic List<WorkflowInstance> getWorkflowInstances(WorkflowClient.Status wfStatus, String model, String payload, org.joda.time.DateTime startTimeLimit, org.joda.time.DateTime endTimeLimit) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public List<WorkflowInstance> getWorkflowInstances(WorkflowClient.Status wfStatus) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public List<WorkflowInstance> getWorkflowInstances(WorkflowClient.Status wfStatus, org.joda.time.DateTime startTimeLimit, org.joda.time.DateTime endTimeLimit) throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public List<WorkflowInstance> getWorkflowInstances() throws org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.ClientException
public List<HistoryItem> getWorkflowInstanceHistory(String instanceURI, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- the workflow instance uriexpectedStatus
- provide the status code that is expected, default is 200 OK.org.apache.sling.testing.clients.ClientException
- if the request failedpublic org.apache.sling.testing.clients.SlingHttpResponse setWorkflowInstanceStatus(String instanceURI, WorkflowClient.Status status, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
instanceURI
- path to the instance urlstatus
- status to be set, either WorkflowClient.Status.ABORTED
,
WorkflowClient.Status.RUNNING
or WorkflowClient.Status.SUSPENDED
expectedStatus
- Expected HTTP status, otherwise 200 is assumedorg.apache.sling.testing.clients.ClientException
- if POST request has problemsCopyright © 2018. All rights reserved.