[Commits] (bcm) persist email address and homedir as chandler-specific properties of a user

commits at osafoundation.org commits at osafoundation.org
Mon Feb 14 13:12:54 PST 2005


Commit by: bcm
Modified files:
server/slam/etc/MessageResources.properties 1.3 1.4
server/slam/src/org/osaf/slam/dao/UserDAO.java 1.3 1.4
server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java 1.1 1.2
server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java 1.2 1.3
server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java 1.1 1.2
server/slam/src/org/osaf/slam/model/User.java 1.4 1.5
server/slam/test/org/osaf/slam/TestHelper.java 1.4 1.5
server/slam/test/org/osaf/slam/dao/UserDAOTest.java 1.6 1.7
server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java 1.1 1.2
server/slam/test/org/osaf/slam/web/UserActionTest.java 1.1 1.2
server/slam/web/WEB-INF/jsp/user/list.jsp 1.1 1.2

Log message:
persist email address and homedir as chandler-specific properties of a user
resource. don't include the root user when listing users. make homedir path
calculation internal to UserDAO.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/server/slam/etc/MessageResources.properties.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/server/slam/src/org/osaf/slam/dao/UserDAO.java.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/slam/src/org/osaf/slam/model/User.java.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/server/slam/test/org/osaf/slam/TestHelper.java.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/server/slam/test/org/osaf/slam/dao/UserDAOTest.java.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/slam/test/org/osaf/slam/web/UserActionTest.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/slam/web/WEB-INF/jsp/user/list.jsp.diff?r1=text&tr1=1.1&r2=text&tr2=1.2

Index: server/slam/test/org/osaf/slam/TestHelper.java
diff -u server/slam/test/org/osaf/slam/TestHelper.java:1.4 server/slam/test/org/osaf/slam/TestHelper.java:1.5
--- server/slam/test/org/osaf/slam/TestHelper.java:1.4	Wed Feb  9 18:32:38 2005
+++ server/slam/test/org/osaf/slam/TestHelper.java	Mon Feb 14 13:12:50 2005
@@ -30,6 +30,7 @@
 
         User user = new User();
         user.setUsername("dummy" + serial);
+        user.setEmail(user.getUsername() + "@osafoundation.org");
         user.setPassword(user.getUsername());
 
         return user;

Index: server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java
diff -u server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java:1.1 server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java:1.2
--- server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java:1.1	Fri Feb 11 13:49:19 2005
+++ server/slam/test/org/osaf/slam/manager/ProvisioningManagerTest.java	Mon Feb 14 13:12:51 2005
@@ -41,7 +41,6 @@
 
         User user = TestHelper.makeDummyUser();
         mgr.createUser(user);
-        assertNotNull(user.getHomedir());
 
         User user2 = mgr.getUser(user.getUsername());
         assertTrue(user.equals(user2));

Index: server/slam/etc/MessageResources.properties
diff -u server/slam/etc/MessageResources.properties:1.3 server/slam/etc/MessageResources.properties:1.4
--- server/slam/etc/MessageResources.properties:1.3	Mon Feb 14 12:38:37 2005
+++ server/slam/etc/MessageResources.properties	Mon Feb 14 13:12:48 2005
@@ -31,8 +31,11 @@
 User.List.HeadTitle=Chandler Server | Users
 User.List.Title=Users
 User.List.TH.User=User
+User.List.TH.Email=Email
+User.List.TH.Homedir=Homedir
 User.List.TH.DateCreated=Created
 User.List.TH.DateLastModified=Last Modified
+User.List.NoUsers=No users have been created.
 
 User.View.HeadTitle= Chandler Server | {0}
 User.View.Title={0}

Index: server/slam/test/org/osaf/slam/dao/UserDAOTest.java
diff -u server/slam/test/org/osaf/slam/dao/UserDAOTest.java:1.6 server/slam/test/org/osaf/slam/dao/UserDAOTest.java:1.7
--- server/slam/test/org/osaf/slam/dao/UserDAOTest.java:1.6	Fri Feb 11 17:01:06 2005
+++ server/slam/test/org/osaf/slam/dao/UserDAOTest.java	Mon Feb 14 13:12:51 2005
@@ -45,6 +45,8 @@
         User user2 = dao.getUser(user.getUsername());
         assertTrue(user.equals(user2));
         assertEquals(user.hashCode(), user2.hashCode());
