com.day.cq.tagging.TagManager Java Examples
The following examples show how to use
com.day.cq.tagging.TagManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphqlProductViewHandlerTest.java From commerce-cif-connector with Apache License 2.0 | 7 votes |
@Before public void setUp() { servletRequest = Mockito.mock(SlingHttpServletRequest.class); resourceResolver = Mockito.mock(ResourceResolver.class); Mockito.when(servletRequest.getResourceResolver()).thenReturn(resourceResolver); tagManager = Mockito.mock(TagManager.class); Mockito.when(resourceResolver.adaptTo(TagManager.class)).thenReturn(tagManager); commerceBasePathsService = Mockito.mock(CommerceBasePathsService.class); Mockito.when(resourceResolver.adaptTo(CommerceBasePathsService.class)).thenReturn(commerceBasePathsService); Mockito.when(commerceBasePathsService.getProductsBasePath()).thenReturn("/var/commerce/products"); requestPathInfo = Mockito.mock(RequestPathInfo.class); Mockito.when(servletRequest.getRequestPathInfo()).thenReturn(requestPathInfo); Mockito.when(requestPathInfo.getSuffix()).thenReturn("/var/commerce/products"); omniSearchHandler = Mockito.mock(OmniSearchHandler.class); searchResult = Mockito.mock(SearchResult.class); viewHandler = new GraphqlProductViewHandler(); viewHandler.omniSearchHandler = omniSearchHandler; Mockito.when(omniSearchHandler.getResults(resourceResolver, null, 0, 0)).thenReturn(searchResult); }
Example #2
Source File: ResourceResolverConsumer.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: GeometrixxMediaPageContent.java From aem-solr-search with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: PageImpl.java From jackalope with Apache License 2.0 | 5 votes |
@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; }
Example #5
Source File: GraphqlProductViewHandler.java From commerce-cif-connector with Apache License 2.0 | 4 votes |
@Override protected ViewQuery createQuery(SlingHttpServletRequest request, Session session, String queryString) throws RepositoryException { queryString = preserveWildcards(queryString); PredicateGroup gqlPredicateGroup = PredicateConverter.createPredicatesFromGQL(queryString); ResourceResolver resolver = request.getResourceResolver(); tagManager = resolver.adaptTo(TagManager.class); Set<String> predicateSet = customizePredicateGroup(gqlPredicateGroup); // set default start path RequestPathInfo pathInfo = request.getRequestPathInfo(); CommerceBasePathsService cbps = resolver.adaptTo(CommerceBasePathsService.class); String defaultStartPath = cbps.getProductsBasePath(); String startPath = (pathInfo.getSuffix() != null && pathInfo.getSuffix().startsWith(defaultStartPath)) ? pathInfo.getSuffix() : defaultStartPath; if (!predicateSet.contains(PathPredicateEvaluator.PATH)) { gqlPredicateGroup.add(new Predicate(PathPredicateEvaluator.PATH).set(PathPredicateEvaluator.PATH, startPath)); } String refererHeader = request.getHeader(REFERER_HEADER); if (StringUtils.isNotBlank(refererHeader) && refererHeader.contains(PAGE_EDITOR_PATH + "/")) { int p = refererHeader.lastIndexOf(PAGE_EDITOR_PATH); String pagePath = refererHeader.substring(p + PAGE_EDITOR_PATH.length()); if (pagePath.endsWith(".html")) { pagePath = pagePath.substring(0, pagePath.length() - ".html".length()); } CatalogSearchSupport catalogSearch = new CatalogSearchSupport(resolver); String catalogPath = catalogSearch.findCatalogPath(pagePath); String rootCategoryId = catalogSearch.findCategoryId(catalogPath); if (rootCategoryId != null) { gqlPredicateGroup.add(new Predicate(CATEGORY_ID_PARAMETER).set(CATEGORY_ID_PARAMETER, rootCategoryId)); gqlPredicateGroup.add(new Predicate(CATEGORY_PATH_PARAMETER).set(CATEGORY_PATH_PARAMETER, catalogPath)); } } else { LOGGER.warn("The path of the edited page cannot be determined"); } // append node type constraint to match product data index /etc/commerce/oak:index/commerce gqlPredicateGroup.add(new Predicate(TypePredicateEvaluator.TYPE).set(TypePredicateEvaluator.TYPE, NT_UNSTRUCTURED)); // append limit constraint if (gqlPredicateGroup.get(Predicate.PARAM_LIMIT) == null) { String limit = request.getParameter(LIMIT); if ((limit != null) && (!limit.equals(""))) { int offset = Integer.parseInt(StringUtils.substringBefore(limit, "..")); int total = Integer.parseInt(StringUtils.substringAfter(limit, "..")); gqlPredicateGroup.set(Predicate.PARAM_LIMIT, Long.toString(total - offset)); gqlPredicateGroup.set(Predicate.PARAM_OFFSET, Long.toString(offset)); } else { gqlPredicateGroup.set(Predicate.PARAM_LIMIT, Long.toString(DEFAULT_LIMIT)); } } // add product property constraint addProductConstraint(gqlPredicateGroup); // append order constraint if (!predicateSet.contains(Predicate.ORDER_BY)) { gqlPredicateGroup.add(new Predicate(Predicate.ORDER_BY) .set(Predicate.ORDER_BY, "@" + JCR_LASTMODIFIED) .set(Predicate.PARAM_SORT, Predicate.SORT_DESCENDING)); } return new GQLViewQuery(resolver, omniSearchHandler, xssAPI, gqlPredicateGroup); }