Java源码示例:com.day.cq.tagging.Tag
示例1
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;
}
示例2
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;
}
示例3
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;
}
示例4
@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;
}
示例5
public Tag[] getTags() {
return tags;
}