use of com.adobe.cq.xf.social.ExperienceFragmentSocialVariation in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class MockXFFactory method getExperienceFragmentSocialVariation.
public static ExperienceFragmentSocialVariation getExperienceFragmentSocialVariation(Page page) {
ExperienceFragmentSocialVariation socialVariation = mock(ExperienceFragmentSocialVariation.class);
StringBuilder stringBuilder = new StringBuilder();
String image = null;
for (Resource resource : page.getContentResource().getChild("root").getChildren()) {
if (resource.isResourceType(IMAGE_RT) && StringUtils.isEmpty(image)) {
image = resource.getValueMap().get("fileReference", String.class);
}
String text = resource.getValueMap().get("text", String.class);
if (StringUtils.isNotEmpty(text)) {
stringBuilder.append(text);
}
}
when(socialVariation.getText()).thenReturn(stringBuilder.toString());
when(socialVariation.getImagePath()).thenReturn(image);
return socialVariation;
}
use of com.adobe.cq.xf.social.ExperienceFragmentSocialVariation in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class SocialMediaHelperImpl method createMetadataProvider.
/**
* Instantiates the suitable metadata provider based on the contents of the current page.
*/
private WebsiteMetadata createMetadataProvider() {
try {
Product product = CommerceHelper.findCurrentProduct(currentPage);
ExperienceFragmentSocialVariation smVariant = findExperienceFragmentSocialVariation();
if (product == null) {
if (smVariant == null) {
return new WebsiteMetadataProvider();
} else {
return new ExperienceFragmentWebsiteMetadataProvider(smVariant);
}
} else {
if (smVariant == null) {
return new ProductMetadataProvider(product);
} else {
return new ExperienceFragmentProductMetadataProvider(product, smVariant);
}
}
} catch (NoClassDefFoundError e) {
return new WebsiteMetadataProvider();
}
}
use of com.adobe.cq.xf.social.ExperienceFragmentSocialVariation in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class SocialMediaHelperImpl method createMetadataProvider.
/**
* Instantiates the suitable metadata provider based on the contents of the current page.
*/
private WebsiteMetadata createMetadataProvider() {
Product product = CommerceHelper.findCurrentProduct(currentPage);
ExperienceFragmentSocialVariation smVariant = findExperienceFragmentSocialVariation();
if (product == null) {
if (smVariant == null) {
return new WebsiteMetadataProvider();
} else {
return new ExperienceFragmentWebsiteMetadataProvider(smVariant);
}
} else {
if (smVariant == null) {
return new ProductMetadataProvider(product);
} else {
return new ExperienceFragmentProductMetadataProvider(product, smVariant);
}
}
}
use of com.adobe.cq.xf.social.ExperienceFragmentSocialVariation in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class SocialMediaHelperImpl method findExperienceFragmentSocialVariation.
private ExperienceFragmentSocialVariation findExperienceFragmentSocialVariation() {
Page variantPage = currentPage.getPageManager().getPage(variantPath);
if (variantPage == null)
return null;
ExperienceFragmentSocialVariation socialVariant = variantPage.adaptTo(ExperienceFragmentSocialVariation.class);
return socialVariant;
}
use of com.adobe.cq.xf.social.ExperienceFragmentSocialVariation in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class MockXFFactory method getExperienceFragmentSocialVariation.
public static ExperienceFragmentSocialVariation getExperienceFragmentSocialVariation(Page page) {
ExperienceFragmentSocialVariation socialVariation = mock(ExperienceFragmentSocialVariation.class);
StringBuilder stringBuilder = new StringBuilder();
String image = null;
for (Resource resource : page.getContentResource().getChild("root").getChildren()) {
if (resource.isResourceType(IMAGE_RT) && StringUtils.isEmpty(image)) {
image = resource.getValueMap().get("fileReference", String.class);
}
String text = resource.getValueMap().get("text", String.class);
if (StringUtils.isNotEmpty(text)) {
stringBuilder.append(text);
}
}
when(socialVariation.getText()).thenReturn(stringBuilder.toString());
when(socialVariation.getImagePath()).thenReturn(image);
return socialVariation;
}
Aggregations