Class PageDAO

All Implemented Interfaces:
Observer, Initializable, Component, LogEnabled, Serviceable

DAO for manipulating pages
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager smanager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • 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,Object> getPagesInfos(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,Object> getPagesInfos(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,Object> getPageInfos(String pageId)
      Get the page's properties
      Parameters:
      pageId - the page ID
      Returns:
      the properties
    • getPageInfos

      public Map<String,Object> getPageInfos(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,Object> getPageInfos(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
    • getPageInfos

      public Map<String,Object> getPageInfos(Page page)
      Get the page's properties
      Parameters:
      page - the page
      Returns:
      the properties
    • getPageProperties

      Get the page's properties
      Parameters:
      pageId - the id of page
      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,Object> createPage(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
    • copyPage

      public Map<String,String> copyPage(String id, String target, boolean keepReferences) throws javax.jcr.RepositoryException
      Copy a page
      Parameters:
      id - The id of page to copy
      target - The id of parent target page
      keepReferences - true to keep references
      Returns:
      the result map
      Throws:
      javax.jcr.RepositoryException - if an error occurred during copy
    • pastePage

      @Deprecated public Map<String,String> pastePage(String targetId, String sourceId, boolean keepReferences) throws javax.jcr.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:
      javax.jcr.RepositoryException - if an error occurs
    • movePage

      public Map<String,Object> movePage(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,Object> setLink(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.
    • getAvailableTemplates

      Get available template for specified page
      Parameters:
      pageId - The page's id
      Returns:
      the list of available template
    • 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
    • getAvailableTemplates

      Get available template for specified pages
      Parameters:
      pageIds - The id of pages
      Returns:
      the list of available template
    • 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,Object> getServiceInfo(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,Object> renamePage(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,Object> deletePage(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,Object> deletePage(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,Object> setBlank(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,Object> setTemplate(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,Object> setTemplate(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

      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<String> getTags(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,Object> tag(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,Object> tag(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,Object> tag(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<String> findPagedIdsByTag(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,Object> setVisibility(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

      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<String> getDeleteablePageContentIds(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
    • getUnreferencedContents

      Get the unreferenced contents of a Page or a ZoneItem
      Parameters:
      id - The id of page or zone item
      Returns:
      The list of unreferenced contents
    • getAttachmentsRootNode

      Returns the page's attachments root node
      Parameters:
      id - the page's id
      Returns:
      The attachments' root node informations
    • getPageParents

      Returns the page's parents ids
      Parameters:
      id - the page's id
      Returns:
      The attachments' root node informations
    • getPageContents

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

      public List<Content> getPageContents(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<String> getUserRights(PagesContainer pagesCt)
      Get the user rights on page container (page or sitemap)
      Parameters:
      pagesCt - The pages container
      Returns:
      The user's rights