1 23 package org.infoglue.cms.applications.workflowtool.function; 24 25 import org.infoglue.cms.controllers.kernel.impl.simple.GroupControllerProxy; 26 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy; 27 import org.infoglue.cms.security.InfoGlueGroup; 28 import org.infoglue.cms.security.InfoGlueRole; 29 import org.infoglue.cms.util.workflow.OwnerFactory; 30 31 import com.opensymphony.workflow.WorkflowException; 32 33 64 public class Owner extends InfoglueFunction 65 { 66 69 private static final String OWNER_PARAMETER = "owner"; 70 71 74 private static final String ROLE_ARGUMENT = "role"; 75 76 79 private static final String GROUP_ARGUMENT = "group"; 80 81 84 private String roleName; 85 86 89 private String groupName; 90 91 94 public Owner() 95 { 96 super(); 97 } 98 99 104 protected void execute() throws WorkflowException 105 { 106 try 107 { 108 final InfoGlueRole role = RoleControllerProxy.getController(getDatabase()).getRole(roleName); 109 if(groupName == null) 110 { 111 setParameter(OWNER_PARAMETER, OwnerFactory.create(role).getIdentifier()); 112 } 113 else 114 { 115 final InfoGlueGroup group = GroupControllerProxy.getController(getDatabase()).getGroup(groupName); 116 setParameter(OWNER_PARAMETER, OwnerFactory.create(role, group).getIdentifier()); 117 } 118 } 119 catch(Exception e) 120 { 121 throwException(e); 122 } 123 } 124 125 131 protected void initialize() throws WorkflowException 132 { 133 super.initialize(); 134 this.roleName = getArgument(ROLE_ARGUMENT); 135 this.groupName = getArgument(GROUP_ARGUMENT, null); 136 } 137 } 138 | Popular Tags |