Skip to content

Commit 0b50a20

Browse files
committed
Propagate DumAemEvent to object creation
Include the DumAemEvent when creating DumAemObjectGeneric instances. AemNodeNavigator (and its reactive variant) now pass session.getEvent() to objectService.getDumAemObjectGeneric. The DumAemObjectService convenience overload without an event was removed in favor of a single method that requires a DumAemEvent. Tests were updated to call the service with DumAemEvent.NONE. This preserves event context when constructing AEM objects.
1 parent 9e3df6c commit 0b50a20

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

aem/aem-plugin/src/main/java/com/viglet/dumont/connector/plugin/aem/navigator/AemNodeNavigator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ private Mono<Void> navigateChildrenReactive(DumAemSession session, DumAemObjectG
158158
private void processChildNode(DumAemSession session, String childPath) {
159159
DumAemCommonsUtils.getInfinityJson(childPath, session.getConfiguration(), false)
160160
.ifPresent(infinityJson -> {
161-
DumAemObjectGeneric childObject = objectService.getDumAemObjectGeneric(childPath, infinityJson);
161+
DumAemObjectGeneric childObject = objectService.getDumAemObjectGeneric(childPath, infinityJson,
162+
session.getEvent());
162163
processNode(session, childObject);
163164

164165
if (session.isRecursive()) {
@@ -173,7 +174,8 @@ private void processChildNode(DumAemSession session, String childPath) {
173174
private Mono<Void> processChildNodeReactive(DumAemSession session, String childPath) {
174175
return reactiveUtils.getInfinityJsonReactive(childPath, session.getConfiguration())
175176
.flatMap(infinityJson -> {
176-
DumAemObjectGeneric childObject = objectService.getDumAemObjectGeneric(childPath, infinityJson);
177+
DumAemObjectGeneric childObject = objectService.getDumAemObjectGeneric(childPath, infinityJson,
178+
session.getEvent());
177179
processNode(session, childObject);
178180

179181
if (session.isRecursive()) {

aem/aem-plugin/src/main/java/com/viglet/dumont/connector/plugin/aem/service/DumAemObjectService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import org.json.JSONObject;
44
import org.springframework.stereotype.Service;
5+
56
import com.viglet.dumont.connector.aem.commons.DumAemObjectGeneric;
67
import com.viglet.dumont.connector.aem.commons.bean.DumAemEvent;
78

89
@Service
910
public class DumAemObjectService {
10-
11-
public DumAemObjectGeneric getDumAemObjectGeneric(String path, JSONObject infinityJson) {
12-
return getDumAemObjectGeneric(path, infinityJson, DumAemEvent.NONE);
13-
}
14-
1511
public DumAemObjectGeneric getDumAemObjectGeneric(String path, JSONObject infinityJson,
1612
DumAemEvent dumAemEvent) {
1713
return new DumAemObjectGeneric(path, infinityJson, dumAemEvent);

aem/aem-plugin/src/test/java/com/viglet/dumont/connector/plugin/aem/service/DumAemObjectServiceTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void shouldCreateObjectWithPathAndJson() {
5757
JSONObject json = new JSONObject();
5858
json.put("jcr:primaryType", "cq:Page");
5959

60-
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test", json);
60+
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test", json, DumAemEvent.NONE);
6161

6262
assertNotNull(result);
6363
assertEquals("/content/test", result.getPath());
@@ -72,7 +72,7 @@ void shouldHandlePageTypeJson() {
7272
jcrContent.put("jcr:title", "Test Page");
7373
json.put("jcr:content", jcrContent);
7474

75-
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test/page", json);
75+
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test/page", json, DumAemEvent.NONE);
7676

7777
assertNotNull(result);
7878
assertEquals("/content/test/page", result.getPath());
@@ -84,7 +84,8 @@ void shouldHandleAssetTypeJson() {
8484
JSONObject json = new JSONObject();
8585
json.put("jcr:primaryType", "dam:Asset");
8686

87-
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/dam/test.jpg", json);
87+
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/dam/test.jpg", json,
88+
DumAemEvent.NONE);
8889

8990
assertNotNull(result);
9091
assertEquals("/content/dam/test.jpg", result.getPath());
@@ -95,7 +96,7 @@ void shouldHandleAssetTypeJson() {
9596
void shouldHandleEmptyJsonObject() {
9697
JSONObject json = new JSONObject();
9798

98-
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test", json);
99+
DumAemObjectGeneric result = service.getDumAemObjectGeneric("/content/test", json, DumAemEvent.NONE);
99100

100101
assertNotNull(result);
101102
assertEquals("/content/test", result.getPath());
@@ -159,7 +160,7 @@ void shouldHandleContentFragment() {
159160
json.put("jcr:content", jcrContent);
160161

161162
DumAemObjectGeneric result = service.getDumAemObjectGeneric(
162-
"/content/dam/test/cf", json);
163+
"/content/dam/test/cf", json, DumAemEvent.NONE);
163164

164165
assertNotNull(result);
165166
}
@@ -175,7 +176,7 @@ void shouldHandleFolderAndUnstructuredTypes(String primaryType, String path) {
175176
JSONObject json = new JSONObject();
176177
json.put("jcr:primaryType", primaryType);
177178

178-
DumAemObjectGeneric result = service.getDumAemObjectGeneric(path, json);
179+
DumAemObjectGeneric result = service.getDumAemObjectGeneric(path, json, DumAemEvent.NONE);
179180

180181
assertNotNull(result);
181182
}
@@ -201,7 +202,7 @@ void shouldHandleNestedJsonStructures() {
201202
json.put("jcr:content", jcrContent);
202203

203204
DumAemObjectGeneric result = service.getDumAemObjectGeneric(
204-
"/content/test/page", json);
205+
"/content/test/page", json, DumAemEvent.NONE);
205206

206207
assertNotNull(result);
207208
assertNotNull(result.getJcrNode());

0 commit comments

Comments
 (0)