+        assertNotNull(user2.getEmail());
+        assertNotNull(user2.getHomedir());
 
         user2.setPassword("changed password");
         dao.saveUser(user2);
@@ -52,6 +54,8 @@
         User user3 = dao.getUser(user.getUsername());
         assertEquals(user2.getPassword(), user3.getPassword());
         assertTrue(! user.getPassword().equals(user3.getPassword()));
+        assertEquals(user.getEmail(), user3.getEmail());
+        assertEquals(user.getHomedir(), user3.getHomedir());
 
         dao.removeUser(user.getUsername());
         try {

Index: server/slam/web/WEB-INF/jsp/user/list.jsp
diff -u server/slam/web/WEB-INF/jsp/user/list.jsp:1.1 server/slam/web/WEB-INF/jsp/user/list.jsp:1.2
--- server/slam/web/WEB-INF/jsp/user/list.jsp:1.1	Fri Feb 11 17:01:08 2005
+++ server/slam/web/WEB-INF/jsp/user/list.jsp	Mon Feb 14 13:12:52 2005
@@ -1,31 +1,52 @@
 <%@ include file="/WEB-INF/jsp/taglibs.jsp"  %>
 <%@ include file="/WEB-INF/jsp/tagfiles.jsp" %>
 
-<table cellpadding="3" cellspacing="1" border="0" width="100%">
-  <tr>
-    <td class="md" valign="bottom">
-      <b><fmt:message key="User.List.TH.User"/></b>
-    </td>
-    <td class="md" valign="bottom">
-      <b><fmt:message key="User.List.TH.DateCreated"/></b>
-    </td>
-    <td class="md" valign="bottom">
-      <b><fmt:message key="User.List.TH.DateLastModified"/></b>
-    </td>
-  </tr>
-  <c:forEach var="user" items="${Users}">
-    <tr>
-      <td class="md" nowrap="nowrap">
-        <html:link page="/do/user?username=${user.username}">
-          ${user.username}
-        </html:link>
-      </td>
-      <td class="md" nowrap="nowrap">
-        ${user.dateCreated}
-      </td>
-      <td class="md" nowrap="nowrap">
-        ${user.dateModified}
-      </td>
-    </tr>
-  </c:forEach>
-</table>
+<c:choose>
+  <c:when test="${not empty Users}">
+    <table cellpadding="3" cellspacing="1" border="0" width="100%">
+      <tr>
+        <td class="md" valign="bottom">
+          <b><fmt:message key="User.List.TH.User"/></b>
+        </td>
+        <td class="md" valign="bottom">
+          <b><fmt:message key="User.List.TH.Email"/></b>
+        </td>
+        <td class="md" valign="bottom">
+          <b><fmt:message key="User.List.TH.Homedir"/></b>
+        </td>
+        <td class="md" valign="bottom">
+          <b><fmt:message key="User.List.TH.DateCreated"/></b>
+        </td>
+        <td class="md" valign="bottom">
+          <b><fmt:message key="User.List.TH.DateLastModified"/></b>
+        </td>
+      </tr>
+      <c:forEach var="user" items="${Users}">
+        <tr>
+          <td class="md" nowrap="nowrap">
+            <html:link page="/do/user?username=${user.username}">
+              ${user.username}
+            </html:link>
+          </td>
+          <td class="md" nowrap="nowrap">
+            <html:link href="mailto:${user.email}">${user.email}</html:link>
+          </td>
+          <td class="md" nowrap="nowrap">
+            <html:link page="${user.homedir}">${user.homedir}</html:link>
+          </td>
+          <td class="md" nowrap="nowrap">
+            ${user.dateCreated}
+          </td>
+          <td class="md" nowrap="nowrap">
+            ${user.dateModified}
+          </td>
+        </tr>
+      </c:forEach>
+    </table>
+  </c:when>
+  <c:otherwise>
+    <div class="md">
+      <i><fmt:message key="User.List.NoUsers"/></i>
+      </div>
+  </c:otherwise>
+</c:choose>

Index: server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java
diff -u server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java:1.1 server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java:1.2
--- server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java:1.1	Fri Feb 11 13:49:18 2005
+++ server/slam/src/org/osaf/slam/manager/impl/ProvisioningManagerImpl.java	Mon Feb 14 13:12:50 2005
@@ -50,8 +50,7 @@
      */
     public void createUser(User user) {
         userDao.saveUser(user);
-        String homedir = userDao.createHomedir(user.getUsername());
-        user.setHomedir(homedir);
+        userDao.createHomedir(user.getUsername());
 
         // XXX: until we get user-level access controls in place, add
         // the user to the root role. this will allow him to see the

Index: server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java
diff -u server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java:1.2 server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java:1.3
--- server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java:1.2	Fri Feb 11 13:49:17 2005
+++ server/slam/src/org/osaf/slam/dao/slide/UserDAOSlide.java	Mon Feb 14 13:12:49 2005
@@ -26,6 +26,12 @@
     private static final String PROP_PASSWORD = "S:password";
     private static final PropertyName PROP_NAME_PASSWORD =
         new PropertyName(SlideConstants.NAMESPACE_SLIDE, "password");
+    private static final String PROP_EMAIL = "email";
+    private static final PropertyName PROP_NAME_EMAIL =
+        new PropertyName(SlideConstants.NAMESPACE_CHANDLER, "email");
+    private static final String PROP_HOMEDIR = "homedir";
+    private static final PropertyName PROP_NAME_HOMEDIR =
+        new PropertyName(SlideConstants.NAMESPACE_CHANDLER, "homedir");
     private static final Log log = LogFactory.getLog(UserDAOSlide.class);
 
     /**
@@ -47,9 +53,10 @@
             User user = new User();
             populateUser(user, responseEntity.getProperties());
             // skip the users resource, which is included in the
-            // propfind
-            if (! user.getUsername().
-                equals(SlideConstants.COLLECTION_USERS)) {
+            // propfind, and skip the root user
+            if (! (user.getUsername().
+                   equals(SlideConstants.COLLECTION_USERS) ||
+                   user.getUsername().equals(SlideConstants.USER_ROOT))) {
                 users.add(user);
             }
         }
@@ -86,13 +93,14 @@
             log.debug("saving user " + user);
         }
 
-        Hashtable props = depopulateUser(user);
         WebdavTemplate template = getWebdavTemplate();
         String path = makeUserPath(template.getPath(), user.getUsername());
         if (user.getDateCreated() == null) {
             // new user
             template.mkcolMethod(path);
+            user.setHomedir(calculateHomedir(user.getUsername()));
         }
+        Hashtable props = depopulateUser(user);
         template.proppatchMethod(path, props, true);
 
         // pull the newly created user back out of the repository
@@ -122,30 +130,33 @@
 
     /**
      */
-    public String createHomedir(String username) {
+    public String calculateHomedir(String username) {
         WebdavTemplate template = getWebdavTemplate();
-        String path = makeHomedirPath(template.getPath(), username);
+        return makeHomedirPath(template.getPath(), username);
+    }
 
+    /**
+     */
+    public void createHomedir(String username) {
+        String path = calculateHomedir(username);
         if (log.isDebugEnabled()) {
             log.debug("creating homedir " + path + " for user " + username);
         }
 
+        WebdavTemplate template = getWebdavTemplate();
         template.mkcolMethod(path);
         template.close();
-
-        return path;
     }
 
     /**
      */
     public void deleteHomedir(String username) {
-        WebdavTemplate template = getWebdavTemplate();
-        String path = makeHomedirPath(template.getPath(), username);
-
+        String path = calculateHomedir(username);
         if (log.isDebugEnabled()) {
             log.debug("deleting homedir " + path + " for user " + username);
         }
 
+        WebdavTemplate template = getWebdavTemplate();
         template.deleteMethod(path);
         template.close();
     }
@@ -167,12 +178,20 @@
             else if (name.equals(PROP_PASSWORD)) {
                 user.setPassword(value);
             }
+            else if (name.equals(PROP_EMAIL)) {
+                user.setEmail(value);
+            }
+            else if (name.equals(PROP_HOMEDIR)) {
+                user.setHomedir(value);
+            }
         }
     }
 
     private Hashtable depopulateUser(User user) {
         Hashtable props = new Hashtable();
         props.put(PROP_NAME_PASSWORD, user.getPassword());
+        props.put(PROP_NAME_EMAIL, user.getEmail());
+        props.put(PROP_NAME_HOMEDIR, user.getHomedir());
         return props;
     }
 }

