001/*
002 * (C) Copyright 2007 Nuxeo SA (http://nuxeo.com/) and others.
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 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.comment.api;
023
024import java.util.List;
025
026import org.nuxeo.ecm.core.api.DocumentModel;
027
028/**
029 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
030 */
031public interface CommentManager {
032
033    List<DocumentModel> getComments(DocumentModel docModel);
034
035    List<DocumentModel> getComments(DocumentModel docModel, DocumentModel parent);
036
037    /**
038     * @deprecated CommentManager cannot find the author if invoked remotely so one should use
039     *             {@link #createComment(DocumentModel, String, String)}
040     */
041    @Deprecated
042    DocumentModel createComment(DocumentModel docModel, String comment);
043
044    /**
045     * Creates a comment document model, filling its properties with given info and linking it to given document.
046     *
047     * @param docModel the document to comment
048     * @param comment the comment content
049     * @param author the comment author
050     * @return the comment document model.
051     */
052    DocumentModel createComment(DocumentModel docModel, String comment, String author);
053
054    DocumentModel createComment(DocumentModel docModel, DocumentModel comment);
055
056    DocumentModel createComment(DocumentModel docModel, DocumentModel parent, DocumentModel child);
057
058    void deleteComment(DocumentModel docModel, DocumentModel comment);
059
060    /**
061     * Gets documents in relation with a particular comment.
062     *
063     * @param comment the comment
064     * @return the list of documents
065     */
066    List<DocumentModel> getDocumentsForComment(DocumentModel comment);
067
068    /**
069     * Gets thread in relation with a given comment (post or comment)
070     *
071     * @param comment
072     * @return
073     * @since 5.5
074     */
075    DocumentModel getThreadForComment(DocumentModel comment);
076
077    /**
078     * Creates a comment document model. It gives opportunity to save the comments in a specified location.
079     *
080     * @param docModel the document to comment
081     * @param comment the comment content
082     * @param path the location path
083     * @return the comment document model.
084     */
085    DocumentModel createLocatedComment(DocumentModel docModel, DocumentModel comment, String path);
086
087}