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     * @return
042     */
043    public List<DocumentModel> importDocuments(DocumentModel root, File source) throws IOException;
044
045
046    /**
047     * Imports {@link DocumentModel} in Nuxeo from an XML Stream.
048     *
049     * @param root target container {@link DocumentModel}
050     * @param xmlStream stream source for Xml contnt
051     * @return
052     */
053    public List<DocumentModel> importDocuments(DocumentModel root, InputStream xmlStream) throws IOException;
054
055    /**
056     * Same as {@link #importDocuments(DocumentModel, File)} with map injected into mvel contexts used during parsing
057     *
058     * @param root target container {@link DocumentModel}
059     * @param source source file, can be XML or Zip with XML index
060     * @param mvelContext Context added each time a mvel expression is resolved
061     * @return
062     */
063    public List<DocumentModel> importDocuments(DocumentModel root, File source, Map<String, Object> mvelContext)
064            throws IOException;
065
066    /**
067     * Same as {@link #importDocuments(DocumentModel, InputStream)} with map injected into mvel contexts used during
068     * parsing
069     *
070     * @param root target container {@link DocumentModel}
071     * @param xmlStream stream source for Xml contnt
072     * @param mvelContext Context added each time a mvel expression is resolved
073     * @return
074     */
075    public List<DocumentModel> importDocuments(DocumentModel root, InputStream xmlStream,
076            Map<String, Object> mvelContext) throws IOException;
077
078    public List<DocumentModel> importDocuments(DocumentModel root, File source, Map<String, Object> mvelContext,
079                        boolean deferSave) throws IOException;
080
081    /**
082     * Imports {@link DocumentModel} in Nuxeo from an XML or a Zip archive.
083     *
084     * @param root target container {@link DocumentModel}
085     * @param source source file, can be XML or Zip with XML index
086     * @param deferSave if true, do not save docs in docsStack during processing, save them after full parse of xml doc
087     * @since 7.4
088     * @return
089     */
090    public List<DocumentModel> importDocuments(DocumentModel root, File source, boolean deferSave) throws IOException;
091
092}