Interface PageManagementService


  • public interface PageManagementService
    This class offers APIs to create, move and delete pages and page sections.
    Author:
    ivol
    • Method Detail

      • createAndInsertPage

        Page createAndInsertPage​(Page page)
        Creates a new subpage below the given page as last page.
        Parameters:
        page - Page to add the subpage to. May not be null.
        Returns:
        The created subpage or null if the page could not be created.
      • createAndInsertPage

        Page createAndInsertPage​(Page page,
                                 Language language)
        Creates a new subpage below the given page as last page for a given language.
        Parameters:
        page - Page to add the subpage to. May not be null.
        language - the language of the page
        Returns:
        The created subpage or null if the page could not be created.
      • createAndInsertPage

        Page createAndInsertPage​(Page page,
                                 int position)
        Creates a new subpage at the given position into the given page.
        Parameters:
        page - Page to add the subpage to
        position - Position at which the page should be inserted, -1 will add the page as last page below the parent page, -2 will add the page as orphan page.
        Returns:
        The created subpage or null if the page could not be created.
      • createOrphanPage

        Page createOrphanPage​(Page page)
        Creates a new orphan page (page without a parent). The given page will be used to copy basic properties from like Workflow model and page configuration.
        Parameters:
        page - Page which will be used to base the new page on (for Workflow model and basic configuration). May not be null.
        Returns:
        The created subpage or null if the page could not be created.
      • createAndInsertPageFromMediaItemVersion

        Page createAndInsertPageFromMediaItemVersion​(Page parentPage,
                                                     MediaItemVersion mediaItemVersion)
                                              throws NoAuthorizationException
        Creates a new page as a copy of a given media item version, and places it below the given page as last page. The type of the media item version must be an element holder type, otherwise an IllegalArgumentException is thrown.

        The following information is copied from the media item version to the page:

        • Title
        • Language
        • Content area, i.e. elements and links
        • Lead text and image
        • Publication and expiration date
        • URL title
        • Html title
        • Meta description and keywords
        • Include in search engine flag
        • SEO priority and update frequency
        • Remark
        The page will be created in the initial, unpublished workflow state.
        Parameters:
        parentPage - The new page will be placed under this page.
        mediaItemVersion - The media item version to copy.
        Returns:
        The created page.
        Throws:
        NoAuthorizationException - If the user does not have permission to create the page.
        IllegalArgumentException - When the parameters are empty or invalid.
        Since:
        10.32.0
      • createPageVersion

        PageVersion createPageVersion​(Page page,
                                      Language language)
        Creates a new empty version of the specified page.
        Parameters:
        page - Page to create the new page version for
        language - Language to create the new version in. Specify null to create a new page version in the current editing language.
        Returns:
        The created page version
      • createPageVersion

        PageVersion createPageVersion​(PageVersion pageVersion,
                                      Language language)
        Creates a new version based on the specified page version. The metadata and elements are copied to the new page version.
        Parameters:
        pageVersion - Page version to create the new page version from
        language - Language to create the new version in. Specify null to create a new page version in the current editing language.
        Returns:
        The created page version
      • createPageVersionFromMediaItemVersion

        PageVersion createPageVersionFromMediaItemVersion​(Page page,
                                                          MediaItemVersion mediaItemVersion)
                                                   throws NoAuthorizationException
        Creates a new page version as a copy of a given media item version and adds it to the given page. The type of the media item version must be an element holder type, otherwise an IllegalArgumentException is thrown.

        The following information is copied from the media item version to the page version:

        • Title
        • Language
        • Content area, i.e. elements and links
        • Lead text and image
        • Publication and expiration date
        • URL title
        • Html title
        • Meta description and keywords
        • Include in search engine flag
        • SEO priority and update frequency
        • Remark
        The page version will be created in the initial, unpublished workflow state.
        Parameters:
        page - The page to which to add the new version.
        mediaItemVersion - The media item version to copy.
        Returns:
        The created page version.
        Throws:
        NoAuthorizationException - If user does not have permission to create the page version.
        IllegalArgumentException - When the parameters are empty or invalid.
        Since:
        10.32.0
      • createAndInsertPageSection

        Page createAndInsertPageSection​(Page page)
        Creates a new page section below the given page section as last page section. Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        page - Page section to add the sub page section to. May not be null.
        Returns:
        The created sub page section or null if the page section could not be created.
      • createAndInsertPageSection

        Page createAndInsertPageSection​(Page page,
                                        Language language)
        Creates a new page section below the given page section as last page section for a given language. Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        page - Page section to add the sub page section to. May not be null.
        language - the language of the page section
        Returns:
        The created sub page section or null if the page section could not be created.
      • createAndInsertDatabasePage

        Page createAndInsertDatabasePage​(Page page,
                                         DatabaseEntity databaseEntity)
        Creates a new database page below the given page as last page.
        Parameters:
        page - Page to add the sub database page to. May not be null.
        databaseEntity - Database page type to create the database page from
        Returns:
        The created sub database page or null if the database page could not be created.
      • createAndInsertPageFromPageModel

        @Deprecated
        Page createAndInsertPageFromPageModel​(Page page,
                                              nl.gx.webmanager.cms.pagemodel.PageModel pageModel)
        Deprecated.
        Create and insert a new page based on a page model below the given page.
        Parameters:
        page - Page to add the sub page to. May not be null.
        pageModel - Page model on which the new page is based
        Returns:
        The created sub page or null if the page could not be created.
      • createAndInsertPageFromPageModel

        @Deprecated
        Page createAndInsertPageFromPageModel​(Page page,
                                              nl.gx.webmanager.cms.pagemodel.PageModel pageModel,
                                              int position)
        Deprecated.
        Create and insert a new page based on a page model below the given page at the given position.
        Parameters:
        page - Page to add the sub page to. May not be null.
        pageModel - Page model on which the new page is based
        position - Position at which the database page should be inserted, -1 will add the database page as last page below the parent page.
        Returns:
        The created sub page or null if the page could not be created.
      • createAndInsertPageSectionFromPageModel

        @Deprecated
        Page createAndInsertPageSectionFromPageModel​(Page page,
                                                     nl.gx.webmanager.cms.pagemodel.PageModel pageModel)
        Deprecated.
        Create and insert a new page section based on a page model below the given page section.
        Parameters:
        page - Page section to add the sub page section to. May not be null.
        pageModel - Page model on which the new page section is based
        Returns:
        The created sub page section or null if the page section could not be created.
      • createPageModel

        @Deprecated
        nl.gx.webmanager.cms.pagemodel.PageModel createPageModel​(Website website)
        Deprecated.
        Creates a new page model.
        Parameters:
        website - Website to create the page model for
        Returns:
        Returns the created page model object
      • copyPage

        Page copyPage​(Page page,
                      Page targetParentPage)
               throws NoAuthorizationException
        Copies a page and assigns the copy under the given target page. Copies a page version for each language (if there is a page version available for a language).
        For each language the current page version is copied, which is the published version with the most recent publication date. If no published version is available, a non published version is copied with the most recent publication date.

        If the parentTarget parameter is null then the copy will be assigned to the same parent as the source page, or if the source page has no parent the copy will be moved to the orphan pages pool.

        Regarding authorization an user needs both CREATE and UPDATE permissions on pages, CREATE permission on page versions, and CREATE permissions on all the page version's elements.

        For example, to copy the home page and its most current version as an orphan page: copyPage(homePage, homePage.getCurrent(), null).

        Steps performed:

        • Permissions of the current user are checked
        • A Event.Type.PRE page event of type EntityEvent.COPY is fired
        • Requested page and page version is copied
        • A Event.Type.POST page event of type EntityEvent.CREATE is fired
        • A Event.Type.POST page event of type EntityEvent.COPY is fired
        Parameters:
        page - The page to copy. May not be null.
        targetParentPage - The copy will be assigned under this page.
        Returns:
        The copied page.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page.
      • copyPage

        Page copyPage​(PageVersion pageVersion,
                      Page targetParentPage)
               throws NoAuthorizationException
        Copies a page and assigns the copy under the given target page. The source page is specified by one of its page versions. Also, only that page version is copied.
        Parameters:
        pageVersion - The pageVersion which page to copy. May not be null.
        targetParentPage - The copy will be assigned under this page.
        Returns:
        The copied page.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page.
      • copyBlock

        Page copyBlock​(Page pageSection,
                       Page targetParentPageSection)
                throws NoAuthorizationException
        Copies a page section and assigns the copy under the given target page section. For further reading see copyPage(Page, Page). Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        pageSection - The page section to copy. May not be null.
        targetParentPageSection - The copy will be assigned under this page section.
        Returns:
        The copied page section.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page section.
      • copyBlock

        Page copyBlock​(PageVersion pageSectionVersion,
                       Page targetParentPageSection)
                throws NoAuthorizationException
        Copies a page section and assigns the copy under the given target page section. For further reading see copyPage(PageVersion, Page). Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        pageSectionVersion - The page section version for which its page section to copy. May not be null.
        targetParentPageSection - The copy will be assigned under this page section.
        Returns:
        The copied page section.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page section.
      • copyPageVersion

        PageVersion copyPageVersion​(PageVersion pageVersion)
                             throws NoAuthorizationException
        Copies a page version. The created page version belongs to the same page as the original version and has the same language.
        Parameters:
        pageVersion - The page version to copy. May not be null.
        Returns:
        The copied page version.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page version.
      • copyPageVersion

        PageVersion copyPageVersion​(PageVersion pageVersion,
                                    Language language)
                             throws NoAuthorizationException
        Copies a page version for the specified language. The copied page version exists for the same page as the source page version. Next to this, the copied page version is available for the given language. If the language parameter is null the copy exists for the same language as the source page version.
        Parameters:
        pageVersion - The page version to copy. May not be null.
        language - The copy will be created for this language.
        Returns:
        The copied page version.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page version.
      • copyPageModel

        @Deprecated
        nl.gx.webmanager.cms.pagemodel.PageModel copyPageModel​(nl.gx.webmanager.cms.pagemodel.PageModel pageModel)
                                                        throws NoAuthorizationException
        Deprecated.
        Not implemented yet.
        Parameters:
        pageModel - Not implemented yet.
        Returns:
        Not implemented yet.
        Throws:
        NoAuthorizationException - If user has no rights to copy the page model.
      • copyPage

        Page copyPage​(Page page,
                      Page targetPage,
                      boolean recursive)
               throws NoAuthorizationException
        Copies the page including subpages to the targetpage.
        Parameters:
        page - Page that will be copied, the root of the branch.
        targetPage - Page under which the duplicated branch will be inserted.
        recursive - Whether the complete subtree of pages should be copied also, or not.
        Returns:
        the last copied page
        Throws:
        NoAuthorizationException - If user has no rights to copy one of the pages.
      • movePage

        boolean movePage​(Page page,
                         Page toPage)
        Moves a page to another parent page as last page below that parent page.
        Parameters:
        page - Page that will be moved.
        toPage - Page under which the source page will be inserted.
        Returns:
        true if the move succeeded, false otherwise
      • moveToOrphanPages

        boolean moveToOrphanPages​(Page page)
        Moves the page to the orphanage (orphanage contains all pages without a parent).
        Parameters:
        page - Page to move
        Returns:
        true if the move succeeded, false otherwise
      • moveToOrphanPages

        boolean moveToOrphanPages​(Page page,
                                  int position)
        Moves a page to the orphanage at the specified position.
        Parameters:
        page - Page to move
        position - The position of the page between all orphan pages
        Returns:
        true if the move succeeded, false otherwise
      • movePage

        boolean movePage​(Page page,
                         Page toPage,
                         int position)
        Moves a page to another location.
        Parameters:
        page - Page that will be moved
        toPage - Page under which the source page will be inserted
        position - New position at which the page should be moved into
        Returns:
        true if the move succeeded, false otherwise
      • deletePage

        boolean deletePage​(Page page,
                           boolean recursive)
        Deletes a page completely, including all its subpages if recursive is true.
        Parameters:
        page - Page to delete
        recursive - if true then all pages below this page are also deleted, if false only the page itself is deleted and all its first level subpages are moved to the orphan pages remaining the lower level structure
        Returns:
        true if the delete succeeded, false otherwise
      • deletePageVersion

        boolean deletePageVersion​(PageVersion pageVersion,
                                  boolean recursive)
        Deletes a page version, including all its subpages if it is the last version of the page and recursive is true.
        Parameters:
        pageVersion - PageVersion to delete. If this is the only version of the page, the page itself will also be deleted.
        recursive - Only applicable if this is the last version of the page. If true then all pages below this page are also deleted, if false only the page itself is deleted and all its first level subpages are moved to the orphan pages remaining the lower level structure
        Returns:
        true if the delete succeeded, false otherwise
      • deletePageModel

        @Deprecated
        boolean deletePageModel​(nl.gx.webmanager.cms.pagemodel.PageModel pageModel)
        Deprecated.
        Deletes an existing page model.
        Parameters:
        pageModel - Page model to delete
        Returns:
        true if the delete succeeded, false otherwise
      • addRedirect

        boolean addRedirect​(PageVersion pageVersion)
        Adds a redirect to this page version.
        Parameters:
        pageVersion - Page version to add the redirect to
        Returns:
        true if adding the redirect succeeded, false otherwise
      • getOrCreatePageLabel

        PageLabel getOrCreatePageLabel​(String label)
        Returns the page label with the specified name. If no such page label exists, it is created automatically and than returned. If the label is null or empty or creating the page label failed for whatever reason, null is returned.
        Parameters:
        label - The name of the page label to return and/or create.
        Returns:
        The page label with the specified name or null if creating the page label failed.
      • getPageLabel

        PageLabel getPageLabel​(String label)
        Returns the page label with the specified name or null if no such label exists.
        Parameters:
        label - The name of the page label to return.
        Returns:
        The page label with the specified name or null if no such label exists.
      • deletePageLabel

        void deletePageLabel​(PageLabel pageLabel)
        Removes the specified page label.
        Parameters:
        pageLabel - the page label to delete.
      • getOrCreateBlockLabel

        BlockLabel getOrCreateBlockLabel​(String label)
        Returns the page section label with the specified name. If no such page section label exists, it is created automatically and then returned. If the label is null or empty or creating the page section label failed for whatever reason, null is returned. Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        label - The name of the page section label to return and/or create.
        Returns:
        The page section label with the specified name or null if creating the page section label failed.
      • getBlockLabel

        BlockLabel getBlockLabel​(String label)
        Returns the page section label with the specified name or null if no such label exists. Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        label - The name of the page section label to return.
        Returns:
        The page section label with the specified name or null if no such label exists.
      • deleteBlockLabel

        void deleteBlockLabel​(BlockLabel pageSectionLabel)
        Removes the specified page label. Note that the names "block" and "page section" both refer to the same concept.
        Parameters:
        pageSectionLabel - the page section label to delete.
      • reorderElements

        boolean reorderElements​(PageVersion pageVersion,
                                Element[] elements)
        Reorders all the elements of a page version. The given elements defines the new ordering of elements. Note that there is no authorization required to reorder elements.

        Before the reordering is applied to the given page version the original elements are checked with the new ordering to determine whether the elements are really reordered. If a reordering is needed then:

        • The reordering is applied
        • A Event.Type.POST page version event of type EntityEvent.UPDATE is fired
        • A Event.Type.POST page event of type EntityEvent.UPDATE is fired
        Parameters:
        pageVersion - The page version which elements should be reordered.
        elements - Elements that defines the new ordering of the page version's elements. The size of the elements array should match the number of the page version's elements
        Returns:
        Returns true if reorder is successful, false otherwise.
      • reorderElements

        @Deprecated
        boolean reorderElements​(nl.gx.webmanager.cms.pagemodel.PageModel pageModel,
                                Element[] elements)
        Deprecated.
        Reorders all the elements of a page model. The given elements defines the new ordering of elements. Note that there is no authorization required to reorder elements.
        Parameters:
        pageModel - The page model which elements should be reordered.
        elements - Elements that defines the new ordering of the page model's elements. The size of the elements array should match the number of the page version's elements
        Returns:
        Returns true if reorder is successful, false otherwise.
      • performWorkflowAction

        @Deprecated
        void performWorkflowAction​(PageVersion pageVersion,
                                   WorkflowAction workflowAction)
                            throws UnExecutableWorkflowActionException
        Deprecated.
        Not for public use. This method is expected to be retained only as a package private method. Replaced by WorkflowService.performWorkflowAction(nl.gx.webmanager.cms.workflow.WorkflowEnabled, WorkflowAction)
        Performs the given workflowAction to progress this pageVersion to the next state.
        Parameters:
        pageVersion - the pageVersion
        workflowAction - the workflowAction
        Throws:
        UnExecutableWorkflowActionException - If the given workflow action is invalid.
        See Also:
        WorkflowService.performWorkflowAction(nl.gx.webmanager.cms.workflow.WorkflowEnabled, WorkflowAction)
      • performPostUpdateActions

        @Deprecated
        void performPostUpdateActions​(PageVersion pageVersion)
        Deprecated.
        Not for public use. Replaced by the generic event mechanism that triggers the update.
        Tells WebManager a page version has been updated. Must be used after setting some properties of the page version to ensure that dependent components do their job.

        Currently the SEO service (Search Engine Optimization) is instructed to update the page version's friendly URL if necessary.

        Parameters:
        pageVersion - The page version that has been updated.
      • getFromOriginId

        Page getFromOriginId​(Website website,
                             String originId)
        Find a Page based on its originId.
        Parameters:
        website - an originId is always unique within a Website
        originId - the OriginId
        Returns:
        the matching Page, or null if no Page was found or if the provided originId was null or empty
        See Also:
        ContentItem.getOriginId()