001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (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 * <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 016 * 017 * $Id: IOManager.java 30145 2008-02-13 16:56:56Z dmihalache $ 018 */ 019 020package org.nuxeo.ecm.platform.io.api; 021 022import java.io.IOException; 023import java.io.InputStream; 024import java.io.OutputStream; 025import java.io.Serializable; 026import java.util.Collection; 027import java.util.Map; 028 029import org.nuxeo.ecm.core.api.DocumentLocation; 030import org.nuxeo.ecm.core.api.DocumentRef; 031 032/** 033 * Service handling complex import/export of documents and associated resources. 034 * 035 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 036 */ 037public interface IOManager extends Serializable { 038 039 String DOCUMENTS_ADAPTER_NAME = "documents"; 040 041 /** 042 * Returns the adapter with given name. 043 */ 044 IOResourceAdapter getAdapter(String name); 045 046 /** 047 * Adds an adapter with given name and definition. 048 */ 049 void addAdapter(String name, IOResourceAdapter adapter); 050 051 /** 052 * Removes adapter with given name. 053 */ 054 void removeAdapter(String name); 055 056 /** 057 * Import document and resources described by given input stream at given document location. 058 * 059 * @param in stream representing the documents and resources to import. Can be a zip file of a group of export 060 * files. The service is responsible for unzipping and redirecting import to specific import services. 061 * @param repo the repository name. 062 * @param root Optional location of document that must be taken as root of the import (can be null). 063 */ 064 void importDocumentsAndResources(InputStream in, String repo, DocumentRef root) throws IOException; 065 066 /** 067 * Export documents and resources. 068 * 069 * @param out stream that can be turned into a zip holding a group of file for each additional resources types. 070 * @param repo TODO 071 * @param sources locations of documents to export. 072 * @param recurse recurse into sources children 073 * @param format export format. XXX see what format is actually accepted. 074 * @param ioAdapters list of adapters to use for additional resources. 075 */ 076 void exportDocumentsAndResources(OutputStream out, String repo, Collection<DocumentRef> sources, boolean recurse, 077 String format, Collection<String> ioAdapters) throws IOException; 078 079 /** 080 * Copy documents and resources to another location (on a same machine). 081 * 082 * @param repo the initial repository name. 083 * @param sources locations of documents to export. 084 * @param targetLocation location of the document where copies must be placed. 085 * @param ioAdapters list of adapters to use for additional resources. 086 * @return the list of copied documents references. 087 */ 088 Collection<DocumentRef> copyDocumentsAndResources(String repo, Collection<DocumentRef> sources, 089 DocumentLocation targetLocation, Collection<String> ioAdapters); 090 091 void importFromStream(InputStream in, DocumentLocation targetLocation, String docReaderFactoryClassName, 092 Map<String, Object> rFactoryParams, String docWriterFactoryClassName, Map<String, Object> wFactoryParams); 093 094}