001/*
002 *  Copyright 2021 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.List;
021
022import org.ametys.cms.repository.comment.AbstractComment;
023import org.ametys.plugins.repository.AmetysRepositoryException;
024
025/**
026 * A commentable ametys object
027 * @param <T> type of the referenced model item
028 */
029public interface CommentableAmetysObject<T extends AbstractComment>
030{
031    /**
032     * Creates a comment
033     * @return The new comment
034     */
035    public T createComment();
036    
037    /**
038     * Creates a comment with the given id and creation date
039     * This method allow to create a comment from existing data (ex: data import from archive) 
040     * The id is not generated here, the source is trusted. Be careful using this method
041     * @param commentId the comment's id
042     * @param creationDate the comment's creation date
043     * @return the new comment
044     */
045    public T createComment(String commentId, ZonedDateTime creationDate);
046    
047    /**
048     * Get a comment
049     * @param commentId The comment
050     * @return The comment
051     * @throws AmetysRepositoryException if  error occurs
052     */
053    public T getComment(String commentId) throws AmetysRepositoryException;
054
055    /**
056     * Get the list of available comments (validated, not validated, both or none :))
057     * @param includeNotValidatedComments true to get the non validated comments.
058     * @param includeValidatedComments true to get the validated comment.
059     * @return A non null list of comments on the ametys object.
060     * @throws AmetysRepositoryException if an error occurred
061     */
062    public List<T> getComments(boolean includeNotValidatedComments, boolean includeValidatedComments) throws AmetysRepositoryException;
063}