001/* 002 * (C) Copyright 2006-2009 Nuxeo SA (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 016 */ 017 018package org.nuxeo.ecm.platform.publisher.remoting.marshaling.basic; 019 020import org.nuxeo.common.utils.Path; 021import org.nuxeo.ecm.core.api.NuxeoException; 022import org.nuxeo.ecm.platform.publisher.api.PublicationNode; 023import org.nuxeo.ecm.platform.publisher.api.PublishedDocument; 024 025import java.util.List; 026 027/** 028 * Java implementation for the marshaled {@link PublicationNode}. 029 * 030 * @author tiry 031 */ 032public class BasicPublicationNode implements PublicationNode { 033 034 private static final long serialVersionUID = 1L; 035 036 protected String nodeType; 037 038 protected String nodePath; 039 040 protected String nodeTitle; 041 042 protected String treeName; 043 044 protected String sid; 045 046 public BasicPublicationNode(String nodeType, String nodePath, String nodeTitle, String treeName) { 047 this(nodeType, nodePath, nodeTitle, treeName, null); 048 } 049 050 public BasicPublicationNode(String nodeType, String nodePath, String nodeTitle, String treeName, String sid) { 051 this.nodePath = nodePath; 052 this.nodeType = nodeType; 053 this.nodeTitle = nodeTitle; 054 this.treeName = treeName; 055 this.sid = sid; 056 } 057 058 public List<PublishedDocument> getChildrenDocuments() { 059 throw new NuxeoException("Can not be called on a remote node"); 060 } 061 062 public List<PublicationNode> getChildrenNodes() { 063 throw new NuxeoException("Can not be called on a remote node"); 064 } 065 066 public String getNodeType() { 067 return nodeType; 068 } 069 070 public PublicationNode getParent() { 071 return null; 072 } 073 074 public String getPath() { 075 return nodePath; 076 } 077 078 public String getTitle() { 079 return nodeTitle; 080 } 081 082 public String getName() { 083 if (nodePath == null) { 084 return null; 085 } 086 return new Path(nodePath).lastSegment(); 087 } 088 089 public String getTreeConfigName() { 090 return treeName; 091 } 092 093 public String getSessionId() { 094 return sid; 095 } 096 097 public String getType() { 098 return this.getClass().getSimpleName(); 099 } 100 101}