You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by eg...@apache.org on 2003/06/06 15:58:50 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/ac User.java FileUser.java
egli 2003/06/06 06:58:49
Modified: src/java/org/apache/lenya/cms/ac User.java FileUser.java
Log:
Added delete method to delete a user and a method to
remove all groups.
Revision Changes Path
1.11 +21 -4 cocoon-lenya/src/java/org/apache/lenya/cms/ac/User.java
Index: User.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac/User.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- User.java 4 Jun 2003 13:19:57 -0000 1.10
+++ User.java 6 Jun 2003 13:58:49 -0000 1.11
@@ -134,10 +134,21 @@
}
/**
+ *
+ */
+ public void removeAllGroups() {
+ for (Iterator iter = groups.iterator(); iter.hasNext();) {
+ Group group = (Group) iter.next();
+ group.removeUser(this);
+ }
+ groups.clear();
+ }
+
+ /**
* @param set
*/
public void addGroup(Group group) {
- assert group != null;
+ assert group != null;
groups.add(group);
group.addUser(this);
}
@@ -161,8 +172,14 @@
* @param publication
* @throws AccessControlException
*/
- public abstract void save()
- throws AccessControlException;
+ public abstract void save() throws AccessControlException;
+
+ /**
+ *
+ */
+ public void delete() throws AccessControlException {
+ removeAllGroups();
+ }
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
1.9 +20 -8 cocoon-lenya/src/java/org/apache/lenya/cms/ac/FileUser.java
Index: FileUser.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac/FileUser.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FileUser.java 5 Jun 2003 12:00:50 -0000 1.8
+++ FileUser.java 6 Jun 2003 13:58:49 -0000 1.9
@@ -66,7 +66,7 @@
*/
public class FileUser extends User {
private Category log = Category.getInstance(FileUser.class);
-
+
public static final String ID = "identity";
public static final String FULL_NAME = "fullname";
public static final String EMAIL = "email";
@@ -78,7 +78,7 @@
public static final String CLASS_ATTRIBUTE = "class";
private Publication publication;
-
+
/**
* @param id
*/
@@ -86,7 +86,6 @@
super(id);
this.publication = publication;
}
-
/**
* @param publication
@@ -102,7 +101,7 @@
String email,
String password) {
super(id, fullName, email, password);
- this.publication = publication;
+ this.publication = publication;
}
public FileUser(Publication publication, Configuration config)
@@ -143,7 +142,6 @@
}
}
-
/**
* @return
*/
@@ -165,10 +163,10 @@
child = new DefaultConfiguration(PASSWORD);
child.setValue(email);
child.setAttribute(PASSWORD_ATTRIBUTE, "md5");
- config.addChild(child);
+ config.addChild(child);
// add group nodes
child = new DefaultConfiguration(GROUPS);
- config.addChild(child);
+ config.addChild(child);
Iterator groupsIter = getGroups();
while (groupsIter.hasNext()) {
@@ -193,6 +191,20 @@
} catch (Exception e) {
throw new AccessControlException(e);
}
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.lenya.cms.ac.User#delete()
+ */
+ public void delete() throws AccessControlException {
+ super.delete();
+
+ UserManager manager = UserManager.instance(publication);
+
+ manager.remove(this);
+ File xmlPath = manager.getPath();
+ File xmlfile = new File(xmlPath, getId() + UserManager.SUFFIX);
+ xmlfile.delete();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org