001/* 002 * (C) Copyright 2006-2008 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 * Nuxeo - initial API and implementation 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.importer.executor; 021 022import org.apache.commons.logging.Log; 023import org.apache.commons.logging.LogFactory; 024import org.nuxeo.ecm.platform.importer.base.GenericMultiThreadedImporter; 025import org.nuxeo.ecm.platform.importer.base.ImporterRunner; 026import org.nuxeo.ecm.platform.importer.source.FileSourceNode; 027import org.nuxeo.ecm.platform.importer.source.SourceNode; 028 029/** 030 * Default importer 031 * 032 * @author Thierry Delprat 033 */ 034public class DefaultImporterExecutor extends AbstractImporterExecutor { 035 036 private static final Log log = LogFactory.getLog(DefaultImporterExecutor.class); 037 038 protected GenericMultiThreadedImporter importer = null; 039 040 protected String repositoryName; 041 042 public DefaultImporterExecutor() { 043 } 044 045 public DefaultImporterExecutor(String repositoryName) { 046 this.repositoryName=repositoryName; 047 } 048 049 @Override 050 protected Log getJavaLogger() { 051 return log; 052 } 053 054 public long getCreatedDocsCounter() { 055 return GenericMultiThreadedImporter.getCreatedDocsCounter(); 056 } 057 058 public String run(String inputPath, String targetPath, Boolean skipRootContainerCreation, Integer batchSize, 059 Integer nbTheards, Boolean interactive) { 060 SourceNode source = new FileSourceNode(inputPath); 061 return run(source, targetPath, skipRootContainerCreation, batchSize, nbTheards, interactive); 062 } 063 064 public String run(SourceNode source, String targetPath, Boolean skipRootContainerCreation, Integer batchSize, 065 Integer nbTheards, Boolean interactive) { 066 importer = new GenericMultiThreadedImporter(source, targetPath, skipRootContainerCreation, batchSize, 067 nbTheards, getLogger()); 068 importer.setFactory(getFactory()); 069 importer.setThreadPolicy(getThreadPolicy()); 070 importer.setTransactionTimeout(getTransactionTimeout()); 071 return doRun(importer, interactive); 072 } 073 074 @Override 075 public String run(ImporterRunner runner, Boolean interactive) { 076 return doRun(runner, interactive); 077 } 078 079}