Author: ludovic
Date: 2007-12-18 20:50:04 +0100 (Tue, 18 Dec 2007)
New Revision: 6416

Modified:
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
Log:
CURRIKI-1179 added getSpaceNames for user and role

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-18 19:31:00 UTC (rev 6415)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2007-12-18 19:50:04 UTC (rev 6416)
@@ -552,9 +552,24 @@
         * @return list of Strings (space names)
      * @throws SpaceManagerException  
         */
-    public List getSpaceNames(String userName, String role, XWikiContext 
context) throws SpaceManagerException{
-        notImplemented();
-        return null;
+    public List getSpaceNames(String userName, String role, XWikiContext 
context) throws SpaceManagerException {
+        String sql;
+        if (role==null)
+         sql = "select distinct doc.web from XWikiDocument as doc, BaseObject 
as obj, StringProperty as memberprop where doc.name='MemberGroup' and 
doc.fullName=obj.name and obj.className = 'XWiki.XWikiAllGroup'"
+                + " and obj.id=memberprop.id.id and 
memberprop.id.name='member' and memberprop.value='" + userName + "'";
+        else {
+            String roleGroupName = getRoleGroupName("", role).substring(1);
+            sql = "select distinct doc.web from XWikiDocument as doc, 
BaseObject as obj, StringProperty as memberprop where doc.name='" + 
roleGroupName + "' and doc.fullName=obj.name and obj.className = 
'XWiki.XWikiAllGroup'"
+                   + " and obj.id=memberprop.id.id and 
memberprop.id.name='member' and memberprop.value='" + userName + "'";
+
+        }
+        List spaceList = null;
+        try {
+            spaceList = context.getWiki().getStore().search(sql, 0, 0, 
context);
+        } catch (XWikiException e) {
+            throw new SpaceManagerException(e);
+        }
+        return spaceList;
     }
 
     public void updateSpaceFromRequest(Space space, XWikiContext context) 
throws SpaceManagerException {

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to