Package org.ametys.web.repository.page
Class PageDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.web.repository.page.PageDAO
-
- All Implemented Interfaces:
Observer
,Initializable
,Component
,LogEnabled
,Serviceable
public class PageDAO extends AbstractLogEnabled implements Serviceable, Component, Initializable, Observer
DAO for manipulating pages
-
-
Field Summary
Fields Modifier and Type Field Description static String
__SERVICE_PARAM_UNTOUCHED_BINARY
Constant for untouched binary metadata.static String
ROLE
Avalon Role-
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description PageDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
_isTagValid(Page page, String tagName)
Test if a tag is valid for a specific pageMap<String,String>
copyPage(String id, String target, boolean keepReferences)
Copy a pageMap<String,Object>
createPage(String parentId, String title, String longTitle)
Create a new pageMap<String,Object>
deletePage(String pageId, boolean deleteBelongingContents)
Delete a page and its sub-pages.Map<String,Object>
deletePage(ModifiablePage page, boolean deleteBelongingContents)
Delete a page and its sub-pages.List<String>
findPagedIdsByTag(String sitename, String lang, String tag)
Returns the ids of the pages matching the tagMap<String,Object>
getAttachmentsRootNode(String id)
Returns the page's attachments root nodeList<Map<String,Object>>
getAvailableContentTypes(String pageId, String zoneName)
Get available content types for specified pageList<Map<String,Object>>
getAvailableContentTypesForCreation(String pageId, String zoneName, String parentId, String pageTitle, String template)
Get available content types for a page being createdList<Map<String,Object>>
getAvailableServices(String pageId, String zoneName)
Get available services for specified pageList<Map<String,Object>>
getAvailableServicesForCreation(String pageId, String zoneName, String parentId, String pageTitle, String template)
Get available services for a page being createdList<Map<String,Object>>
getAvailableTemplates(String pageId)
Get available template for specified pageList<Map<String,Object>>
getAvailableTemplates(List<String> pageIds)
Get available template for specified pagesList<Map<String,Object>>
getAvailableTemplatesForCreation(String pageId, String parentId, String pageTitle)
Get available content types for a page being createdList<String>
getDeleteablePageContentIds(String pageId, boolean onlyNewlyCreatedContents)
Get the contents that belong to thePage
and its sub-pages and that can be deleted.Map<String,Object>
getDeleteablePageContents(String id)
Get the contents of aPage
and its subpages which can be deleted.List<Content>
getPageContents(Page page)
Get the contents of a page and its child pagesList<Content>
getPageContents(Page page, boolean ignoreContentsOfNonRemovablePage)
Get the contents of a page and its child pagesMap<String,Object>
getPageInfos(String pageId)
Get the page's propertiesMap<String,Object>
getPageInfos(String pageId, String zoneName, String zoneItemId)
Get the page's propertiesMap<String,Object>
getPageInfos(Page page)
Get the page's propertiesMap<String,Object>
getPageInfos(Page page, String zoneName, String zoneItemId)
Get the page's propertiesMap<String,Object>
getPageParents(String id)
Returns the page's parents idsMap<String,Object>
getPageProperties(String pageId)
Get the page's propertiesMap<String,Object>
getPagesInfos(List<String> pageIds)
Get the properties of given pagesMap<String,Object>
getPagesInfos(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.Map<String,Object>
getServiceInfo(String pageId, String serviceId)
Get service infoString
getServiceParametersAction(String serviceId)
Get the script class name to execute to add or update this serviceSet<String>
getTags(List<String> pageIds)
Get the tags from the pagesList<Map<String,Object>>
getUnreferencedContents(String id)
protected Set<String>
getUserRights(PagesContainer pagesCt)
Get the user rights on page container (page or sitemap)boolean
hasRight(String id, String rightId)
Check current user right on given page or sitemapvoid
initialize()
Map<String,Object>
movePage(String id, String parentId, int index)
Move a pagevoid
observe(Event event, Map<String,Object> transientVars)
Observes an event.Map<String,String>
pastePage(String targetId, String sourceId, boolean keepReferences)
Deprecated.Map<String,Object>
renamePage(String pageId, String title, String longTitle, boolean updatePath, boolean createAlias)
Rename a pagevoid
service(ServiceManager smanager)
Map<String,Object>
setBlank(List<String> pageIds)
Set pages as blank pageMap<String,Object>
setLink(List<String> pageIds, String url, String urlType)
Set pages as redirectionMap<String,Object>
setTemplate(List<String> pageIds, String templateName)
Set a template to pagesMap<String,Object>
setTemplate(List<String> pageIds, String templateName, boolean checkAvailableTemplate)
Set a template to pagesMap<String,Object>
setVisibility(List<String> pageIds, boolean visible)
Set the visible of pagesboolean
supports(Event event)
Checks if the event is supported.Map<String,Object>
tag(List<String> pageIds, List<String> tagNames, String mode, Map<String,Object> contextualParameters)
Tag a list of pagesMap<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 pagesMap<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-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__SERVICE_PARAM_UNTOUCHED_BINARY
public static final String __SERVICE_PARAM_UNTOUCHED_BINARY
Constant for untouched binary metadata.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PageDAO
public PageDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- 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 interfaceObserver
- 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.
-
observe
public void observe(Event event, Map<String,Object> transientVars) throws Exception
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
public Map<String,Object> getPagesInfos(List<String> pageIds, String zoneName, String zoneItemId)
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
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 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
public Map<String,Object> getPageInfos(Page page, String zoneName, String zoneItemId)
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
public Map<String,Object> getPageInfos(Page page)
Get the page's properties- Parameters:
page
- the page- Returns:
- the properties
-
getPageProperties
public Map<String,Object> getPageProperties(String pageId)
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 sitemaprightId
- 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 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:
RepositoryException
- if an error occurred during copy
-
pastePage
@Deprecated public Map<String,String> pastePage(String targetId, String sourceId, boolean keepReferences) throws 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:
RepositoryException
- if an error occurs
-
movePage
public Map<String,Object> movePage(String id, String parentId, int index)
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
public Map<String,Object> setLink(List<String> pageIds, String url, String urlType)
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.
-
getAvailableTemplates
public List<Map<String,Object>> getAvailableTemplates(String pageId)
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 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
public List<Map<String,Object>> getAvailableServices(String pageId, String zoneName)
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
-
getAvailableTemplates
public List<Map<String,Object>> getAvailableTemplates(List<String> pageIds)
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 createdparentId
- The id of parent pagepageTitle
- 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 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
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 deletedeleteBelongingContents
- 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 deletedeleteBelongingContents
- 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 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
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<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 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> 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
public boolean _isTagValid(Page page, String tagName)
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
public List<String> findPagedIdsByTag(String sitename, String lang, String tag)
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
public Map<String,Object> setVisibility(List<String> pageIds, boolean visible)
Set the visible of pages- Parameters:
pageIds
- The id of pagesvisible
-true
to set pages as visible,false
otherwise- Returns:
- The result map
-
getDeleteablePageContents
public Map<String,Object> getDeleteablePageContents(String id)
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
public List<String> getDeleteablePageContentIds(String pageId, boolean onlyNewlyCreatedContents)
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
public List<Map<String,Object>> getUnreferencedContents(String id)
- Parameters:
id
- The id of page or zone item- Returns:
- The list of unreferenced contents
-
getAttachmentsRootNode
public Map<String,Object> getAttachmentsRootNode(String id)
Returns the page's attachments root node- Parameters:
id
- the page's id- Returns:
- The attachments' root node informations
-
getPageParents
public Map<String,Object> getPageParents(String id)
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 pageignoreContentsOfNonRemovablePage
- 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
-
-