001/*
002 * (C) Copyright 2011 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 *    Mariana Cedica
018 */
019package org.nuxeo.ecm.platform.importer.service;
020
021import org.nuxeo.ecm.platform.importer.executor.AbstractImporterExecutor;
022import org.nuxeo.ecm.platform.importer.factories.DefaultDocumentModelFactory;
023import org.nuxeo.ecm.platform.importer.factories.ImporterDocumentModelFactory;
024import org.nuxeo.ecm.platform.importer.log.ImporterLogger;
025import org.nuxeo.ecm.platform.importer.source.SourceNode;
026
027/**
028 * Allows basic configuration of the default importer :
029 * <p>
030 * Allows configuration of the a DocumentModelFactory and the document types it creates ( if no implementation is
031 * contributed, <code>DefaultDocumentModelFactory</code> is used;
032 * <p>
033 * Also allows configuration of the SourceNode implementation; if none is provided the
034 * <code>FileSourceNode<code>> it's used by default
035 */
036public interface DefaultImporterService {
037
038    /**
039     * Imports documents using a DefaultImporterExecutor and the contributed documentModelFactory and SourceNode
040     * implementations; If no documentModelFactory implementation was contributed to the service,
041     * <code>DefaultDocumentModelFactory</code> it's used If no SourceNode implementation was contributed to the
042     * service, <code>FileSourceNode</code> it's used
043     *
044     * @param destionationPath
045     * @param sourcePath
046     * @param skipRootContainerCreation
047     * @param batchSize
048     * @param noImportingThreads
049     */
050    void importDocuments(String destionationPath, String sourcePath, boolean skipRootContainerCreation, int batchSize,
051            int noImportingThreads);
052
053    /***
054     * Imports documents using a the given executor and the contributed documentModelFactory and SourceNode
055     * implementations; If no documentModelFactory implementation was contributed to the service,
056     * <code>DefaultDocumentModelFactory</code> it's used If no SourceNode implementation was contributed to the
057     * service, <code>FileSourceNode</code> it's used
058     *
059     * @param executor
060     * @param destinationPath
061     * @param sourcePath
062     * @param skipRootContainerCreation
063     * @param batchSize
064     * @param noImportingThreads
065     * @param interactive
066     */
067    String importDocuments(AbstractImporterExecutor executor, String destinationPath, String sourcePath,
068            boolean skipRootContainerCreation, int batchSize, int noImportingThreads, boolean interactive);
069
070    /***
071     * Imports documents using a the given executor and the contributed documentModelFactory and SourceNode
072     * implementations; Allows to overwrite the leaf and folderish types used by the documentModelFactory when
073     * importing; if one of them is not specified then the contributed one is used If no documentModelFactory
074     * implementation was contributed to the service, <code>DefaultDocumentModelFactory</code> it's used If no
075     * SourceNode implementation was contributed to the service, <code>FileSourceNode</code> it's used
076     *
077     * @param executor
078     * @param destinationPath
079     * @param sourcePath
080     * @param skipRootContainerCreation
081     * @param batchSize
082     * @param noImportingThreads
083     * @param interactive
084     */
085    String importDocuments(AbstractImporterExecutor executor, String leafType, String folderishType,
086            String destinationPath, String sourcePath, boolean skipRootContainerCreation, int batchSize,
087            int noImportingThreads, boolean interactive);
088
089    void setSourceNodeClass(Class<? extends SourceNode> sourceNodeClass);
090
091    void setDocModelFactoryClass(Class<? extends ImporterDocumentModelFactory> docModelFactoryClass);
092
093    void setLeafDocType(String fileDocType);
094
095    void setFolderishDocType(String folderishDocType);
096
097    void setImporterLogger(ImporterLogger importerLogger);
098
099    /**
100     * @since 5.9.4
101     */
102    void setTransactionTimeout(int transactionTimeout);
103
104    /**
105     * @since 7.1
106     * @param repositoryName
107     */
108    void setRepository(String repositoryName);
109
110    /**
111     * Added waiting the importer refactoring. Only used by Scan Importer.
112     *
113     * @since 5.7.3
114     */
115    @Deprecated
116    Class<? extends SourceNode> getSourceNodeClass();
117
118    /**
119     * Added waiting the importer refactoring. Only used by Scan Importer.
120     *
121     * @since 5.7.3
122     */
123    @Deprecated
124    Class<? extends ImporterDocumentModelFactory> getDocModelFactoryClass();
125
126    /**
127     * Sets the bulk mode for the importer.
128     *
129     * @param bulkMode {@code true} to enable bulk mode (default), or {@code false} to disable it
130     * @since 8.3
131     */
132    void setBulkMode(boolean bulkMode);
133
134    /**
135     * Sets whether or not the GenericMultiThreadedImporter should log performance metrics
136     *
137     * @param enablePerfLogging
138     * @since 9.3
139     */
140    void setEnablePerfLogging(boolean enablePerfLogging);
141
142    /**
143     * Gets the enablePerfLogging value used by the GenericMultiThreadImporter. Only used by Scan Importer and JAXRS
144     * Importer.
145     *
146     * @since 9.3
147     */
148    boolean getEnablePerfLogging();
149
150}