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