Package org.ametys.cms.repository
Class ContentDAO
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.repository.ContentDAO
- All Implemented Interfaces:
Component,Contextualizable,LogEnabled,Serviceable
- Direct Known Subclasses:
HierarchicalReferenceTablesDeleteContentDAO,WebContentDAO
public class ContentDAO
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable
DAO for manipulating contents
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringDeletion status : deletedprotected static final StringDeletion status : lockedprotected static final StringDeletion status : referencedprotected static final StringDeletion status : unauthorizedprotected static final StringDeletion status : undeletedprotected ContentHelperContent helperprotected ContentTypeExtensionPointContent-type extension pointprotected ContentWorkflowHelperWorkflow helper componentprotected ContextCocoon contextprotected ContentTypesHelperContent types helperprotected CurrentUserProviderComponent to get current userprotected HierarchicalReferenceTablesHelperThe helper component for hierarchical simple contentsprotected LockContentManagerComponent to manager lockprotected ModifiableContentHelperThe modifiable content helperprotected ObservationManagerAmetys observation mangerprotected AmetysObjectResolverAmetys resolverprotected RightManagerRights managerprotected TagProviderExtensionPointComponent to get tagsprotected UserHelperHelper for usersprotected UserManagerThe user managerprotected WorkflowProviderWorkflow componentstatic final StringAvalon Role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_addOrRemoveReaction(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType, boolean remove) Add or remove reaction if exists on the given content.protected voidCopy the ACL of a contentprotected void_copyAttachments(Content srcContent, Content targetContent) Copy the attachments of a contentprotected String_getContentDeletionStatus(Content content, String deleteRightId) Get the deletion status of the content : - unauthorized: The content can't be deleted because of rights - locked: The content is locked - referenced: The content has ingoing references_getEventParametersForDeletion(Content content) Get parameters for content deletedEventprotected intGet the invert action id (used for forced deletion).Initialize the result map.protected boolean_isContentReferenced(Content content) Test if content is still referenced before removing itprotected boolean_isTagValid(String tagName, Map<String, Object> contextualParameters) Is the tag a content tagprotected String_reallyDeleteContent(Content content) Delete the content and notify observers.protected void_removeAllTagsInReplaceMode(TaggableAmetysObject mContent, ContentDAO.TagMode tagMode, Set<String> oldTags) Remove all tags from the given content if tagMode is equals to REPLACE.protected boolean_removeReferences(Content content) Remove all the references to the given content._transformContentToParams(Content content) Transform the content to aMapwith id, title and name.booleanDetermines if the current user has right to delete the contentbooleanDetermines if the current user has right to delete the contentvoidcontextualize(Context context) copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, int initWorkflowActionId) Copy a content.copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, String lang, int initWorkflowActionId) Copy a content.copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, String lang, int initWorkflowActionId, boolean notifyObservers, boolean checkpoint, boolean waitAsyncObservers, boolean copyACL) Copy a content.deleteContents(List<String> contentsId) Delete contentsdeleteContents(List<String> contentsId, boolean ignoreRights) Delete contentsdeleteContents(List<String> contentsId, String deleteRightId) Delete contentsforceDeleteContents(List<String> contentsId) Delete contents and force the deletion of invert relations.forceDeleteContentsObj(List<Content> contents, String deleteRightId) Delete contents and force the deletion of invert relations.intforceDeleteContentsWithLog(List<Content> contents, String deleteRightId, Logger logger) Delete contents and force the deletion of invert relations, then log the result.Returns the content's attachments root nodegetContentDescription(String contentId, String workspaceName) Get the content's properties for descriptiongetContentDescription(Content content) Get the content's properties for descriptiongetContentProperties(String contentId, String workspaceName) Get the content propertiesgetContentProperties(Content content) Get the content propertiesgetContentsProperties(List<String> contentIds, String workspaceName) Get the contents propertiesgetContentViews(String contentId, boolean includeInternal) Get the views of a contentprotected StringGet the right to delete a content.Get the tags of contentsgetUserRights(Content content) Get the user rights on contentvoidnotifyContentCopied(Content content, boolean waitAsyncObservers) Notify observers that the content has been createdAdd or remove a reaction on a contentbooleanreact(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType) Add a reaction on aContent.voidAdd a report on a contentvoidservice(ServiceManager smanager) tag(List<String> contentIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag a list of contentsTag a list of contents with the given tagsbooleanunreact(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType) Remove reaction if exists on aContent.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role -
_CONTENT_DELETION_STATUS_DELETED
Deletion status : deleted- See Also:
-
_CONTENT_DELETION_STATUS_UNDELETED
Deletion status : undeleted- See Also:
-
_CONTENT_DELETION_STATUS_REFERENCED
Deletion status : referenced- See Also:
-
_CONTENT_DELETION_STATUS_UNAUTHORIZED
Deletion status : unauthorized- See Also:
-
_CONTENT_DELETION_STATUS_LOCKED
Deletion status : locked- See Also:
-
_resolver
Ametys resolver -
_observationManager
Ametys observation manger -
_currentUserProvider
Component to get current user -
_tagProvider
Component to get tags -
_workflowProvider
Workflow component -
_contentWorkflowHelper
Workflow helper component -
_lockManager
Component to manager lock -
_contentTypeEP
Content-type extension point -
_contentHelper
Content helper -
_cTypesHelper
Content types helper -
_rightManager
Rights manager -
_context
Cocoon context -
_usersManager
The user manager -
_userHelper
Helper for users -
_hierarchicalSimpleContentsHelper
The helper component for hierarchical simple contents -
_modifiableContentHelper
The modifiable content helper
-
-
Constructor Details
-
ContentDAO
public ContentDAO()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
forceDeleteContents
Delete contents and force the deletion of invert relations.- Parameters:
contentsId- The ids of contents to delete- Returns:
- the deleted and undeleted contents
-
forceDeleteContentsObj
Delete contents and force the deletion of invert relations.- Parameters:
contents- The contents to deletedeleteRightId- The deletion right's id to check. Can be null to ignore rights- Returns:
- the deleted and undeleted contents
-
_getInvertActionId
Get the invert action id (used for forced deletion).- Returns:
- The invert action id
-
getRightToDelete
Get the right to delete a content.- Returns:
- The right ID to delete a content
-
_removeReferences
Remove all the references to the given content.- Parameters:
content- The content- Returns:
trueif references have been all removed successfully
-
deleteContents
Delete contents- Parameters:
contentsId- The ids of contents to delete- Returns:
- the deleted and undeleted contents
-
deleteContents
Delete contents- Parameters:
contentsId- The ids of contents to deleteignoreRights- true to ignore user rights- Returns:
- the deleted and undeleted contents
-
deleteContents
Delete contents- Parameters:
contentsId- The ids of contents to deletedeleteRightId- The deletion right's id to check. Can be null to ignore rights- Returns:
- the deleted and undeleted contents
-
_initializeResultsMap
Initialize the result map.- Returns:
- The empty result map.
-
_reallyDeleteContent
Delete the content and notify observers.- Parameters:
content- The content to delete- Returns:
- The deletion status "deleted" or "undeleted" if an exception occurs
-
_transformContentToParams
Transform the content to aMapwith id, title and name.- Parameters:
content- The content to transform- Returns:
- A
Mapwith essentials informations of the content
-
_getContentDeletionStatus
Get the deletion status of the content : - unauthorized: The content can't be deleted because of rights - locked: The content is locked - referenced: The content has ingoing references- Parameters:
content- The contentdeleteRightId- The right ID- Returns:
nullif content deletion can be done or the status if there is something wrong for deletion
-
_isContentReferenced
Test if content is still referenced before removing it- Parameters:
content- The content to remove- Returns:
- true if content is still referenced
-
_getEventParametersForDeletion
Get parameters for content deletedEvent- Parameters:
content- the removed content- Returns:
- the event's parameters
-
getContentsProperties
Get the contents properties- Parameters:
contentIds- The ids of contentsworkspaceName- The workspace name. Can be null to get contents in current workspace.- Returns:
- The contents' properties
-
getContentProperties
Get the content properties- Parameters:
contentId- The id of contentworkspaceName- The workspace name. Can be null to get content in current workspace.- Returns:
- The content's properties
-
getContentProperties
Get the content properties- Parameters:
content- The content- Returns:
- The content properties
-
getContentDescription
Get the content's properties for description- Parameters:
contentId- The id of contentworkspaceName- The workspace name. Can be null to get content in current workspace.- Returns:
- The content's properties for description
-
getContentDescription
Get the content's properties for description- Parameters:
content- The content- Returns:
- The content's properties for description
-
getContentViews
Get the views of a content- Parameters:
contentId- the content's idincludeInternal- Set to true to include internal views.- Returns:
- the views
-
getUserRights
Get the user rights on content- Parameters:
content- The content- Returns:
- The user's rights
-
getTags
Get the tags of contents- Parameters:
contentIds- The content's ids- Returns:
- the tags
-
tag
public Map<String,Object> tag(List<String> contentIds, List<String> tagNames, Map<String, Object> contextualParameters) Tag a list of contents with the given tags- Parameters:
contentIds- The ids of contents to tagtagNames- The tagscontextualParameters- The contextual parameters- Returns:
- the result
-
tag
public Map<String,Object> tag(List<String> contentIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag a list of contents- Parameters:
contentIds- 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
-
_removeAllTagsInReplaceMode
protected void _removeAllTagsInReplaceMode(TaggableAmetysObject mContent, ContentDAO.TagMode tagMode, Set<String> oldTags) Remove all tags from the given content if tagMode is equals to REPLACE.- Parameters:
mContent- The contenttagMode- The tagoldTags- Tags to remove
-
_isTagValid
Is the tag a content tag- Parameters:
tagName- The tag namecontextualParameters- The contextual parameters- Returns:
- true if the tag is a valid content tag
-
copy
public ModifiableContent copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, int initWorkflowActionId) throws AmetysRepositoryException Copy a content.- Parameters:
originalContent- the original content.parent- the object in which to create a content.name- the content name.initWorkflowActionId- The initial workflow action id- Returns:
- the copied content.
- Throws:
AmetysRepositoryException- If an error occured
-
copy
public ModifiableContent copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, String lang, int initWorkflowActionId) throws AmetysRepositoryException Copy a content.- Parameters:
originalContent- the original content.parent- the object in which to create a content.name- the content name.lang- the content language. If null, the content language will be the same of the original contentinitWorkflowActionId- The initial workflow action id- Returns:
- the copied content.
- Throws:
AmetysRepositoryException- If an error occured
-
copy
public ModifiableContent copy(DefaultContent originalContent, ModifiableTraversableAmetysObject parent, String name, String lang, int initWorkflowActionId, boolean notifyObservers, boolean checkpoint, boolean waitAsyncObservers, boolean copyACL) throws AmetysRepositoryException Copy a content.- Parameters:
originalContent- the original content.parent- the object in which to create a content.name- the content name.lang- the content language. If null, the content language will be the same of the original contentinitWorkflowActionId- The initial workflow action idnotifyObservers- Set to false to do not fire observer eventscheckpoint- true to check the content in if it is versionablewaitAsyncObservers- true to wait for asynchronous observers to completecopyACL- true to copy ACL of source content- Returns:
- the copied content.
- Throws:
AmetysRepositoryException- If an error occured
-
_copyAttachments
Copy the attachments of a content- Parameters:
srcContent- The source contenttargetContent- The target content
-
_copyACL
Copy the ACL of a content- Parameters:
srcContent- The source contenttargetContent- The target content
-
notifyContentCopied
public void notifyContentCopied(Content content, boolean waitAsyncObservers) throws com.opensymphony.workflow.WorkflowException Notify observers that the content has been created- Parameters:
content- The content addedwaitAsyncObservers- true to wait for asynchonous observers to finish- Throws:
com.opensymphony.workflow.WorkflowException- If an error occurred
-
getAttachmentsRootNode
Returns the content's attachments root node- Parameters:
id- the content's id- Returns:
- The attachments' root node informations
-
canDelete
Determines if the current user has right to delete the content- Parameters:
content- The content- Returns:
- true if current user is authorized to delete the content
-
canDelete
Determines if the current user has right to delete the content- Parameters:
content- The contentdeleteRightId- The right's id to check for deletion- Returns:
- true if current user is authorized to delete the content
-
react
Add or remove a reaction on a content- Parameters:
contentId- The content idreactionName- the reaction name (ex: LIKE)remove- true to remove the reaction, false to add reaction- Returns:
- the result with the current actors of this reaction
-
react
public boolean react(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType) Add a reaction on aContent.- Parameters:
content- the contentuserIdentity- the issuer of reactionreactionType- the reaction type- Returns:
- true if a change was made
-
unreact
public boolean unreact(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType) Remove reaction if exists on aContent.- Parameters:
content- the contentuserIdentity- the issuer of reactionreactionType- the reaction type- Returns:
trueif a change was made
-
_addOrRemoveReaction
protected boolean _addOrRemoveReaction(Content content, UserIdentity userIdentity, ReactionableObject.ReactionType reactionType, boolean remove) Add or remove reaction if exists on the given content.- Parameters:
content- the contentuserIdentity- the issuer of reactionreactionType- the reaction typeremove-trueif it's to remove the reaction- Returns:
trueif a change was made
-
report
Add a report on a content- Parameters:
content- The content- Throws:
IllegalArgumentException- if the content is not aReportableObjectAccessDeniedException- if the current user has not read access on the given content
-
forceDeleteContentsWithLog
Delete contents and force the deletion of invert relations, then log the result.- Parameters:
contents- The contents to deletedeleteRightId- The deletion right's id to check. Can be null to ignore rightslogger- The logger- Returns:
- the number of deleted contents
-