use of com.day.cq.tagging.Tag in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PageImpl method initModel.
@PostConstruct
private void initModel() {
title = currentPage.getTitle();
if (StringUtils.isBlank(title)) {
title = currentPage.getName();
}
Tag[] tags = currentPage.getTags();
keywords = new String[tags.length];
int index = 0;
for (Tag tag : tags) {
keywords[index++] = tag.getTitle(currentPage.getLanguage(false));
}
if (currentDesign != null) {
String designPath = currentDesign.getPath();
if (!Designer.DEFAULT_DESIGN_PATH.equals(designPath)) {
this.designPath = designPath;
if (resolver.getResource(designPath + "/static.css") != null) {
staticDesignPath = designPath + "/static.css";
}
loadFavicons(designPath);
}
}
populateClientLibCategories();
templateName = extractTemplateName();
}
use of com.day.cq.tagging.Tag in project acs-aem-commons by Adobe-Consulting-Services.
the class PropertyMergePostProcessorTest method testMergeAllTags.
@Test
public void testMergeAllTags() throws Exception {
final TagManager mockTagManager = mock(TagManager.class);
Tag fakeTag = mock(Tag.class);
when(mockTagManager.resolve(any())).thenReturn(fakeTag);
context.registerAdapter(ResourceResolver.class, TagManager.class, mockTagManager);
ResourceResolver rr = context.resourceResolver();
MockSlingHttpServletRequest request = context.request();
request.setParameterMap(new HashMap<String, Object>() {
{
put("./asset/jcr:content/metadata/dam:tag1", new String[] { "tag1:tag1a", "tag1:tag1b" });
put("./asset/jcr:content/metadata/dam:tag2", new String[] { "tag2:tag2a", "tag2:tag2b" });
put(":" + PropertyMergePostProcessor.OPERATION_ALL_TAGS + "@PropertyMerge", "jcr:content/metadata/dam:combined-tags");
}
});
Map<String, Object> emptyProperties = new HashMap<>();
Resource content = rr.create(rr.resolve("/"), "content", emptyProperties);
Resource dam = rr.create(content, "dam", emptyProperties);
request.setResource(dam);
Resource asset = rr.create(dam, "asset", emptyProperties);
Resource jcrContent = rr.create(asset, "jcr:content", emptyProperties);
Resource metadata = rr.create(jcrContent, "metadata", new HashMap<String, Object>() {
{
put("dam:tag1", new String[] { "tag1:tag1a", "tag1:tag1b" });
put("dam:tag2", new String[] { "tag2:tag2a", "tag2:tag2b" });
}
});
PropertyMergePostProcessor processor = new PropertyMergePostProcessor();
List<Modification> changeLog = new ArrayList<>();
processor.process(request, changeLog);
Assert.assertFalse("Should have observed some changes", changeLog.isEmpty());
String[] tags = metadata.getValueMap().get("dam:combined-tags", String[].class);
Assert.assertArrayEquals(new String[] { "tag1:tag1a", "tag1:tag1b", "tag2:tag2a", "tag2:tag2b" }, tags);
}
use of com.day.cq.tagging.Tag in project acs-aem-commons by Adobe-Consulting-Services.
the class TagCreator method createTag.
private void createTag(TagDefinition tagDefinition, TagManager tagManager) {
ReportRowSatus status;
try {
if (tagManager.resolve(tagDefinition.getId()) == null) {
status = ReportRowSatus.CREATED;
} else {
status = ReportRowSatus.UPDATED_EXISTING;
}
final Tag tag = tagManager.createTag(tagDefinition.getId(), tagDefinition.getTitle(), tagDefinition.getDescription(), false);
if (tag != null) {
setTitles(tag, tagDefinition);
record(status, tag.getTagID(), tag.getPath(), tag.getTitle());
log.debug("Created tag [ {} -> {} ]", tagDefinition.getId(), tagDefinition.getTitle());
} else {
log.error("Tag [ {} ] is null", tagDefinition.getId());
}
} catch (Exception e) {
record(ReportRowSatus.FAILED_TO_CREATE, tagDefinition.getId(), tagDefinition.getPath(), tagDefinition.getTitle());
log.error("Unable to create tag [ {} -> {} ]", tagDefinition.getId(), tagDefinition.getTitle());
}
}
use of com.day.cq.tagging.Tag in project acs-aem-commons by Adobe-Consulting-Services.
the class TagsCellValue method getTags.
public List<Tag> getTags() {
TagManager tagMgr = request.getResourceResolver().adaptTo(TagManager.class);
Resource resource = (Resource) request.getAttribute("result");
log.debug("Loading tags from {}@{}", new String[] { resource.getPath(), property });
List<Tag> tags = new ArrayList<Tag>();
String[] values = resource.getValueMap().get(property, String[].class);
if (values != null) {
for (String value : values) {
tags.add(tagMgr.resolve(value));
}
}
log.debug("Loaded {} tags", tags.size());
return tags;
}
use of com.day.cq.tagging.Tag in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PageImpl method initModel.
@PostConstruct
protected void initModel() {
title = currentPage.getTitle();
description = currentPage.getDescription();
if (StringUtils.isBlank(title)) {
title = currentPage.getName();
}
Tag[] tags = currentPage.getTags();
keywords = new String[tags.length];
int index = 0;
for (Tag tag : tags) {
keywords[index++] = tag.getTitle(currentPage.getLanguage(false));
}
if (currentDesign != null) {
String designPath = currentDesign.getPath();
if (!Designer.DEFAULT_DESIGN_PATH.equals(designPath)) {
this.designPath = designPath;
if (resolver.getResource(designPath + "/static.css") != null) {
staticDesignPath = designPath + "/static.css";
}
loadFavicons(designPath);
}
}
populateClientlibCategories();
templateName = extractTemplateName();
brandSlug = Utils.getInheritedValue(currentPage, PN_BRANDSLUG);
}
Aggregations