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


Java NameConstants类代码示例

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


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

示例1: populateSearchListItems

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
private void populateSearchListItems() {
    listItems = new ArrayList<>();
    if (!StringUtils.isBlank(query)) {
        SimpleSearch search = resource.adaptTo(SimpleSearch.class);
        if (search != null) {
            search.setQuery(query);
            search.setSearchIn(startIn);
            search.addPredicate(new Predicate("type", "type").set("type", NameConstants.NT_PAGE));
            search.setHitsPerPage(limit);
            try {
                collectSearchResults(search.getResult());
            } catch (RepositoryException e) {
                LOGGER.error("Unable to retrieve search results for query.", e);
            }
        }
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:18,代码来源:ListImpl.java

示例2: getTitle

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
/**
 * Returns the title of the given resource. If the title is empty it will fallback to the page title, title,
 * or name of the given page.
 * @param resource  The resource.
 * @param page      The page to fallback to.
 * @return          The best suited title found (or <code>null</code> if resource is <code>null</code>).
 */
public static String getTitle(final Resource resource, final Page page) {
    if (resource != null) {
        final ValueMap properties = resource.adaptTo(ValueMap.class);
        if (properties != null) {
            final String title = properties.get(NameConstants.PN_TITLE, String.class);
            if (StringUtils.isNotBlank(title)) {
                return title;
            } else {
                return getPageTitle(page);
            }
        }
    } else {
        LOGGER.debug("Provided resource argument is null");
    }
    return null;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:24,代码来源:WeRetailHelper.java

示例3: testMethods

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
@Test
public void testMethods() throws Exception {
    Resource mockResource = mock(Resource.class);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(NameConstants.PN_TITLE, MOCK_RESOURCE_TITLE);
    ValueMap vm = new ValueMapDecorator(map);
    when(mockResource.adaptTo(ValueMap.class)).thenReturn(vm);

    assertEquals(MOCK_RESOURCE_TITLE, WeRetailHelper.getTitle(mockResource, page));
    assertEquals(ORDER_DETAILS_TITLE, WeRetailHelper.getPageTitle(page));
    assertEquals(ORDER_DETAILS_TITLE, WeRetailHelper.getTitle(page));

    assertNull(WeRetailHelper.getTitle(null, page));
    assertNull(WeRetailHelper.getPageTitle(null));
    assertNull(WeRetailHelper.getTitle(null));

    // If the resource does not have a title, the page title is returned
    Map<String, Object> map2 = new HashMap<String, Object>();
    ValueMap vm2 = new ValueMapDecorator(map2);
    when(mockResource.adaptTo(ValueMap.class)).thenReturn(vm2);
    assertEquals(ORDER_DETAILS_TITLE, WeRetailHelper.getTitle(mockResource, page));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:23,代码来源:WeRetailHelperTest.java

示例4: indexData

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
@Override
public void indexData(Map<String, Object> data, Resource resource, String containerPath) {

    Asset asset = resource.adaptTo(Asset.class);
    if (asset != null) {
        data.put(IndexFields.PATH, asset.getPath());
        Object tagsArr = asset.getMetadata(NameConstants.PN_TAGS);
        if (tagsArr != null && tagsArr instanceof Object[]) {
            Object[] tags = (Object[]) tagsArr;
            for (Object tag : tags) {
                putMultiValue(data, IndexFields.TAGS, tag.toString());
            }
        }

        String title = StringUtils.trimToNull((String) asset.getMetadataValue("dc:title"));
        if (title == null || title.trim().length() == 0) {
            title = asset.getName();
        }
        data.put(IndexFields.TITLE, title);
    }
}
 
开发者ID:mwmd,项目名称:ease,代码行数:22,代码来源:AssetIndexer.java

示例5: all

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
private void all(Session session, Iterator<Resource> items) {

        while (items.hasNext()) {
            Resource res = items.next();
            if (NameConstants.NT_PAGE.equals(res.getResourceType()) || DamConstants.NT_DAM_ASSET.equals(res.getResourceType())) {
                if (!this.includeNonActivated) {
                    ReplicationStatus status = replicator.getReplicationStatus(session, res.getPath());
                    if (status != null && (status.isActivated())) {
                        add(res.getPath(), null);
                    }
                } else {
                    add(res.getPath(), null);
                }
            }
            all(session, res.listChildren());
        }
    }
 
开发者ID:mwmd,项目名称:ease,代码行数:18,代码来源:IndexServiceImpl.java

示例6: findAllVersions

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
private List<Version> findAllVersions(String path, Session session)
        throws RepositoryException {
    List<Version> versions = new ArrayList<Version>();

    Node node = session.getNode(path);
    if (node.hasNode(NameConstants.NN_CONTENT)) {
        Node contentNode = node.getNode(NameConstants.NN_CONTENT);
        if (contentNode.isNodeType(JcrConstants.MIX_VERSIONABLE)) {
            versions =   getVersions(contentNode.getPath(), session);
        } else if (node.isNodeType(JcrConstants.MIX_VERSIONABLE)) {
            versions = getVersions(path, session);
        }
    }

    return versions;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:ReplicateVersionImpl.java

示例7: GenericListImpl

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
public GenericListImpl(Resource listParsys) {
    List<Item> tempItems = new ArrayList<Item>();
    Map<String, Item> tempValueMapping = new HashMap<String, Item>();
    Iterator<Resource> children = listParsys.listChildren();
    while (children.hasNext()) {
        Resource res = children.next();
        ValueMap map = res.getValueMap();
        String title = map.get(NameConstants.PN_TITLE, String.class);
        String value = map.get(PN_VALUE, String.class);
        if (title != null && value != null) {
            ItemImpl item = new ItemImpl(title, value, map);
            tempItems.add(item);
            tempValueMapping.put(value, item);
        }
    }
    items = Collections.unmodifiableList(tempItems);
    valueMapping = Collections.unmodifiableMap(tempValueMapping);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:GenericListImpl.java

示例8: getLastModified

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
/**
 * Get the last modified date for a generic resource.
 *
 * @param resource
 * @return
 */
private static long getLastModified(final Resource resource) {
    final ValueMap properties = resource.adaptTo(ValueMap.class);

    final Date cqLastModified = properties.get(NameConstants.PN_PAGE_LAST_MOD, Date.class);
    if (cqLastModified != null) {
        return cqLastModified.getTime();
    }

    final Date jcrLastModified = properties.get(JcrConstants.JCR_LASTMODIFIED, Date.class);
    if (jcrLastModified != null) {
        return jcrLastModified.getTime();
    }

    return 0L;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:ContentFinderHitBuilder.java

示例9: activate

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
@Activate
protected void activate(Map<String, Object> properties) {
    this.externalizerDomain = PropertiesUtil.toString(properties.get(PROP_EXTERNALIZER_DOMAIN),
            DEFAULT_EXTERNALIZER_DOMAIN);
    this.includeLastModified = PropertiesUtil.toBoolean(properties.get(PROP_INCLUDE_LAST_MODIFIED),
            DEFAULT_INCLUDE_LAST_MODIFIED);
    this.includeInheritValue = PropertiesUtil.toBoolean(properties.get(PROP_INCLUDE_INHERITANCE_VALUE),
            DEFAULT_INCLUDE_INHERITANCE_VALUE);
    this.changefreqProperties = PropertiesUtil.toStringArray(properties.get(PROP_CHANGE_FREQUENCY_PROPERTIES),
            new String[0]);
    this.priorityProperties = PropertiesUtil.toStringArray(properties.get(PROP_PRIORITY_PROPERTIES), new String[0]);
    this.damAssetProperty = PropertiesUtil.toString(properties.get(PROP_DAM_ASSETS_PROPERTY), "");
    this.damAssetTypes = Arrays
            .asList(PropertiesUtil.toStringArray(properties.get(PROP_DAM_ASSETS_TYPES), new String[0]));
    this.excludeFromSiteMapProperty = PropertiesUtil.toString(properties.get(PROP_EXCLUDE_FROM_SITEMAP_PROPERTY),
            NameConstants.PN_HIDE_IN_NAV);
    this.characterEncoding = PropertiesUtil.toString(properties.get(PROP_CHARACTER_ENCODING_PROPERTY), null);
    this.extensionlessUrls = PropertiesUtil.toBoolean(properties.get(PROP_EXTENSIONLESS_URLS),
            DEFAULT_EXTENSIONLESS_URLS);
    this.removeTrailingSlash = PropertiesUtil.toBoolean(properties.get(PROP_REMOVE_TRAILING_SLASH), 
            DEFAULT_REMOVE_TRAILING_SLASH);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:23,代码来源:SiteMapServlet.java

示例10: getResults

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
private List<ListItem> getResults(SlingHttpServletRequest request, Resource searchResource, Page currentPage) {
    ValueMap valueMap = searchResource.getValueMap();
    ValueMap contentPolicyMap = getContentPolicyProperties(searchResource, request.getResource());
    int searchTermMinimumLength = valueMap.get(Search.PN_SEARCH_TERM_MINIMUM_LENGTH, contentPolicyMap.get(Search
            .PN_SEARCH_TERM_MINIMUM_LENGTH, SearchImpl.PROP_SEARCH_TERM_MINIMUM_LENGTH_DEFAULT));
    int resultsSize = valueMap.get(Search.PN_RESULTS_SIZE, contentPolicyMap.get(Search.PN_RESULTS_SIZE,
            SearchImpl.PROP_RESULTS_SIZE_DEFAULT));
    String searchRootPagePath = getSearchRootPagePath(searchResource, currentPage, contentPolicyMap);
    if (StringUtils.isEmpty(searchRootPagePath)) {
        searchRootPagePath = currentPage.getPath();
    }
    List<ListItem> results = new ArrayList<>();
    String fulltext = request.getParameter(PARAM_FULLTEXT);
    if (fulltext == null || fulltext.length() < searchTermMinimumLength) {
        return results;
    }
    long resultsOffset = 0;
    if (request.getParameter(PARAM_RESULTS_OFFSET) != null) {
        resultsOffset = Long.parseLong(request.getParameter(PARAM_RESULTS_OFFSET));
    }
    Map<String, String> predicatesMap = new HashMap<>();
    predicatesMap.put(PREDICATE_FULLTEXT, fulltext);
    predicatesMap.put(PREDICATE_PATH, searchRootPagePath);
    predicatesMap.put(PREDICATE_TYPE, NameConstants.NT_PAGE);
    PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
    ResourceResolver resourceResolver = request.getResource().getResourceResolver();
    Query query = queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
    if (resultsSize != 0) {
        query.setHitsPerPage(resultsSize);
    }
    if (resultsOffset != 0) {
        query.setStart(resultsOffset);
    }
    SearchResult searchResult = query.getResult();

    List<Hit> hits = searchResult.getHits();
    if (hits != null) {
        for (Hit hit : hits) {
            try {
                Resource hitRes = hit.getResource();
                Page page = getPage(hitRes);
                if (page != null) {
                    results.add(new PageListItemImpl(request, page));
                }
            } catch (RepositoryException e) {
                LOGGER.error("Unable to retrieve search results for query.", e);
            }
        }
    }
    return results;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:52,代码来源:SearchResultServlet.java

示例11: getPoliciesRootPage

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
/**
 * Given a {@code resourceResolver} and a {@code path} to a content policy, this method will return the policies root page
 * {@link Resource} for the provided {@code path}.
 *
 * @param resourceResolver a resource resolver
 * @param path             the path to analyse
 * @return the policies root page as a {@link Resource} or {@code null}
 */
@Nullable
private Resource getPoliciesRootPage(@Nonnull ResourceResolver resourceResolver, @Nonnull String path) {
    Resource resource = resourceResolver.getResource(path);
    if (resource != null && resource.getResourceType().equals(NameConstants.NT_PAGE)) {
        return resource;
    } else if (StringUtils.isNotEmpty(path) && path.lastIndexOf('/') > 0) {
        return getPoliciesRootPage(resourceResolver, path.substring(0, path.lastIndexOf('/')));
    } else {
        return null;
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:20,代码来源:ImageDelegateRenderCondition.java

示例12: extractTemplateName

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
protected String extractTemplateName() {
    String templateName = null;
    String templatePath = pageProperties.get(NameConstants.PN_TEMPLATE, String.class);
    if (StringUtils.isNotEmpty(templatePath)) {
        int i = templatePath.lastIndexOf("/");
        if (i > 0) {
            templateName = templatePath.substring(i + 1);
        }
    }
    return templateName;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:12,代码来源:PageImpl.java

示例13: getLastModifiedDate

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
@Override
public Calendar getLastModifiedDate() {
    if (lastModifiedDate == null) {
        lastModifiedDate = pageProperties.get(NameConstants.PN_PAGE_LAST_MOD, Calendar.class);
    }
    return lastModifiedDate;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:8,代码来源:PageImpl.java

示例14: setUp

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
@Before
public void setUp() {
    when(formStructureHelperFactory.getFormStructureHelper(any(Resource.class))).thenReturn(formStructureHelper);
    when(requestDispatcherFactory.getRequestDispatcher(any(Resource.class), any())).thenReturn(requestDispatcher);
    CONTEXT.registerService(FormStructureHelperFactory.class, formStructureHelperFactory);
    CONTEXT.registerService(SlingModelFilter.class, new SlingModelFilter() {

        private final Set<String> IGNORED_NODE_NAMES = new HashSet<String>() {{
            add(NameConstants.NN_RESPONSIVE_CONFIG);
            add(MSMNameConstants.NT_LIVE_SYNC_CONFIG);
            add("cq:annotations");
        }};

        @Override
        public Map<String, Object> filterProperties(Map<String, Object> map) {
            return map;
        }

        @Override
        public Iterable<Resource> filterChildResources(Iterable<Resource> childResources) {
            return StreamSupport
                    .stream(childResources.spliterator(), false)
                    .filter(r -> !IGNORED_NODE_NAMES.contains(r.getName()))
                    .collect(Collectors.toList());
        }
    });
    FormsHelperStubber.createStub();
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:29,代码来源:ContainerImplTest.java

示例15: internalSetUp

import com.day.cq.wcm.api.NameConstants; //导入依赖的package包/类
protected static void internalSetUp(AemContext aemContext, String testBase, String contentRoot) {
    aemContext.load().json(testBase + CoreComponentTestContext.TEST_CONTENT_JSON, contentRoot);
    contentPolicyManager = mock(ContentPolicyManager.class);
    aemContext.registerInjectActivateService(new MockAdapterFactory());
    aemContext.registerAdapter(ResourceResolver.class, ContentPolicyManager.class,
            new Function<ResourceResolver, ContentPolicyManager>() {
                @Nullable
                @Override
                public ContentPolicyManager apply(@Nullable ResourceResolver resolver) {
                    return contentPolicyManager;
                }
            });
    aemContext.addModelsForClasses(MockResponsiveGrid.class);
    aemContext.load().json(testBase + "/test-conf.json", "/conf/coretest/settings");
    aemContext.load().json(testBase + "/default-tags.json", "/etc/tags/default");
    SlingModelFilter slingModelFilter = mock(SlingModelFilter.class);
    aemContext.registerService(SlingModelFilter.class, slingModelFilter);
    aemContext.registerService(SlingModelFilter.class, new SlingModelFilter() {

        private final Set<String> IGNORED_NODE_NAMES = new HashSet<String>() {{
            add(NameConstants.NN_RESPONSIVE_CONFIG);
            add(MSMNameConstants.NT_LIVE_SYNC_CONFIG);
            add("cq:annotations");
        }};

        @Override
        public Map<String, Object> filterProperties(Map<String, Object> map) {
            return map;
        }

        @Override
        public Iterable<Resource> filterChildResources(Iterable<Resource> childResources) {
            return StreamSupport
                    .stream(childResources.spliterator(), false)
                    .filter(r -> !IGNORED_NODE_NAMES.contains(r.getName()))
                    .collect(Collectors.toList());
        }
    });
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:40,代码来源:PageImplTest.java


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