Hi all,
I’m using Rhino Security in my project. I would like to use
NHibernate event listeners that implement IPostInsertEventListener and
IPostUpdateEventListener to associate entities with an EntityGroup.
For example, if a Patient object has a reference to a Hospital object,
then I’d like to associate the patient entity with the hospital
EntityGroup when the NH event listener executes.
In the event listener, I am getting a reference to the
IAuthorizationRepository through my WindsorContainer. The container
also registers ISession, which is a factory method that returns a
child session of the current session. That way, the
IAuthorizationRepository is configured with the child session. I can
call methods such as
IAuthorizationRepository.GetEntityGroupsByName(groupName) within the
event listener and they return the correct data. However, when I try
to call IAuthorizationRepository.AssociateEntityWith(patient,
groupName), nothing happens.
I am using NHProfiler to debug and I don’t see any inserts being
called. I’ve also stepped through the RhinoSecurity code from this
call and it seems to work fine, but no insert is being issued to the
DB.
I know I am doing something wrong, but cannot figure out what. Is
using the IAuthorizationRepository within an NHEventListener an
appropriate design choice. If so, do you know where I’m going wrong?
Here is the event listener:
public class EncounterSaveOrUpdateEventListener :
IPostInsertEventListener
{
public void OnPostInsert(PostInsertEvent @event)
{
var patient = @event.Entity as Patient;
if (patient != null)
{
//the windsor container is configured to return a
child session when ISession is requested from the container
var authRepository =
SafeServiceLocator<IAuthorizationRepository>.GetService();
//I’ve simplified the code for this email. The real
code contains additional checks
if(_authRepository.GetEntitiesGroupByName(patient.Hosptial.Name) !=
null)
_authRepository.AssociateEntityWith(patient,
patient.Hosptial.Name);
}
}
}
Any help is appreciated
Cheers,
Jim Wheaton
--
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en.