Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPORTAL-3519 BZ1117813 Unique name for category's createContent
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrohling authored and ppalaga committed Jul 23, 2014
1 parent eb51cb5 commit ad39062
Showing 1 changed file with 7 additions and 9 deletions.
Expand Up @@ -481,7 +481,7 @@ public void importAllPortlets() throws Exception {
}

if (!isExist) {
app = category.createContent(portletName, contentType, contentId);
app = category.createContent(uniqueDefinitionName(portletName, contentId), contentType, contentId);
app.setDisplayName(displayName);
app.setDescription(getLocalizedStringValue(descriptionLS, portletName));
app.setAccessPermissions(permissions);
Expand All @@ -491,20 +491,18 @@ public void importAllPortlets() throws Exception {
}
}

private String uniqueDefinitionName(String portletName, String contentId) {
String unique = portletName.substring(0,Math.min(portletName.length(), 20)) + String.valueOf(contentId.hashCode());
String sanitized = sanitizePortletName(unique);
return sanitized;
}

private String sanitizePortletApplicationName(String portletApplicationName) {
return portletApplicationName.replace('/', '_');
}

private String sanitizePortletName(String portletName) {
String sanitizedPortletName = portletName.replace('/', '_');

// PortletName can have following format in the auto-import task:
// local._responsive-community-portlet.ResponsiveCommunityPortlet
// We are going to return last token as sanitizedPortletName
int lastDotIndex = sanitizedPortletName.lastIndexOf('.');
if (lastDotIndex > 0) {
sanitizedPortletName = sanitizedPortletName.substring(lastDotIndex + 1);
}
/*
* PortletName should validate similar to UIApplicationForm for Application Name
* as this is read-only value in Application Registry.
Expand Down

0 comments on commit ad39062

Please sign in to comment.