Index: server/slam/src/org/osaf/slam/model/User.java
diff -u server/slam/src/org/osaf/slam/model/User.java:1.4 server/slam/src/org/osaf/slam/model/User.java:1.5
--- server/slam/src/org/osaf/slam/model/User.java:1.4	Fri Feb 11 12:40:43 2005
+++ server/slam/src/org/osaf/slam/model/User.java	Mon Feb 14 13:12:50 2005
@@ -12,6 +12,7 @@
 
     private String username;
     private String password;
+    private String email;
     private String homedir;
     private DateTime dateCreated;
     private DateTime dateModified;
@@ -47,6 +48,18 @@
 
     /**
      */
+    public String getEmail() {
+        return email;
+    }
+
+    /**
+     */
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    /**
+     */
     public String getHomedir() {
         return homedir;
     }

Index: server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java
diff -u server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java:1.1 server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java:1.2
--- server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java:1.1	Fri Feb 11 12:40:42 2005
+++ server/slam/src/org/osaf/slam/dao/slide/SlideConstants.java	Mon Feb 14 13:12:49 2005
@@ -18,6 +18,11 @@
     public static final String NAMESPACE_SLIDE =
         "http://jakarta.apache.org/slide/";
     /**
+     * The namespace for Chandler-specific properties.
+     */
+    public static final String NAMESPACE_CHANDLER =
+        "http://osafoundation.org/chandler/";
+    /**
      * The name of the WebDAV property containing the resource's
      * "common" or "display" name.
      */
