001/* 002 * (C) Copyright 2007-2016 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 */ 019package org.nuxeo.ecm.platform.comment.impl; 020 021import java.util.List; 022 023import org.nuxeo.ecm.core.api.DocumentModel; 024import org.nuxeo.ecm.platform.comment.api.CommentManager; 025import org.nuxeo.ecm.platform.comment.api.CommentableDocument; 026import org.nuxeo.runtime.api.Framework; 027 028/** 029 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a> 030 */ 031public class CommentableDocumentAdapter implements CommentableDocument { 032 033 private static final long serialVersionUID = 2996381735762615450L; 034 035 final DocumentModel docModel; 036 037 public CommentableDocumentAdapter(DocumentModel docModel) { 038 this.docModel = docModel; 039 } 040 041 public DocumentModel addComment(DocumentModel comment) { 042 CommentManager commentManager = Framework.getService(CommentManager.class); 043 return commentManager.createComment(docModel, comment); 044 } 045 046 public DocumentModel addComment(DocumentModel parent, DocumentModel comment) { 047 CommentManager commentManager = Framework.getService(CommentManager.class); 048 return commentManager.createComment(docModel, parent, comment); 049 } 050 051 public void removeComment(DocumentModel comment) { 052 CommentManager commentManager = Framework.getService(CommentManager.class); 053 commentManager.deleteComment(docModel, comment); 054 } 055 056 public List<DocumentModel> getComments() { 057 CommentManager commentManager = Framework.getService(CommentManager.class); 058 return commentManager.getComments(docModel); 059 } 060 061 public List<DocumentModel> getComments(DocumentModel parent) { 062 CommentManager commentManager = Framework.getService(CommentManager.class); 063 return commentManager.getComments(docModel, parent); 064 } 065 066}