trying to check if user/initiator who run a request for activation workflow, had enough permission to activate the page. depending on the user access, I am trying to update the workflow model under OR split. used below code to get the user privileges
Session session = resourceResolver.adaptTo(Session.class);
AccessControlManager acm = session.getAccessControlManager();
Privilege p[] = UIHelper.getAllPermission(acm, resource);
Issue is session.getUserID() return the workflow user, Need a way to get the session adaptTo initiator userID().
Please let me know, if any suggestions to achieve it or suggest if any alternate approach to check user has permission to replicate the page.
Thanks!
Views
Replies
Total Likes
Here is the sample workflow model which is responsible to read workflow initiator(process step) and selecting that initiator as participant using dynamic participant step -
Sample process step -
package com.aem.demo.core.workflows;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
@component(property = { Constants.SERVICE_DESCRIPTION + "=This workflow step is responsible to put initiator details",
Constants.SERVICE_VENDOR + "=AEM Demo Debal", "process.label" + "=Initiator details" })
public class GetInitiatorInfoStep implements WorkflowProcess {
private final Logger logger = LoggerFactory.getLogger(GetInitiatorInfoStep.class);
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
throws WorkflowException {
WorkflowData workflowData = workItem.getWorkflowData();
workflowData.getMetaDataMap().put("initiator", workItem.getWorkflow().getInitiator());
}
}
Dynamic Participant Step
package com.aem.demo.core.workflows;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.ParticipantStepChooser;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;
@component(service = ParticipantStepChooser.class, immediate = true, property = {"chooser.label" + "=Initiator details info" })
public class InitiatorDetailsStep implements ParticipantStepChooser {
private final Logger logger = LoggerFactory.getLogger(InitiatorDetailsStep.class);
@Override
public String getParticipant(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
throws WorkflowException {
String participant = "";
MetaDataMap map = workItem.getWorkflow().getWorkflowData().getMetaDataMap();
String reviewer = (String) map.get("initiator");
logger.info("*** Reviewer ***", reviewer);
if (!reviewer.isEmpty()) {
participant = reviewer;
} else {
participant = "reviewers";
}
return participant;
}
}
After staring the workflow on page , I have captured below details -
Impersonating as Debal -
Task is assigned to Debal Das(Initiator) and inbox notification has come -
Initiator name at workflow instance node -
Similar data were captured for Iris Mccoy -
Please refer following links- https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/workflows-get-initiator-in...
Thanks for the response @DEBAL_DAS . I can able to get the workflow initiator. I want to check if initiator had enough privileges' to replicate a page in the workflow process. Issue is I can't get session adaptTo to initiator to check the privilege's. I am always getting session with workflow-user rather than a initiator session.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies