New Posts New Posts RSS Feed: EntityServerSaveInterceptor + Verifier / Validate
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityServerSaveInterceptor + Verifier / Validate

 Post Reply Post Reply
Author
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: EntityServerSaveInterceptor + Verifier / Validate
    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.


Edited by midnit - 27-Jan-2012 at 8:15pm
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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;

}

Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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?

Edited by midnit - 30-Jan-2012 at 6:49am
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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.



Edited by midnit - 30-Jan-2012 at 6:50am
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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?


Edited by DenisK - 30-Jan-2012 at 7:42pm
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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. :)


Edited by DenisK - 31-Jan-2012 at 1:56pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down