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.server; 019 020import org.nuxeo.common.utils.Path; 021import org.nuxeo.ecm.core.api.DocumentModel; 022import org.nuxeo.ecm.core.api.DocumentRef; 023import org.nuxeo.ecm.platform.publisher.api.PublishedDocument; 024import org.nuxeo.ecm.platform.publisher.helper.VersioningHelper; 025import org.nuxeo.ecm.platform.publisher.remoting.marshaling.ExtendedDocumentLocation; 026 027/** 028 * {@link PublishedDocument} implementation that uses a {@link DocumentModel} to store the result of a remote 029 * publication. 030 * 031 * @author tiry 032 */ 033public class ExternalCorePublishedDocument implements PublishedDocument { 034 035 private static final long serialVersionUID = 1L; 036 037 protected String sourceServer; 038 039 protected String repositoryName; 040 041 protected DocumentRef ref; 042 043 protected String versionLabel; 044 045 protected String path; 046 047 protected String parentPath; 048 049 protected boolean isPending; 050 051 public ExternalCorePublishedDocument(DocumentModel doc) { 052 ExtendedDocumentLocation xLoc = ExtendedDocumentLocation.extractFromDoc(doc); 053 this.sourceServer = xLoc.getOriginalServer(); 054 this.repositoryName = xLoc.getServerName(); 055 this.ref = xLoc.getDocRef(); 056 versionLabel = VersioningHelper.getVersionLabelFor(doc); 057 Path p = doc.getPath(); 058 path = p.toString(); 059 parentPath = p.removeLastSegments(1).toString(); 060 } 061 062 public DocumentRef getSourceDocumentRef() { 063 return ref; 064 } 065 066 public String getSourceRepositoryName() { 067 return repositoryName; 068 } 069 070 public String getSourceServer() { 071 return sourceServer; 072 } 073 074 public String getSourceVersionLabel() { 075 return versionLabel; 076 } 077 078 public String getPath() { 079 return path; 080 } 081 082 public String getParentPath() { 083 return parentPath; 084 } 085 086 public boolean isPending() { 087 return isPending; 088 } 089 090 public Type getType() { 091 return Type.REMOTE; 092 } 093 094}