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

Deleting undefined page links using the JAVA API does not work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 6.15.9
    • None

    Description

      Issue Summary

      Using the JAVA API methods com.atlassian.confluence.core.ContentEntityObject.removeOutgoingLink() and com.atlassian.confluence.links.DefaultLinkManager.removeLink() in a script is not working

      Environment

      Steps to Reproduce

      1. In a test space create undefined page links in at least 2 different pages;
      2. Open the Script Console under the Administration console;
      3. Copy the contents of the attached Script.txt into the console;
      4. Edit the space key in line 24 to match your test space;
      5. Click on Run - verify that the output lists the different pages created and the undefined links created in step #1;
      6. Open the pages listed on the output of the previous steps;
      7. Go back to the Script Console and uncomment the code dlm.removeLink(link2) in line 37;
      8. Click on Run.

      Expected Results

      The undefined links listed in the script output should be removed from the page.

      Actual Results

      After step #6 the page links are still present in the pages.
      Running the script after step #Y just returns null and the below exception is thrown in the atlassian_confluence.log:

      2019-09-24 13:37:02,768 WARN [http-nio-26156-exec-2] [runner.rest.common.UserScriptEndpoint] exec Script console script failed: 
       -- referer: http://localhost:26156/c6156/plugins/servlet/scriptrunner/admin/console | url: /c6156/rest/scriptrunner/latest/user/exec/ | traceId: 00b5911e85ae0161 | userName: admin | sr.execution.id: 587f7765-62a7-480a-bb03-ae1ddb5b9f33
      java.lang.NullPointerException
      	at com.atlassian.confluence.links.DefaultLinkManager.removeLink(DefaultLinkManager.java:73)
      	at com.atlassian.confluence.links.LinkManager$removeLink.call(Unknown Source)
      	at Script53.run(Script53.groovy:42)
      ...
      

      Notes

      The classes and methods in question are documented in:

      Workaround

      Currently there is no known workaround for this behaviour. A workaround will be added here when available

      Attachments

        Activity

          People

            Unassigned Unassigned
            bcosta@atlassian.com Bruno Costa (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: