Class ConfluenceClient


  • public class ConfluenceClient
    extends java.lang.Object

    ConfluenceClient class

    This class is intended to be used to interact with Confluence REST API

    There are some methods that make use of the Confluence JSON-RPC 2.0 API, but until all the methods are ported to the new REST API, we will have to use them to leverage all the features provided by Confluence

    Author:
    Antonio David Perez Morales <adperezmorales@gmail.com>
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfluenceClient​(java.lang.String protocol, java.lang.String host, java.lang.Integer port, java.lang.String path, java.lang.String username, java.lang.String password)
      Creates a new client instance using the given parameters
    • Constructor Detail

      • ConfluenceClient

        public ConfluenceClient​(java.lang.String protocol,
                                java.lang.String host,
                                java.lang.Integer port,
                                java.lang.String path,
                                java.lang.String username,
                                java.lang.String password)
                         throws org.apache.manifoldcf.core.interfaces.ManifoldCFException

        Creates a new client instance using the given parameters

        Parameters:
        protocol - the protocol
        host - the host
        port - the port
        path - the path to Confluence instance
        username - the username used to make the requests. Null or empty to use anonymous user
        password - the password
        Throws:
        org.apache.manifoldcf.core.interfaces.ManifoldCFException
    • Method Detail

      • close

        public void close()

        Close the client. No further requests can be done

      • check

        public boolean check()
                      throws java.lang.Exception

        Check method used to test if Confluence instance is up and running

        Returns:
        a Boolean indicating whether the Confluence instance is alive or not
        Throws:
        java.lang.Exception
      • checkAuth

        public boolean checkAuth()
                          throws java.lang.Exception

        Check method used to test if Confluence instance is up and running when using Authority connector (JSON-RPC API)

        This method will be deleted when all JSON-RPC methods are available through the REST API

        Returns:
        a Boolean indicating whether the Confluence instance is alive or not
        Throws:
        java.lang.Exception
      • getPages

        public ConfluenceResponse<Page> getPages()
                                          throws java.lang.Exception

        Get a list of Confluence pages

        Returns:
        a ConfluenceResponse containing the result pages and some pagination values
        Throws:
        java.lang.Exception
      • getPages

        public ConfluenceResponse<Page> getPages​(int start,
                                                 int limit,
                                                 com.google.common.base.Optional<java.lang.String> space,
                                                 com.google.common.base.Optional<java.lang.String> pageType)
                                          throws java.lang.Exception

        Get a list of Confluence pages using pagination

        Parameters:
        start - The start value to get pages from
        limit - The number of pages to get from start
        Returns:
        a ConfluenceResponse containing the result pages and some pagination values
        Throws:
        java.lang.Exception
      • getPageAttachments

        public ConfluenceResponse<Attachment> getPageAttachments​(java.lang.String pageId)
                                                          throws java.lang.Exception

        Get the attachments of the given page

        Parameters:
        pageId - the page id
        Returns:
        a ConfluenceResponse instance containing the attachment results and some pagination values
        Throws:
        java.lang.Exception
      • getPageAttachments

        public ConfluenceResponse<Attachment> getPageAttachments​(java.lang.String pageId,
                                                                 int start,
                                                                 int limit)
                                                          throws java.lang.Exception

        Get the attachments of the given page using pagination

        Parameters:
        pageId - the page id
        start - The start value to get attachments from
        limit - The number of attachments to get from start
        Returns:
        a ConfluenceResponse instance containing the attachment results and some pagination values
        Throws:
        java.lang.Exception
      • getAttachment

        public Attachment getAttachment​(java.lang.String attachmentId)

        Gets a specific attachment contained in the specific page

        Parameters:
        attachmentId -
        Returns:
        the Attachment instance
      • getPage

        public Page getPage​(java.lang.String pageId)

        Get a Confluence page identified by its id

        Parameters:
        pageId - the page id
        Returns:
        the Confluence page
      • getLabels

        public java.util.List<Label> getLabels​(java.lang.String pageId)

        Get the labels of a specific page

        Parameters:
        pageId - The pageId to get the labels
        Returns:
        a List<Label> of labels
      • getUserAuthorities

        public ConfluenceUser getUserAuthorities​(java.lang.String username)
                                          throws java.lang.Exception
        Parameters:
        username -
        Returns:
        Throws:
        java.lang.Exception