Skip to content

Commit

Permalink
#30411 first shot with some addition and name refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Nov 26, 2024
1 parent f4195a7 commit 7e1ea55
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
if (UtilMethods.isSet(whoIAM)) {

final CollectorContextMap innerCollectorContextMap = new WrapperCollectorContextMap(collectorContextMap,
Map.of("uri", cachedVanityUrl.forwardTo));
Map.of(URL, cachedVanityUrl.forwardTo));
match.get(whoIAM).collect(innerCollectorContextMap, collectorPayloadBean);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,51 @@
*/
public interface Collector {

String CLUSTER = "cluster";
String COME_FROM_VANITY_URL = "comeFromVanityURL";
String CONTENT_TYPE_ID = "content_type_id";
String CONTENT_TYPE_NAME = "content_type_name";
String CONTENT_TYPE_VAR_NAME = "content_type_var_name";
String DETAIL_PAGE_URL = "detail_page_url";
String ID = "identifier";
String TITLE = "title";
String INODE = "inode"; // NOT USED YET BUT MAY BE DESIRED
String BASE_TYPE = "baseType";
String PATH = "path"; // NOT USED YET BUT MAY BE DESIRED
String LIVE = "live"; // NOT USED YET BUT MAY BE DESIRED
String WORKING = "working"; // NOT USED YET BUT MAY BE DESIRED
String CONTENT_TYPE_VAR_NAME = "contentType";
String CONTENT_TYPE_NAME = "contentTypeName";
String CONTENT_TYPE_ID = "contentTypeId";
String SITE_ID = "conHost";
String SITE_NAME = "conHostName";
String LANGUAGE_ID = "languageId";
String LANGUAGE = "language";

String EVENT_SOURCE = "event_source";
String EVENT_TYPE = "event_type";
String HOST = "host";
String ID = "id";
String IS_EXPERIMENT_PAGE = "isexperimentpage";
String IS_TARGET_PAGE = "istargetpage";
String LANGUAGE = "language";
String LANGUAGE_ID = "language_id";
String CLUSTER = "cluster";
String OBJECT = "object";
String PERSONA = "persona";
String REFERER = "referer";
String RENDER_MODE = "renderMode";
String REQUEST_ID = "request_id";
String RESPONSE = "response";
String RESPONSE_CODE = "response_code";
String SERVER = "server";
String SESSION_ID = "sessionId";
String SESSION_NEW = "sessionNew";
String SITE = "site";
String TITLE = "title";
String URL = "url";
String USER_AGENT = "userAgent";
String UTC_TIME = "utc_time";


String RENDER_MODE = "renderMode";
String RESPONSE = "response";
String RESPONSE_CODE = "response_code";


String COME_FROM_VANITY_URL = "comeFromVanityURL";
String DETAIL_PAGE_URL = "detail_page_url";
String IS_EXPERIMENT_PAGE = "isexperimentpage";
String IS_TARGET_PAGE = "istargetpage";


String VANITY_QUERY_STRING = "vanity_query_string";

String VANITY_URL_KEY = "vanity_url";
String FORWARD_TO = "forwardTo";
/**
* Test if the collector should run
* @param collectorContextMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public interface CollectorContextMap {

String REQUEST_ID = "requestId";
String REQUEST = "request";
String TIME = "time";
String CLUSTER = "cluster";
String SERVER = "server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
final Host site = (Host) collectorContextMap.get(CollectorContextMap.CURRENT_HOST);
final String language = (String)collectorContextMap.get(CollectorContextMap.LANG);
collectorPayloadBean.put(URL, uri);
collectorPayloadBean.put(HOST, Objects.nonNull(site)?site.getHostname():host);
collectorPayloadBean.put(SITE_NAME, Objects.nonNull(site)?site.getHostname():host);
collectorPayloadBean.put(LANGUAGE, language);
collectorPayloadBean.put(SITE, null != site?site.getIdentifier():StringPool.UNKNOWN);
collectorPayloadBean.put(SITE_ID, null != site?site.getIdentifier():StringPool.UNKNOWN);
final String eventType = collectorContextMap.get(CollectorContextMap.EVENT_TYPE) == null?
EventType.CUSTOM_USER_EVENT.getType():(String)collectorContextMap.get(CollectorContextMap.EVENT_TYPE);
collectorPayloadBean.put(EVENT_TYPE, eventType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
fileObject.put(ID, fileAsset.getIdentifier());
fileObject.put(TITLE, fileAsset.getTitle());
fileObject.put(URL, uri);
fileObject.put(CONTENT_TYPE_ID, fileAsset.getContentType().id());
fileObject.put(CONTENT_TYPE_NAME, fileAsset.getContentType().name());
fileObject.put(CONTENT_TYPE_VAR_NAME, fileAsset.getContentType().variable());
fileObject.put(BASE_TYPE, fileAsset.getContentType().baseType().name());
});
}

collectorPayloadBean.put(OBJECT, fileObject);
collectorPayloadBean.put(URL, uri);
collectorPayloadBean.put(HOST, Objects.nonNull(site)?site.getHostname():host);
collectorPayloadBean.put(SITE_NAME, Objects.nonNull(site)?site.getHostname():host);
collectorPayloadBean.put(LANGUAGE, language);
collectorPayloadBean.put(SITE, null != site?site.getIdentifier():StringPool.UNKNOWN);
collectorPayloadBean.put(SITE_ID, null != site?site.getIdentifier():StringPool.UNKNOWN);
collectorPayloadBean.put(EVENT_TYPE, EventType.FILE_REQUEST.getType());

return collectorPayloadBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
pageObject.put(ID, detailPageContent.getIdentifier());
pageObject.put(TITLE, detailPageContent.getTitle());
pageObject.put(URL, uri);
pageObject.put(CONTENT_TYPE_ID, urlMapContentlet.getContentType().id());
pageObject.put(CONTENT_TYPE_NAME, urlMapContentlet.getContentType().name());
pageObject.put(CONTENT_TYPE_VAR_NAME, urlMapContentlet.getContentType().variable());
pageObject.put(BASE_TYPE, urlMapContentlet.getContentType().baseType().name());
pageObject.put(DETAIL_PAGE_URL, Try.of(detailPageContent::getURI).getOrElse(StringPool.BLANK));
collectorPayloadBean.put(OBJECT, pageObject);
}
Expand All @@ -87,7 +91,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
collectorPayloadBean.put(LANGUAGE, language);

if (Objects.nonNull(site)) {
collectorPayloadBean.put(HOST, site.getHostname());
collectorPayloadBean.put(SITE_NAME, site.getHostname());
}
return collectorPayloadBean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
pageObject.put(CONTENT_TYPE_ID, urlMapContentType.id());
pageObject.put(CONTENT_TYPE_NAME, urlMapContentType.name());
pageObject.put(CONTENT_TYPE_VAR_NAME, urlMapContentType.variable());
pageObject.put(BASE_TYPE, urlMapContentType.baseType().name());
collectorPayloadBean.put(EVENT_TYPE, EventType.URL_MAP.getType());
}
} else {
Expand All @@ -83,8 +84,6 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
pageObject.put(ID, page.getIdentifier());
pageObject.put(TITLE, page.getTitle());
collectorPayloadBean.put(EVENT_TYPE, EventType.PAGE_REQUEST.getType());
pageObject.put("id", page.getIdentifier());
pageObject.put("title", page.getTitle());
}
pageObject.put(URL, uri);
}
Expand All @@ -94,7 +93,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
collectorPayloadBean.put(LANGUAGE, language);

if (Objects.nonNull(site)) {
collectorPayloadBean.put(HOST, site.getHostname());
collectorPayloadBean.put(SITE_NAME, site.getHostname());
}

return collectorPayloadBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
public class SyncVanitiesCollector implements Collector {

public static final String VANITY_URL_KEY = "vanity_url";
public static final String FORWARD_TO = "forward_to";

public SyncVanitiesCollector() {
}
Expand All @@ -32,9 +30,9 @@ public boolean test(CollectorContextMap collectorContextMap) {
@Override
public CollectorPayloadBean collect(final CollectorContextMap collectorContextMap,
final CollectorPayloadBean collectorPayloadBean) {
if (null != collectorContextMap.get("request")) {
if (null != collectorContextMap.get(CollectorContextMap.REQUEST)) {

final HttpServletRequest request = (HttpServletRequest)collectorContextMap.get("request");
final HttpServletRequest request = (HttpServletRequest)collectorContextMap.get(CollectorContextMap.REQUEST);
final String vanityUrl = (String)request.getAttribute(Constants.CMS_FILTER_URI_OVERRIDE);
final String vanityQueryString = (String)request.getAttribute(Constants.CMS_FILTER_QUERY_STRING_OVERRIDE);
if (request instanceof VanityUrlRequestWrapper) {
Expand Down Expand Up @@ -66,7 +64,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
collectorPayloadBean.put(URL, uri);
collectorPayloadBean.put(LANGUAGE, language);
collectorPayloadBean.put(LANGUAGE_ID, languageId);
collectorPayloadBean.put(SITE, site.getIdentifier());
collectorPayloadBean.put(SITE_ID, site.getIdentifier());
collectorPayloadBean.put(EVENT_TYPE, EventType.VANITY_REQUEST.getType());

return collectorPayloadBean;
Expand Down

0 comments on commit 7e1ea55

Please sign in to comment.