use of com.day.cq.wcm.api.NameConstants.NN_CONTENT in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentDataImpl method getLocalizedFragmentVariationPath.
/**
* Returns the localized path of the experience fragment variation if the experience fragment resource is defined
* in a template.
*
* @return Localized experience fragment variation path
* @see ExperienceFragment#getLocalizedFragmentVariationPath()
*/
@Nullable
public String getLocalizedFragmentVariationPath() {
if (localizedFragmentVariationPath != null) {
return localizedFragmentVariationPath;
}
// get the configured fragment variation path
String fragmentVariationPath = resource.getValueMap().get(ExperienceFragment.PN_FRAGMENT_VARIATION_PATH, String.class);
if (currentPage != null && inTemplate()) {
final Resource pageResource = Optional.ofNullable(currentPage).map(p -> p.adaptTo(Resource.class)).orElse(null);
final String currentPageRootPath = pageResource != null ? LocalizationUtils.getLocalizationRoot(pageResource, resourceResolver, languageManager, relationshipManager) : null;
// we should use getLocalizationRoot instead of getXfLocalizationRoot once the XF UI supports creating Live and Language Copies
String xfRootPath = getXfLocalizationRoot(fragmentVariationPath, currentPageRootPath);
if (StringUtils.isNotEmpty(currentPageRootPath) && StringUtils.isNotEmpty(xfRootPath)) {
String xfRelativePath = StringUtils.substring(fragmentVariationPath, xfRootPath.length());
String localizedXfRootPath = StringUtils.replace(currentPageRootPath, CONTENT_ROOT, ExperienceFragmentsConstants.CONTENT_PATH, 1);
localizedFragmentVariationPath = StringUtils.join(localizedXfRootPath, xfRelativePath, PATH_DELIMITER_CHAR, NN_CONTENT);
}
}
String xfContentPath = String.join(Character.toString(PATH_DELIMITER_CHAR), fragmentVariationPath, NN_CONTENT);
if (!resourceExists(localizedFragmentVariationPath) && resourceExists(xfContentPath)) {
localizedFragmentVariationPath = xfContentPath;
}
if (!isExperienceFragmentVariation(localizedFragmentVariationPath)) {
localizedFragmentVariationPath = null;
}
return localizedFragmentVariationPath;
}
Aggregations