001/*
002 *  Copyright 2010 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016
017package org.ametys.cms.repository;
018
019import java.time.ZonedDateTime;
020import java.util.Locale;
021import java.util.Map;
022
023import org.w3c.dom.Node;
024
025import org.ametys.cms.content.references.OutgoingReferences;
026import org.ametys.cms.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject;
027import org.ametys.core.user.UserIdentity;
028import org.ametys.plugins.repository.AmetysRepositoryException;
029import org.ametys.plugins.repository.RemovableAmetysObject;
030import org.ametys.plugins.repository.data.extractor.xml.XMLValuesExtractorAdditionalDataGetter;
031import org.ametys.plugins.repository.dublincore.ModifiableDublinCoreAwareAmetysObject;
032import org.ametys.plugins.repository.metadata.ModifiableMetadataAwareAmetysObject;
033import org.ametys.plugins.repository.tag.TaggableAmetysObject;
034
035/**
036 * Modifiable content abstraction 
037 */
038public interface ModifiableContent extends Content, ModifiableModelAwareDataAwareAmetysObject, ModifiableMetadataAwareAmetysObject, ModifiableDublinCoreAwareAmetysObject, RemovableAmetysObject, TaggableAmetysObject
039{
040    /**
041     * Set the title from the given locale
042     * @param title the title.
043     * @param locale The locale
044     * @throws AmetysRepositoryException if an error occurs.
045     */
046    public void setTitle(String title, Locale locale) throws AmetysRepositoryException;
047    
048    /**
049     * Set the title.
050     * Be careful ! Use only if content's title is not a multilingual string. If not sure use {@link #setTitle(String, Locale)} instead.
051     * @param title the title.
052     * @throws AmetysRepositoryException if an error occurs.
053     */
054    public void setTitle(String title) throws AmetysRepositoryException;
055    
056    /**
057     * Set the login of the creator.
058     * @param user the creator.
059     * @throws AmetysRepositoryException if an error occurs.
060     */
061    public void setCreator(UserIdentity user) throws AmetysRepositoryException;
062
063    /**
064     * Set the creation date.
065     * @param creationDate the creation date.
066     * @throws AmetysRepositoryException if an error occurs.
067     */
068    public void setCreationDate(ZonedDateTime creationDate) throws AmetysRepositoryException;
069
070    /**
071     * Set the login of the last contributor.
072     * @param user the last contributor.
073     * @throws AmetysRepositoryException if an error occurs.
074     */
075    public void setLastContributor(UserIdentity user) throws AmetysRepositoryException;
076
077    /**
078     * Set the last modification date.
079     * @param lastModified the last modification date.
080     * @throws AmetysRepositoryException if an error occurs.
081     */
082    public void setLastModified(ZonedDateTime lastModified) throws AmetysRepositoryException;
083    
084    /**
085     * Set the identity of the first validator.
086     * @param user the first validator.
087     * @throws AmetysRepositoryException if an error occurs.
088     */
089    public void setFirstValidator(UserIdentity user) throws AmetysRepositoryException;
090    
091    /**
092     * Set the first validation date
093     * @param validationDate the validation date.
094     * @throws AmetysRepositoryException if an error occurs.
095     */
096    public void setFirstValidationDate(ZonedDateTime validationDate) throws AmetysRepositoryException;
097    
098    /**
099     * Set the identity of the last validator.
100     * @param user the last validator.
101     * @throws AmetysRepositoryException if an error occurs.
102     */
103    public void setLastValidator(UserIdentity user) throws AmetysRepositoryException;
104    
105    /**
106     * Set the last validation date
107     * @param validationDate the validation date.
108     * @throws AmetysRepositoryException if an error occurs.
109     */
110    public void setLastValidationDate (ZonedDateTime validationDate) throws AmetysRepositoryException;
111    
112    /**
113     * Set the identity of the last major validator.
114     * @param user the last major validator.
115     * @throws AmetysRepositoryException if an error occurs.
116     */
117    public void setLastMajorValidator(UserIdentity user) throws AmetysRepositoryException;
118    
119    /**
120     * Set the last validation date resulting from a major modification
121     * @param validationDate the validation date.
122     * @throws AmetysRepositoryException if an error occurs.
123     */
124    public void setLastMajorValidationDate (ZonedDateTime validationDate) throws AmetysRepositoryException;
125    
126    /**
127     * Store the outgoing references of the content.
128     * @param references A non null map of outgoing references grouped by metadata (key are metadata path)
129     * @throws AmetysRepositoryException if an error occurs.
130     */
131    public void setOutgoingReferences(Map<String, OutgoingReferences> references) throws AmetysRepositoryException;
132    
133    /**
134     * Fills the current content with the values from the provided {@link Node}.
135     * <br>This is the anti-operation of {@link Content#toSAX}, as the Node should be a Node previously generated with SAX events from this method.
136     * @param node The node to read for retrieving values to fill
137     * @param additionalDataGetter The object that will retrieve potential additional data for the content's attributes
138     * @throws Exception if an exception occurs
139     */
140    public void fillContent(Node node, XMLValuesExtractorAdditionalDataGetter additionalDataGetter) throws Exception;
141}