1 2 18 19 20 21 package org.apache.lenya.cms.cocoon.workflow; 22 23 import java.util.Map ; 24 25 import org.apache.cocoon.environment.ObjectModelHelper; 26 import org.apache.cocoon.environment.Request; 27 import org.apache.cocoon.environment.Session; 28 import org.apache.lenya.ac.AccessControlException; 29 import org.apache.lenya.ac.Identity; 30 import org.apache.lenya.ac.Role; 31 import org.apache.lenya.ac.impl.PolicyAuthorizer; 32 import org.apache.lenya.cms.workflow.WorkflowFactory; 33 import org.apache.lenya.workflow.Situation; 34 import org.apache.lenya.workflow.WorkflowException; 35 36 39 public class WorkflowHelper { 40 41 47 public static Situation buildSituation(Map objectModel) throws WorkflowException { 48 Request request = ObjectModelHelper.getRequest(objectModel); 49 return buildSituation(request); 50 } 51 52 58 public static Situation buildSituation(Request request) throws WorkflowException { 59 Role[] roles; 60 try { 61 roles = PolicyAuthorizer.getRoles(request); 62 } catch (AccessControlException e) { 63 throw new WorkflowException(e); 64 } 65 Session session = request.getSession(false); 66 if (session == null) { 67 throw new WorkflowException("Session not initialized!"); 68 } 69 Identity identity = Identity.getIdentity(session); 70 71 return WorkflowFactory.newInstance().buildSituation(roles, identity); 72 } 73 74 } 75 | Popular Tags |