Magnolia CMS ships with a pre-configured 4-eyes workflow where every content must be approved by the same group of people, so called “Publishers”.
This can cover 90% of projects, where editorial team is not big enough to allow content segmentation or workflow escalation.
But what happens when you are in a big project, you have a big editorial team and you have to segment your content workflow?
The standard approach would be:
- Download Magnolia source code
- Change the 4-eyes BPML2 diagram (you need Eclipse, jBPML plugin, …!)
- Inject your logic
- Deploy the new 4-eyes workflow
..but..is it really necessary? Of course, not.
As usual in Magnolia, JCR configurations help us on this task.
We need to store somewhere the mapping (JCR path to workflow group) and one right place can be the publish task in the workflow-jbpm module.
With this mapping, any activation from /demo-project will be authorized by people belonging to the “demo-project-publishers” group and any /demo-features activation by people belonging to the “demo-features-publishers”. Just a note: since multiple group can be added to any activation, we’ve left “publishers” group on purporse, to be compliant to a standard Magnolia installation and to allow superuser to do (almost) everything on our activations.
That configuration is read by a Java class (for simplicity, ExtendedConfiguredPublicationTaskDefinition), that need to be extended in order to handle the mapping settings we just added. Here the Java code:
And here the mapping class, GroupsMapping:
And finally, we can easily handle that with a resolver class, ExtendedPublicationTaskParameterResolver:
Let’s try that. We need to start 2 publications, one for each site tree:
As recommended, superuser can see both of them..
.. but what can see other users? Try to log in with Frank, a new user belonging to demo-features-publishers:
He now only see the relevant publication. The other one does not appear to this user.
If you want to see what happen behind the scenes (aka: into JCR), just create a content app that list all Task repository: everything is there:
Quick. And clean.