[xwiki-users] spaces for which the current user has access in a java component
How do I get all the spaces for which the current user has access in a java component? I have the following: List<String> lstSpaces = new ArrayList<String>(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWiki xwiki = xcontext.getWiki(); lstSpaces = xwiki.getSpaces(xcontext); Although this successfully returns all the spaces, it also returns the spaces for which the current user has no "view" or other access rights. Also it seems that the Java .getSpaces is deprecated and I can't seem to find the new method for this. http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/ seems outdated as xwiki.getSpaces() is still active in this javadoc, with no alternative. Is there a new javadoc availible? -- View this message in context: http://xwiki.475771.n2.nabble.com/spaces-for-which-the-current-user-has-acce... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Wed, Dec 9, 2015 at 8:33 AM, gervwyk <[email protected]> wrote:
How do I get all the spaces for which the current user has access in a java component?
Why do you need this? There can be many spaces. Starting with XWiki 7.2 you can have nested documents and each nested document has an associated space which means you can have as many spaces as pages (e.g. thousands). More over, we cannot write a database query to retrieve the spaces (or the pages) the user has access to because access rights are defined at multiple levels (page, space, wiki, farm) that inherit from one another. This means you have to check the access rights for each space (or page) separately. Writing a query to retrieve all the spaces (or pages) and then check the access on each of them is very costly. I wouldn't do it. In any case, I added 2 examples to http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module#HQueryLang... on how to use the new XWikiSpace table (7.2+) Hope this helps, Marius
I have the following:
List<String> lstSpaces = new ArrayList<String>(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWiki xwiki = xcontext.getWiki(); lstSpaces = xwiki.getSpaces(xcontext);
Although this successfully returns all the spaces, it also returns the spaces for which the current user has no "view" or other access rights. Also it seems that the Java .getSpaces is deprecated and I can't seem to find the new method for this. http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/ seems outdated as xwiki.getSpaces() is still active in this javadoc, with no alternative. Is there a new javadoc availible?
-- View this message in context: http://xwiki.475771.n2.nabble.com/spaces-for-which-the-current-user-has-acce... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Ok. So what I'm trying to achieve is the following: We have spaces which has user (view/edit) groups and an admin group for that space. I'm currently writing a rights admin tool which shows the admin group users the spaces which they are the admin of, and they can then select a space to which they can assign a user group. In normal workflow terms: We have managers of departments, and project teams, and we want the managers to give rights to a team within their department to assign the to a project through a admin tool/ webform, instead of going to each page and attaching the objects and making mistakes. So: 1. I want the managers to see the spaces for which they are admin 2. I what them to assign a group to that space. I can successfully assign the group to the space, however, having trouble to let the managers see only the spaces for which they are the admin. -- View this message in context: http://xwiki.475771.n2.nabble.com/spaces-for-which-the-current-user-has-acce... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
gervwyk -
Marius Dumitru Florea