• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JcrConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testNamePropertyUpdater_MultiLevel

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Test
public void testNamePropertyUpdater_MultiLevel() throws Exception {
    final Map<String, Object> config = new HashMap<String, Object>();
    config.put(CQIncludePropertyNamespaceServlet.PROP_NAMESPACEABLE_PROPERTY_VALUE_PATTERNS,
            new String[]{"^\\./.*"});
    config.put("namespace.multi-level", true);

    final CQIncludePropertyNamespaceServlet servlet = new CQIncludePropertyNamespaceServlet();
    servlet.activate(config);

    CQIncludePropertyNamespaceServlet.PropertyNamespaceUpdater visitor =
            servlet.new PropertyNamespaceUpdater("test");

    final JSONObject json = new JSONObject();

    json.put(JcrConstants.JCR_PRIMARYTYPE, "cq:Widget");
    json.put("xtype", "cqinclude");
    json.put("path", "/apps/test.cqinclude.namespace.level-1.json");

    visitor.accept(json);

    assertEquals("/apps/test.cqinclude.namespace.test%252Flevel-1.json", json.get("path"));
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:24,代码来源:CQIncludePropertyNamespaceServletTest.java


示例17: create

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Override
public ReplicationContent create(Session session, ReplicationAction action, ReplicationContentFactory factory, Map<String, Object> map) throws ReplicationException {
  String path = action.getPath();
  ReplicationLog log = action.getLog();

  if (StringUtils.isNotBlank(path)) {
    try {
      HashMap<String, Object> sessionMap = new HashMap<>();
      sessionMap.put(JcrResourceConstants.AUTHENTICATION_INFO_SESSION, session);
      ResourceResolver resolver = resolverFactory.getResourceResolver(sessionMap);

      Resource resource = resolver.getResource(path);
      if (resource != null) {
        String primaryType = resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class);
        ElasticSearchContentBuilder builder = getContentBuilder(primaryType, log);
        if (builder != null) {
          return createReplicationContent(factory, builder.create(path, resolver));
        }
      }
    }
    catch (LoginException e) {
      log.error("Could not retrieve Page Manager", e);
    }

  }
  log.info(getClass().getSimpleName() + ": Path is blank");
  return ReplicationContent.VOID;
}
 
开发者ID:deveth0,项目名称:elasticsearch-aem,代码行数:29,代码来源:ElasticSearchIndexContentBuilder.java


示例18: anAsset

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Override
public Resource anAsset(String path, Object... properties) throws Exception {
	Properties          props    = new Properties(properties);
	Map<String, Object> pairs    = new Properties(properties).toMap();
	String              mimeType = (String) pairs.remove(JcrConstants.JCR_MIMETYPE);
	if (mimeType == null) {
		mimeType = DEFAULT_MIMETYPE;
	}
	return client.getContentBuilder().asset(path, new ByteArrayInputStream("".getBytes("UTF-8")), mimeType, props.toMap()).adaptTo(Resource.class);
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:11,代码来源:Assets.java


示例19: saveScript

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
private Script saveScript(ResourceResolver resolver, final String fileName, final InputStream input,
		final boolean overwrite) {
	Script result = null;
	final Session session = resolver.adaptTo(Session.class);
	final ValueFactory valueFactory;
	try {
		valueFactory = session.getValueFactory();
		final Binary binary = valueFactory.createBinary(input);
		final Node saveNode = session.getNode(getSavePath());

		final Node fileNode, contentNode;
		if (overwrite && saveNode.hasNode(fileName)) {
			fileNode = saveNode.getNode(fileName);
			contentNode = fileNode.getNode(JcrConstants.JCR_CONTENT);
		} else {
			fileNode = saveNode.addNode(generateFileName(fileName, saveNode), JcrConstants.NT_FILE);
			contentNode = fileNode.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
		}

		contentNode.setProperty(JcrConstants.JCR_DATA, binary);
		contentNode.setProperty(JcrConstants.JCR_ENCODING, SCRIPT_ENCODING.name());
		JcrUtils.setLastModified(contentNode, Calendar.getInstance());
		session.save();
		result = scriptFinder.find(fileNode.getPath(), resolver);
	} catch (RepositoryException e) {
		LOG.error(e.getMessage(), e);
	}
	return result;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:30,代码来源:ScriptStorageImpl.java


示例20: replicate

import com.day.cq.commons.jcr.JcrConstants; //导入依赖的package包/类
@Override
public void replicate(Script script, ResourceResolver resolver) throws ExecutionException,
		ReplicationException, PersistenceException {
	eventManager.trigger(Event.BEFORE_REPLICATE, script);

	final List<Script> includes = new LinkedList<>();
	includes.add(script);
	includes.addAll(scriptManager.findIncludes(script, resolver));

	final boolean autocommit = true;
	final Resource includeDir = ResourceUtil
			.getOrCreateResource(resolver, REPLICATION_PATH, JcrConstants.NT_UNSTRUCTURED,
					JcrConstants.NT_UNSTRUCTURED, autocommit);

	for (final Script include : includes) {
		final String path = (script.equals(include) ? SCRIPT_PATH : REPLICATION_PATH) + "/" + FilenameUtils
				.getName(include.getPath());

		LOG.warn("Copying {} to {}", include.getPath(), includeDir.getPath());
		copy(resolver, include.getPath(), includeDir);
		resolver.commit();

		final Session session = resolver.adaptTo(Session.class);
		replicator.replicate(session, ReplicationActionType.ACTIVATE, path);
	}
	resolver.delete(includeDir);
	resolver.commit();
	eventManager.trigger(Event.AFTER_REPLICATE, script);
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:30,代码来源:ScriptReplicatorImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DocCommentTable类代码示例发布时间:2022-05-22
下一篇:
Java ActionPresentationData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap