Skip to content

Commit

Permalink
#30472 adding the shortyid to the content hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Oct 28, 2024
1 parent 3f68810 commit 3658e6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
public class DefaultTransformStrategy extends AbstractTransformStrategy<Contentlet> {

private static final String FILE_ASSET = FileAssetAPI.BINARY_FIELD;
public static final String SHORTY_ID = "shortyId";

/**
* Main constructor
Expand Down Expand Up @@ -127,6 +128,7 @@ private void addCommonProperties(final Contentlet contentlet, final Map<String,
final ContentType type = contentlet.getContentType();

map.put(IDENTIFIER_KEY, contentlet.getIdentifier());
map.put(SHORTY_ID, APILocator.getShortyAPI().shortify(contentlet.getIdentifier()));
map.put(INODE_KEY, contentlet.getInode());
map.put(TITTLE_KEY, contentlet.getTitle());
map.put(CONTENT_TYPE_KEY, type != null ? type.variable() : NOT_APPLICABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.dotmarketing.portlets.workflows.model.WorkflowProcessor;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UUIDUtil;
import com.dotmarketing.util.UtilMethods;
import com.liferay.util.StringPool;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -94,12 +95,12 @@ public void executeAction(final WorkflowProcessor processor,
final HashMap<String, String> objectDetail = new HashMap<>();
final Map<String, Serializable> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}


Expand Down

0 comments on commit 3658e6d

Please sign in to comment.