001/* 002 * (C) Copyright 2009 Nuxeo SA (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 * Thomas Roger 016 */ 017 018package org.nuxeo.ecm.platform.importer.base; 019 020import org.nuxeo.ecm.core.api.repository.RepositoryManager; 021import org.nuxeo.ecm.platform.importer.log.ImporterLogger; 022import org.nuxeo.ecm.platform.importer.source.SourceNode; 023import org.nuxeo.runtime.api.Framework; 024 025/** 026 * Hold the configuration of an ImporterRunner. 027 * 028 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 029 */ 030public class ImporterRunnerConfiguration { 031 032 public static class Builder { 033 private SourceNode sourceNode; 034 035 private String importWritePath; 036 037 private ImporterLogger log; 038 039 private boolean skipRootContainerCreation = false; 040 041 private int batchSize = 50; 042 043 private int nbThreads = 5; 044 045 private String jobName; 046 047 private String repository=null; 048 049 public Builder(SourceNode sourceNode, String importWritePath, ImporterLogger log) { 050 this.sourceNode = sourceNode; 051 this.importWritePath = importWritePath; 052 this.log = log; 053 } 054 055 public Builder skipRootContainerCreation(Boolean skipRootContainerCreation) { 056 if (skipRootContainerCreation != null) { 057 this.skipRootContainerCreation = skipRootContainerCreation; 058 } 059 return this; 060 } 061 062 public Builder repository(String repo) { 063 this.repository = repo; 064 return this; 065 } 066 067 public Builder batchSize(Integer batchSize) { 068 if (batchSize != null) { 069 this.batchSize = batchSize; 070 } 071 return this; 072 } 073 074 public Builder nbThreads(Integer nbThreads) { 075 if (nbThreads != null) { 076 this.nbThreads = nbThreads; 077 } 078 return this; 079 } 080 081 public Builder jobName(String jobName) { 082 if (jobName != null) { 083 this.jobName = jobName; 084 } 085 return this; 086 } 087 088 public ImporterRunnerConfiguration build() { 089 return new ImporterRunnerConfiguration(repository, sourceNode, importWritePath, log, skipRootContainerCreation, 090 batchSize, nbThreads, jobName); 091 } 092 093 } 094 095 public final SourceNode sourceNode; 096 097 public final String importWritePath; 098 099 public final boolean skipRootContainerCreation; 100 101 public final int batchSize; 102 103 public final int nbThreads; 104 105 public final String jobName; 106 107 public final ImporterLogger log; 108 109 public final String repositoryName; 110 111 protected ImporterRunnerConfiguration(String repositoryName, SourceNode sourceNode, String importWritePath, ImporterLogger log, 112 boolean skipRootContainerCreation, int batchSize, int nbThreads, String jobName) { 113 this.sourceNode = sourceNode; 114 this.importWritePath = importWritePath; 115 this.log = log; 116 this.skipRootContainerCreation = skipRootContainerCreation; 117 this.batchSize = batchSize; 118 this.nbThreads = nbThreads; 119 this.jobName = jobName; 120 if (repositoryName!=null) { 121 this.repositoryName = repositoryName; 122 } else { 123 this.repositoryName = Framework.getService(RepositoryManager.class).getDefaultRepositoryName(); 124 } 125 } 126 127}