Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DataCleaner (community edition) Copyright (C) 2014 Neopost - Customer Information Management This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU Lesser General Public License, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this distribution; if not, write to: Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
  
  package org.datacleaner.configuration;
  
  import java.io.File;
  import java.util.Deque;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  
 
Configuration reader that uses the JAXB model to read XML file based configurations for DataCleaner.
 
 public final class JaxbConfigurationReader implements ConfigurationReader<InputStream> {
 
     private static final Logger logger = LoggerFactory.getLogger(JaxbConfigurationReader.class);
 
     public static final String ENCODED_PASSWORD_PREFIX = "enc:";
 
     private final JAXBContext _jaxbContext;
     private final Deque<String_variablePathBuilder;
 
     public JaxbConfigurationReader() {
         this(null);
     }
 
     public JaxbConfigurationReader(ConfigurationReaderInterceptor configurationReaderCallback) {
         if (configurationReaderCallback == null) {
             configurationReaderCallback = new DefaultConfigurationReaderInterceptor();
         }
          = configurationReaderCallback;
          = new ArrayDeque<String>(4);
         try {
              = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(),
                     ObjectFactory.class.getClassLoader());
         } catch (JAXBException e) {
             throw new IllegalStateException(e);
         }
     }
 
     @Override
     public DataCleanerConfiguration read(InputStream input) {
         return create(input);
     }
 
     public DataCleanerConfiguration create(FileObject file) {
         InputStream inputStream = null;
         try {
             inputStream = file.getContent().getInputStream();
             return create(inputStream);
         } catch (FileSystemException e) {
             throw new IllegalArgumentException(e);
         } finally {
             FileHelper.safeClose(inputStream);
         }
     }
 
     public DataCleanerConfiguration create(File file) {
         InputStream inputStream = null;
         try {
             inputStream = new BufferedInputStream(new FileInputStream(file));
             return create(inputStream);
         } catch (FileNotFoundException e) {
             throw new IllegalArgumentException(e);
         } finally {
             FileHelper.safeClose(inputStream);
         }
     }
 
     public DataCleanerConfiguration create(InputStream inputStream) {
         Configuration configuration = unmarshall(inputStream);
         return create(configuration);
     }

    
Convenience method to get the untouched JAXB configuration object from an inputstream.