@@ -47,4 +52,8 @@
      * shared files.
      */
     public static final String COLLECTION_FILES = "files";
+    /**
+     * The name of the Slide root user.
+     */
+    public static final String USER_ROOT = "root";
 }

Index: server/slam/test/org/osaf/slam/web/UserActionTest.java
diff -u server/slam/test/org/osaf/slam/web/UserActionTest.java:1.1 server/slam/test/org/osaf/slam/web/UserActionTest.java:1.2
--- server/slam/test/org/osaf/slam/web/UserActionTest.java:1.1	Fri Feb 11 17:40:41 2005
+++ server/slam/test/org/osaf/slam/web/UserActionTest.java	Mon Feb 14 13:12:51 2005
@@ -93,7 +93,9 @@
     private void fillInUserForm() {
         String serial = new Integer(seq++).toString();
 
-        addRequestParameter("user.username", "Dummy_User_" + serial);
+        addRequestParameter("user.username", "dummy" + serial);
+        addRequestParameter("user.email",
+                            "dummy" + serial + "@osafoundation.org");
         addRequestParameter("password", "chsrv");
     }
 }

Index: server/slam/src/org/osaf/slam/dao/UserDAO.java
diff -u server/slam/src/org/osaf/slam/dao/UserDAO.java:1.3 server/slam/src/org/osaf/slam/dao/UserDAO.java:1.4
--- server/slam/src/org/osaf/slam/dao/UserDAO.java:1.3	Fri Feb 11 13:49:17 2005
+++ server/slam/src/org/osaf/slam/dao/UserDAO.java	Mon Feb 14 13:12:49 2005
@@ -29,7 +29,7 @@
 
     /**
      */
-    public String createHomedir(String username);
+    public void createHomedir(String username);
 
     /**
      */



More information about the Commits mailing list