From 3658e6dbfec52ce4b1c9cdccbc57d6d2e7c8f2aa Mon Sep 17 00:00:00 2001 From: jdotcms Date: Mon, 28 Oct 2024 12:49:10 -0600 Subject: [PATCH] #30472 adding the shortyid to the content hydrate --- .../transform/strategy/DefaultTransformStrategy.java | 2 ++ .../actionlet/AnalyticsFireUserEventActionlet.java | 7 ++++--- .../contentlet/transform/ContentletTransformerTest.java | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java index a33ac6fa79ec..ccbae86f61cf 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java @@ -78,6 +78,7 @@ public class DefaultTransformStrategy extends AbstractTransformStrategy { private static final String FILE_ASSET = FileAssetAPI.BINARY_FIELD; + public static final String SHORTY_ID = "shortyId"; /** * Main constructor @@ -127,6 +128,7 @@ private void addCommonProperties(final Contentlet contentlet, final Map objectDetail = new HashMap<>(); final Map userEventPayload = new HashMap<>(); - userEventPayload.put(ID, Objects.nonNull(objectId) ? objectId : identifier); + userEventPayload.put(ID, UtilMethods.isSet(objectId) ? objectId.trim() : identifier); objectDetail.put(ID, identifier); - objectDetail.put(OBJECT_CONTENT_TYPE_VAR_NAME, Objects.nonNull(objectType) ? objectType : CONTENT); + objectDetail.put(OBJECT_CONTENT_TYPE_VAR_NAME, UtilMethods.isSet(objectType) ? objectType.trim() : CONTENT); userEventPayload.put(OBJECT, objectDetail); - userEventPayload.put(EVENT_TYPE1, eventType); + userEventPayload.put(EVENT_TYPE1, UtilMethods.isSet(eventType)? eventType.trim(): eventType); webEventsCollectorService.fireCollectorsAndEmitEvent(request, response, USER_CUSTOM_DEFINED_REQUEST_MATCHER, userEventPayload); } else { Logger.warn(this, "The request or response is null, can't send the event for the contentlet: " + identifier); diff --git a/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/transform/ContentletTransformerTest.java b/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/transform/ContentletTransformerTest.java index c0f7fd56885c..19129d16b479 100644 --- a/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/transform/ContentletTransformerTest.java +++ b/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/transform/ContentletTransformerTest.java @@ -239,6 +239,7 @@ public void Test_Hydrate_Contentlet_WithUrl() throws DotDataException { assertFalse(newContentlet.getMap().containsKey(Contentlet.NULL_PROPERTIES)); assertEquals(newContentlet.getMap().get(ContentletForm.IDENTIFIER_KEY), identifier); assertEquals(newContentlet.getMap().get(HTMLPageAssetAPI.URL_FIELD), urlExpected); + assertTrue(newContentlet.getMap().containsKey(DefaultTransformStrategy.SHORTY_ID)); } @Test @@ -313,6 +314,7 @@ public String getUrl(Contentlet contentlet) { assertTrue(newContentlet.getMap().containsKey(HTMLPageAssetAPI.URL_FIELD)); assertEquals(urlExpected, newContentlet.getMap().get(HTMLPageAssetAPI.URL_FIELD)); assertFalse(newContentlet.getMap().containsKey(Contentlet.NULL_PROPERTIES)); + assertTrue(newContentlet.getMap().containsKey(DefaultTransformStrategy.SHORTY_ID)); }