本文整理汇总了Java中com.day.cq.tagging.Tag类的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tag类属于com.day.cq.tagging包,在下文中一共展示了Tag类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getJson
import com.day.cq.tagging.Tag; //导入依赖的package包/类
protected JSONObject getJson() {
JSONObject json = new JSONObject();
json.put(ID, getId());
json.put(TITLE, getTitle());
json.put(DESCRIPTION, getDescription());
json.put(BODY, getBody().getBodyAsText());
json.put(AUTHOR, getAuthor().displayName());
json.put(LAST_MODIFIED, SolrTimestamp.convertToUtcAndUseNowIfNull(getLastUpdate()));
json.put(PUBLISH_DATE, SolrTimestamp.convertToUtcAndUseNowIfNull(getPublishDate()));
json.put(SLING_RESOUCE_TYPE, getSlingResourceType());
json.put(URL, getUrl());
JSONArray tags = new JSONArray();
for (Tag tag : getTags()) {
tags.add(tag.getTitle());
}
json.put(TAGS, tags);
return json;
}
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:21,代码来源:GeometrixxMediaPageContent.java
示例2: createTag
import com.day.cq.tagging.Tag; //导入依赖的package包/类
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());
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:TagCreator.java
示例3: initModel
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@PostConstruct
protected 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();
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:26,代码来源:PageImpl.java
示例4: findTag
import com.day.cq.tagging.Tag; //导入依赖的package包/类
public Tag findTag(String tagId, Asset asset, Session session) {
Tag tag = null;
ResourceResolver resourceResolver = null;
try {
resourceResolver = getResourceResolver(session);
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
tag = tagManager.resolve(tagId);
} finally {
if (null != resourceResolver && resourceResolver.isLive()) {
resourceResolver.close();
}
}
return tag;
}
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:17,代码来源:ResourceResolverConsumer.java
示例5: getSolrDoc
import com.day.cq.tagging.Tag; //导入依赖的package包/类
protected SolrInputDocument getSolrDoc() {
SolrInputDocument doc = new SolrInputDocument();
doc.addField(ID, getId());
doc.addField(TITLE, getTitle());
doc.addField(DESCRIPTION, getDescription());
doc.addField(BODY, getBody().getBodyAsText());
doc.addField(AUTHOR, getAuthor().displayName());
doc.addField(LAST_MODIFIED, SolrTimestamp.convertToUtcAndUseNowIfNull(getLastUpdate()));
doc.addField(PUBLISH_DATE, SolrTimestamp.convertToUtcAndUseNowIfNull(getPublishDate()));
doc.addField(SLING_RESOUCE_TYPE, getSlingResourceType());
doc.addField(URL, getUrl());
for (Tag tag : getTags()) {
doc.addField(TAGS, tag.getTitle());
}
return doc;
}
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:21,代码来源:GeometrixxMediaPageContent.java
示例6: setTitles
import com.day.cq.tagging.Tag; //导入依赖的package包/类
private void setTitles(final Tag tag, final TagDefinition tagDefinition) throws RepositoryException {
final Node node = tag.adaptTo(Node.class);
if (node == null) {
log.error("Tag [ {} ] could not be adapted to a Node", tagDefinition.getId());
return;
}
if (!StringUtils.equals(tag.getTitle(), tagDefinition.getTitle())) {
// Ensure if the tag already exists that the title is set properly
node.setProperty("jcr:title", tagDefinition.getTitle());
}
if (!tagDefinition.getLocalizedTitles().isEmpty()){
// If Localized titles are provides ensure they are set properly
final Map<String,String> translationsMap = tagDefinition.getLocalizedTitles();
for (final Map.Entry<String, String> entry : translationsMap.entrySet()) {
node.setProperty("jcr:title." + entry.getKey(), entry.getValue());
}
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:TagCreator.java
示例7: getTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
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;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:20,代码来源:TagsCellValue.java
示例8: getKeywords
import com.day.cq.tagging.Tag; //导入依赖的package包/类
/**
* @return tag title keywords
*/
public String getKeywords() {
if (null != keywords || null == getCurrentPage()) return keywords;
// generate keywords from localized tag titles
final Tag[] tags = getCurrentPage().getTags();
if (ArrayUtils.getLength(tags) > 0 ) {
StringBuilder titles = new StringBuilder();
// append comma delimited tag titles
for(Tag tag : tags) {
if (titles.length() > 0) titles.append(WCMConstants.DELIMITER_COMMA);
titles.append(tag.getTitle(getCurrentPage().getLanguage(false)));
}
if (titles.length() > 0) keywords = titles.toString();
}
return keywords;
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:19,代码来源:PageUse.java
示例9: getKeywords
import com.day.cq.tagging.Tag; //导入依赖的package包/类
/**
* Get keywords from a page.
*
* @param pageContent This is a map of page content
* @param tm This is a Tag Manager instance
* @return keywords This is the meta keywords set on the page
*/
public static String getKeywords(Map<String, Object> pageContent, TagManager tm) {
String keywords = "";
if (pageContent.get("cq:tags") != null) {
ArrayList<?> tags = (ArrayList<?>) pageContent.get("cq:tags");
if (tags != null) {
for (Object obj : tags) {
String value = obj.toString();
if (keywords != null && keywords.length() > 0) {
keywords += ", ";
}
boolean noTagInfo = false;
Tag tag = tm.resolve(value);
if (tag != null) {
if (tag.getTitle() != null && tag.getTitle().length() > 0) {
value = tag.getTitle();
} else if (tag.getName() != null && tag.getName().length() > 0) {
value = tag.getName();
} else {
noTagInfo = true;
}
} else {
noTagInfo = true;
}
if (noTagInfo) {
if (value != null && value.length() > 0) {
if (value.indexOf("/") != -1) {
value = StringUtils.substringAfter(value, "/");
} else if (value.indexOf(":") != -1) {
value = StringUtils.substringAfter(value, ":");
}
}
}
keywords += value;
}
}
}
return keywords;
}
开发者ID:DantaFramework,项目名称:AEM,代码行数:46,代码来源:PageUtils.java
示例10: getTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
public List<Tag> getTags() {
List<Tag> tags = new ArrayList<Tag>();
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
if (contentFragment != null) {
Object[] tagIds = (Object[]) contentFragment.getMetaData().get("cq:tags");
if (tagIds != null) {
for (Object cqTag : tagIds) {
tags.add(tagManager.resolve(cqTag.toString()));
}
}
}
return tags;
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:15,代码来源:Article.java
示例11: testEmpty
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@Test
public void testEmpty() throws IllegalAccessException {
log.info("testEmpty");
TagsCellValue val = new TagsCellValue();
FieldUtils.writeField(val, "property", "tags2", true);
FieldUtils.writeField(val, "request", request, true);
List<Tag> tags = val.getTags();
assertEquals(0, tags.size());
log.info("Test successful!");
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:11,代码来源:TagsCellValueTest.java
示例12: testExporter
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@Test
public void testExporter() throws IllegalAccessException {
log.info("testExporter");
TagsCellValue val = new TagsCellValue();
FieldUtils.writeField(val, "property", "tags", true);
FieldUtils.writeField(val, "request", request, true);
assertTrue(ArrayUtils.isEquals(new Tag[] { tag1, tag2 }, val.getTags().toArray(new Tag[val.getTags().size()])));
log.info("Test successful!");
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:10,代码来源:TagsCellValueTest.java
示例13: doGet
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
String root = request.getParameter(PN_PATH);
if (StringUtils.isNotBlank(root)) {
TagManager tagManager = request.getResourceResolver().adaptTo(TagManager.class);
Tag rootTag = tagManager.resolve(root);
// cannot resolve root tag
if (null == rootTag) {
response.sendError(SlingHttpServletResponse.SC_NOT_FOUND);
} else {
JSONArray items = new JSONArray();
Iterator<Tag> children = rootTag.listChildren();
Tag child = null;
// iterate over child tags
while(children.hasNext()) {
child = children.next();
try {
items.put((Object)new JSONObject()
.put(PN_KEY, child.getTitle())
.put(PN_VALUE, child.getDescription()));
} catch (JSONException e) {
LOG.debug(e.getMessage());
}
child = null;
}
byte[] jsonBytes = items.toString().getBytes("UTF-8");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.setContentLength(jsonBytes.length);
response.getOutputStream().write(jsonBytes);
}
} else {
response.sendError(SlingHttpServletResponse.SC_NOT_FOUND);
}
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:39,代码来源:TagOptionsServlet.java
示例14: getTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
/**
* @param tagIDs
* @return list of valid tags given array of IDs
*/
private List<Tag> getTags(final String[] tagIDs) {
if (0 == ArrayUtils.getLength(tagIDs)) return Collections.emptyList();
final TagManager tm = getResourceResolver().adaptTo(TagManager.class);
List<Tag> tags = new ArrayList<Tag>();
Tag tag = null;
for(String id : tagIDs) {
tag = tm.resolve(id);
if (null != tag) tags.add(tag);
tag = null;
}
return tags;
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:19,代码来源:StyleUse.java
示例15: getTagDescriptions
import com.day.cq.tagging.Tag; //导入依赖的package包/类
/**
* @param tagIDs
* @return list of tag descriptions given array of IDs
*/
public List<String> getTagDescriptions(final String[] tagIDs) {
List<String> descriptions = new ArrayList<String>();
for(Tag tag : getTags(style)) {
if (StringUtils.isNotBlank(tag.getDescription())) {
descriptions.add(tag.getDescription());
}
}
return descriptions;
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:14,代码来源:StyleUse.java
示例16: productRolloutHook
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@Override
public void productRolloutHook(Product productData, Page productPage, Product product) throws CommerceException {
try {
boolean changed = false;
//
// The out-of-the-box commerce components (such as commerce/components/product) support
// two variant axes: "size", plus one (optional) user-defined axis.
// The user-defined axis, if required, is specified using the "variationAxis" and
// "variationTitle" properties.
//
// In the sample product set, the optional axis is always "color".
//
Node productNode = product.adaptTo(Node.class);
if (productData.axisIsVariant("color")) {
if (!productNode.hasProperty("variationAxis")) {
productNode.setProperty("variationAxis", "color");
productNode.setProperty("variationTitle", "Color");
changed = true;
}
} else {
if (productNode.hasProperty("variationAxis") && productNode.getProperty("variationAxis").getString().equals("color")) {
productNode.setProperty("variationAxis", "");
productNode.setProperty("variationTitle", "");
changed = true;
}
}
//
// Copy we-retail namespaced tags from the product to the product page.
//
if (CommerceHelper.copyTags(productData, productPage.getContentResource(),
new Predicate() {
public boolean evaluate(Object o) {
return ((Tag) o).getNamespace().getName().equals("we-retail");
}
})) {
changed = true;
}
//
// Give product pages a product-specific thumbnail so they don't have to fall back to
// the (generic) page_product template's thumbnail. This greatly improves the usability
// of the pages content finder tab.
//
if (!ResourceUtil.isA(productPage.getContentResource(), CommerceConstants.RT_PRODUCT_PAGE_PROXY)) {
String productImageRef = "";
Resource productImage = productData.getImage();
if (productImage != null) {
productImageRef = ResourceUtil.getValueMap(productImage).get("fileReference", "");
}
Node contentNode = productPage.getContentResource().adaptTo(Node.class);
Node pageImageNode = JcrUtils.getOrAddNode(contentNode, "image", "nt:unstructured");
pageImageNode.setProperty("fileReference", productImageRef);
}
if (changed) {
productPage.getPageManager().touch(productPage.adaptTo(Node.class), true, Calendar.getInstance(), false);
}
} catch(Exception e) {
throw new CommerceException("Product rollout hook failed: ", e);
}
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:64,代码来源:WeRetailCommerceServiceImpl.java
示例17: getTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@Override
public com.day.cq.tagging.Tag[] getTags() {
if (tagCache != null) return tagCache;
Resource contentResource = getContentResource();
TagManager tagManager = contentResource.getResourceResolver().adaptTo(TagManager.class);
tagCache = tagManager == null ? new Tag[0] : tagManager.getTags(contentResource);
return tagCache;
}
开发者ID:TWCable,项目名称:jackalope,代码行数:10,代码来源:PageImpl.java
示例18: getTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
public Tag[] getTags() {
return tags;
}
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:4,代码来源:GeometrixxMediaPageContent.java
示例19: testMergeAllTags
import com.day.cq.tagging.Tag; //导入依赖的package包/类
@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);
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:47,代码来源:PropertyMergePostProcessorTest.java
注:本文中的com.day.cq.tagging.Tag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论