3
votes

We have a multi site setup with separate content trees with their own groups and users. The 4-eye principle is strictly enforced, so no user has replication rights.

The limitation of CQ is that if a user with no replication rights clicks on the activate button in SiteAdmin or the Sidekick, the Default Request for Activation workflow gets triggered. This is hardcoded and cannot be changed; the same is valid for deactivation. So what I did is to create a custom workflow step which I placed as the only step into the default workflows. This custom step checks the path of the workload item and triggers the correct workflow for this tree.

First problem: As this step is directly completed and a new workflow is triggered, the user that started the workflow, immediatly gets the message that the workflow is completed. Can I somehow have the second workflow be a subtask so the initial workflow only gets completed when the subtask is completed?

Second problem: The tree specific workflow has one approver step, followed by a custom 4-eye-check step (if the last modified user equals the approver, the workflow steps back to the approver step with an error) and the last step is the com.day.cq.wcm.workflow.process.ActivatePageProcess. But as no user has replication rights the checkbox "Replicate As Participant" is not selected. Thus each page has admin as the cq:lastReplicatedBy. Is it somehow possible to have the approver set without him having replicaton rights?

Code Snippet of our forking workflow:

protected void processItem(WorkItem item, WorkflowSession wfSession, WorkflowData workflowData, String config) throws WorkflowException {
    ResourceResolver resolver = getResourceResolver();
    PageManager pm = resolver.adaptTo(PageManager.class);
    try {
        String path = workflowData.getPayload().toString();
        Page page = pm.getContainingPage(path);
        if (page != null) {
            //calculate the id of the correct model depending on page
            String wfid = getWfId(page);
            WorkflowModel mmodel = wfSession.getModel(wfId);
            wfSession.startWorkflow(model, workflowData);
        }
    } finally {
        closeResourceResolver(resolver);
        wfSession.terminateWorkflow(item.getWorkflow());
    }
}

ps. This is a combined question regarding our special workflow setup. If some moderator thinks I should ask two seperate questions, please let me know.

2

2 Answers

5
votes

This is very interesting case!

First problem:

CQ5.6 and further: In the Day CQ Workflow Email Notification Service configuration, there are check boxes that allow to turn off notification on abort or complete.

CQ5.5:

  • option 1 You can turn off both notifications (abort & complete) by leaving event.topic empty in the very same service configuration ( Day CQ Workflow Email Notification Service)

  • option 2 (the bad way) You can remove the template that is used for generation of that email. (/etc/workflow/notification/email/default/en.txt) This will cause two things:

    1. Email won't be sent anymore.
    2. You will have ugly stack traces in your logs. However, by proper logging configuration these stack traces can be removed from the main error.log.

Second problem: I would go for the easiest way and on CRX level change the value of cq:lastReplicatedBy field afterwards. Any other way would be too complicated in my opinion. (and each solution would be just a workaround, I don't think that there is a clean solution for that)

0
votes

Any workflow model is customizable so you can have your own process doing the tasks. You can add whatever logic before invoking the default workflow steps. Also see this How to modify the Adobe CQ ActivatePageProcess process