001/*
002 * (C) Copyright 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 *     Thierry Delprat
018 */
019package org.nuxeo.ecm.platform.importer.xml.parser;
020
021import java.io.File;
022import java.io.IOException;
023import java.io.InputStream;
024import java.util.List;
025import java.util.Map;
026
027import org.nuxeo.ecm.core.api.DocumentModel;
028
029/**
030 * Interface for importer service
031 *
032 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
033 */
034public interface XMLImporterService {
035
036    /**
037     * Imports {@link DocumentModel} in Nuxeo from an XML or a Zip archive.
038     *
039     * @param root target container {@link DocumentModel}
040     * @param source source file, can be XML or Zip with XML index
041     */
042    List<DocumentModel> importDocuments(DocumentModel root, File source) throws IOException;
043
044
045    /**
046     * Imports {@link DocumentModel} in Nuxeo from an XML Stream.
047     *
048     * @param root target container {@link DocumentModel}
049     * @param xmlStream stream source for Xml contnt
050     */
051    List<DocumentModel> importDocuments(DocumentModel root, InputStream xmlStream) throws IOException;
052
053    /**
054     * Same as {@link #importDocuments(DocumentModel, File)} with map injected into mvel contexts used during parsing
055     *
056     * @param root target container {@link DocumentModel}
057     * @param source source file, can be XML or Zip with XML index
058     * @param mvelContext Context added each time a mvel expression is resolved
059     */
060    List<DocumentModel> importDocuments(DocumentModel root, File source, Map<String, Object> mvelContext)
061            throws IOException;
062
063    /**
064     * Same as {@link #importDocuments(DocumentModel, InputStream)} with map injected into mvel contexts used during
065     * parsing
066     *
067     * @param root target container {@link DocumentModel}
068     * @param xmlStream stream source for Xml contnt
069     * @param mvelContext Context added each time a mvel expression is resolved
070     */
071    List<DocumentModel> importDocuments(DocumentModel root, InputStream xmlStream,
072            Map<String, Object> mvelContext) throws IOException;
073
074    List<DocumentModel> importDocuments(DocumentModel root, File source, Map<String, Object> mvelContext,
075                        boolean deferSave) throws IOException;
076
077    /**
078     * Imports {@link DocumentModel} in Nuxeo from an XML or a Zip archive.
079     *
080     * @param root target container {@link DocumentModel}
081     * @param source source file, can be XML or Zip with XML index
082     * @param deferSave if true, do not save docs in docsStack during processing, save them after full parse of xml doc
083     * @since 7.4
084     */
085    List<DocumentModel> importDocuments(DocumentModel root, File source, boolean deferSave) throws IOException;
086
087}