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


Java JcrConstants类代码示例

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


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

示例1: getParentResouce

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
/**
 * Gets the parent resouce.
 * If the parent resource (to hold our entries) does not exist, create it.
 *
 * @return the parent resouce
 */
private Resource getParentResouce() {
	Resource parentResource = resourceResolver.getResource(UPTIME_CALENDAR_PATH);
	if(parentResource == null) {
		Resource publicResource = resourceResolver.getResource("/etc/pugranch/public");
		Map<String,Object> properties = new HashMap<String,Object>();
		properties.put(JcrConstants.JCR_PRIMARYTYPE, "sling:OrderedFolder");
		try {
			parentResource = resourceResolver.create(publicResource, "uptimeCalendar", properties);
			resourceResolver.commit();
		} catch (PersistenceException e) {
			e.printStackTrace();
		}
	}
	return parentResource;
}
 
开发者ID:auniverseaway,项目名称:aem-touch-admin-console,代码行数:22,代码来源:UptimeEntryServlet.java

示例2: fillEntryProperties

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private void fillEntryProperties(ModifiableEntryBuilder entryBuilder, Mode mode, Progress progressLogger,
		InstanceDetails.InstanceType instanceType, String hostname, Calendar executionTime,
		Resource source, ValueMap values, String executor) {
	entryBuilder.setFileName(source.getName()) //
			.setFilePath(source.getPath()) //
			.setMode(mode.toString()) //
			.setProgressLog(ProgressHelper.toJson(progressLogger.getEntries())) //
			.setExecutionTime(executionTime) //
			.setAuthor(values.get(JcrConstants.JCR_CREATED_BY, StringUtils.EMPTY)) //
			.setUploadTime(values.get(JcrConstants.JCR_CREATED, StringUtils.EMPTY)) //
			.setInstanceType(instanceType.getInstanceName()) //
			.setInstanceHostname(hostname);
	if (StringUtils.isNotBlank(executor)) {
		entryBuilder.setExecutor(executor);
	}
	entryBuilder.save();
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:18,代码来源:HistoryImpl.java

示例3: getThumbnailUrl

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private String getThumbnailUrl(Page page, int width, int height) {
    String ck = "";

    ValueMap metadata = page.getProperties(PN_IMAGE_FILE_JCR_CONTENT);
    if (metadata != null) {
        Calendar imageLastModified = metadata.get(JcrConstants.JCR_LASTMODIFIED, Calendar.class);
        Calendar pageLastModified = page.getLastModified();
        if (pageLastModified != null && pageLastModified.after(imageLastModified)) {
            ck += pageLastModified.getTimeInMillis() / 1000;
        } else if (imageLastModified != null) {
            ck += imageLastModified.getTimeInMillis() / 1000;
        } else if (pageLastModified != null) {
            ck += pageLastModified.getTimeInMillis() / 1000;
        }
    }

    return page.getPath() + ".thumb." + width + "." + height + ".png?ck=" + ck;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:19,代码来源:SocialMediaHelperImpl.java

示例4: getSiteName

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Override
public String getSiteName() {
    Page page = findRootPage();

    String pageTitle = page.getPageTitle();
    if (StringUtils.isNotBlank(pageTitle)) {
        return pageTitle;
    }

    Resource content = page.getContentResource();
    if (content == null) {
        return null;
    }
    String title = content.getValueMap().get(JcrConstants.JCR_TITLE, String.class);
    if (StringUtils.isBlank(title)) {
        return null;
    }
    return title;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:20,代码来源:SocialMediaHelperImpl.java

示例5: getReplicationStatusResource

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Resource getReplicationStatusResource(String path, ResourceResolver resourceResolver) {
    final Page page = resourceResolver.adaptTo(PageManager.class).getContainingPage(path);
    final Asset asset = DamUtil.resolveToAsset(resourceResolver.getResource(path));

    Resource resource;
    String type;

    if (page != null) {
        type = "Page";
        resource = page.getContentResource();
    } else if (asset != null) {
        type = "Asset";
        Resource assetResource = resourceResolver.getResource(asset.getPath());
        resource = assetResource.getChild(JcrConstants.JCR_CONTENT);
    } else {
        type = "Resource";
        resource = resourceResolver.getResource(path);
    }

    log.trace(type + "'s resource that tracks replication status is " + resource.getPath());
    return resource;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:ReplicationStatusManagerImpl.java

示例6: findAllVersions

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的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: getLastModified

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

示例8: getCacheKiller

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
/**
 * Get the timestamp for the last change to the thumbnail.
 *
 * @param asset
 * @return
 */
private static long getCacheKiller(final Asset asset) {
    try {
        Resource resource = asset.getRendition(DAM_THUMBNAIL);
        Resource contentResource = resource.getChild(JcrConstants.JCR_CONTENT);
        ValueMap properties = contentResource.adaptTo(ValueMap.class);

        return properties.get(JcrConstants.JCR_LASTMODIFIED, 0L) / ONE_MILLION;
    } catch (Exception ex) {
        return 0L;
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:ContentFinderHitBuilder.java

示例9: getPage

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
/**
 * Gets the Page object corresponding the with the resource.
 * Will resolve to a Page if the result is a cq:Page or a cq:Page's jcr:content node.
 *
 * @param resource The resource to covert to a Page
 * @return a Page if  the resource is Page like (cq:Page or a cq:Page's jcr:content node), else null
 */
private static Page getPage(final Resource resource) {
    if (resource == null) {
        return null;
    }

    // If resource is a cq:Page node; then return the Page
    if (resource.adaptTo(Page.class) != null) {
        return resource.adaptTo(Page.class);
    }

    // If the resource is a cq:Page/jcr:content node, then return the cq:Page page
    if (StringUtils.equals(resource.getName(), JcrConstants.JCR_CONTENT)) {
        final Resource parent = resource.getParent();
        if (parent != null) {
            return parent.adaptTo(Page.class);
        }
    }

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

示例10: addItems

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private List<MapEntry> addItems(RedirectConfigModel config, Iterator<Resource> items, StringBuilder sb,
        String suffix) {
    List<MapEntry> invalidEntries = new ArrayList<MapEntry>();
    while (items.hasNext()) {
        Resource item = items.next();
        String path = item.getPath();
        ValueMap properties = item.getChild(JcrConstants.JCR_CONTENT).getValueMap();
        FakeSlingHttpServletRequest mockRequest = new FakeSlingHttpServletRequest(resourceResolver,
                config.getProtocol(), config.getDomain(), (config.getProtocol().equals("https") ? 443 : 80));
        String pageUrl = config.getProtocol() + "://" + config.getDomain()
                + resourceResolver.map(mockRequest, item.getPath() + suffix);

        String[] sources = properties.get(config.getProperty(), String[].class);
        for (String source : sources) {
            MapEntry entry = new MapEntry(item, source, pageUrl);
            if (!entry.isValid()) {
                log.warn("Source path {} for content {} contains whitespace", entry.getSource(), path);
                invalidEntries.add(entry);
            } else {
                sb.append(entry.getSource() + " " + entry.getTarget() + "\n");
            }
        }
    }
    return invalidEntries;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:26,代码来源:RedirectMapModel.java

示例11: create

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
/**
 * Create the oak index based on the ensure definition.
 *
 * @param ensuredDefinition the ensure definition
 * @param oakIndexes        the parent oak index folder
 * @return the updated oak index resource
 * @throws PersistenceException
 * @throws RepositoryException
 */
public Resource create(final @Nonnull Resource ensuredDefinition, final @Nonnull Resource oakIndexes) throws PersistenceException,
        RepositoryException {

    final Node oakIndex = JcrUtil.copy(
            ensuredDefinition.adaptTo(Node.class),
            oakIndexes.adaptTo(Node.class),
            ensuredDefinition.getName());

    oakIndex.setPrimaryType(NT_OAK_QUERY_INDEX_DEFINITION);
    oakIndex.setProperty(JcrConstants.JCR_CREATED, Calendar.getInstance());
    oakIndex.setProperty(JcrConstants.JCR_CREATED_BY, ENSURE_OAK_INDEX_USER_NAME);

    log.info("Created Oak Index at [ {} ] with Ensure Definition [ {} ]", oakIndex.getPath(),
            ensuredDefinition.getPath());

    return ensuredDefinition.getResourceResolver().getResource(oakIndex.getPath());
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:EnsureOakIndexJobHandler.java

示例12: CsvUser

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
public CsvUser(Resource resource) throws RepositoryException {
    if (resource == null) {
        throw new IllegalArgumentException("Authorizable object cannot be null");
    }

    final UserManager userManager = resource.adaptTo(UserManager.class);
    this.properties = resource.getValueMap();

    this.authorizable = userManager.getAuthorizableByPath(resource.getPath());

    this.declaredGroups = getGroupIds(authorizable.declaredMemberOf());
    this.transitiveGroups = getGroupIds(authorizable.memberOf());

    this.allGroups.addAll(this.transitiveGroups);
    this.allGroups.addAll(this.declaredGroups);

    this.transitiveGroups.removeAll(this.declaredGroups);

    this.firstName = properties.get("profile/givenName", "");
    this.lastName = properties.get("profile/familyName", "");
    this.email = properties.get("profile/email", "");
    this.createdDate = properties.get(JcrConstants.JCR_CREATED, Calendar.class);
    this.lastModifiedDate = properties.get("cq:lastModified", Calendar.class);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:25,代码来源:UsersExportServlet.java

示例13: moveChildrenToNode

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private void moveChildrenToNode(Resource resource, Node targetNode) throws RepositoryException {
    for (Resource child : resource.getChildren()) {

        // Use this to create a unique node name; else existing components might get overwritten.
        final Node uniqueNode = JcrUtil.createUniqueNode(targetNode, child.getName(),
                JcrConstants.NT_UNSTRUCTURED, targetNode.getSession());

        // Once we have a unique node we made as a place holder, we can copy over it w the real component content
        JcrUtil.copy(child.adaptTo(Node.class), targetNode, uniqueNode.getName(), true);
    }

    // Remove the old long-form-text-par- node
    resource.adaptTo(Node.class).remove();

    // Save all changes
    targetNode.getSession().save();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:LongFormTextComponentImpl.java

示例14: getOrCreateLastParagraphSystemResource

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private Node getOrCreateLastParagraphSystemResource(final Resource resource,
                                                    final int lastIndex) throws RepositoryException {
    final String resourceName = LONG_FORM_TEXT_PAR + lastIndex;
    final Resource lastResource = resource.getChild(resourceName);
    if (lastResource != null) {
        return lastResource.adaptTo(Node.class);
    }

    final Node parentNode = resource.adaptTo(Node.class);

    if (parentNode == null) {
        return null;
    }

    final Session session = parentNode.getSession();
    final Node node = JcrUtil.createPath(parentNode, resourceName, false, JcrConstants.NT_UNSTRUCTURED,
            JcrConstants.NT_UNSTRUCTURED, session, true);

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

示例15: testGetPayloadProperties_Asset

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Test
public void testGetPayloadProperties_Asset() throws Exception {

    // set up jcr properties
    mockJcrProperties();

    Resource payloadRes = mock(Resource.class);
    Resource mdRes = mock(Resource.class);
    when(payloadRes.getResourceType()).thenReturn("dam:Asset");

    when(payloadRes.getChild(JcrConstants.JCR_CONTENT + "/" + DamConstants.METADATA_FOLDER)).thenReturn(mdRes);

    // mock valueMap
    when(mdRes.getValueMap()).thenReturn(vmap);
    Map<String, String> props = SendTemplatedEmailUtils.getPayloadProperties(payloadRes, sdf);

    assertEquals(props.get(PN_CALENDAR), CALENDAR_TOSTRING);
    assertEquals(props.get(PN_TITLE), STR_TOSTRING);
    assertEquals(props.get(PN_LONG), LONG_TOSTRING);
    assertEquals(props.get(PN_STR_ARRAY), STR_ARRAY_TOSTRING);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:SendTemplatedEmailUtilsTest.java


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