1 23 package org.infoglue.cms.util.workflow; 24 25 import java.util.Iterator ; 26 27 import org.infoglue.cms.applications.common.Session; 28 import org.infoglue.cms.entities.mydesktop.WorkflowStepVO; 29 import org.infoglue.cms.security.InfoGluePrincipal; 30 31 37 public class OwnerStepFilter implements StepFilter 38 { 39 private final InfoGluePrincipal userPrincipal; 40 41 44 public OwnerStepFilter() 45 { 46 this(new Session().getInfoGluePrincipal()); 47 } 48 49 53 public OwnerStepFilter(InfoGluePrincipal userPrincipal) 54 { 55 this.userPrincipal = userPrincipal; 56 } 57 58 64 public boolean isAllowed(WorkflowStepVO step) 65 { 66 if(!step.hasOwner() || isUserAdministrator()) 67 { 68 return true; 69 } 70 for(final Iterator owners = OwnerFactory.createAll(userPrincipal).iterator(); owners.hasNext(); ) 71 { 72 final Owner owner = (Owner) owners.next(); 73 if(step.isOwner(owner.getIdentifier())) 74 { 75 return true; 76 } 77 } 78 return false; 79 } 80 81 protected boolean isUserAdministrator() 82 { 83 return userPrincipal.getIsAdministrator(); 84 } 85 86 protected InfoGluePrincipal getUserPrincipal() 87 { 88 return userPrincipal; 89 } 90 } 91 | Popular Tags |