Hello!
I'm trying to verify that a user is in a particular group via a config that is not running on the master node. Specifically, a remote Windows node. Is this possible? How am I able to accomplish this?
Code I am currently using is this:
groovy:
import com.pmease.quickbuild.persistence.*
SessionManager.openSession();
try {
def user = system.userManager.load(request.requesterId)
if (user.groupNames.contains("SpecialUsers"))
logger.info('user is in this group')
else
logger.info('user is not in this group')
} finally {
SessionManager.closeSession();
}
Error (only on remote node):
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.pmease.quickbuild.model.User.memberships, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:576)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:215)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:555)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:143)
at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:294)
at java_util_List$iterator.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java...
- solved #2
- replies 1
- views 311
- stars 0