001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *
012 * $Id: IODocumentManager.java 30413 2008-02-21 18:38:54Z sfermigier $
013 */
014
015package org.nuxeo.ecm.core.io;
016
017import java.io.IOException;
018import java.io.InputStream;
019import java.io.OutputStream;
020import java.io.Serializable;
021import java.util.Collection;
022
023import org.nuxeo.ecm.core.api.DocumentRef;
024
025/**
026 * Defines functional interface that deals directly with documents import using provided DocumentReader or InputStream
027 * as a source and DocumentWriter that knows how the documents will be saved into the repository.
028 *
029 * @author <a href="mailto:dm@nuxeo.com">Dragos Mihalache</a>
030 */
031public interface IODocumentManager extends Serializable {
032
033    DocumentTranslationMap importDocuments(InputStream in, String repo, DocumentRef root) throws IOException;
034
035    DocumentTranslationMap importDocuments(InputStream in, DocumentWriter customDocWriter);
036
037    /**
038     * @param customDocReader reader from the input stream
039     * @param customDocWriter
040     */
041    DocumentTranslationMap importDocuments(DocumentReader customDocReader, DocumentWriter customDocWriter);
042
043    DocumentTranslationMap exportDocuments(OutputStream out, String repo, Collection<DocumentRef> sources,
044            boolean recurse, String format);
045
046    /**
047     * Used in pair with importDocuments(... customDocWriter)
048     */
049    DocumentTranslationMap exportDocuments(OutputStream out, DocumentReader customDocReader, String format);
050}