[Bedework-commit] access r31 - in trunk/src/edu/rpi/cmt/access: .
test
svnadmin at bedework.org
svnadmin at bedework.org
Mon Oct 16 01:21:44 EDT 2006
Author: douglm
Date: 2006-10-16 01:21:42 -0400 (Mon, 16 Oct 2006)
New Revision: 31
Modified:
trunk/src/edu/rpi/cmt/access/AccessPrincipal.java
trunk/src/edu/rpi/cmt/access/AccessXmlUtil.java
trunk/src/edu/rpi/cmt/access/Ace.java
trunk/src/edu/rpi/cmt/access/Acl.java
trunk/src/edu/rpi/cmt/access/Privilege.java
trunk/src/edu/rpi/cmt/access/PrivilegeSet.java
trunk/src/edu/rpi/cmt/access/Privileges.java
trunk/src/edu/rpi/cmt/access/test/Group.java
trunk/src/edu/rpi/cmt/access/test/Principal.java
Log:
Further changes to restore to fix problem restoring overrides.
Many more Java 5 changes.
Modified: trunk/src/edu/rpi/cmt/access/AccessPrincipal.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/AccessPrincipal.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/AccessPrincipal.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -84,11 +84,11 @@
*
* @param val Set of String
*/
- public void setGroupNames(Collection val);
+ public void setGroupNames(Collection<String> val);
/** Get the group names of which principal is a member.
*
* @return Set of String
*/
- public Collection getGroupNames();
+ public Collection<String> getGroupNames();
}
Modified: trunk/src/edu/rpi/cmt/access/AccessXmlUtil.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/AccessXmlUtil.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/AccessXmlUtil.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -283,9 +283,8 @@
xml.property(accessTags.getTag("description"), priv.getDescription());
- Iterator it = priv.iterateContainedPrivileges();
- while (it.hasNext()) {
- emitSupportedPriv((Privilege)it.next());
+ for (Privilege p: priv.getContainedPrivileges()) {
+ emitSupportedPriv(p);
}
xml.closeTag(accessTags.getTag("supported-privilege"));
Modified: trunk/src/edu/rpi/cmt/access/Ace.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/Ace.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/Ace.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -142,7 +142,7 @@
/** Privilege objects defining the access. Used when manipulating acls
*/
- Collection privs;
+ Collection<Privilege> privs;
private boolean inherited;
@@ -279,7 +279,7 @@
*
* @param val Collection of Privilege objects defining the access. Used when manipulating acls
*/
- public void setPrivs(Collection val) {
+ public void setPrivs(Collection<Privilege> val) {
privs = val;
}
@@ -287,9 +287,9 @@
*
* @return Collection of Privilege objects defining the access. Used when manipulating acls
*/
- public Collection getPrivs() {
+ public Collection<Privilege> getPrivs() {
if (privs == null) {
- privs = new ArrayList();
+ privs = new ArrayList<Privilege>();
}
return privs;
}
Modified: trunk/src/edu/rpi/cmt/access/Acl.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/Acl.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/Acl.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -27,7 +27,6 @@
import java.io.Serializable;
import java.util.Collection;
-import java.util.Iterator;
import java.util.TreeSet;
/** Object to represent an acl for a calendar entity or service. We should
@@ -53,7 +52,7 @@
public class Acl extends EncodedAcl implements PrivilegeDefs {
boolean debug;
- private TreeSet aces;
+ private TreeSet<Ace> aces;
/** Used while evaluating access */
@@ -219,10 +218,7 @@
// No specific user access - look for group access
if (who.getGroupNames() != null) {
- Iterator it = who.getGroupNames().iterator();
-
- while (it.hasNext()) {
- String group = (String)it.next();
+ for (String group: who.getGroupNames()) {
if (debug) {
debugsb.append("...Try access for group " + group);
}
@@ -305,7 +301,7 @@
* @return Collection of Ace's representing the acls
* @throws AccessException
*/
- public Collection getAccess(char[] acl) throws AccessException {
+ public Collection<Ace> getAccess(char[] acl) throws AccessException {
decode(acl);
return aces;
@@ -316,8 +312,8 @@
* @param val Collection of aces
* @throws AccessException
*/
- public void setAces(Collection val) throws AccessException {
- aces = (TreeSet)val;
+ public void setAces(Collection<Ace> val) throws AccessException {
+ aces = (TreeSet<Ace>)val;
}
/** Return the ace collection for previously decoded access
@@ -325,7 +321,7 @@
* @return Collection ace collection for previously decoded access
* @throws AccessException
*/
- public Collection getAces() throws AccessException {
+ public Collection<Ace> getAces() throws AccessException {
return aces;
}
@@ -335,7 +331,7 @@
*/
public void addAce(Ace val) {
if (aces == null) {
- aces = new TreeSet();
+ aces = new TreeSet<Ace>();
}
aces.add(val);
@@ -385,10 +381,7 @@
* We can't remove as we check or we get concurrent mod exception.
*/
boolean remove = false;
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: aces) {
if (ace.compareWho(whoDef) == 0) {
remove = true;
break;
@@ -399,11 +392,8 @@
return false;
}
- TreeSet newAces = new TreeSet();
- it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ TreeSet<Ace> newAces = new TreeSet<Ace>();
+ for (Ace ace: aces) {
if (ace.compareWho(whoDef) != 0) {
newAces.add(ace);
}
@@ -435,7 +425,7 @@
* @throws AccessException
*/
public void decode(char[] val) throws AccessException {
- TreeSet ts = new TreeSet();
+ TreeSet<Ace> ts = new TreeSet<Ace>();
setEncoded(val);
@@ -481,7 +471,7 @@
ace.setInherited(true);
if (aces == null) {
- aces = new TreeSet();
+ aces = new TreeSet<Ace>();
aces.add(ace);
} else if (!aces.contains(ace)) {
aces.add(ace);
@@ -505,16 +495,13 @@
* @throws AccessException
*/
public void merge(Acl val) throws AccessException {
- TreeSet valAces = (TreeSet)val.getAces();
+ Collection<Ace> valAces = val.getAces();
if (valAces == null) {
return;
}
- Iterator it = valAces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: valAces) {
ace.setInherited(true);
if (!aces.contains(ace)) {
@@ -537,10 +524,7 @@
startEncoding();
if (aces != null) {
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: aces) {
if (!ace.getInherited()) {
ace.encode(this);
}
@@ -560,10 +544,7 @@
startEncoding();
if (aces != null) {
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: aces) {
ace.encode(this);
}
}
@@ -584,12 +565,9 @@
StringBuffer sb = new StringBuffer();
try {
- Collection aces = getAccess(getEncoded());
+ Collection<Ace> aces = getAccess(getEncoded());
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: aces) {
sb.append(ace.toString());
sb.append(" ");
}
@@ -621,10 +599,7 @@
decode(getEncoded());
}
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
+ for (Ace ace: aces) {
sb.append("\n");
sb.append(ace.toString());
}
Modified: trunk/src/edu/rpi/cmt/access/Privilege.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/Privilege.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/Privilege.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -26,7 +26,7 @@
package edu.rpi.cmt.access;
import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Collection;
/** Define the properties of a privilege for the calendar.
*
@@ -54,7 +54,7 @@
private char encoding;
- private ArrayList containedPrivileges = new ArrayList();
+ private ArrayList<Privilege> containedPrivileges = new ArrayList<Privilege>();
/** Constructor
*
@@ -124,19 +124,18 @@
}
/**
+ * @return containedPrivileges
+ */
+ public Collection<Privilege> getContainedPrivileges() {
+ return containedPrivileges;
+ }
+ /**
* @param val
*/
void addContainedPrivilege(Privilege val) {
containedPrivileges.add(val);
}
- /**
- * @return String
- */
- public Iterator iterateContainedPrivileges() {
- return containedPrivileges.iterator();
- }
-
/* ====================================================================
* Decoding methods
* ==================================================================== */
@@ -215,9 +214,8 @@
acl.back();
- Iterator it = subRoot.iterateContainedPrivileges();
- while (it.hasNext()) {
- Privilege p = matchEncoding((Privilege)it.next(), acl);
+ for (Privilege cp: subRoot.getContainedPrivileges()) {
+ Privilege p = matchEncoding(cp, acl);
if (p != null) {
return p;
}
@@ -260,9 +258,8 @@
true,
val.getIndex());
- Iterator it = val.iterateContainedPrivileges();
- while (it.hasNext()) {
- newval.addContainedPrivilege(cloneDenied((Privilege)it.next()));
+ for (Privilege p: val.getContainedPrivileges()) {
+ newval.addContainedPrivilege(cloneDenied(p));
}
return newval;
Modified: trunk/src/edu/rpi/cmt/access/PrivilegeSet.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/PrivilegeSet.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/PrivilegeSet.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -26,7 +26,6 @@
package edu.rpi.cmt.access;
import java.io.Serializable;
-import java.util.Iterator;
/** Allowed privileges for a principal
*
@@ -226,9 +225,8 @@
/* Iterate over the children */
- Iterator it = priv.iterateContainedPrivileges();
- while (it.hasNext()) {
- setPrivilege((Privilege)it.next());
+ for (Privilege p: priv.getContainedPrivileges()) {
+ setPrivilege(p);
}
}
Modified: trunk/src/edu/rpi/cmt/access/Privileges.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/Privileges.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/Privileges.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
/** Define the privileges we recognize for the calendar.
*
@@ -258,8 +257,8 @@
* @return Collection
* @throws AccessException
*/
- public static Collection getPrivs(EncodedAcl acl) throws AccessException {
- ArrayList al = new ArrayList();
+ public static Collection<Privilege> getPrivs(EncodedAcl acl) throws AccessException {
+ ArrayList<Privilege> al = new ArrayList<Privilege>();
while (acl.hasMore()) {
char c = acl.getChar();
@@ -288,9 +287,8 @@
/* Iterate over the children */
- Iterator it = p.iterateContainedPrivileges();
- while (it.hasNext()) {
- setState(states, (Privilege)it.next(), denial);
+ for (Privilege pr: p.getContainedPrivileges()) {
+ setState(states, pr, denial);
}
}
}
Modified: trunk/src/edu/rpi/cmt/access/test/Group.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/test/Group.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/test/Group.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -26,7 +26,6 @@
package edu.rpi.cmt.access.test;
import java.util.Collection;
-import java.util.Iterator;
import java.util.TreeSet;
/** Group object for access suite tests.
@@ -37,7 +36,7 @@
public class Group extends Principal {
/** members of the group
*/
- private Collection groupMembers;
+ private Collection<Principal> groupMembers;
/* ====================================================================
* Constructors
@@ -65,7 +64,7 @@
*
* @param val Collection of group members.
*/
- public void setGroupMembers(Collection val) {
+ public void setGroupMembers(Collection<Principal> val) {
groupMembers = val;
}
@@ -73,9 +72,9 @@
*
* @return Collection group members
*/
- public Collection getGroupMembers() {
+ public Collection<Principal> getGroupMembers() {
if (groupMembers == null) {
- groupMembers = new TreeSet();
+ groupMembers = new TreeSet<Principal>();
}
return groupMembers;
}
@@ -91,11 +90,7 @@
* @return true if the account name is in the group members.
*/
public boolean isMember(String account, boolean group) {
- Iterator it = getGroupMembers().iterator();
-
- while (it.hasNext()) {
- Principal mbr = (Principal)it.next();
-
+ for (Principal mbr: getGroupMembers()) {
if (mbr.getAccount().equals(account)) {
if (group == (mbr instanceof Group)) {
return true;
@@ -131,9 +126,7 @@
sb.append(", groupMembers={");
boolean first = true;
- Iterator it = getGroupMembers().iterator();
- while (it.hasNext()) {
- Principal mbr = (Principal)it.next();
+ for (Principal mbr: getGroupMembers()) {
String name = "";
if (first) {
name = null;
Modified: trunk/src/edu/rpi/cmt/access/test/Principal.java
===================================================================
--- trunk/src/edu/rpi/cmt/access/test/Principal.java 2006-09-28 19:32:40 UTC (rev 30)
+++ trunk/src/edu/rpi/cmt/access/test/Principal.java 2006-10-16 05:21:42 UTC (rev 31)
@@ -43,10 +43,10 @@
private String account; // null for guest
/* groups of which this user is a member */
- protected Collection groups;
+ protected Collection<Principal> groups;
// Derived from the groups.
- protected Collection groupNames;
+ protected Collection<String> groupNames;
// For acl evaluation
protected AccessPrincipal aclPrincipal;
@@ -113,7 +113,7 @@
*
* @param val Collection of Principal
*/
- public void setGroups(Collection val) {
+ public void setGroups(Collection<Principal> val) {
groupNames = null;
groups = val;
}
@@ -122,9 +122,9 @@
*
* @return Collection of Principal
*/
- public Collection getGroups() {
+ public Collection<Principal> getGroups() {
if (groups == null) {
- groups = new TreeSet();
+ groups = new TreeSet<Principal>();
}
return groups;
@@ -159,7 +159,7 @@
*
* @param val Set of String
*/
- public void setGroupNames(Collection val) {
+ public void setGroupNames(Collection<String> val) {
groupNames = val;
}
@@ -167,12 +167,10 @@
*
* @return Set of String
*/
- public Collection getGroupNames() {
+ public Collection<String> getGroupNames() {
if (groupNames == null) {
- groupNames = new TreeSet();
- Iterator it = iterateGroups();
- while (it.hasNext()) {
- Principal group = (Principal)it.next();
+ groupNames = new TreeSet<String>();
+ for (Principal group: getGroups()) {
groupNames.add(group.getAccount());
}
}
More information about the Bedework-commit
mailing list