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:
Component
,LogEnabled
,Serviceable
public class PageDAO extends AbstractLogEnabled implements Serviceable, Component
DAO for manipulating pages
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PageDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private boolean
_canCreate(PagesContainer parentPage)
private boolean
_canDelete(Page page)
private Map<String,Object>
_content2Json(Content content, Locale locale)
private Page
_createPage(PagesContainer parent, String pageTitle, String template)
private List<String>
_getChildrenPageIds(Page page)
private AmetysObjectIterable<Content>
_getIncomingContentReferences(String pageId)
private AmetysObjectIterable<Page>
_getIncomingPageReferences(String pageId)
private Page
_getPageRedirection(Page page)
private boolean
_hasRight(ContentType contentType, Page page)
private boolean
_hasRight(Service service, Page page)
private boolean
_isInfiniteRedirection(Page page, List<String> pagesSequence)
private boolean
_isLocked(Content content)
private boolean
_isNew(Content content)
private boolean
_isPageExist(String id)
private boolean
_isParentInvisible(Page page)
Check each parent and return true if one of them is invisibleprivate boolean
_isPreviewable(Page page)
Determine if this page is previewableprivate boolean
_isReferenced(Content content)
boolean
_isTagValid(Page page, String tagName)
Test if a tag is valid for a specific pageprivate Map<String,Object>
_page2Json(Page page)
private Map<String,Object>
_publication2Json(Page page)
private void
_removeOldZones(ModifiablePage page, String templateName)
private void
_updateContentsAfterCopy(Page createdPage)
private Map<String,Object>
_zone2json(Zone zone)
private Map<String,Object>
_zoneitem2json(ZoneItem zoneItem)
Map<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.Map<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(Page page)
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>
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 sitemapMap<String,Object>
movePage(String id, String parentId, int index)
Move a pageMap<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 pagesMap<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
-
_resolver
private AmetysObjectResolver _resolver
-
_observationManager
private ObservationManager _observationManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_skinsManager
private SkinsManager _skinsManager
-
_templatesHandler
private TemplatesAssignmentHandler _templatesHandler
-
_serviceHandler
private ServicesAssignmentHandler _serviceHandler
-
_cTypeHandler
private ContentTypesAssignmentHandler _cTypeHandler
-
_contentTypeExtensionPoint
private ContentTypeExtensionPoint _contentTypeExtensionPoint
-
_serviceExtensionPoint
private ServiceExtensionPoint _serviceExtensionPoint
-
_workflowProvider
private WorkflowProvider _workflowProvider
-
_sharedContentManager
private SharedContentManager _sharedContentManager
-
_tagProvider
private TagProviderExtensionPoint _tagProvider
-
_webLanguagesManager
private WebLanguagesManager _webLanguagesManager
-
_contentDAO
private WebContentDAO _contentDAO
-
_copySiteComponent
private CopySiteComponent _copySiteComponent
-
_rightManager
private RightManager _rightManager
-
_synchronizeComponent
private SynchronizeComponent _synchronizeComponent
-
_repository
private Repository _repository
-
_pageDataTypeExtensionPoint
private PageDataTypeExtensionPoint _pageDataTypeExtensionPoint
-
-
Constructor Detail
-
PageDAO
public PageDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
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(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
-
_canCreate
private boolean _canCreate(PagesContainer parentPage)
-
_canDelete
private boolean _canDelete(Page page)
-
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
-
_hasRight
private boolean _hasRight(ContentType contentType, Page page)
-
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
-
_createPage
private Page _createPage(PagesContainer parent, String pageTitle, String template)
-
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
-
_removeOldZones
private void _removeOldZones(ModifiablePage page, String templateName)
-
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
-
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
-
_isReferenced
private boolean _isReferenced(Content content)
-
_page2Json
private Map<String,Object> _page2Json(Page page)
-
_publication2Json
private Map<String,Object> _publication2Json(Page page)
-
_getIncomingContentReferences
private AmetysObjectIterable<Content> _getIncomingContentReferences(String pageId)
-
_getIncomingPageReferences
private AmetysObjectIterable<Page> _getIncomingPageReferences(String pageId)
-
_zone2json
private Map<String,Object> _zone2json(Zone zone)
-
_zoneitem2json
private Map<String,Object> _zoneitem2json(ZoneItem zoneItem)
-
_updateContentsAfterCopy
private void _updateContentsAfterCopy(Page createdPage) throws AmetysRepositoryException
- Throws:
AmetysRepositoryException
-
_getChildrenPageIds
private List<String> _getChildrenPageIds(Page page)
-
_isParentInvisible
private boolean _isParentInvisible(Page page)
Check each parent and return true if one of them is invisible- Parameters:
page
- page to check- Returns:
- true if at least one parent is invisible
-
_isPreviewable
private boolean _isPreviewable(Page page)
Determine if this page is previewable- Parameters:
page
- The page to look at- Returns:
- true if the page can be previewed
-
_isPageExist
private boolean _isPageExist(String id)
-
_isInfiniteRedirection
private boolean _isInfiniteRedirection(Page page, List<String> pagesSequence)
-
_getPageRedirection
private Page _getPageRedirection(Page page)
-
-