BackendImpl.java, Importer.java:
Removed code duplication regarding whether to clear a backend before an import.
Suffix.java:
Code cleanup
| | |
| | | |
| | | try |
| | | { |
| | | final EnvironmentConfig envConfig = getEnvConfigForImport(); |
| | | |
| | | if (!importConfig.appendToExistingData() |
| | | && (importConfig.clearBackend() || cfg.getBaseDN().size() <= 1)) |
| | | if (Importer.mustClearBackend(importConfig, cfg)) |
| | | { |
| | | // We have the writer lock on the environment, now delete the |
| | | // environment and re-open it. Only do this when we are |
| | |
| | | } |
| | | } |
| | | |
| | | Importer importer = new Importer(importConfig, cfg, envConfig); |
| | | final EnvironmentConfig envConfig = getEnvConfigForImport(); |
| | | final Importer importer = new Importer(importConfig, cfg, envConfig); |
| | | rootContainer = initializeRootContainer(envConfig); |
| | | return importer.processImport(rootContainer); |
| | | } |
| | |
| | | // Determine the number of indexes. |
| | | this.indexCount = getTotalIndexCount(localDBBackendCfg); |
| | | |
| | | this.clearedBackend = |
| | | !importConfiguration.appendToExistingData() |
| | | && (importConfiguration.clearBackend() || localDBBackendCfg.getBaseDN().size() <= 1); |
| | | this.clearedBackend = mustClearBackend(importConfiguration, localDBBackendCfg); |
| | | this.scratchFileWriterList = |
| | | new ArrayList<ScratchFileWriterTask>(indexCount); |
| | | this.scratchFileWriterFutures = new CopyOnWriteArrayList<Future<Void>>(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the backend must be cleared. |
| | | * |
| | | * @param importCfg the import configuration object |
| | | * @param backendCfg the backend configuration object |
| | | * @return true if the backend must be cleared, false otherwise |
| | | */ |
| | | public static boolean mustClearBackend(LDIFImportConfig importCfg, LocalDBBackendCfg backendCfg) |
| | | { |
| | | return !importCfg.appendToExistingData() |
| | | && (importCfg.clearBackend() || backendCfg.getBaseDN().size() <= 1); |
| | | } |
| | | |
| | | private File getTempDir(LocalDBBackendCfg localDBBackendCfg, String tmpDirectory) |
| | | { |
| | | File parentDir; |
| | |
| | | logger.error(ERR_JEB_IMPORT_LDIF_PENDING_ERR, e.getMessage()); |
| | | throw e; |
| | | } |
| | | //Check the DN cache. |
| | | boolean parentThere = dnCache.contains(dn); |
| | | //If the parent isn't found in the DN cache, then check the dn2id database |
| | | //for the DN only if the backend wasn't cleared. |
| | | if(!parentThere |
| | | boolean parentThere = !dnCache.contains(dn) |
| | | && !clearedBackend |
| | | && getDN2ID().get(null, dn, LockMode.DEFAULT) != null) |
| | | { |
| | | parentThere = true; |
| | | } |
| | | && getDN2ID().get(null, dn, LockMode.DEFAULT) != null; |
| | | //Add the DN to the parent set if needed. |
| | | if (parentThere) { |
| | | synchronized(synchObject) { |