001/* 002 * (C) Copyright 2006-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.web; 021 022import static org.jboss.seam.ScopeType.CONVERSATION; 023import static org.jboss.seam.ScopeType.EVENT; 024 025import java.io.Serializable; 026import java.util.List; 027 028import org.apache.commons.logging.Log; 029import org.apache.commons.logging.LogFactory; 030import org.jboss.seam.annotations.Factory; 031import org.jboss.seam.annotations.Name; 032import org.jboss.seam.annotations.Scope; 033import org.nuxeo.ecm.core.api.DocumentModel; 034import org.nuxeo.ecm.platform.comment.api.CommentableDocument; 035 036/** 037 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a> 038 */ 039@Name("commentManagerActions") 040@Scope(CONVERSATION) 041public class CommentManagerActionsBean extends AbstractCommentManagerActionsBean implements Serializable { 042 043 private static final Log log = LogFactory.getLog(CommentManagerActionsBean.class); 044 045 private static final long serialVersionUID = 6994714264125958209L; 046 047 protected CommentableDocument getCommentableDoc() { 048 if (commentableDoc == null) { 049 DocumentModel currentDocument = navigationContext.getCurrentDocument(); 050 if (currentDocument == null) { 051 // what can I do? 052 return null; 053 } 054 commentableDoc = currentDocument.getAdapter(CommentableDocument.class); 055 } 056 return commentableDoc; 057 } 058 059 /** 060 * Retrieves the list of comment trees associated with a document and constructs a flat list of comments associated 061 * with their depth (to easily display them with indentation). 062 */ 063 @Factory(value = "documentThreadedComments", scope = EVENT) 064 public List<ThreadEntry> getCommentsAsThread() { 065 return getCommentsAsThread(null); 066 } 067 068}