Hi there,
according to this ticket (https://jira.atlassian.com/browse/CONF-14162) i need to implement a XMLRPC plugin to retrieve all permissions for a given space and distribute it via the API.
Simple as it is i thought of something like
Space space = spaceManager.getSpace(spaceKey); List<SpacePermission> permissions = space.getPermissions();
But in fact all i got was a LazyInitializationException thrown by Hibernate. It seems that the Object isn't bound to a session anymore, so i can't access the permissions. There is a topic on that which advises to wrap the whole block in a transaction (https://developer.atlassian.com/display/CONFDEV/Hibernate+Sessions+and+Transaction+Management+Guidelines) If i do that i get a exception telling me, that there is no Session.
Searching through the API i found the class com.atlassian.confluence.security.persistence.dao.hibernate.HibernateSpacePermissionDao which also offer a findPermissionsForSpace(Space space) method. Unfortunately it is returning null.
Does anybody know how to deal with this case? I just need all permissions of a space inside a XMLRPC Plugin.
Thanks!
Martin
Community moderators have prevented the ability to post new answers.
Got it working by sticking to this Code Example:
https://developer.atlassian.com/display/CONFDEV/RPC+Module
package com.atlassian.confluence.extra.helloworldrpcv2; import com.atlassian.confluence.spaces.SpaceManager; import com.atlassian.sal.api.transaction.TransactionCallback; import com.atlassian.sal.api.transaction.TransactionTemplate; public class DefaultHelloWorld implements HelloWorld { private final TransactionTemplate transactionTemplate; private final SpaceManager spaceManager; public DefaultHelloWorld(final SpaceManager spaceManager, final TransactionTemplate transactionTemplate) { this.spaceManager = spaceManager; this.transactionTemplate = transactionTemplate; } public String sayHello() { return (String) transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction() { return String.format("Hello world! Number of spaces: %d", spaceManager.getAllSpaces().size()); } }); } }
Though, the examples on https://developer.atlassian.com/display/CONFDEV/Hibernate+Sessions+and+Transaction+Management+Guidelines are not working for me, due to some wicked dependencies and package problems.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.