Package org.ametys.cms.repository
Class ModifiableContentHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.repository.ModifiableContentHelper
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
Provides helper methods to use the
ModifiableContent API on DefaultContents.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolverThe Ametys object resolverstatic final StringConstants for the root of commentsstatic final StringConstants for the root of contributor commentsstatic final StringThe Avalon role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_storeDatetimeMetadata(DefaultContent content, String metadataName, ZonedDateTime date) Store a metadata of type datetime in the contentprotected void_storeUserMetadata(DefaultContent content, String metadataName, UserIdentity user) Store a metadata of type user in the contentvoidcopyTitle(Content srcContent, ModifiableContent targetContent) Copy the title of the source content to the target contentgetCommentsDataHolder(DefaultContent content, boolean createNew) Retrieves the data holder for the given content's commentsgetContentAndCommentId(javax.jcr.Node commentNode) Get the content and the comment identifier from a comment node.getContributorCommentsDataHolder(DefaultContent content, boolean createNew) Retrieves the data holder for the given content's contributor commentsvoidservice(ServiceManager manager) voidsetCreationDate(DefaultContent content, ZonedDateTime creationDate) Set aDefaultContentcreation date.voidsetCreator(DefaultContent content, UserIdentity user) Set aDefaultContentuser.voidsetFirstValidationDate(DefaultContent content, ZonedDateTime validationDate) Set aDefaultContentfirst validation date.voidsetFirstValidator(DefaultContent content, UserIdentity user) Set aDefaultContentfirst validator.voidsetLastContributor(DefaultContent content, UserIdentity user) Set aDefaultContentcontributor.voidsetLastMajorValidationDate(DefaultContent content, ZonedDateTime validationDate) Set aDefaultContentlast major validation date.voidsetLastMajorValidator(DefaultContent content, UserIdentity user) Set aDefaultContentlast major validator.voidsetLastModified(DefaultContent content, ZonedDateTime lastModified) Set aDefaultContentlast modification date.voidsetLastValidationDate(DefaultContent content, ZonedDateTime validationDate) Set aDefaultContentlast validation date.voidsetLastValidator(DefaultContent content, UserIdentity user) Set aDefaultContentlast validator.voidsetOutgoingReferences(DefaultContent content, Map<String, OutgoingReferences> references) Store the outgoing references on the content.voidsetTitle(DefaultContent content, String title) Set the title of non-multilingualDefaultContent.voidsetTitle(DefaultContent content, String title, Locale locale) Set aDefaultContenttitle for the given locale.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
METADATA_COMMENTS
Constants for the root of comments- See Also:
-
METADATA_CONTRIBUTOR_COMMENTS
Constants for the root of contributor comments- See Also:
-
_resolver
The Ametys object resolver
-
-
Constructor Details
-
ModifiableContentHelper
public ModifiableContentHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
setTitle
public void setTitle(DefaultContent content, String title, Locale locale) throws AmetysRepositoryException Set aDefaultContenttitle for the given locale.- Parameters:
content- theDefaultContentto set.title- the title to set.locale- The locale. Can be null if the content is not a multilingual content.- Throws:
AmetysRepositoryException- if an error occurs.
-
setTitle
Set the title of non-multilingualDefaultContent. Be careful! Use only if content's title is not a multilingual string. If not sure usesetTitle(DefaultContent, String, Locale)instead.- Parameters:
content- theDefaultContentto set.title- the title to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
copyTitle
public void copyTitle(Content srcContent, ModifiableContent targetContent) throws AmetysRepositoryException Copy the title of the source content to the target content- Parameters:
srcContent- The source contenttargetContent- The target content- Throws:
AmetysRepositoryException- if an error occurs.
-
setCreator
Set aDefaultContentuser.- Parameters:
content- theDefaultContentto set.user- the user to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setCreationDate
public void setCreationDate(DefaultContent content, ZonedDateTime creationDate) throws AmetysRepositoryException Set aDefaultContentcreation date.- Parameters:
content- theDefaultContentto set.creationDate- the creation date to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastContributor
public void setLastContributor(DefaultContent content, UserIdentity user) throws AmetysRepositoryException Set aDefaultContentcontributor.- Parameters:
content- theDefaultContentto set.user- the contributor to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastModified
public void setLastModified(DefaultContent content, ZonedDateTime lastModified) throws AmetysRepositoryException Set aDefaultContentlast modification date.- Parameters:
content- theDefaultContentto set.lastModified- the last modification date to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setFirstValidator
public void setFirstValidator(DefaultContent content, UserIdentity user) throws AmetysRepositoryException Set aDefaultContentfirst validator.- Parameters:
content- theDefaultContentto set.user- the validator to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setFirstValidationDate
public void setFirstValidationDate(DefaultContent content, ZonedDateTime validationDate) throws AmetysRepositoryException Set aDefaultContentfirst validation date.- Parameters:
content- theDefaultContentto set.validationDate- the first validation date.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastValidator
public void setLastValidator(DefaultContent content, UserIdentity user) throws AmetysRepositoryException Set aDefaultContentlast validator.- Parameters:
content- theDefaultContentto set.user- the validator to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastValidationDate
public void setLastValidationDate(DefaultContent content, ZonedDateTime validationDate) throws AmetysRepositoryException Set aDefaultContentlast validation date.- Parameters:
content- theDefaultContentto set.validationDate- the last validation date.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastMajorValidator
public void setLastMajorValidator(DefaultContent content, UserIdentity user) throws AmetysRepositoryException Set aDefaultContentlast major validator.- Parameters:
content- theDefaultContentto set.user- the validator to set.- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastMajorValidationDate
public void setLastMajorValidationDate(DefaultContent content, ZonedDateTime validationDate) throws AmetysRepositoryException Set aDefaultContentlast major validation date.- Parameters:
content- theDefaultContentto set.validationDate- the last major validation date.- Throws:
AmetysRepositoryException- if an error occurs.
-
setOutgoingReferences
public void setOutgoingReferences(DefaultContent content, Map<String, OutgoingReferences> references) throws AmetysRepositoryExceptionStore the outgoing references on the content.- Parameters:
content- The content concerned by these outgoing references.references- A non null map of outgoing references grouped by metadata (key are metadata path)- Throws:
AmetysRepositoryException- if an error occurs.
-
_storeDatetimeMetadata
protected void _storeDatetimeMetadata(DefaultContent content, String metadataName, ZonedDateTime date) Store a metadata of type datetime in the content- Parameters:
content- the content described by the metadatametadataName- the name of the metadatadate- the value to set- Throws:
AmetysRepositoryException- when an error occurred
-
_storeUserMetadata
protected void _storeUserMetadata(DefaultContent content, String metadataName, UserIdentity user) throws AmetysRepositoryException Store a metadata of type user in the content- Parameters:
content- the content described by the metadatametadataName- the name of the metadatauser- the value to set- Throws:
AmetysRepositoryException- when an error occurred
-
getCommentsDataHolder
public ModifiableModelLessDataHolder getCommentsDataHolder(DefaultContent content, boolean createNew) Retrieves the data holder for the given content's comments- Parameters:
content- the contentcreateNew-trueto create the comments' data holder if it does not already exist,falseotherwise- Returns:
- the data holder for content's comments, or
nullif the data holder does not already exist and createNew is set tofalse
-
getContributorCommentsDataHolder
public ModifiableModelLessDataHolder getContributorCommentsDataHolder(DefaultContent content, boolean createNew) Retrieves the data holder for the given content's contributor comments- Parameters:
content- the contentcreateNew-trueto create the contributor comments' data holder if it does not already exist,falseotherwise- Returns:
- the data holder for content's contributor comments, or
nullif the data holder does not already exist and createNew is set tofalse
-
getContentAndCommentId
Get the content and the comment identifier from a comment node. This supports both comment from contributor and visitor- Parameters:
commentNode- the comment node- Returns:
- the content and the comment id or null if it wasn't possible to retrieve the content
-