You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/06/25 16:50:02 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/workflow WorkflowFactory.java RoleCondition.java
andreas 2003/06/25 07:50:02
Modified: src/java/org/apache/lenya/cms/workflow WorkflowFactory.java
RoleCondition.java
Log:
reflecting access controller changes
Revision Changes Path
1.8 +13 -16 cocoon-lenya/src/java/org/apache/lenya/cms/workflow/WorkflowFactory.java
Index: WorkflowFactory.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/WorkflowFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WorkflowFactory.java 6 Jun 2003 13:35:17 -0000 1.7
+++ WorkflowFactory.java 25 Jun 2003 14:50:02 -0000 1.8
@@ -13,9 +13,12 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.lenya.cms.ac.AccessControlException;
-import org.apache.lenya.cms.ac.Identity;
+import org.apache.lenya.cms.ac.ItemManager;
+import org.apache.lenya.cms.ac.Role;
import org.apache.lenya.cms.ac.User;
import org.apache.lenya.cms.ac.UserManager;
+import org.apache.lenya.cms.ac2.Identity;
+import org.apache.lenya.cms.ac2.Policy;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationFactory;
@@ -74,9 +77,8 @@
/*
* Creates a new workflow situation.
*/
- public Situation buildSituation(User user) throws WorkflowException {
- assert user != null;
- return new CMSSituation(user);
+ public Situation buildSituation(Role roles[]) throws WorkflowException {
+ return new CMSSituation(roles);
}
public Situation buildSituation(Map objectModel) throws WorkflowException {
@@ -87,24 +89,19 @@
throw new WorkflowException("No session object available!");
}
- Identity identity = (Identity) session.getAttribute("org.apache.lenya.cms.ac.Identity");
-
- if (identity == null) {
- throw new WorkflowException("No session object available!");
- }
-
- String username = identity.getUsername();
-
Publication publication = PublicationFactory.getPublication(objectModel);
+ File configDir = new File(publication.getDirectory(), ItemManager.PATH);
+
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ Policy policy = (Policy) session.getAttribute(Policy.class.getName());
- User user;
+ Role roles[];
try {
- user = UserManager.instance(publication).getUser(username);
+ roles = policy.getRoles(identity);
} catch (AccessControlException e) {
throw new WorkflowException(e);
}
-
- return buildSituation(user);
+ return buildSituation(roles);
}
1.2 +8 -21 cocoon-lenya/src/java/org/apache/lenya/cms/workflow/RoleCondition.java
Index: RoleCondition.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/RoleCondition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RoleCondition.java 30 May 2003 19:32:44 -0000 1.1
+++ RoleCondition.java 25 Jun 2003 14:50:02 -0000 1.2
@@ -6,13 +6,7 @@
package org.apache.lenya.cms.workflow;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.lenya.cms.ac.Group;
import org.apache.lenya.cms.ac.Role;
-import org.apache.lenya.cms.ac.User;
import org.apache.lenya.workflow.Condition;
import org.apache.lenya.workflow.Situation;
@@ -32,24 +26,13 @@
public boolean isComplied(Situation situation) {
CMSSituation situationImpl = (CMSSituation) situation;
- User user = situationImpl.getUser();
- Iterator userGroups = user.getGroups();
- Set userRoles = new HashSet();
-
- while (userGroups.hasNext()) {
- Iterator groupRoles = ((Group)userGroups.next()).getRoles();
- assert groupRoles != null;
- while (groupRoles.hasNext()) {
- userRoles.add(groupRoles.next());
- }
- }
+ Role roles[] = situationImpl.getRoles();
Role conditionRole = new Role(getExpression().trim());
boolean complied = false;
- Iterator roles = userRoles.iterator();
- while (!complied && roles.hasNext()) {
- if (conditionRole.equals(roles.next())) {
+ for (int i = 0; i < roles.length; i++) {
+ if (conditionRole.equals(roles[i])) {
complied = true;
}
}
@@ -67,11 +50,15 @@
this.expression = expression;
}
+ /**
+ * Returns the expression of this condition.
+ * @return A string.
+ */
public String getExpression() {
return expression;
}
- /* (non-Javadoc)
+ /**
* @see java.lang.Object#toString()
*/
public String toString() {
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org