Class HibernatePageDao

    • Constructor Detail

      • HibernatePageDao

        public HibernatePageDao()
    • Method Detail

      • getPageById

        public Page getPageById​(long id)
        Description copied from interface: PageDao
        Get the page with the given id.
        Specified by:
        getPageById in interface PageDao
        Parameters:
        id - of the page to load
        Returns:
        the page with the given id, or null if no such page exists
      • getCommentCountOnPage

        public int getCommentCountOnPage​(long id)
        Description copied from interface: PageDao
        Count the number of comments on the passed in page.
        Specified by:
        getCommentCountOnPage in interface PageDao
      • getPageByIdWithComments

        public Page getPageByIdWithComments​(long id)
        Description copied from interface: PageDao
        Get the page with the given id, and perform an eager load of the comments and their children. This can be used as a performance optimisation when it is known that all comments will be displayed.
        Specified by:
        getPageByIdWithComments in interface PageDao
        Parameters:
        id - of the page to load
        Returns:
        the page with the given id, or null if no such page exists
      • getPage

        public Page getPage​(Space space,
                            String pageTitle,
                            boolean eagerLoadComments)
      • getPageWithComments

        public Page getPageWithComments​(Space space,
                                        String pageTitle)
        Description copied from interface: PageDao
        Get the page by space and title, and perform an eager load of the comments and their children. This can be used as a performance optimisation when it is known that all comments will be displayed.
        Specified by:
        getPageWithComments in interface PageDao
        Parameters:
        space - The space the page belongs to
        pageTitle - The title of the page
        Returns:
        the page with the given title in the given space, or null if no such page exists
      • getPage

        public Page getPage​(Space space,
                            String pageTitle)
        Description copied from interface: PageDao
        Get the page by space and title.
        Specified by:
        getPage in interface PageDao
        Parameters:
        space - The space the page belongs to
        pageTitle - The title of the page
        Returns:
        the page with the given title in the given space, or null if no such page exists
      • getPagesWithPermissions

        public List<Page> getPagesWithPermissions​(@NonNull Space space)
        Description copied from interface: PageDao
        Get all current pages in a space and eagerly fetch permissions at the same time. This is an optimisation for when you known that permissions will need to be fetched for all or most of the pages later.
        Specified by:
        getPagesWithPermissions in interface PageDao
        Returns:
        a list of all the current pages in a space
      • getPageIds

        public Collection<Long> getPageIds​(Space space)
        Description copied from interface: PageDao
        Get the ids of all pages (current and historical) in the given space.
        Specified by:
        getPageIds in interface PageDao
        Parameters:
        space - space to retrieve page ids from, can not be null.
        Returns:
        a Collection of ids for pages.
      • findPagesWithCurrentOrHistoricalTitleInPermittedSpace

        public List<AbstractPage> findPagesWithCurrentOrHistoricalTitleInPermittedSpace​(SpacePermissionQueryBuilder permissionQueryBuilder,
                                                                                        String pageTitle,
                                                                                        Space space,
                                                                                        int maxResultCount)
        Description copied from interface: PageDao
        Searches for pages in the space specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.

        Only pages in spaces the remote user is able to view will be returned.

        Specified by:
        findPagesWithCurrentOrHistoricalTitleInPermittedSpace in interface PageDao
        pageTitle - title of a page in a previous version.
        space - Space to search. Must not be null.
        maxResultCount - maximum pages to return
      • findBlogsWithCurrentOrHistoricalTitleInPermittedSpace

        public List<AbstractPage> findBlogsWithCurrentOrHistoricalTitleInPermittedSpace​(SpacePermissionQueryBuilder permissionQueryBuilder,
                                                                                        String blogTitle,
                                                                                        Space space,
                                                                                        int maxResultCount)
        Description copied from interface: PageDao
        Searches for blogs in the space specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.

        Only blogs in spaces the remote user is able to view will be returned.

        Specified by:
        findBlogsWithCurrentOrHistoricalTitleInPermittedSpace in interface PageDao
        Parameters:
        permissionQueryBuilder - required to determine how to construct database queries for space permissions, for the current user
        blogTitle - title of a page in a previous version.
        space - Space to search. Must not be null.
        maxResultCount - maximum pages to return
        Returns:
        a list of pages that have the given title in a previous version
      • findBlogsWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept

        public List<AbstractPage> findBlogsWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept​(SpacePermissionQueryBuilder permissionQueryBuilder,
                                                                                                  String blogTitle,
                                                                                                  Space space,
                                                                                                  int maxResultCount)
        Description copied from interface: PageDao
        Searches for blog posts in all spaces except the one specified, looking for those that have the given title in a current or previous version, and returns the first maxResultCount results.

        Only pages in spaces the remote user is able to view will be returned.

        Specified by:
        findBlogsWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept in interface PageDao
        blogTitle - Title of the blog to find
        space - Space to exclude from search. If null, all spaces are searched.
        maxResultCount - maximum blog posts to return
        Returns:
        a list of blog posts that have or have had the given title
      • findPagesWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept

        public List<AbstractPage> findPagesWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept​(SpacePermissionQueryBuilder permissionQueryBuilder,
                                                                                                  String pageTitle,
                                                                                                  Space space,
                                                                                                  int maxResultCount)
        Description copied from interface: PageDao
        Searches for pages in all spaces except the one specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.

        Only pages in spaces the remote user is able to view will be returned.

        Specified by:
        findPagesWithCurrentOrHistoricalTitleInAllPermittedSpacesExcept in interface PageDao
        pageTitle - title of a page in a previous version.
        space - Space to exclude from search. If null, all spaces are searched.
        maxResultCount - maximum pages to return
      • countCurrentPages

        public int countCurrentPages()
        Description copied from interface: PageDao
        Counts the total number of current pages across all spaces
        Specified by:
        countCurrentPages in interface PageDao
        Returns:
        the number of current pages
      • countDraftPages

        public int countDraftPages()
        Description copied from interface: PageDao
        Counts the number of pages that are drafts. This does not include drafts of pages that have already been published (i.e. pages with unpublished changes).
        Specified by:
        countDraftPages in interface PageDao
        Returns:
        the number of draft pages
      • countPagesWithUnpublishedChanges

        public int countPagesWithUnpublishedChanges()
        Description copied from interface: PageDao
        Counts the number of published pages that have unpublished changes.
        Specified by:
        countPagesWithUnpublishedChanges in interface PageDao
        Returns:
        the number of pages with unpublished changes.
      • getPageCount

        public long getPageCount​(@NonNull String spaceKey)
        Description copied from interface: PageDao
        Get total number of current pages in a space
        Specified by:
        getPageCount in interface PageDao
        Parameters:
        spaceKey - the space to look for pages in
        Returns:
        a count number of pages
      • getPageCount

        public long getPageCount​(@NonNull String spaceKey,
                                 List<ContentStatus> statuses)
        Description copied from interface: PageDao
        Get total number of pages in a space, within any of the given statuses.
        Specified by:
        getPageCount in interface PageDao
        Parameters:
        spaceKey - the space to look for pages in
        statuses - list of statuses the pages can be in
        Returns:
        a count number of pages
      • getPageStatistics

        public Optional<PageStatisticsDTO> getPageStatistics()
        Description copied from interface: PageDao
        Fetches statistics about pages
        Specified by:
        getPageStatistics in interface PageDao
        Returns:
        a PageStatisticsDTO with information about pages such as total, current, and draft count
      • countAllPages

        public int countAllPages()
        Description copied from interface: PageDao
        Counts the total number of all page entities across all spaces, including non-current pages
        Specified by:
        countAllPages in interface PageDao
        Returns:
        the number of pages
      • getDescendants

        public List<Page> getDescendants​(Page page)
        Description copied from interface: PageDao
        Finds all descendant pages (recursive) of the given page
        Specified by:
        getDescendants in interface PageDao
        Returns:
        List of descendant pages
      • countPagesInSubtree

        public int countPagesInSubtree​(@NonNull Page page)
        Description copied from interface: PageDao
        Return total descendant page including input page
        Specified by:
        countPagesInSubtree in interface PageDao
        Returns:
        total page
      • getAncestorsFor

        public Map<Long,​List<Long>> getAncestorsFor​(Collection<Long> ids)
        Description copied from interface: PageDao
        Get the list page ids of the ancestors of the given page ids.
        Specified by:
        getAncestorsFor in interface PageDao
        Parameters:
        ids - the list of page ids to get ancestor page ids for
        Returns:
        a map where the key is the given page id and the value is a list of all its ancestors' page ids
      • getDescendantTitles

        public List<String> getDescendantTitles​(Page page)
        Description copied from interface: PageDao
        Finds all descendant titles of the given page
        Specified by:
        getDescendantTitles in interface PageDao
        Returns:
        List of descendant titles
      • getDescendantIds

        public List<Long> getDescendantIds​(Page page)
        Description copied from interface: PageDao
        Finds the ids of all descendant pages of the given page
        Specified by:
        getDescendantIds in interface PageDao
        Returns:
        List of page ids
      • getDescendantIds

        public List<Long> getDescendantIds​(Page page,
                                           ContentStatus... contentStatus)
        Description copied from interface: PageDao
        Finds the ids of all descendant pages of the given page
        Specified by:
        getDescendantIds in interface PageDao
        Returns:
        List of page ids
      • getDraftChildren

        public PageResponse<Page> getDraftChildren​(Page page,
                                                   LimitedRequest pageRequest,
                                                   Depth depth)
        Description copied from interface: PageDao
        Returns the children of a page which have a status of DRAFT, limited to the pagination requested. Will fetch drafts all drafts regardless of whether the current authenticated user has permission to view the drafts
        Specified by:
        getDraftChildren in interface PageDao
        Parameters:
        page - the page to find children for
        pageRequest - the pagination requested
        depth - the depth to return children to
        Returns:
        the paginated response of Page entities
      • getAllChildren

        public PageResponse<Page> getAllChildren​(Page page,
                                                 LimitedRequest pageRequest,
                                                 Depth depth)
        Description copied from interface: PageDao
        Returns all children of a page (including drafts), limited to the pagination requested.
        Specified by:
        getAllChildren in interface PageDao
        Parameters:
        page - the page to find children for
        pageRequest - the pagination requested
        depth - the depth to return children to
        Returns:
        the paginated response of Page entities
      • getMaxSiblingPosition

        public Integer getMaxSiblingPosition​(Page page)
        Description copied from interface: PageDao
        Gets the highest position value of all the page's siblings. This is useful when we need to find what position to assign to a new page that should go to the bottom.
        Specified by:
        getMaxSiblingPosition in interface PageDao
        Parameters:
        page - The page whose siblings from which to get the max position
        Returns:
        The highest position value of all the page's siblings
      • saveRawWithoutReindex

        public void saveRawWithoutReindex​(com.atlassian.core.bean.EntityObject objectToSave)
        Description copied from interface: ContentEntityObjectDaoInternal

        This is for internal use only, Do not rely on it as a public API.

        Perform a saveRaw but without performing the re-index; it is unnecessary in the context of a migration or upgrade.

        Specified by:
        saveRawWithoutReindex in interface ContentEntityObjectDaoInternal<Page>
      • scanFilteredPages

        public PageResponse<Page> scanFilteredPages​(List<ContentStatus> statuses,
                                                    LimitedRequest pageRequest,
                                                    Predicate<? super Page> filter)
        Description copied from interface: PageDaoInternal
        Retrieves a page response of all the pages with specified content statuses.
        Specified by:
        scanFilteredPages in interface PageDaoInternal
        Parameters:
        statuses - list of content status which we are interested to fetch
        pageRequest - limit and cursor of the pages to retrieve. Cursor in pageRequest can't be null.
        filter - the predicate to filter the returned results by, may be null
        Returns:
        the paginated list of pages
      • scanFilteredPages

        public PageResponse<Page> scanFilteredPages​(Space space,
                                                    List<ContentStatus> statuses,
                                                    LimitedRequest pageRequest,
                                                    Predicate<? super Page> filter)
        Description copied from interface: PageDaoInternal
        Retrieves a page response of all pages in space with specified content statuses.
        Specified by:
        scanFilteredPages in interface PageDaoInternal
        Parameters:
        space - the space to locate the page in
        statuses - content status to match
        pageRequest - limit and cursor of the pages to retrieve. Cursor in pageRequest can't be null.
        filter - the predicate to filter the returned results by, may be null
        Returns:
        the paginated list of pages