Parameters:
inputStream
Returns:
 
     public Configuration unmarshall(InputStream inputStream) {
         try {
             final Unmarshaller unmarshaller = .createUnmarshaller();
             unmarshaller.setEventHandler(new JaxbValidationEventHandler());
 
             final Configuration configuration = (Configurationunmarshaller.unmarshal(inputStream);
             return configuration;
         } catch (JAXBException e) {
             throw new IllegalStateException(e);
         }
     }

    
Convenience method to marshal a JAXB configuration object into an output stream.

Parameters:
configuration
outputStream
 
     public void marshall(Configuration configurationOutputStream outputStream) {
         try {
             final Marshaller marshaller = .createMarshaller();
             marshaller.setProperty(..);
             marshaller.setEventHandler(new JaxbValidationEventHandler());
             marshaller.marshal(configurationoutputStream);
         } catch (JAXBException e) {
             throw new IllegalStateException(e);
         }
     }
 
     public DataCleanerConfiguration create(Configuration jaxbConfiguration) {
         final ConfigurationMetadataType metadata = jaxbConfiguration.getConfigurationMetadata();
         if (metadata != null) {
             .info("Configuration name: {}"metadata.getConfigurationName());
             .info("Configuration version: {}"metadata.getConfigurationVersion());
             .info("Configuration description: {}"metadata.getConfigurationDescription());
             .info("Author: {}"metadata.getAuthor());
             .info("Created date: {}"metadata.getCreatedDate());
             .info("Updated date: {}"metadata.getUpdatedDate());
         }
 
         final DataCleanerHomeFolder homeFolder = .getHomeFolder();
 
         // create temporary environment and configuration objects - they will be
         // passed along during building of the final ones.
         final TemporaryMutableDataCleanerEnvironment temporaryEnvironment = new TemporaryMutableDataCleanerEnvironment(
                 .createBaseEnvironment());
         DataCleanerConfigurationImpl temporaryConfiguration = new DataCleanerConfigurationImpl(temporaryEnvironment,
                 homeFolder);
 
         // update the temporary environment if overrides are specified in
         // configuration file.
         updateTaskRunnerIfSpecified(jaxbConfigurationtemporaryEnvironmenttemporaryConfiguration);
         updateStorageProviderIfSpecified(jaxbConfigurationtemporaryEnvironmenttemporaryConfiguration);
         updateDescriptorProviderIfSpecified(jaxbConfigurationtemporaryEnvironmenttemporaryConfiguration);
 
         // add datastore catalog
         final DatastoreCatalog datastoreCatalog;
         {
             addVariablePath("datastoreCatalog");
             datastoreCatalog = createDatastoreCatalog(jaxbConfiguration.getDatastoreCatalog(), temporaryConfiguration,
                     temporaryEnvironment);
             removeVariablePath();
 
             temporaryConfiguration = temporaryConfiguration.withDatastoreCatalog(datastoreCatalog);
         }
 
         // add reference data catalog
         final ReferenceDataCatalog referenceDataCatalog;
         {
             addVariablePath("referenceDataCatalog");
             referenceDataCatalog = createReferenceDataCatalog(jaxbConfiguration.getReferenceDataCatalog(),
                     temporaryEnvironmenttemporaryConfiguration);
             removeVariablePath();
         }
 
         final DataCleanerEnvironmentImpl finalEnvironment = new DataCleanerEnvironmentImpl(temporaryEnvironment);
         final DataCleanerConfigurationImpl dataCleanerConfiguration = new DataCleanerConfigurationImpl(
                 finalEnvironmenthomeFolderdatastoreCatalogreferenceDataCatalog);
 
         return dataCleanerConfiguration;
     }
 
     private void updateDescriptorProviderIfSpecified(Configuration jaxbConfiguration,
             TemporaryMutableDataCleanerEnvironment environmentDataCleanerConfiguration temporaryConfiguration) {
         final DescriptorProvider descriptorProvider = createDescriptorProvider(jaxbConfigurationenvironment,
                 temporaryConfiguration);
         if (descriptorProvider != null) {
             environment.setDescriptorProvider(descriptorProvider);
         }
     }
 
             DataCleanerEnvironment environmentDataCleanerConfiguration temporaryConfiguration) {
         final DescriptorProvider descriptorProvider;
         final CustomElementType customDescriptorProviderElement = configuration.getCustomDescriptorProvider();
         final ClasspathScannerType classpathScannerElement = configuration.getClasspathScanner();
         if (customDescriptorProviderElement != null) {
             descriptorProvider = createCustomElement(customDescriptorProviderElementDescriptorProvider.class,
                     temporaryConfigurationtrue);
         } else {
             final Collection<Class<? extends RenderingFormat<?>>> excludedRenderingFormats = new HashSet<Class<? extends RenderingFormat<?>>>();
             if (classpathScannerElement != null) {
                 final List<StringexcludedRenderingFormatList = classpathScannerElement.getExcludedRenderingFormat();
                 for (String excludedRenderingFormat : excludedRenderingFormatList) {
                     try {
                         @SuppressWarnings("unchecked")
                         Class<? extends RenderingFormat<?>> cls = (Class<? extends RenderingFormat<?>>) 
                                 .loadClass(excludedRenderingFormat);
                         excludedRenderingFormats.add(cls);
                     } catch (ClassNotFoundException e) {
                         .error("Could not find excluded rendering format class: " + excludedRenderingFormate);
                     }
                 }
             }
 
             final ClasspathScanDescriptorProvider classpathScanner = new ClasspathScanDescriptorProvider(
                     environment.getTaskRunner(), excludedRenderingFormats);
             if (classpathScannerElement != null) {
                 final List<Packagepackages = classpathScannerElement.getPackage();
                 for (Package pkg : packages) {
                     String packageName = pkg.getValue();
                     if (packageName != null) {
                         packageName = packageName.trim();
                         Boolean recursive = pkg.isRecursive();
                         if (recursive == null) {
                             recursive = true;
                         }
                         classpathScanner.scanPackage(packageNamerecursive);
                     }
                 }
             }
             descriptorProvider = classpathScanner;
         }
 
         return descriptorProvider;
     }
 
     private void updateStorageProviderIfSpecified(Configuration configuration,
             TemporaryMutableDataCleanerEnvironment environmentDataCleanerConfiguration temporaryConfiguration) {
         final StorageProviderType storageProviderType = configuration.getStorageProvider();
 
         if (storageProviderType == null) {
             return;
         }
 
         final StorageProvider storageProvider = createStorageProvider(storageProviderTypeenvironment,
                 temporaryConfiguration);
         environment.setStorageProvider(storageProvider);
     }
 
     private StorageProvider createStorageProvider(StorageProviderType storageProviderType,
             DataCleanerEnvironment environmentDataCleanerConfiguration temporaryConfiguration) {
 
         final CombinedStorageProviderType combinedStorageProvider = storageProviderType.getCombined();
         if (combinedStorageProvider != null) {
             final StorageProviderType collectionsStorage = combinedStorageProvider.getCollectionsStorage();
             final StorageProviderType rowAnnotationStorage = combinedStorageProvider.getRowAnnotationStorage();
 
             final StorageProvider collectionsStorageProvider = createStorageProvider(collectionsStorageenvironment,
                     temporaryConfiguration);
             final StorageProvider rowAnnotationStorageProvider = createStorageProvider(rowAnnotationStorage,
                     environmenttemporaryConfiguration);
 
             return new CombinedStorageProvider(collectionsStorageProviderrowAnnotationStorageProvider);
         }
 
         final InMemoryStorageProviderType inMemoryStorageProvider = storageProviderType.getInMemory();
         if (inMemoryStorageProvider != null) {
             int maxRowsThreshold = inMemoryStorageProvider.getMaxRowsThreshold();
             return new InMemoryStorageProvider(maxRowsThreshold);
         }
 
         final CustomElementType customStorageProvider = storageProviderType.getCustomStorageProvider();
         if (customStorageProvider != null) {
             return createCustomElement(customStorageProviderStorageProvider.classtemporaryConfigurationtrue);
         }
 
         final BerkeleyDbStorageProviderType berkeleyDbStorageProvider = storageProviderType.getBerkeleyDb();
         if (berkeleyDbStorageProvider != null) {
             final File parentDirectory = new File(.getTemporaryStorageDirectory());
             final BerkeleyDbStorageProvider storageProvider = new BerkeleyDbStorageProvider(parentDirectory);
             final Boolean cleanDirectoryOnStartup = berkeleyDbStorageProvider.isCleanDirectoryOnStartup();
             if (cleanDirectoryOnStartup != null && cleanDirectoryOnStartup.booleanValue()) {
                 storageProvider.cleanDirectory();
             }
             return storageProvider;
         }
 
         final HsqldbStorageProviderType hsqldbStorageProvider = storageProviderType.getHsqldb();
         if (hsqldbStorageProvider != null) {
             String directoryPath = hsqldbStorageProvider.getTempDirectory();
             if (directoryPath == null) {
                 directoryPath = .getTemporaryStorageDirectory();
             }
 
             directoryPath = createFilename(directoryPath);
 
             if (directoryPath == null) {
                 return new HsqldbStorageProvider();
             } else {
                 return new HsqldbStorageProvider(directoryPath);
             }
         }
 
         final H2StorageProviderType h2StorageProvider = storageProviderType.getH2Database();
         if (h2StorageProvider != null) {
             String directoryPath = h2StorageProvider.getTempDirectory();
             if (directoryPath == null) {
                 directoryPath = .getTemporaryStorageDirectory();
             }
 
             directoryPath = createFilename(directoryPath);
 
             if (directoryPath == null) {
                 return new H2StorageProvider();
             } else {
                 return new H2StorageProvider(directoryPath);
             }
         }
 
         throw new IllegalStateException("Unknown storage provider type: " + storageProviderType);
     }
 
     @SuppressWarnings("deprecation")
     private String createFilename(String filename) {
         return .createFilename(filename);
     }
 
             DataCleanerEnvironment environmentDataCleanerConfiguration temporaryConfiguration) {
         final List<DictionarydictionaryList = new ArrayList<Dictionary>();
         final List<SynonymCatalogsynonymCatalogList = new ArrayList<SynonymCatalog>();
 
         final List<StringPatternstringPatterns = new ArrayList<StringPattern>();
 
         if (referenceDataCatalog != null) {
 
             final Dictionaries dictionaries = referenceDataCatalog.getDictionaries();
             if (dictionaries != null) {
                 for (Object dictionaryType : dictionaries
                         .getTextFileDictionaryOrValueListDictionaryOrDatastoreDictionary()) {
                     if (dictionaryType instanceof DatastoreDictionaryType) {
                         final DatastoreDictionaryType ddt = (DatastoreDictionaryTypedictionaryType;
 
                         final String name = ddt.getName();
                         checkName(nameDictionary.classdictionaryList);
 
                         addVariablePath(name);
 
                         final String dsName = getStringVariable("datastoreName"ddt.getDatastoreName());
                         final String columnPath = getStringVariable("columnPath"ddt.getColumnPath());
 
                         final DatastoreDictionary dict = new DatastoreDictionary(namedsNamecolumnPath);
                         dict.setDescription(ddt.getDescription());
 
                         dictionaryList.add(dict);
 
                         removeVariablePath();
 
                     } else if (dictionaryType instanceof TextFileDictionaryType) {
                         final TextFileDictionaryType tfdt = (TextFileDictionaryTypedictionaryType;
 
                         final String name = tfdt.getName();
                         checkName(nameDictionary.classdictionaryList);
 
                         addVariablePath(name);
 
                         String filenamePath = getStringVariable("filename"tfdt.getFilename());
                         String filename = createFilename(filenamePath);
                         String encoding = getStringVariable("encoding"tfdt.getEncoding());
                         if (encoding == null) {
                             encoding = .;
                         }
 
                         final TextFileDictionary dict = new TextFileDictionary(namefilenameencoding);
                         dict.setDescription(tfdt.getDescription());
                         dictionaryList.add(dict);
 
                         removeVariablePath();
                     } else if (dictionaryType instanceof ValueListDictionaryType) {
                         final ValueListDictionaryType vldt = (ValueListDictionaryTypedictionaryType;
 
                         final String name = vldt.getName();
                         checkName(nameDictionary.classdictionaryList);
 
                         final List<Stringvalues = vldt.getValue();
                         final SimpleDictionary dict = new SimpleDictionary(namevalues);
                         dict.setDescription(vldt.getDescription());
                         dictionaryList.add(dict);
                     } else if (dictionaryType instanceof CustomElementType) {
                         final Dictionary customDictionary = createCustomElement((CustomElementTypedictionaryType,
                                 Dictionary.classtemporaryConfigurationfalse);
                         checkName(customDictionary.getName(), Dictionary.classdictionaryList);
                         dictionaryList.add(customDictionary);
                     } else {
                         throw new IllegalStateException("Unsupported dictionary type: " + dictionaryType);
                     }
                 }
             }
 
             final SynonymCatalogs synonymCatalogs = referenceDataCatalog.getSynonymCatalogs();
             if (synonymCatalogs != null) {
                 for (Object synonymCatalogType : synonymCatalogs
                         .getTextFileSynonymCatalogOrDatastoreSynonymCatalogOrCustomSynonymCatalog()) {
                     if (synonymCatalogType instanceof TextFileSynonymCatalogType) {
                         final TextFileSynonymCatalogType tfsct = (TextFileSynonymCatalogTypesynonymCatalogType;
 
                         final String name = tfsct.getName();
                         checkName(nameSynonymCatalog.classsynonymCatalogList);
 
                         addVariablePath(name);
 
                         final String filenamePath = getStringVariable("filename"tfsct.getFilename());
                         final String filename = createFilename(filenamePath);
                         String encoding = getStringVariable("encoding"tfsct.getEncoding());
                         if (encoding == null) {
                             encoding = .;
                         }
                         final boolean caseSensitive = getBooleanVariable("caseSensitive"tfsct.isCaseSensitive(), true);
                         final TextFileSynonymCatalog sc = new TextFileSynonymCatalog(namefilenamecaseSensitive,
                                 encoding);
                         sc.setDescription(tfsct.getDescription());
                         synonymCatalogList.add(sc);
 
                         removeVariablePath();
 
                     } else if (synonymCatalogType instanceof CustomElementType) {
                         final SynonymCatalog customSynonymCatalog = createCustomElement(
                                 (CustomElementTypesynonymCatalogTypeSynonymCatalog.classtemporaryConfiguration,
                                 false);
                         checkName(customSynonymCatalog.getName(), SynonymCatalog.classsynonymCatalogList);
                         synonymCatalogList.add(customSynonymCatalog);
                     } else if (synonymCatalogType instanceof DatastoreSynonymCatalogType) {
                         final DatastoreSynonymCatalogType datastoreSynonymCatalogType = (DatastoreSynonymCatalogTypesynonymCatalogType;
 
                         final String name = datastoreSynonymCatalogType.getName();
                         checkName(nameSynonymCatalog.classsynonymCatalogList);
 
                         addVariablePath(name);
 
                         final String dataStoreName = getStringVariable("datastoreName",
                                 datastoreSynonymCatalogType.getDatastoreName());
                         final String masterTermColumnPath = getStringVariable("masterTermColumnPath",
                                 datastoreSynonymCatalogType.getMasterTermColumnPath());
 
                         final String[] synonymColumnPaths = datastoreSynonymCatalogType.getSynonymColumnPath().toArray(
                                 new String[0]);
                         final DatastoreSynonymCatalog sc = new DatastoreSynonymCatalog(namedataStoreName,
                                 masterTermColumnPathsynonymColumnPaths);
                         sc.setDescription(datastoreSynonymCatalogType.getDescription());
                         synonymCatalogList.add(sc);
 
                         removeVariablePath();
                     } else {
                         throw new IllegalStateException("Unsupported synonym catalog type: " + synonymCatalogType);
                     }
                 }
             }
 
             final StringPatterns stringPatternTypes = referenceDataCatalog.getStringPatterns();
             if (stringPatternTypes != null) {
                 for (Object obj : stringPatternTypes.getRegexPatternOrSimplePattern()) {
                     if (obj instanceof RegexPatternType) {
                         final RegexPatternType regexPatternType = (RegexPatternTypeobj;
 
                         final String name = regexPatternType.getName();
                         checkName(nameStringPattern.classstringPatterns);
 
                         addVariablePath(name);
 
                         final String expression = getStringVariable("expression"regexPatternType.getExpression());
                         final boolean matchEntireString = getBooleanVariable("matchEntireString",
                                 regexPatternType.isMatchEntireString(), true);
                         final RegexStringPattern sp = new RegexStringPattern(nameexpressionmatchEntireString);
                         sp.setDescription(regexPatternType.getDescription());
                         stringPatterns.add(sp);
 
                         removeVariablePath();
                     } else if (obj instanceof SimplePatternType) {
                         final SimplePatternType simplePatternType = (SimplePatternTypeobj;
 
                         final String name = simplePatternType.getName();
                         checkName(nameStringPattern.classstringPatterns);
 
                         addVariablePath(name);
 
                         final String expression = getStringVariable("expression"simplePatternType.getExpression());
                         final SimpleStringPattern sp = new SimpleStringPattern(nameexpression);
                         sp.setDescription(simplePatternType.getDescription());
                         stringPatterns.add(sp);
 
                         removeVariablePath();
                     } else {
                         throw new IllegalStateException("Unsupported string pattern type: " + obj);
                     }
                 }
             }
         }
 
         return new ReferenceDataCatalogImpl(dictionaryListsynonymCatalogListstringPatterns);
     }
 
     private DatastoreCatalog createDatastoreCatalog(DatastoreCatalogType datastoreCatalogType,
             DataCleanerConfigurationImpl temporaryConfigurationDataCleanerEnvironment environment) {
         final Map<StringDatastoredatastores = new HashMap<StringDatastore>();
 
         // read all single, non-custom datastores
         final List<AbstractDatastoreTypedatastoreTypes = datastoreCatalogType
                 .getJdbcDatastoreOrAccessDatastoreOrCsvDatastore();
         for (AbstractDatastoreType datastoreType : datastoreTypes) {
             final String name = datastoreType.getName();
             checkName(nameDatastore.classdatastores);
             addVariablePath(name);
 
             final Datastore ds;
             if (datastoreType instanceof CsvDatastoreType) {
                 ds = createDatastore(name, (CsvDatastoreTypedatastoreType);
             } else if (datastoreType instanceof JdbcDatastoreType) {
                 ds = createDatastore(name, (JdbcDatastoreTypedatastoreType);
             } else if (datastoreType instanceof FixedWidthDatastoreType) {
                 ds = createDatastore(name, (FixedWidthDatastoreTypedatastoreType);
             } else if (datastoreType instanceof SasDatastoreType) {
                 ds = createDatastore(name, (SasDatastoreTypedatastoreType);
             } else if (datastoreType instanceof AccessDatastoreType) {
                 ds = createDatastore(name, (AccessDatastoreTypedatastoreType);
             } else if (datastoreType instanceof XmlDatastoreType) {
                 ds = createDatastore(name, (XmlDatastoreTypedatastoreType);
             } else if (datastoreType instanceof ExcelDatastoreType) {
                 ds = createDatastore(name, (ExcelDatastoreTypedatastoreType);
             } else if (datastoreType instanceof JsonDatastoreType) {
                 ds = createDatastore(name, (JsonDatastoreTypedatastoreType);
             } else if (datastoreType instanceof DbaseDatastoreType) {
                 ds = createDatastore(name, (DbaseDatastoreTypedatastoreType);
             } else if (datastoreType instanceof OpenOfficeDatabaseDatastoreType) {
                 ds = createDatastore(name, (OpenOfficeDatabaseDatastoreTypedatastoreType);
             } else if (datastoreType instanceof PojoDatastoreType) {
                 ds = createDatastore(name, (PojoDatastoreTypedatastoreTypetemporaryConfiguration);
             } else if (datastoreType instanceof CouchdbDatastoreType) {
                 ds = createDatastore(name, (CouchdbDatastoreTypedatastoreType);
             } else if (datastoreType instanceof MongodbDatastoreType) {
                 ds = createDatastore(name, (MongodbDatastoreTypedatastoreType);
             } else if (datastoreType instanceof ElasticSearchDatastoreType) {
                 ds = createDatastore(name, (ElasticSearchDatastoreTypedatastoreType);
             } else if (datastoreType instanceof CassandraDatastoreType) {
                 ds = createDatastore(name, (CassandraDatastoreTypedatastoreType);
             } else if (datastoreType instanceof HbaseDatastoreType) {
                 ds = createDatastore(name, (HbaseDatastoreTypedatastoreType);
             } else if (datastoreType instanceof SalesforceDatastoreType) {
                 ds = createDatastore(name, (SalesforceDatastoreTypedatastoreType);
             } else if (datastoreType instanceof SugarCrmDatastoreType) {
                 ds = createDatastore(name, (SugarCrmDatastoreTypedatastoreType);
             } else if (datastoreType instanceof CompositeDatastoreType) {
                 // skip composite datastores at this point
                 continue;
             } else {
                 throw new UnsupportedOperationException("Unsupported datastore type: " + datastoreType);
             }
 
             final String datastoreDescription = datastoreType.getDescription();
             ds.setDescription(datastoreDescription);
 
             removeVariablePath();
             datastores.put(nameds);
         }
 
         // create custom datastores
         final List<CustomElementTypecustomDatastores = datastoreCatalogType.getCustomDatastore();
         for (CustomElementType customElementType : customDatastores) {
             Datastore ds = createCustomElement(customElementTypeDatastore.classtemporaryConfigurationtrue);
             String name = ds.getName();
             checkName(nameDatastore.classdatastores);
             datastores.put(nameds);
         }
 
         // create composite datastores as the last step
         final List<CompositeDatastoreTypecompositeDatastores = CollectionUtils2.filterOnClass(datastoreTypes,
                 CompositeDatastoreType.class);
         for (CompositeDatastoreType compositeDatastoreType : compositeDatastores) {
             String name = compositeDatastoreType.getName();
             checkName(nameDatastore.classdatastores);
 
             List<StringdatastoreNames = compositeDatastoreType.getDatastoreName();
             List<DatastorechildDatastores = new ArrayList<Datastore>(datastoreNames.size());
             for (String datastoreName : datastoreNames) {
                 Datastore datastore = datastores.get(datastoreName);
                 if (datastore == null) {
                     throw new IllegalStateException("No such datastore: " + datastoreName
                             + " (found in composite datastore: " + name + ")");
                 }
                 childDatastores.add(datastore);
             }
 
             CompositeDatastore ds = new CompositeDatastore(namechildDatastores);
             ds.setDescription(compositeDatastoreType.getDescription());
             datastores.put(nameds);
         }
 
         final DatastoreCatalogImpl result = new DatastoreCatalogImpl(datastores.values());
         return result;
     }
 
     private Datastore createDatastore(String nameCassandraDatastoreType datastoreType) {
 
         final String hostname = getStringVariable("hostname"datastoreType.getHostname());
         Integer port = getIntegerVariable("port"datastoreType.getPort());
         if (port == null) {
             port = .;
         }
         final String keySpace = getStringVariable("keyspace"datastoreType.getKeyspace());
         final String username = getStringVariable("username"datastoreType.getUsername());
         final String password = getPasswordVariable("password"datastoreType.getPassword());
         final boolean ssl = getBooleanVariable("ssl"datastoreType.isSsl(), false);
 
         final List<org.datacleaner.configuration.jaxb.CassandraDatastoreType.TableDeftableDefList = datastoreType
                 .getTableDef();
         final SimpleTableDef[] tableDefs;
         if (tableDefList == null || tableDefList.isEmpty()) {
             tableDefs = null;
         } else {
             tableDefs = new SimpleTableDef[tableDefList.size()];
             for (int i = 0; i < tableDefs.lengthi++) {
                 final org.datacleaner.configuration.jaxb.CassandraDatastoreType.TableDef tableDef = tableDefList.get(i);
                 final String tableName = tableDef.getTableName();
                 final List<org.datacleaner.configuration.jaxb.CassandraDatastoreType.TableDef.ColumncolumnList = tableDef
                         .getColumn();
 
                 final String[] columnNames = new String[columnList.size()];
                 final ColumnType[] columnTypes = new ColumnType[columnList.size()];
 
                 for (int j = 0; j < columnTypes.lengthj++) {
                     final String propertyName = columnList.get(j).getName();
                     final String propertyTypeName = columnList.get(j).getType();
                     final ColumnType propertyType;
                     if (StringUtils.isNullOrEmpty(propertyTypeName)) {
                         propertyType = .;
                     } else {
                         propertyType = ColumnTypeImpl.valueOf(propertyTypeName);
                     }
                     columnNames[j] = propertyName;
                     columnTypes[j] = propertyType;
                 }
 
                 tableDefs[i] = new SimpleTableDef(tableNamecolumnNamescolumnTypes);
             }
         }
 
         return new CassandraDatastore(namehostnameportkeySpaceusernamepasswordssltableDefs);
     }
 
     private Datastore createDatastore(String nameElasticSearchDatastoreType datastoreType) {
         final String clusterName = getStringVariable("clusterName"datastoreType.getClusterName());
         final String hostname = getStringVariable("hostname"datastoreType.getHostname());
 
         Integer port = getIntegerVariable("port"datastoreType.getPort());
         if (port == null) {
             port = .;
         }
 
         final String indexName = getStringVariable("indexName"datastoreType.getIndexName());
 
         final List<org.datacleaner.configuration.jaxb.ElasticSearchDatastoreType.TableDeftableDefList = datastoreType
                 .getTableDef();
         final SimpleTableDef[] tableDefs;
         if (tableDefList.isEmpty()) {
             tableDefs = null;
         } else {
             tableDefs = new SimpleTableDef[tableDefList.size()];
             for (int i = 0; i < tableDefs.lengthi++) {
                 final org.datacleaner.configuration.jaxb.ElasticSearchDatastoreType.TableDef tableDef = tableDefList
                         .get(i);
 
                 final String docType = tableDef.getDocumentType();
                 final List<FieldfieldList = tableDef.getField();
 
                 final String[] columnNames = new String[fieldList.size()];
                 final ColumnType[] columnTypes = new ColumnType[fieldList.size()];
 
                 for (int j = 0; j < columnTypes.lengthj++) {
                     final String propertyName = fieldList.get(j).getName();
                     final String propertyTypeName = fieldList.get(j).getType();
                     final ColumnType propertyType;
                     if (StringUtils.isNullOrEmpty(propertyTypeName)) {
                         propertyType = .;
                     } else {
                         propertyType = ColumnTypeImpl.valueOf(propertyTypeName);
                     }
                     columnNames[j] = propertyName;
                     columnTypes[j] = propertyType;
                 }
 
                 tableDefs[i] = new SimpleTableDef(docTypecolumnNamescolumnTypes);
             }
         }
 
         return new ElasticSearchDatastore(namehostnameportclusterNameindexNametableDefs);
     }
 
     private Datastore createDatastore(String nameJsonDatastoreType datastoreType) {
         final String filename = getStringVariable("filename"datastoreType.getFilename());
         final Resource resource = .createResource(filename);
         return new JsonDatastore(nameresource);
     }
 
     private Datastore createDatastore(String nameHbaseDatastoreType datastoreType) {
         final String zookeeperHostname = getStringVariable("zookeeperHostname"datastoreType.getZookeeperHostname());
         final int zookeeperPort = getIntegerVariable("zookeeperPort"datastoreType.getZookeeperPort());
         final List<org.datacleaner.configuration.jaxb.HbaseDatastoreType.TableDeftableDefList = datastoreType
                 .getTableDef();
 
         final SimpleTableDef[] tableDefs;
         if (tableDefList.isEmpty()) {
             tableDefs = null;
         } else {
             tableDefs = new SimpleTableDef[tableDefList.size()];
             for (int i = 0; i < tableDefs.lengthi++) {
                 final org.datacleaner.configuration.jaxb.HbaseDatastoreType.TableDef tableDef = tableDefList.get(i);
                 final String tableName = tableDef.getName();
                 final List<org.datacleaner.configuration.jaxb.HbaseDatastoreType.TableDef.ColumncolumnList = tableDef
                         .getColumn();
                 final String[] columnNames = new String[columnList.size()];
                 final ColumnType[] columnTypes = new ColumnType[columnList.size()];
                 for (int j = 0; j < columnTypes.lengthj++) {
                     final Column column = columnList.get(j);
                     final String columnName;
                     final String family = column.getFamily();
                     if (Strings.isNullOrEmpty(family)) {
                         columnName = column.getName();
                     } else {
                         columnName = family + ":" + column.getName();
                     }
                     final String columnTypeName = column.getType();
                     final ColumnType columnType;
                     if (StringUtils.isNullOrEmpty(columnTypeName)) {
                         columnType = .;
                     } else {
                         columnType = ColumnTypeImpl.valueOf(columnTypeName);
                     }
                     columnNames[j] = columnName;
                     columnTypes[j] = columnType;
                 }
 
                 tableDefs[i] = new SimpleTableDef(tableNamecolumnNamescolumnTypes);
             }
         }
         return new HBaseDatastore(namezookeeperHostnamezookeeperPorttableDefs);
     }
 
     private Datastore createDatastore(String nameSalesforceDatastoreType datastoreType) {
         String username = getStringVariable("username"datastoreType.getUsername());
         String password = getPasswordVariable("password"datastoreType.getPassword());
         String securityToken = getStringVariable("securityToken"datastoreType.getSecurityToken());
         String endpointUrl = getStringVariable("endpointUrl"datastoreType.getEndpointUrl());
         return new SalesforceDatastore(nameusernamepasswordsecurityTokenendpointUrl);
     }
 
     private Datastore createDatastore(String nameSugarCrmDatastoreType datastoreType) {
         String baseUrl = getStringVariable("baseUrl"datastoreType.getBaseUrl());
         String username = getStringVariable("username"datastoreType.getUsername());
         String password = getPasswordVariable("password"datastoreType.getPassword());
         return new SugarCrmDatastore(namebaseUrlusernamepassword);
     }
 
     private Datastore createDatastore(String nameMongodbDatastoreType mongodbDatastoreType) {
         String hostname = getStringVariable("hostname"mongodbDatastoreType.getHostname());
         Integer port = getIntegerVariable("port"mongodbDatastoreType.getPort());
         String databaseName = getStringVariable("databaseName"mongodbDatastoreType.getDatabaseName());
         String username = getStringVariable("username"mongodbDatastoreType.getUsername());
         String password = getPasswordVariable("password"mongodbDatastoreType.getPassword());
 
         List<org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDeftableDefList = mongodbDatastoreType
                 .getTableDef();
         final SimpleTableDef[] tableDefs;
         if (tableDefList.isEmpty()) {
             tableDefs = null;
         } else {
             tableDefs = new SimpleTableDef[tableDefList.size()];
             for (int i = 0; i < tableDefs.lengthi++) {
                 final org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDef tableDef = tableDefList.get(i);
                 final String collectionName = tableDef.getCollection();
                 final List<org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDef.PropertypropertyList = tableDef
                         .getProperty();
                 final String[] propertyNames = new String[propertyList.size()];
                 final ColumnType[] columnTypes = new ColumnType[propertyList.size()];
                 for (int j = 0; j < columnTypes.lengthj++) {
                     final String propertyName = propertyList.get(j).getName();
                     final String propertyTypeName = propertyList.get(j).getType();
                     final ColumnType propertyType;
                     if (StringUtils.isNullOrEmpty(propertyTypeName)) {
                         propertyType = .;
                     } else {
                         propertyType = ColumnTypeImpl.valueOf(propertyTypeName);
                     }
                     propertyNames[j] = propertyName;
                     columnTypes[j] = propertyType;
                 }
 
                 tableDefs[i] = new SimpleTableDef(collectionNamepropertyNamescolumnTypes);
             }
         }
 
         MongoDbDatastore ds = new MongoDbDatastore(namehostnameportdatabaseNameusernamepasswordtableDefs);
         return ds;
     }
 
     private Datastore