From 355cf09ec6c7378e8a86fb0746eda3047dc1499a Mon Sep 17 00:00:00 2001 From: Reijer Copier Date: Thu, 30 Nov 2023 14:12:34 +0100 Subject: [PATCH 1/4] Reenable tests --- .../java/org/deegree/workspace/SimpleSqlFeatureStoreTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/deegree-tests/deegree-resource-deps-tests/src/test/java/org/deegree/workspace/SimpleSqlFeatureStoreTest.java b/deegree-tests/deegree-resource-deps-tests/src/test/java/org/deegree/workspace/SimpleSqlFeatureStoreTest.java index 325e507c79..ed6d89df4f 100644 --- a/deegree-tests/deegree-resource-deps-tests/src/test/java/org/deegree/workspace/SimpleSqlFeatureStoreTest.java +++ b/deegree-tests/deegree-resource-deps-tests/src/test/java/org/deegree/workspace/SimpleSqlFeatureStoreTest.java @@ -131,7 +131,6 @@ public void testResourceGraph() { } @Test - @Ignore public void testDestroySingle() { FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok"); Assert.assertNotNull("Feature store is expected to be created.", fs); @@ -144,7 +143,6 @@ public void testDestroySingle() { } @Test - @Ignore public void testDestroyInitializeSingle() { FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok"); Assert.assertNotNull("Feature store is expected to be created.", fs); @@ -158,7 +156,6 @@ public void testDestroyInitializeSingle() { } @Test - @Ignore public void testReinitializeChain() { FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok"); Assert.assertNotNull("Feature store is expected to be created.", fs); From b2767db2393489674b96a180ff179ca6c6c5e021 Mon Sep 17 00:00:00 2001 From: Reijer Copier Date: Thu, 30 Nov 2023 16:45:55 +0100 Subject: [PATCH 2/4] Fix collecting resources to destroy --- .../deegree/workspace/standard/DefaultWorkspace.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java index a3739a7081..af34bdf79b 100644 --- a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java +++ b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java @@ -518,7 +518,7 @@ public void add(ResourceLocation location) { @Override public void destroy(ResourceIdentifier id) { - List> resourcesToRemove = collectResourcesToDestroy(id); + List> resourcesToRemove = collectResourcesToDestroy(id); for (ResourceIdentifier resourceId : resourcesToRemove) { T res = (T) resources.get(resourceId); @@ -534,14 +534,14 @@ public void destroy(ResourceIdentifier id) { } } - private List> collectResourcesToDestroy(ResourceIdentifier id) { - List> resourcesToRemove = new ArrayList<>(); - ResourceNode node = graph.getNode(id); + private List> collectResourcesToDestroy(ResourceIdentifier id) { + List> resourcesToRemove = new ArrayList<>(); + ResourceNode node = graph.getNode(id); if (node == null) { return resourcesToRemove; } for (ResourceNode n : node.getDependents()) { - collectResourcesToDestroy(n.getMetadata().getIdentifier()); + resourcesToRemove.addAll(collectResourcesToDestroy(n.getMetadata().getIdentifier())); } resourcesToRemove.add(id); return resourcesToRemove; From 97b718d51ddecadedf29e979dc893490873b8535 Mon Sep 17 00:00:00 2001 From: Reijer Copier Date: Thu, 30 Nov 2023 18:32:22 +0100 Subject: [PATCH 3/4] Properly reinitialize destroyed resources --- .../org/deegree/workspace/standard/DefaultWorkspace.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java index af34bdf79b..7d9a443c67 100644 --- a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java +++ b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java @@ -367,10 +367,10 @@ public T init(ResourceIdentifier id, PreparedResources p List> mdList = new ArrayList>(); ResourceMetadata md = resourceMetadata.get(id); mdList.add(md); - graph.insertNode(md); - List> dependencies = new ArrayList>(); - WorkspaceUtils.collectDependencies(dependencies, graph.getNode(id)); - mdList.addAll(dependencies); + for (ResourceIdentifier dependencyId : md.getDependencies()) { + ResourceMetadata dependencyMd = resourceMetadata.get(dependencyId); + mdList.add(dependencyMd); + } ResourceGraph g = new ResourceGraph(mdList); mdList = g.toSortedList(); @@ -380,6 +380,7 @@ public T init(ResourceIdentifier id, PreparedResources p LOG.info("Resource {} already available.", metadata.getIdentifier()); continue; } + graph.insertNode(metadata); ResourceBuilder builder = prepared.getBuilder(metadata.getIdentifier()); LOG.info("Building resource {}.", metadata.getIdentifier()); try { From 176db664ad05885a3e465b3813192268fa3e44db Mon Sep 17 00:00:00 2001 From: Reijer Copier Date: Fri, 1 Dec 2023 12:25:21 +0100 Subject: [PATCH 4/4] Also reinitialize soft dependencies --- .../org/deegree/workspace/standard/DefaultWorkspace.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java index 7d9a443c67..c4069bc7f9 100644 --- a/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java +++ b/deegree-core/deegree-core-workspace/src/main/java/org/deegree/workspace/standard/DefaultWorkspace.java @@ -371,6 +371,12 @@ public T init(ResourceIdentifier id, PreparedResources p ResourceMetadata dependencyMd = resourceMetadata.get(dependencyId); mdList.add(dependencyMd); } + for (ResourceIdentifier dependencyId : md.getSoftDependencies()) { + ResourceMetadata dependencyMd = resourceMetadata.get(dependencyId); + if (dependencyMd != null) { + mdList.add(dependencyMd); + } + } ResourceGraph g = new ResourceGraph(mdList); mdList = g.toSortedList();