Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-39321

$permissionHelper.canEdit() throws exception in browser if user does not have edit permission

    XMLWordPrintable

Details

    Description

      Summary

      When using the $permissionHelper.canEdit($action.remoteUser, $pageVar) with a user and page Object, if the function returns true it displays 'true' in a page. If the user does not have permission, this should return false. Instead it returns the stack trace below.

      Environment

      • Mac OS X
      • Java 1.8

      Steps to Reproduce

      1. Create a user macro to read in a target page and then check if the user has permission as follows:
        ## @param Page:title=Target Page|type=confluence-content|required=true|desc=check if editable
        
        $permissionHelper.canEdit($action.remoteUser, $paramPage)
        

      Expected Results

      If the function returns true it displays 'true'. If the user does not have permission, this should return 'false'.

      Actual Results

      The below exception is thrown in the browser:

      Oops - an error has occurred
       logo System Error
      A system error has occurred — our apologies!
      For immediate troubleshooting, consult our knowledge base for a solution.
      If you would like to receive support from Atlassian's support team, ask your Confluence administrator to create a support issue on Atlassian's support system with the following information:
      a description of your problem and what you were doing at the time it occurred
      a copy of the error and system information found below
      a copy of the application logs (if possible).
      Your Confluence administrator can use the support request form to create a support ticket which will include this information.
      We will respond as promptly as possible.
      Thank you!
      Return to site homepage…
      Cause
      java.lang.RuntimeException: Error rendering template for decorator root
          at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:202)
      caused by: java.lang.RuntimeException: Error rendering template for decorator page
          at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:202)
      caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDisplayableItems' in class com.atlassian.confluence.plugin.descriptor.web.ConfluenceWebInterfaceManager threw exception net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection at template/includes/menu-macros.vm[line 133, column 45]
          at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
      caused by: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
          at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
      caused by: net.sf.hibernate.HibernateException: collection was evicted
          at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3332)
      Stack Trace:[hide]
      java.lang.RuntimeException: Error rendering template for decorator root
      	at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:202)
      	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
      	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      	at org.apache.velocity.Template.merge(Template.java:328)
      ...
      Caused by: net.sf.hibernate.HibernateException: collection was evicted
      	at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3332)
      	at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
      	... 487 more
      

      Workaround

      No workaround found so far

      Attachments

        1. permissionHelperError.png
          259 kB
          Daniel Ponzio

        Activity

          People

            Unassigned Unassigned
            dponzio Daniel Ponzio
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: