Package org.ametys.web.repository.page
Class PageDAO
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.web.repository.page.AbstractSitemapElementsDAO
org.ametys.web.repository.page.PageDAO
- All Implemented Interfaces:
Observer
,Initializable
,Component
,LogEnabled
,Serviceable
public class PageDAO
extends AbstractSitemapElementsDAO
implements Component, Initializable, Observer
DAO for manipulating pages
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Constant for untouched binary metadata.static final String
Avalon RoleFields inherited from class org.ametys.web.repository.page.AbstractSitemapElementsDAO
_contentDAO, _contentHelper
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
_isTagValid
(Page page, String tagName) Test if a tag is valid for a specific pageCopy a pagecreatePage
(String parentId, String title, String longTitle) Create a new pagecreatePage
(ModifiableSitemapElement parent, String name, String title, String longTitle) Create a new page blank page.deletePage
(String pageId, boolean deleteBelongingContents) Delete a page and its sub-pages.deletePage
(ModifiablePage page, boolean deleteBelongingContents) Delete a page and its sub-pages.static String
findFreePageName
(TraversableAmetysObject parent, String originalPageName) find a free name under a given parent nodestatic String
findFreePageName
(TraversableAmetysObject parent, String originalPageName, String currentName) find a free name under a given parent nodestatic String
findFreePageNameByTitle
(TraversableAmetysObject parent, String initialTitle) find a free name under a given parent nodestatic String
findFreePageNameByTitle
(TraversableAmetysObject parent, String initialTitle, String currentName) find a free name under a given parent nodestatic String
findFreeTitle
(SitemapElement parent, String initialTitle) find a free title under a given parent nodefindPagedIdsByTag
(String sitename, String lang, String tag) Returns the ids of the pages matching the tagReturns the page's attachments root nodegetAvailableContentTypes
(String pageId, String zoneName) Get available content types for specified pagegetAvailableContentTypesForCreation
(String pageId, String zoneName, String parentId, String pageTitle, String template) Get available content types for a page being createdgetAvailableServices
(String pageId, String zoneName) Get available services for specified pagegetAvailableServicesForCreation
(String pageId, String zoneName, String parentId, String pageTitle, String template) Get available services for a page being createdgetAvailableTemplatesForCreation
(String pageId, String parentId, String pageTitle) Get available content types for a page being createdgetDeleteablePageContentIds
(String pageId, boolean onlyNewlyCreatedContents) Get the contents that belong to thePage
and its sub-pages and that can be deleted.Get the contents of aPage
and its subpages which can be deleted.getPageContents
(SitemapElement sitemapElement) Get the contents of a page and its child pagesgetPageContents
(SitemapElement sitemapElement, boolean ignoreContentsOfNonRemovablePage) Get the contents of a page and its child pagesgetPageInfos
(String pageId) Get the page's propertiesgetPageInfos
(String pageId, String zoneName, String zoneItemId) Get the page's propertiesgetPageInfos
(Page page) Get the page's propertiesgetPageInfos
(Page page, String zoneName, String zoneItemId) Get the page's propertiesgetPageParents
(String id) Returns the page's parents idsgetPageProperties
(String pageId) Get the page's propertiesgetPagesInfos
(List<String> pageIds) Get the properties of given pagesgetPagesInfos
(List<String> pageIds, String zoneName, String zoneItemId) Get the properties of given pagesint
getPriority
(Event event) Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.getServiceInfo
(String pageId, String serviceId) Get service infogetServiceParametersAction
(String serviceId) Get the script class name to execute to add or update this serviceGet the tags from the pagesgetUserRights
(SitemapElement pagesCt) Get the user rights on sitemap element (page or sitemap)boolean
Check current user right on given page or sitemapvoid
Move a pagevoid
Observes an event.Deprecated.renamePage
(String pageId, String title, String longTitle, boolean updatePath, boolean createAlias) Rename a pagevoid
service
(ServiceManager smanager) Set pages as blank pageSet pages as redirectionsetTemplate
(List<String> pageIds, String templateName) Set a template to pagessetTemplate
(List<String> pageIds, String templateName, boolean checkAvailableTemplate) Set a template to pagessetVisibility
(List<String> pageIds, boolean visible) Set the visible of pagesboolean
Checks if the event is supported.tag
(List<String> pageIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag a list of pagestag
(List<String> pageIds, List<String> contentIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag a list of contents and/org pagestag
(List<String> pageIds, List<String> contentIds, List<String> tagNames, Map<String, Object> contextualParameters) Tag a list of contents with the given tagstag
(List<String> pageIds, List<String> tagNames, ContentDAO.TagMode mode, Map<String, Object> contextualParameters, boolean ignoreRights) Tag a list of pagestag
(ModifiablePage page, List<String> tagNames, ContentDAO.TagMode tagMode) Tag a pageMethods inherited from class org.ametys.web.repository.page.AbstractSitemapElementsDAO
_sitemapElement2json
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
__SERVICE_PARAM_UNTOUCHED_BINARY
Constant for untouched binary metadata.- See Also:
-
ROLE
Avalon Role
-
-
Constructor Details
-
PageDAO
public PageDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractSitemapElementsDAO
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getPriority
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 interfaceObserver
- Parameters:
event
- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
supports
Description copied from interface:Observer
Checks if the event is supported. If true, the observe(Event) method will be called. -
observe
Description copied from interface:Observer
Observes an event.- Specified by:
observe
in interfaceObserver
- 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
Get the properties of given pages- Parameters:
pageIds
- the id of pageszoneName
- 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
Get the properties of given pages- Parameters:
pageIds
- the id of pages- Returns:
- the properties of pages in a result map
-
getPageInfos
Get the page's properties- Parameters:
pageId
- the page ID- Returns:
- the properties
-
getPageInfos
Get the page's properties- Parameters:
pageId
- the page IDzoneName
- 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
Get the page's properties- Parameters:
page
- the pagezoneName
- 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
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
Check current user right on given page or sitemap- Parameters:
id
- The id of the page or sitemaprightId
- The if of right to check- Returns:
- true if user has right
-
createPage
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
-
createPage
public ModifiablePage createPage(ModifiableSitemapElement parent, String name, String title, String longTitle) throws IllegalArgumentException Create a new page blank page. In the case wherename
isnull
, the value of title will be used. In all case, the name (or title) will be used to derive the page name (and therefore path by filtering it withNameHelper.filterName(String)
and appending an integer if a page with the same name already exist.- Parameters:
parent
- the sitemap element where the new page is createdname
- the name to use as path for the page. (if null, the title will be used)title
- the title of the pagelongTitle
- the long title of the page- Returns:
- The result map with id of the created page
- Throws:
IllegalArgumentException
- If the provided name (or title) can not be used in URI
-
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 copytarget
- The id of parent target pagekeepReferences
- true to keep references- Returns:
- the result map
- Throws:
javax.jcr.RepositoryException
- if an error occurred during copy
-
findFreePageNameByTitle
find a free name under a given parent node- Parameters:
parent
- The parentinitialTitle
- The title of the page- Returns:
- The free name
-
findFreePageNameByTitle
public static String findFreePageNameByTitle(TraversableAmetysObject parent, String initialTitle, String currentName) find a free name under a given parent node- Parameters:
parent
- The parentinitialTitle
- The title of the pagecurrentName
- The current name of the node, that can thus be authorized- Returns:
- The free name
-
findFreePageName
find a free name under a given parent node- Parameters:
parent
- The parentoriginalPageName
- The name of the page- Returns:
- The free name
-
findFreePageName
public static String findFreePageName(TraversableAmetysObject parent, String originalPageName, String currentName) find a free name under a given parent node- Parameters:
parent
- The parentoriginalPageName
- The name of the pagecurrentName
- The current name of the node, that can thus be authorized- Returns:
- The free name
-
findFreeTitle
find a free title under a given parent node- Parameters:
parent
- The parentinitialTitle
- The title of the page- Returns:
- The free title
-
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 insourceId
- the page to copykeepReferences
- 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
Move a page- Parameters:
id
- The page idparentId
- The id of parent destinationindex
- The position in parent child nodes where page will be inserted. -1 means as the last child.- Returns:
- the result map
-
setLink
Set pages as redirection- Parameters:
pageIds
- the id of pages to modifyurl
- the url of redirectionurlType
- the type of redirection- Returns:
- the id of pages which succeeded or failed.
-
getAvailableContentTypes
Get available content types for specified page- Parameters:
pageId
- The page's idzoneName
- 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 createdzoneName
- the name of the zoneparentId
- The id of parent pagepageTitle
- The title of page to createtemplate
- The template of page to create- Returns:
- the list of available services
-
getAvailableServices
Get available services for specified page- Parameters:
pageId
- The page's idzoneName
- 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 createdzoneName
- the name of the zoneparentId
- The id of parent pagepageTitle
- The title of page to createtemplate
- 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 createdparentId
- The id of parent pagepageTitle
- The title of page to create- Returns:
- the list of available services
-
getServiceInfo
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 renametitle
- The page's titlelongTitle
- The page's long title.updatePath
- true to update page's pathcreateAlias
- true to create a alias- Returns:
- the result map
-
deletePage
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 deletedeleteBelongingContents
- true to delete the contents that belong to the page and its sub-pages only- Returns:
- The id of deleted pages
-
deletePage
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 deletedeleteBelongingContents
- true to delete the contents that belong to the page and its sub-pages only- Returns:
- The id of deleted pages
-
setBlank
Set pages as blank page- Parameters:
pageIds
- the id of pages to modify- Returns:
- the id of pages which succeeded or failed.
-
setTemplate
Set a template to pages- Parameters:
pageIds
- the id of pages to updatetemplateName
- 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 updatetemplateName
- The template namecheckAvailableTemplate
- 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
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 tagtagNames
- The tagsmode
- 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> tagNames, ContentDAO.TagMode mode, Map<String, Object> contextualParameters, boolean ignoreRights) Tag a list of pages- Parameters:
pageIds
- The ids of pages to tagtagNames
- The tagsmode
- 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 nameignoreRights
-true
to ignore rights on tag- Returns:
- the result
-
tag
Tag a page- Parameters:
page
- The page to tagtagNames
- The tagstagMode
- The mode for updating tags: 'REPLACE' to replace tags, 'INSERT' to add tags or 'REMOVE' to remove tags.- Returns:
- the list of invalid tags that were not set
-
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 tagcontentIds
- The ids of contents to tagtagNames
- The tagscontextualParameters
- 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 tagcontentIds
- The ids of contents to tagtagNames
- The tagsmode
- 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
Test if a tag is valid for a specific page- Parameters:
page
- The pagetagName
- The tag name- Returns:
- True if the tag is valid
-
findPagedIdsByTag
Returns the ids of the pages matching the tag- Parameters:
sitename
- The site idlang
- The language codetag
- The tag id- Returns:
- Array of pages ids
-
setVisibility
Set the visible of pages- Parameters:
pageIds
- The id of pagesvisible
-true
to set pages as visible,false
otherwise- Returns:
- The result map
-
getDeleteablePageContents
Get the contents of aPage
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
Get the contents that belong to thePage
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 pageonlyNewlyCreatedContents
- true to return only the newly created contents- Returns:
- The ids of deleteable contents
-
getUnreferencedContents
- 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
Get the contents of a page and its child pages- Parameters:
sitemapElement
- The page- Returns:
- The list of contents
-
getPageContents
public List<Content> getPageContents(SitemapElement sitemapElement, boolean ignoreContentsOfNonRemovablePage) Get the contents of a page and its child pages- Parameters:
sitemapElement
- The pageignoreContentsOfNonRemovablePage
- true to ignore contents of non-removable pages (virtual pages)- Returns:
- The list of contents
-
getUserRights
Get the user rights on sitemap element (page or sitemap)- Parameters:
pagesCt
- The sitemap element- Returns:
- The user's rights
-