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.impl.service; 019 020import org.nuxeo.ecm.platform.publisher.api.PublicationNode; 021import org.nuxeo.ecm.platform.publisher.api.RemotePublicationTreeManager; 022import org.nuxeo.runtime.api.Framework; 023 024/** 025 * Remotable implementation of the {@link PublicationNode} interface. Because some {@link PublicationNode} 026 * implementation may be bound to local resources (network connexions, local filesystem ...) all {@link PublicationNode} 027 * returned by the service are wrapped into this RemotablePublicationNode. 028 * 029 * @author tiry 030 */ 031public class ProxyNode extends AbstractRemotableNode implements PublicationNode { 032 033 private static final long serialVersionUID = 1L; 034 035 protected String nodeType; 036 037 protected String nodeLabel; 038 039 protected String nodePath; 040 041 protected String nodeName; 042 043 public ProxyNode(PublicationNode node, String sid) { 044 nodeType = node.getNodeType(); 045 nodeLabel = node.getTitle(); 046 nodePath = node.getPath(); 047 treeName = node.getTreeConfigName(); 048 nodeName = node.getName(); 049 sessionId = sid; 050 } 051 052 @Override 053 protected RemotePublicationTreeManager getPublisher() { 054 if (service == null) { 055 service = Framework.getService(RemotePublicationTreeManager.class); 056 } 057 return service; 058 } 059 060 public String getTitle() { 061 return nodeLabel; 062 } 063 064 public String getName() { 065 return nodeName; 066 } 067 068 public String getNodeType() { 069 return nodeType; 070 } 071 072 public String getType() { 073 return this.getClass().getSimpleName(); 074 } 075 076 public String getPath() { 077 return nodePath; 078 } 079 080 public String getTreeConfigName() { 081 return treeName; 082 } 083 084 public String getSessionId() { 085 return sessionId; 086 } 087 088 @Override 089 protected String getServerTreeSessionId() { 090 return getSessionId(); 091 } 092 093 @Override 094 protected String getTargetTreeName() { 095 return treeName; 096 } 097 098 @Override 099 protected PublicationNode switchToServerNode(PublicationNode node) { 100 // no wrap 101 return node; 102 } 103 104 @Override 105 protected PublicationNode switchToClientNode(PublicationNode node) { 106 // no wrap 107 return node; 108 } 109 110}