Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#30472 adding the shortyid to the content hydrate #30475

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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