I want to check if a user has view permission for a page or attachment. I use the PermissionHelper and get this Error:
com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while performing an XHTML storage transformation (Error creating bean with name '....': Unsatisfied dependency expressed through constructor argument with index 4 of type [com.atlassian.confluence.security.PermissionHelper]: : No unique bean of type [com.atlassian.confluence.security.PermissionHelper] is defined: Unsatisfied dependency of type [class com.atlassian.confluence.security.PermissionHelper]: expected at least 1 matching bean; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.confluence.security.PermissionHelper] is defined: Unsatisfied dependency of type [class com.atlassian.confluence.security.PermissionHelper]: expected at least 1 matching bean)
private PermissionHelper permissionHelper; public TestManager(PermissionHelper permissionHelper) { this.permissionHelper = permissionHelper; } public void test() { if (permissionHelper.canView(user, page)) { // do something } }
Community moderators have prevented the ability to post new answers.
Did you try to add component import into atlassian-plugin.xml
Thanks. This helped. But now i use the PermissionManager.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not at all :-). Just noticed that PermissionHelper is a class and not interface so it can not be imported through component-import. Removed wrong xml snipped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay. PermissionManager is the right class to use.
if (permissionManager.hasPermission(user, Permission.VIEW, page)) { // do something }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.