Class PageDAO

    • Constructor Detail

    • Method Detail

      • getPriority

        public int getPriority​(Event event)
        Description copied from interface: Observer
        Retrieves the priority to observe this event.
        This can be used to process a supported event before others observers.
        Specified by:
        getPriority in interface Observer
        Parameters:
        event - the event.
        Returns:
        the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
      • supports

        public boolean supports​(Event event)
        Description copied from interface: Observer
        Checks if the event is supported. If true, the observe(Event) method will be called.
        Specified by:
        supports in interface Observer
        Parameters:
        event - the event.
        Returns:
        true for observing this event, false otherwise.
      • observe

        public void observe​(Event event,
                            Map<String,​Object> transientVars)
                     throws Exception
        Description copied from interface: Observer
        Observes an event.
        Specified by:
        observe in interface Observer
        Parameters:
        event - the event.
        transientVars - transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.
        Throws:
        Exception - if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
      • getPagesInfos

        public Map<String,​ObjectgetPagesInfos​(List<String> pageIds,
                                                      String zoneName,
                                                      String zoneItemId)
        Get the properties of given pages
        Parameters:
        pageIds - the id of pages
        zoneName - The optional zone name to limit informations of zones to that zone. Can be null or empty to avoid limitation.
        zoneItemId - The optional zone item identifier to limit informations of zones to that zone item. Can be null or empty to avoid limitation.
        Returns:
        the properties of pages in a result map
      • getPagesInfos

        public Map<String,​ObjectgetPagesInfos​(List<String> pageIds)
        Get the properties of given pages
        Parameters:
        pageIds - the id of pages
        Returns:
        the properties of pages in a result map
      • getPageInfos

        public Map<String,​ObjectgetPageInfos​(String pageId,
                                                     String zoneName,
                                                     String zoneItemId)
        Get the page's properties
        Parameters:
        pageId - the page ID
        zoneName - The optional zone name to limit informations of zones to that zone. Can be null or empty to avoid limitation.
        zoneItemId - The optional zone item identifier to limit informations of zones to that zone item. Can be null or empty to avoid limitation.
        Returns:
        the properties
      • getPageInfos

        public Map<String,​ObjectgetPageInfos​(Page page,
                                                     String zoneName,
                                                     String zoneItemId)
        Get the page's properties
        Parameters:
        page - the page
        zoneName - The optional zone name to limit informations of zones to that zone. Can be null or empty to avoid limitation.
        zoneItemId - The optional zone item identifier to limit informations of zones to that zone item. Can be null or empty to avoid limitation.
        Returns:
        the properties
      • hasRight

        public boolean hasRight​(String id,
                                String rightId)
        Check current user right on given page or sitemap
        Parameters:
        id - The id of the page or sitemap
        rightId - The if of right to check
        Returns:
        true if user has right
      • createPage

        public Map<String,​ObjectcreatePage​(String parentId,
                                                   String title,
                                                   String longTitle)
        Create a new page
        Parameters:
        parentId - The parent id. Can not be null.
        title - The page's title. Can not be null.
        longTitle - The page's long title. Can be null or blank.
        Returns:
        The result map with id of created page
      • pastePage

        @Deprecated
        public Map<String,​StringpastePage​(String targetId,
                                                  String sourceId,
                                                  boolean keepReferences)
                                           throws RepositoryException
        Deprecated.
        Copy a page under another page
        Parameters:
        targetId - the page to copy in
        sourceId - the page to copy
        keepReferences - true to keep references for contents, or false to duplicate contents
        Returns:
        The id of created page is a result map.
        Throws:
        RepositoryException - if an error occurs
      • movePage

        public Map<String,​ObjectmovePage​(String id,
                                                 String parentId,
                                                 int index)
        Move a page
        Parameters:
        id - The page id
        parentId - The id of parent destination
        index - The position in parent child nodes where page will be inserted. -1 means as the last child.
        Returns:
        the result map
      • setLink

        public Map<String,​ObjectsetLink​(List<String> pageIds,
                                                String url,
                                                String urlType)
        Set pages as redirection
        Parameters:
        pageIds - the id of pages to modify
        url - the url of redirection
        urlType - the type of redirection
        Returns:
        the id of pages which succeeded or failed.
      • getAvailableContentTypes

        public List<Map<String,​Object>> getAvailableContentTypes​(String pageId,
                                                                       String zoneName)
        Get available content types for specified page
        Parameters:
        pageId - The page's id
        zoneName - the name of the zone
        Returns:
        the list of available content types
      • getAvailableContentTypesForCreation

        public List<Map<String,​Object>> getAvailableContentTypesForCreation​(String pageId,
                                                                                  String zoneName,
                                                                                  String parentId,
                                                                                  String pageTitle,
                                                                                  String template)
        Get available content types for a page being created
        Parameters:
        pageId - The page's id. Can be null of the page is not yet created
        zoneName - the name of the zone
        parentId - The id of parent page
        pageTitle - The title of page to create
        template - The template of page to create
        Returns:
        the list of available services
      • getAvailableServices

        public List<Map<String,​Object>> getAvailableServices​(String pageId,
                                                                   String zoneName)
        Get available services for specified page
        Parameters:
        pageId - The page's id
        zoneName - the name of the zone
        Returns:
        the list of available services
      • getAvailableServicesForCreation

        public List<Map<String,​Object>> getAvailableServicesForCreation​(String pageId,
                                                                              String zoneName,
                                                                              String parentId,
                                                                              String pageTitle,
                                                                              String template)
        Get available services for a page being created
        Parameters:
        pageId - The page's id. Can be null of the page is not yet created
        zoneName - the name of the zone
        parentId - The id of parent page
        pageTitle - The title of page to create
        template - The template of page to create
        Returns:
        the list of available services
      • getAvailableTemplatesForCreation

        public List<Map<String,​Object>> getAvailableTemplatesForCreation​(String pageId,
                                                                               String parentId,
                                                                               String pageTitle)
        Get available content types for a page being created
        Parameters:
        pageId - The page's id. Can be null of the page is not yet created
        parentId - The id of parent page
        pageTitle - The title of page to create
        Returns:
        the list of available services
      • getServiceInfo

        public Map<String,​ObjectgetServiceInfo​(String pageId,
                                                       String serviceId)
        Get service info
        Parameters:
        pageId - Optional, the page id of the service. To get some basic info about the page.
        serviceId - The id of the service
        Returns:
        a Map containing some info about the service (label, url..)
      • renamePage

        public Map<String,​ObjectrenamePage​(String pageId,
                                                   String title,
                                                   String longTitle,
                                                   boolean updatePath,
                                                   boolean createAlias)
        Rename a page
        Parameters:
        pageId - The id of page to rename
        title - The page's title
        longTitle - The page's long title.
        updatePath - true to update page's path
        createAlias - true to create a alias
        Returns:
        the result map
      • deletePage

        public Map<String,​ObjectdeletePage​(String pageId,
                                                   boolean deleteBelongingContents)
        Delete a page and its sub-pages. The contents that belong only to the deleted page will be deleted if 'deleteBelongingContents' is set to true. The newly created contents are deleted whatever the value if 'deleteBelongingContents'.
        Parameters:
        pageId - the id of page to delete
        deleteBelongingContents - true to delete the contents that belong to the page and its sub-pages only
        Returns:
        The id of deleted pages
      • deletePage

        public Map<String,​ObjectdeletePage​(ModifiablePage page,
                                                   boolean deleteBelongingContents)
        Delete a page and its sub-pages. The contents that belong only to the deleted page will be deleted if 'deleteBelongingContents' is set to true. The newly created contents are deleted whatever the value if 'deleteBelongingContents'.
        Parameters:
        page - the page to delete
        deleteBelongingContents - true to delete the contents that belong to the page and its sub-pages only
        Returns:
        The id of deleted pages
      • setBlank

        public Map<String,​ObjectsetBlank​(List<String> pageIds)
        Set pages as blank page
        Parameters:
        pageIds - the id of pages to modify
        Returns:
        the id of pages which succeeded or failed.
      • setTemplate

        public Map<String,​ObjectsetTemplate​(List<String> pageIds,
                                                    String templateName)
        Set a template to pages
        Parameters:
        pageIds - the id of pages to update
        templateName - The template name
        Returns:
        the id of pages which succeeded
      • setTemplate

        public Map<String,​ObjectsetTemplate​(List<String> pageIds,
                                                    String templateName,
                                                    boolean checkAvailableTemplate)
        Set a template to pages
        Parameters:
        pageIds - the id of pages to update
        templateName - The template name
        checkAvailableTemplate - true if you want to check available template
        Returns:
        the id of pages which succeeded
      • getServiceParametersAction

        public String getServiceParametersAction​(String serviceId)
        Get the script class name to execute to add or update this service
        Parameters:
        serviceId - the service id
        Returns:
        the script class name. Can be empty
      • getTags

        public Set<StringgetTags​(List<String> pageIds)
        Get the tags from the pages
        Parameters:
        pageIds - The ids of the pages
        Returns:
        the tags of the pages
      • tag

        public Map<String,​Objecttag​(List<String> pageIds,
                                            List<String> tagNames,
                                            String mode,
                                            Map<String,​Object> contextualParameters)
        Tag a list of pages
        Parameters:
        pageIds - The ids of pages to tag
        tagNames - The tags
        mode - The mode for updating tags: 'REPLACE' to replace tags, 'INSERT' to add tags or 'REMOVE' to remove tags.
        contextualParameters - Contextual parameters. Must contain the site name
        Returns:
        the result
      • tag

        public Map<String,​Objecttag​(List<String> pageIds,
                                            List<String> contentIds,
                                            List<String> tagNames,
                                            Map<String,​Object> contextualParameters)
        Tag a list of contents with the given tags
        Parameters:
        pageIds - The ids of pages to tag
        contentIds - The ids of contents to tag
        tagNames - The tags
        contextualParameters - The contextual parameters
        Returns:
        the result map
      • tag

        public Map<String,​Objecttag​(List<String> pageIds,
                                            List<String> contentIds,
                                            List<String> tagNames,
                                            String mode,
                                            Map<String,​Object> contextualParameters)
        Tag a list of contents and/org pages
        Parameters:
        pageIds - The ids of pages to tag
        contentIds - The ids of contents to tag
        tagNames - The tags
        mode - The mode for updating tags: 'REPLACE' to replace tags, 'INSERT' to add tags or 'REMOVE' to remove tags.
        contextualParameters - The contextual parameters
        Returns:
        the result
      • _isTagValid

        public boolean _isTagValid​(Page page,
                                   String tagName)
        Test if a tag is valid for a specific page
        Parameters:
        page - The page
        tagName - The tag name
        Returns:
        True if the tag is valid
      • findPagedIdsByTag

        public List<StringfindPagedIdsByTag​(String sitename,
                                              String lang,
                                              String tag)
        Returns the ids of the pages matching the tag
        Parameters:
        sitename - The site id
        lang - The language code
        tag - The tag id
        Returns:
        Array of pages ids
      • setVisibility

        public Map<String,​ObjectsetVisibility​(List<String> pageIds,
                                                      boolean visible)
        Set the visible of pages
        Parameters:
        pageIds - The id of pages
        visible - true to set pages as visible, false otherwise
        Returns:
        The result map
      • getDeleteablePageContents

        public Map<String,​ObjectgetDeleteablePageContents​(String id)
        Get the contents of a Page and its subpages which can be deleted. A content is deleteable if user has right, the content is not locked and not referenced by other pages.
        Parameters:
        id - The id of page
        Returns:
        The list of deletable contents
      • getDeleteablePageContentIds

        public List<StringgetDeleteablePageContentIds​(String pageId,
                                                        boolean onlyNewlyCreatedContents)
        Get the contents that belong to the Page and its sub-pages and that can be deleted. A content is deleteable if user has right, the content is not locked and it's not referenced by other pages. If 'onlyNewlyCreatedContents' is set to 'true', only newly created contents will be returned
        Parameters:
        pageId - The id of page
        onlyNewlyCreatedContents - true to return only the newly created contents
        Returns:
        The ids of deleteable contents
      • getPageParents

        public Map<String,​ObjectgetPageParents​(String id)
        Returns the page's parents ids
        Parameters:
        id - the page's id
        Returns:
        The attachments' root node informations
      • getPageContents

        public List<ContentgetPageContents​(Page page)
        Get the contents of a page and its child pages
        Parameters:
        page - The page
        Returns:
        The list of contents
      • getPageContents

        public List<ContentgetPageContents​(Page page,
                                             boolean ignoreContentsOfNonRemovablePage)
        Get the contents of a page and its child pages
        Parameters:
        page - The page
        ignoreContentsOfNonRemovablePage - true to ignore contents of non-removable pages (virtual pages)
        Returns:
        The list of contents
      • getUserRights

        protected Set<StringgetUserRights​(PagesContainer pagesCt)
        Get the user rights on page container (page or sitemap)
        Parameters:
        pagesCt - The pages container
        Returns:
        The user's rights