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

Unable to like a ContentEntityObject that is not an AbstractPage

    XMLWordPrintable

Details

    Description

      I am currently working on a Confluence plugin that uses a ContentEntityObject subclass (= a UserStatus) and I ran into an issue.

      The user can like this ContentEntityObject, and it works when the user is trying to like his or her own content. Problem is, when the content is not his/her own, we get a RuntimeException:

      [INFO] [talledLocalContainer] java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66)
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32)
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60)
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
      [INFO] [talledLocalContainer] 	at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.like.DefaultLikeManager.addLike(DefaultLikeManager.java:88)
      

      That's because of the LikeEvent that is dispatched after the LikeEntity has been created, it seems there is a listener that expects an "AbstractPage" object with this event, which our object is not (here it's an UserStatus).

      It doesn't seem very logical to me to be able to like any ContentEntityObject but crash if you try to like something that is not a BlogPost or a Page.

      Attachments

        Issue Links

          Activity

            People

              sday@atlassian.com Samuel Day (Inactive)
              e56503a653e5 Romain Pouclet
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: