For a project I would like to use the UserBean set up by Oliver Busse:
I have altered it a bit so I can also use it for other databases, not just the current database.
Most of the my bean is from the original code although I made some additions to capture the user acl priviliges too:
int accPriv = thisDb.queryAccessPrivileges(session.getEffectiveUserName()); if ((accPriv & thisDb.DBACL_CREATE_DOCS) > 0) { if (!aclPriviliges.contains("DBACL_CREATE_DOCS")) { aclPriviliges.add("DBACL_CREATE_DOCS"); } } if ((accPriv & thisDb.DBACL_DELETE_DOCS) > 0) { if (!aclPriviliges.contains("DBACL_DELETE_DOCS")) { aclPriviliges.add("DBACL_DELETE_DOCS"); } } if ((accPriv & thisDb.DBACL_CREATE_PRIV_AGENTS) > 0) { if (!aclPriviliges.contains("DBACL_CREATE_PRIV_AGENTS")) { aclPriviliges.add("DBACL_CREATE_PRIV_AGENTS"); } } //etc...
faces-config:
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>org.quintessens.comments.utils.UserBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Here is how I initiate the bean:
<xp:this.beforePageLoad><![CDATA[#{javascript:var db:NotesDatabase = session.getDatabase("","apps/quintessens/comments.nsf");
UserBean.init(db);}]]></xp:this.beforePageLoad>
I notice I can only use the bean with session and request scope. View scope gives a 500 error.
The UserBean class itself is mostly as the original:
Some modifications:
public Database db;
public UserBean() {
this.init( db);
}
and
public void init(Database db) {
session = getCurrentSession();
try {
Database thisDb = db;
...
int accPriv = thisDb.queryAccessPrivileges(session.getEffectiveUserName());
...
}
Although I do not get an error with the session and request scope, the ACL user priviliges are incorrect.
If I run the class not as Managed Bean as followed:
var thisDb:NotesDatabase = session.getDatabase("","apps/quintessens/comments2.nsf");
Bean = new org.quintessens.comments.utils.UserBean(thisDb);
return Bean.aclPriviliges;
I get the correct user information returned.
Can someone shine a light how I can run the class with parameters once again as a managed bean?