001/*
002 * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.comment.api;
021
022import java.util.List;
023
024import org.nuxeo.ecm.core.api.DocumentModel;
025
026/**
027 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
028 */
029public interface CommentManager {
030
031    List<DocumentModel> getComments(DocumentModel docModel);
032
033    List<DocumentModel> getComments(DocumentModel docModel, DocumentModel parent);
034
035    /**
036     * @deprecated CommentManager cannot find the author if invoked remotely so one should use
037     *             {@link #createComment(DocumentModel, String, String)}
038     */
039    @Deprecated
040    DocumentModel createComment(DocumentModel docModel, String comment);
041
042    /**
043     * Creates a comment document model, filling its properties with given info and linking it to given document.
044     *
045     * @param docModel the document to comment
046     * @param comment the comment content
047     * @param author the comment author
048     * @return the comment document model.
049     */
050    DocumentModel createComment(DocumentModel docModel, String comment, String author);
051
052    DocumentModel createComment(DocumentModel docModel, DocumentModel comment);
053
054    DocumentModel createComment(DocumentModel docModel, DocumentModel parent, DocumentModel child);
055
056    void deleteComment(DocumentModel docModel, DocumentModel comment);
057
058    /**
059     * Gets documents in relation with a particular comment.
060     *
061     * @param comment the comment
062     * @return the list of documents
063     */
064    List<DocumentModel> getDocumentsForComment(DocumentModel comment);
065
066    /**
067     * Gets thread in relation with a given comment (post or comment)
068     *
069     * @param comment
070     * @return
071     * @since 5.5
072     */
073    DocumentModel getThreadForComment(DocumentModel comment);
074
075    /**
076     * Creates a comment document model. It gives opportunity to save the comments in a specified location.
077     *
078     * @param docModel the document to comment
079     * @param comment the comment content
080     * @param path the location path
081     * @return the comment document model.
082     */
083    DocumentModel createLocatedComment(DocumentModel docModel, DocumentModel comment, String path);
084
085}