Author: ludovic
Date: 2007-12-24 10:14:34 +0100 (Mon, 24 Dec 2007)
New Revision: 6454

Modified:
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceUserProfile.java
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceUserProfileImpl.java
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
Log:
CURRIKI-1179 Updated SpaceUserProfile api

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
 2007-12-23 21:54:07 UTC (rev 6453)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
 2007-12-24 09:14:34 UTC (rev 6454)
@@ -334,7 +334,7 @@
      * @param context
      * @return
      */
-    public SpaceUserProfile getUserSpaceProfile(String spaceName, String user, 
XWikiContext context) throws SpaceManagerException;
+    public SpaceUserProfile getSpaceUserProfile(String spaceName, String user, 
XWikiContext context) throws SpaceManagerException;
 
     /**
      * Get the space user profile page name

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceUserProfile.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceUserProfile.java
     2007-12-23 21:54:07 UTC (rev 6453)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceUserProfile.java
     2007-12-24 09:14:34 UTC (rev 6454)
@@ -10,19 +10,85 @@
  * To change this template use File | Settings | File Templates.
  */
 public interface SpaceUserProfile {
+
+    /**
+     * Profile text of the user in this group
+     * @return
+     */
     public String getProfile();
 
+    /**
+     * Allows to modify the profile text of the user in the group
+     * It is needed to call "save" to really make the change
+     * @param profile
+     */
     public void setProfile(String profile);
 
+    /**
+     * Setting to see if the user wishes to receive email notifications
+     * @return
+     */
     public boolean getAllowNotifications();
 
+    /**
+     * Setting to see if the user wishes to receive email notifications on his 
own changes
+     * @return
+     */
     public boolean getAllowNotificationsFromSelf();
 
+    /**
+     * Allows to change the email notification setting
+     * @param allowNotifications
+     */
     public void setAllowNotifications(boolean allowNotifications);
 
+    /**
+     * Allows to change the email notification from self setting
+     * @param allowNotificationsFromSelf
+     */
     public void setAllowNotificationsFromSelf(boolean 
allowNotificationsFromSelf);
 
+    /**
+     * Allows to update the profile settings from the request object
+     * @throws SpaceManagerException
+     */
     public void updateProfileFromRequest() throws SpaceManagerException;
 
+    /**
+     * Saves changes made to the profile
+     * @throws XWikiException
+     */
     public void save() throws XWikiException;
+
+    /**
+     * Allows to retrieve a user property from the User page
+     * @param propName
+     * @return
+     */
+    public String getUserProperty(String propName);
+
+    /**
+     * Allows to retrieve the first name of the user
+     * @return
+     */
+    public String getFirstName();
+
+    /**
+     * Allows to retrieve the last name of the user
+     * @return
+     */
+    public String getLastName();
+
+    /**
+     * Allows to retrieve the email of the user
+     * @return
+     */
+    public String getEmail();
+
+    /**
+     * Allows to retrieve the user URL
+     * @return
+     */
+    public String getUserURL();
+
 }

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2007-12-23 21:54:07 UTC (rev 6453)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2007-12-24 09:14:34 UTC (rev 6454)
@@ -749,7 +749,7 @@
        return context.getWiki().getGroupService(context);
     }
 
-    public SpaceUserProfile getUserSpaceProfile(String spaceName, String 
username, XWikiContext context) throws SpaceManagerException {
+    public SpaceUserProfile getSpaceUserProfile(String spaceName, String 
username, XWikiContext context) throws SpaceManagerException {
         return newUserSpaceProfile(username, spaceName, context);
     }
 

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceUserProfileImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceUserProfileImpl.java
        2007-12-23 21:54:07 UTC (rev 6453)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceUserProfileImpl.java
        2007-12-24 09:14:34 UTC (rev 6454)
@@ -17,12 +17,15 @@
  */
 public class SpaceUserProfileImpl extends Document implements SpaceUserProfile 
{
     private static final String SPACE_USER_PROFILE_CLASS_NAME = 
"XWiki.SpaceUserProfileClass";
+    private String userName;
     private SpaceManager manager;
+    private Document userDoc;
 
 
     public SpaceUserProfileImpl(String userName, String spaceName, 
SpaceManager manager, XWikiContext context) throws XWikiException {
         super(null, context);
         this.manager = manager;
+        this.userName = userName;
         String docName = manager.getSpaceUserProfilePageName(userName, 
spaceName);
         doc = context.getWiki().getDocument(docName, context);
     }
@@ -31,6 +34,12 @@
         return SPACE_USER_PROFILE_CLASS_NAME;
     }
 
+    protected Document getUserDocument() throws XWikiException {
+        if (userDoc==null)
+         userDoc = new Document(context.getWiki().getDocument(userName, 
context), context);
+        return userDoc;
+    }
+
     public String getProfile() {
         return doc.getStringValue(getSpaceUserProfileClassName(), "profile");
     }
@@ -62,4 +71,32 @@
             throw new SpaceManagerException(e);
         }
     }
+
+    public String getUserProperty(String propName) {
+        try {
+            return (String) 
getUserDocument().getObject("XWiki.XWikiUsers").display(propName, "view");
+        } catch (XWikiException e) {
+            return "";
+        }
+    }
+
+    public String getFirstName() {
+        return getUserProperty("first_name");
+    }
+
+    public String getLastName() {
+        return getUserProperty("last_name");
+    }
+
+    public String getEmail() {
+        return getUserProperty("email");
+    }
+
+    public String getUserURL() {
+        try {
+            return getUserDocument().getURL();
+        } catch (XWikiException e) {
+            return "";
+        }
+    }
 }

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
     2007-12-23 21:54:07 UTC (rev 6453)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
     2007-12-24 09:14:34 UTC (rev 6454)
@@ -24,6 +24,7 @@
 import org.xwiki.plugin.spacemanager.api.Space;
 import org.xwiki.plugin.spacemanager.api.SpaceManager;
 import org.xwiki.plugin.spacemanager.api.SpaceManagerException;
+import org.xwiki.plugin.spacemanager.api.SpaceUserProfile;
 
 import java.util.List;
 import java.util.Collection;
@@ -364,12 +365,14 @@
     // public List getRoles(Space space) throws SpaceManagerException;
 
     /**
-     *
-     * @param space
+     * Gets a user profile object
+     * @param spaceName
      * @param user
      * @return
      */
-    // public SpaceUserProfile getUserSpaceProfile(Space space, String user) 
throws SpaceManagerException;
+    public SpaceUserProfile getSpaceUserProfile(String spaceName, String user) 
throws SpaceManagerException {
+        return getSpaceManager().getSpaceUserProfile(spaceName, user, context);
+    }
 
     /**
      * Count number of spaces

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to