Publication publication;
try {
publication = PublicationFactory.getPublication(objectModel);
} catch (PublicationException e) {
throw new ExecutionException(e);
}
Request request = ObjectModelHelper.getRequest(objectModel);
setNotifying(request);
Parameters taskParameters = extractTaskParameters(parameters, publication, request);
getTaskParameters().parameterize(taskParameters);
String taskId = request.getParameter(TaskWrapperParameters.TASK_ID);
taskId = parameters.getParameter(TaskWrapperParameters.TASK_ID, taskId);
String webappUrl = ServletHelper.getWebappURI(request);
initialize(taskId, publication, webappUrl, taskParameters);
String eventName = request.getParameter(WorkflowInvoker.EVENT_REQUEST_PARAMETER);
if (eventName == null) {
eventName = request.getParameter(WorkflowInvoker.LENYA_EVENT_REQUEST_PARAMETER);
}
if (eventName != null) {
Session session = request.getSession(false);
if (session == null) {
log.debug("No session found - not enabling workflow handling.");
} else {
Identity identity = Identity.getIdentity(session);
if (identity == null) {
log.debug("No identity found - not enabling workflow handling.");
} else {
log.debug("Identity found - enabling workflow handling.");
Role[] roles;
try {
roles = PolicyAuthorizer.getRoles(request);
} catch (AccessControlException e) {
throw new ExecutionException(e);
}
setWorkflowAware(eventName, identity, roles);
}
}
}