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.localfs; 019 020import java.io.IOException; 021import java.util.Map; 022 023import org.dom4j.DocumentException; 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.core.api.NuxeoException; 026import org.nuxeo.ecm.platform.publisher.api.AbstractBasePublishedDocumentFactory; 027import org.nuxeo.ecm.platform.publisher.api.PublicationNode; 028import org.nuxeo.ecm.platform.publisher.api.PublishedDocument; 029import org.nuxeo.ecm.platform.publisher.api.PublishedDocumentFactory; 030 031public class FSPublishedDocumentFactory extends AbstractBasePublishedDocumentFactory implements 032 PublishedDocumentFactory { 033 034 public PublishedDocument publishDocument(DocumentModel doc, PublicationNode targetNode, Map<String, String> params) 035 { 036 037 try { 038 FSPublishedDocument pubDoc = new FSPublishedDocument("local", doc); 039 pubDoc.persist(targetNode.getPath()); 040 return pubDoc; 041 } catch (DocumentException | IOException e) { 042 throw new NuxeoException("Error duning FS Publishing", e); 043 } 044 } 045 046 public PublishedDocument wrapDocumentModel(DocumentModel doc) { 047 try { 048 049 doc = snapshotDocumentBeforePublish(doc); 050 return new FSPublishedDocument("local", doc); 051 } catch (DocumentException e) { 052 throw new NuxeoException("Error while wrapping DocumentModel as FSPublishedDocument", e); 053 } 054 } 055 056}