xpages - SessionAsSigner & restoreWrappedDocument() -


faced following issue: actively use dominodocument class (wrapped document) in projects, particularly basis business model objects.

very have need access / iterate business model objects anonymous user underlying lotus.domino.document retrieved based on sessionassigner session object (for example in case of rest services, or in case of xagent, etc).

the behavior of restorewrappeddocument() method in such cases breaks flexibility of using such architecture: method tries restore wrapped document based on current execution environment access rights, , of course causes errors acl.

let’s consider following code snippet example:

public void test3() {     try {          system.out.println(">>>>>");         system.out.println(">>>>> start");          lotus.domino.database db = appbean.getsessionassigner().getdatabase(appbean.getinstance().getcontactsdbservername(), appbean.getinstance().getcontactsdbname(), false);          document notesdoc = db.getalldocuments().getfirstdocument();         string dbname = notesdoc.getparentdatabase().getserver() + "!!" + notesdoc.getparentdatabase().getfilepath();         dominodocument ds = dominodocument.wrap(dbname, notesdoc, null, "exception", false, "useweb", null);          system.out.println(">> 1 >> " + ds.getvalue("form"));          ds.getdocument().recycle();          try {             ds.restorewrappeddocument();         }catch(throwable e2){             system.out.println(">> 2 - exception - >> " + e2.tostring());             e2.printstacktrace();         }          try {             system.out.println(">> 3 >> " + ds.getvalue("form"));         }catch(throwable e3){             system.out.println(">> 3 - exception - >> " + e3.tostring());         }          system.out.println(">>>>> end");         system.out.println(">>>>>");      }catch(exception e){         e.printstacktrace();     } } 

1) scenario 1: executing code authenticated user has access target db gives following result:

enter image description here

so method works expected , perfect.

2) scenario 2: executing code anonymous user causes exception (generally, expected):

enter image description here

you can see restorewrappeddocument() executes helper methods in order db, , of course done current user access level (anonymous).

possible solutions:

  1. the obvious solution add custom logic business object model, perform custom restore (basically based on server&db names , document unid or noteid).
  2. what curious whether there more smart or built-in method exist restoring wrapped documents sessionassigner rights?

thanks!

i don't think there's proper way this, other option 1, better or worse.

however, , i'm not saying good idea, seems dominodocument gets session through current request map. if want tricky, try temporarily swapping session out sessionassigner in request scope, calling restorewrappeddocument, , swapping back.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -