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