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

RPC storePage parentId should handle string type

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      If use use the confluence XMLRPC interface with perl and try and set a parentId you get a ClassCastException:

      Perl script:

      #!/opt/local/bin/perl
      use strict;
      use XMLRPC::Lite;
      my $username="admin";
      my $password="admin";
      my $baseurl="http://localhost:8080";
      my $spaceKey="ds";
      my $pageTitle="Confluence Overview"; 
      my $confluence = XMLRPC::Lite->proxy("$baseurl/rpc/xmlrpc");
      my $token = $confluence->call("confluence1.login", $username, $password)->result();
      my $parentPage = $confluence->call("confluence1.getPage", $token, $spaceKey, $pageTitle)->result();
      my $newpage = {
          space => $spaceKey,
          title => "New Child Page",
          content => "Content",
          parentId => $parentPage->{id},
        };
      my $createdpage = $confluence->call("confluence1.storePage", $token, $newpage)->result();
      die "could not create child page" unless $createdpage;
      

      The problem is because perl sees the parentId is an integer and actually passes it to confluence rpc as an integer.
      Confluence RPC is expecting a string and responds with this error:

      java.lang.ClassCastException: java.lang.Integer
              at com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage(ConfluenceXmlRpcHandlerImpl.java:352)
              ... 50 more
      

      Because the ConfluenceXmlRpcHandlerImpl expects a string in the storePage method:

          public Hashtable storePage(String token, Hashtable pageStruct) throws RemoteException
          {
              // ...
              if (pageStruct.containsKey("parentId"))
                  pageStruct.put("parentId", new Long((String) pageStruct.get("parentId")));
              // ...
          }
      

      Fix this by changing the storePage to handle both String and Integer input.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mjensen m@ (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: