Print Page | Close Window

EntityServerSaveInterceptor + Verifier / Validate

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3239
Printed Date: 20-Oct-2025 at 4:53am


Topic: EntityServerSaveInterceptor + Verifier / Validate
Posted By: midnit
Subject: EntityServerSaveInterceptor + Verifier / Validate
Date Posted: 27-Jan-2012 at 8:04pm
I am using DevForce 6.1.0.
 
I am saving an entity from the client, intercepting the save on the server, loading additional items and modifying them based on that entity, then saving all the changes.
 
What I am seeing is that after modifying the entities in the interceptor the verifiers don't fire on anything except the initial entity. I then moved the code to the ValidateSave (as opposed to ExecuteSave) and called base.ValidateSave after all my manipulation and it still only fires the verifiers on the initial entity that was trigger via the client.
 
They all commit to the database, but only one gets verified.
 
Is there any way to get the verifiers to fire on all the entities that I loaded up and modified in the interceptor? The entities are the same type as the initial one.



Replies:
Posted By: midnit
Date Posted: 27-Jan-2012 at 8:14pm
It just hit me that it could also be how I have declared the Verifiers. Here is one...
 

private static Verifier<NominationTbl> VerifyReceiptTransferPointDates()

{

DelegateVerifier<NominationTbl> v = new DelegateVerifier<NominationTbl>(null, VerifyReceiptTransferPointDatesCondition);

v.VerifierOptions.ExecutionModes = VerifierExecutionModes.Instance;

return v;

}



Posted By: midnit
Date Posted: 27-Jan-2012 at 9:21pm
Ok, I added triggers and see that the verifier fires if a trigger is tripped - but the instance verifiers don't. I can call VerifierEngine.Execute(entity) but should I have to or do I have something wrong?


Posted By: midnit
Date Posted: 28-Jan-2012 at 1:37pm

I will lump this in here since its all the same general area of code. When I fire the VerifierEngine.Execute(entity) in the ValidateSave method via the saveinterceptor I am not seeing a way to know who the user is performing the save. In the interceptor I know I can use this.Principal, but the EntityManager on the entity has no Principal value. My instance verifier performs different validation based on the users security preferences - which are stored in the principal...except the principal is empty. These verifiers are only server side.



Posted By: DenisK
Date Posted: 30-Jan-2012 at 7:23pm
Hi midnit,

Ok, I added triggers and see that the verifier fires if a trigger is tripped - but the instance verifiers don't. I can call VerifierEngine.Execute(entity) but should I have to or do I have something wrong? 

I'm not sure if this is a bug or a feature request but looking at the code, it seems that the behavior is correct. We don't execute instance verifiers for entities queried in the EntityServerSaveInterceptor. For the time being, you have to call VerifierEngine.Execute(entity). Let me find out if this is something we can fix, implement or if this is intentional.

[snip]..........My instance verifier performs different validation based on the users security preferences - which are stored in the principal...except the principal is empty. These verifiers are only server side.

Correct me if I'm wrong, but, in this use case, are you asking for a way to access the user's principal inside your verifier?


Posted By: midnit
Date Posted: 31-Jan-2012 at 5:37am
Correct me if I'm wrong, but, in this use case, are you asking for a way to access the user's principal inside your verifier?
 
Yes. In intial testing client-side I had used entity.EntityManager.Principal but of course this does not work once the verifier hits the server. We have had this basic discussion before regarding EntityManager.Principal being null on the server but I wasn't using Verifiers in that discussion. I believe another user chimed in saying it would be nice if it was populated.
 
Is there any way that already exists that I can access the Principal in a consistent manner between client and server in a verifier? I have worked around this but would love to remove the code :)
 
Sorry I kinda posted this in the wrong forum...it wasn't so Verifier specific when I first started thinking about it.


Posted By: DenisK
Date Posted: 31-Jan-2012 at 11:54am
Re: instance verifier not executed, I will be adding a feature request for this.

Re: Principal, yes, this issue has been previously brought up by others as well. We're going to be reviewing the design. For the time being, the most consistent way to access the Principal is to use Thread.CurrentPrincipal

No problem on the posting. It can go either way actually. :)



Print Page | Close Window