diff --git a/step-controller/step-controller-server/src/main/java/step/core/imports/converter/ArtefactsToPlans.java b/step-controller/step-controller-server/src/main/java/step/core/imports/converter/ArtefactsToPlans.java index a20b8eae0..03f62cfce 100644 --- a/step-controller/step-controller-server/src/main/java/step/core/imports/converter/ArtefactsToPlans.java +++ b/step-controller/step-controller-server/src/main/java/step/core/imports/converter/ArtefactsToPlans.java @@ -115,7 +115,7 @@ protected Document migrateArtefactToPlan(AtomicInteger successCount, AtomicInteg Document plan = new Document(); - plan.put(AbstractIdentifiableObject.ID, artefactIdToPlanId.get(t.getId())); + plan.put(AbstractIdentifiableObject.ID, artefactIdToPlanId.get(t.getId().toString())); plan.put("attributes", attributes); plan.put("root", migrateArtefact(t)); plan.put("visible", visiblePlan); diff --git a/step-core/src/main/java/step/core/entities/EntityDependencyTreeVisitor.java b/step-core/src/main/java/step/core/entities/EntityDependencyTreeVisitor.java index b6d98b125..ffef005f7 100644 --- a/step-core/src/main/java/step/core/entities/EntityDependencyTreeVisitor.java +++ b/step-core/src/main/java/step/core/entities/EntityDependencyTreeVisitor.java @@ -28,7 +28,9 @@ public class EntityDependencyTreeVisitor { private static final Logger logger = LoggerFactory.getLogger(EntityDependencyTreeVisitor.class); private final EntityManager entityManager; private final ObjectPredicate objectPredicate; - private final Map, BeanInfo> beanInfoCache = new ConcurrentHashMap<>(); + // Declared as static for performance reasons. In the current implementation, this class gets instantiated quite often + // TODO declare it as non-static to avoid potential leaks + private static final Map, BeanInfo> beanInfoCache = new ConcurrentHashMap<>(); public EntityDependencyTreeVisitor(EntityManager entityManager, ObjectPredicate objectPredicate) { super(); diff --git a/step-core/src/main/java/step/core/imports/ImportContext.java b/step-core/src/main/java/step/core/imports/ImportContext.java index a3aa45af5..d8319cf85 100644 --- a/step-core/src/main/java/step/core/imports/ImportContext.java +++ b/step-core/src/main/java/step/core/imports/ImportContext.java @@ -18,6 +18,12 @@ ******************************************************************************/ package step.core.imports; +import ch.exense.commons.io.FileHelper; +import step.core.Version; +import step.core.collections.CollectionFactory; +import step.core.collections.inmemory.InMemoryCollectionFactory; +import step.resources.LocalResourceManagerImpl; + import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -25,11 +31,6 @@ import java.util.Map; import java.util.Set; -import step.core.collections.filesystem.FilesystemCollectionFactory; -import ch.exense.commons.io.FileHelper; -import step.core.Version; -import step.resources.LocalResourceManagerImpl; - public class ImportContext implements AutoCloseable { private final ImportConfiguration importConfiguration; @@ -40,8 +41,7 @@ public class ImportContext implements AutoCloseable { private final File workFolder; private final LocalResourceManagerImpl localResourceMgr; - private final File tempWorkspace; - private final FilesystemCollectionFactory tempCollectionFactory; + private final CollectionFactory tempCollectionFactory; private final Map references = new HashMap(); private final Map newToOldReferences = new HashMap(); @@ -51,8 +51,7 @@ public ImportContext(ImportConfiguration importConfiguration) throws IOException super(); this.importConfiguration = importConfiguration; - tempWorkspace = FileHelper.createTempFolder(); - tempCollectionFactory = new FilesystemCollectionFactory(tempWorkspace); + tempCollectionFactory = new InMemoryCollectionFactory(null); workFolder = FileHelper.createTempFolder("step-import"); localResourceMgr = new LocalResourceManagerImpl(workFolder); } @@ -81,7 +80,7 @@ public LocalResourceManagerImpl getLocalResourceMgr() { return localResourceMgr; } - public FilesystemCollectionFactory getTempCollectionFactory() { + public CollectionFactory getTempCollectionFactory() { return tempCollectionFactory; } @@ -108,6 +107,5 @@ public File getWorkFolder() { @Override public void close() throws Exception { FileHelper.deleteFolder(workFolder); - FileHelper.deleteFolder(tempWorkspace); } } diff --git a/step-core/src/main/java/step/core/imports/ImportManager.java b/step-core/src/main/java/step/core/imports/ImportManager.java index 61884088c..b282d9bb8 100644 --- a/step-core/src/main/java/step/core/imports/ImportManager.java +++ b/step-core/src/main/java/step/core/imports/ImportManager.java @@ -32,9 +32,9 @@ import step.core.accessors.Accessor; import step.core.accessors.DefaultJacksonMapperProvider; import step.core.collections.Collection; +import step.core.collections.CollectionFactory; import step.core.collections.Document; import step.core.collections.Filters; -import step.core.collections.filesystem.FilesystemCollectionFactory; import step.core.entities.Entity; import step.core.entities.EntityManager; import step.migration.MigrationManager; @@ -124,7 +124,7 @@ public ImportResult importAll(ImportConfiguration importConfig) throws Exception private void importEntitiesFromTemporaryCollection(ImportConfiguration importConfig, ImportContext importContext, List entityNames) { // Perform migration tasks on temporary collections - final FilesystemCollectionFactory tempCollectionFactory = importContext.getTempCollectionFactory(); + final CollectionFactory tempCollectionFactory = importContext.getTempCollectionFactory(); migrationManager.migrate(tempCollectionFactory, importContext.getVersion(), Version.getCurrentVersion()); // Replace IDs of all entities if overwriting is disabled @@ -172,7 +172,7 @@ private String importEntitiesToTemporaryCollection(ImportConfiguration importCon Entity entityByName = entityManager.getEntityByName(name); boolean skip = skipEntityType(importConfig.getEntitiesFilter(), name); - FilesystemCollectionFactory tempCollectionFactory = importContext.getTempCollectionFactory(); + CollectionFactory tempCollectionFactory = importContext.getTempCollectionFactory(); Collection tempCollection = tempCollectionFactory.getCollection(name, Document.class); if (entityByName == null) {