First of all - if code runs under user's privileges, you can't call queryAccess
for database you can't open. To work around this you could force the code to use signer's session and get the access. But...
I recommend this: make a bean named hasAccess. About the scope:
- application scope is shared among users - useless
- session scope - quite fine, but in case of ACL change
you would need to restart http or wait for session timeout
- view scope is recommended
- request scope wont help much
Implement map interface, so you can bind it like #{hasAccess[database]}
where database
will be filepath, or some special key to lookup database. Implement cache and return true/false, according to user's access. How do you determine user's access is up to you, but I think the best method is to use try/catch with attempt to open that database and check it with isOpen().