当前位置: 首页>>代码示例>>Java>>正文


Java TagManager类代码示例

本文整理汇总了Java中com.day.cq.tagging.TagManager的典型用法代码示例。如果您正苦于以下问题:Java TagManager类的具体用法?Java TagManager怎么用?Java TagManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TagManager类属于com.day.cq.tagging包,在下文中一共展示了TagManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateTagListItems

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
private void populateTagListItems() {
    listItems = new ArrayList<>();
    String[] tags = properties.get(PN_TAGS, new String[0]);
    boolean matchAny = properties.get(PN_TAGS_MATCH, TAGS_MATCH_ANY_VALUE).equals(TAGS_MATCH_ANY_VALUE);
    if (ArrayUtils.isNotEmpty(tags)) {
        Page rootPage = getRootPage(PN_TAGS_PARENT_PAGE);
        if (rootPage != null) {
            TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
            if (tagManager != null) {
                RangeIterator<Resource> resourceRangeIterator = tagManager.find(rootPage.getPath(), tags, matchAny);
                if (resourceRangeIterator != null) {
                    while (resourceRangeIterator.hasNext()) {
                        Page containingPage = pageManager.getContainingPage(resourceRangeIterator.next());
                        if (containingPage != null) {
                            listItems.add(containingPage);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:23,代码来源:ListImpl.java

示例2: createTag

import com.day.cq.tagging.TagManager; //导入依赖的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: findTag

import com.day.cq.tagging.TagManager; //导入依赖的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

示例4: init

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
@PostConstruct
public void init() throws SlingModelsException {

    final Resource authorResource =
        resource.getResourceResolver().resolve(authorRef + "/profile");
    final GeometrixxMediaAuthorSummary authorSummary =
        authorResource.adaptTo(GeometrixxMediaAuthorSummary.class);

    final TagManager tagManager = resource.getResourceResolver().adaptTo(TagManager.class);

    id = resource.getParent().getPath();
    url = id + ".html";
    author = authorSummary != null ? authorSummary : new GeometrixxMediaAuthorSummary();
    body = articleBody != null ? articleBody : new GeometrixxMediaArticleBody("");
    tags = tagManager.getTags(resource);

}
 
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:18,代码来源:GeometrixxMediaPageContent.java

示例5: getValue

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
@Override
public String getValue(Object result) {
  
  Resource resource = (Resource) result;
  
  TagManager tagMgr = resource.getResourceResolver().adaptTo(TagManager.class);

  log.debug("Loading tags from {}@{}", new String[] { resource.getPath(), property });
  List<String> tags = new ArrayList<String>();
  String[] values = resource.getValueMap().get(property, String[].class);
  if (values != null) {
    for (String value : values) {
      tags.add(tagMgr.resolve(value).getTitle());
    }
  }
  log.debug("Loaded {} tags", tags);

  return StringUtils.join(tags,";");
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:20,代码来源:TagReportCellCSVExporter.java

示例6: getTags

import com.day.cq.tagging.TagManager; //导入依赖的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

示例7: init

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
@Before
public void init() {
  log.info("init");
  
  MockitoAnnotations.initMocks(this);

  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("tags", TAGS_VALUE);

  when(request.getAttribute("result")).thenReturn(mockResource);
  when(mockResource.getValueMap()).thenReturn(new ValueMapDecorator(properties));

  when(request.getResourceResolver()).thenReturn(resolver);
  when(resolver.adaptTo(TagManager.class)).thenReturn(tagMgr);

  when(tagMgr.resolve(TAGS_VALUE[0])).thenReturn(tag1);
  when(tagMgr.resolve(TAGS_VALUE[1])).thenReturn(tag2);

  when(tag1.getTitle()).thenReturn(TAGS_VALUE[0]);
  when(tag2.getTitle()).thenReturn(TAGS_VALUE[1]);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:TagsCellValueTest.java

示例8: init

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
@Before
public void init() {
  log.info("init");
  
  MockitoAnnotations.initMocks(this);

  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("tags", TAGS_VALUE);
  when(mockResource.getValueMap()).thenReturn(new ValueMapDecorator(properties));

  when(mockResource.getResourceResolver()).thenReturn(resolver);
  when(resolver.adaptTo(TagManager.class)).thenReturn(tagMgr);

  when(tagMgr.resolve(TAGS_VALUE[0])).thenReturn(tag1);
  when(tagMgr.resolve(TAGS_VALUE[1])).thenReturn(tag2);

  when(tag1.getTitle()).thenReturn(TAGS_VALUE[0]);
  when(tag2.getTitle()).thenReturn(TAGS_VALUE[1]);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:20,代码来源:TagReportCellCSVExporterTest.java

示例9: getKeywords

import com.day.cq.tagging.TagManager; //导入依赖的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.TagManager; //导入依赖的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: importTags

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
/**
 * Perform the tag creation based on the successfully parsed values in parseTags(..).
 *
 * @param manager the action manager
 */
public void importTags(ActionManager manager) {
    tagDefinitions.values().stream().forEach(tagDefinition -> {
        try {
            manager.withResolver(rr -> {
                final TagManager tagManager = rr.adaptTo(TagManager.class);
                ReportRowSatus status;

                createTag(tagDefinition, tagManager);
            });
        } catch (Exception e) {
            log.error("Unable to import tags via ACS Commons MCP - Tag Creator", e);
        }
    });
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:20,代码来源:TagCreator.java

示例12: hasTags

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
protected static boolean hasTags(ResourceResolver rr, RequestParameter[] params) {
    if (params == null) {
        return false;
    } else {
        TagManager tagManager = rr.adaptTo(TagManager.class);
        return Stream.of(params).allMatch(param
                -> looksLikeTag(param.getString())
                && tagManager.resolve(param.getString()) != null
        );
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:PropertyMergePostProcessor.java

示例13: doGet

import com.day.cq.tagging.TagManager; //导入依赖的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.TagManager; //导入依赖的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: process

import com.day.cq.tagging.TagManager; //导入依赖的package包/类
/**
 * @param executionContext
 * @param contentModel
 * @throws Exception
 */
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Resource resource = request.getResource();
        log.debug("for {}", resource.getPath());
        if (resource != null) {
            ResourceResolver resourceResolver = request.getResourceResolver();
            Designer designer = resourceResolver.adaptTo(Designer.class);
            final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
            final TagManager tm = (TagManager) resource.getResourceResolver().adaptTo(TagManager.class);
            Page page = pageManager.getContainingPage(resource);
            if (page != null) {
                if (!contentModel.has(PAGE_PROPERTIES_KEY)) {
                    Configuration configuration = configurationProvider.getFor(page.getContentResource().getResourceType());
                    Collection<String> bodyClasses = configuration.asStrings(XK_CONTAINER_CLASSES_CP, Mode.MERGE);
                    Node pageContentNode = page.getContentResource().adaptTo(Node.class);
                    Map<String, Object> pageContent = propsToMap(pageContentNode.getProperties());
                    pageContent.put(PATH, page.getPath());
                    pageContent.put(PAGE_NAME, page.getName());
                    pageContent.put(LINK, page.getPath() + HTML_EXT);
                    pageContent.put(BODY_CLASSES, bodyClasses);
                    pageContent.put(TITLE, page.getTitle());
                    pageContent.put(DESCRIPTION, page.getProperties().get(JCR_DESCRIPTION, ""));
                    pageContent.put(PAGE_TITLE, page.getProperties().get(PAGE_TITLE, ""));
                    pageContent.put(SUBTITLE, page.getProperties().get(SUBTITLE, ""));
                    pageContent.put(HIDE_IN_NAV, page.getProperties().get(HIDE_IN_NAV, ""));
                    pageContent.put(KEYWORDS, PageUtils.getKeywords(pageContent, tm));
                    pageContent.put(TAGS, PageUtils.getTags(pageContent));
                    pageContent.put(WCM_MODE, GeneralRequestObjects.getWCMModeString(request));
                    pageContent.put(IS_EDIT_MODE, GeneralRequestObjects.isEditMode(request));
                    pageContent.put(IS_DESIGN_MODE, GeneralRequestObjects.isDesignMode(request));
                    pageContent.put(IS_EDIT_OR_DESIGN_MODE, GeneralRequestObjects.isEditOrDesignMode(request));

                    if (designer != null) {
                        Design design = designer.getDesign(page);
                        if (design != null && design.getPath() != null) {
                            pageContent.put(FAVICON, design.getPath() + "/" + FAVICON + ICO_EXT);
                        }
                    }

                    String navigationTitle = PageUtils.getNavigationTitle(page);
                    if (null != navigationTitle) {
                        pageContent.put(NAVIGATION_TITLE, PageUtils.getNavigationTitle(page));
                    }
                    // add transformed path image
                    String pageImagePath = assetPathService.getPageImagePath(page, page.getContentResource());
                    if(StringUtils.isNotEmpty(pageImagePath)){
                        pageContent.put(IMAGE_PATH, pageImagePath);
                    }

                    // add interface mode
                    if (AuthoringUIMode.fromRequest(request) == AuthoringUIMode.TOUCH) {
                        pageContent.put(IS_TOUCH_UI_MODE, true);
                        pageContent.put(IS_CLASSIC_UI_MODE, false);
                    } else {
                        pageContent.put(IS_CLASSIC_UI_MODE, true);
                        pageContent.put(IS_TOUCH_UI_MODE, false);
                    }
                    contentModel.set(PAGE_PROPERTIES_KEY, pageContent);
                }
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:74,代码来源:AddPagePropertiesContextProcessor.java


注:本文中的com.day.cq.tagging.TagManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。