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


Java ResourceResolver.create方法代码示例

本文整理汇总了Java中org.apache.sling.api.resource.ResourceResolver.create方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceResolver.create方法的具体用法?Java ResourceResolver.create怎么用?Java ResourceResolver.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sling.api.resource.ResourceResolver的用法示例。


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

示例1: getOrCreate

import org.apache.sling.api.resource.ResourceResolver; //导入方法依赖的package包/类
private Resource getOrCreate(String path, Map<String, Object> properties) throws PersistenceException, RepositoryException {
	ResourceResolver resolver = client.getResourceResolver();
	Resource         resource = resolver.getResource(path);
	if (properties.containsKey("unit:vanityTarget")) {
		resource = resolver.resolve((String) properties.get("unit:vanityTarget"));
	} else {
		Resource     parent = resolver.getResource("/");
		PathIterator it     = new PathIterator(path);
		it.first();
		while (it.hasNext()) {
			String curPath = it.next();
			String segment = StringUtils.substringAfterLast(curPath, "/");
			resource = resolver.getResource(curPath);
			if (resource == null) {
				if (it.hasNext()) {
					resource = resolver.create(parent, segment, new HashMap<>());
				} else {
					resource = resolver.create(parent, segment, properties);
				}
			}
			parent = resource;
		}
	}
	return resource;
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:26,代码来源:Resources.java

示例2: copy

import org.apache.sling.api.resource.ResourceResolver; //导入方法依赖的package包/类
private Resource copy(ResourceResolver resolver, String sourcePath, Resource destParent)
		throws PersistenceException {
	Resource source = resolver.getResource(sourcePath);

	Map<String, Object> properties = Maps.newHashMap(source.getValueMap());
	properties.remove(JcrConstants.JCR_UUID);
	Resource dest = resolver.create(destParent, source.getName(), properties);

	if (source.getChild(JcrConstants.JCR_CONTENT) != null) {
		copy(resolver, sourcePath + "/" + JcrConstants.JCR_CONTENT, dest);
	}
	return dest;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:14,代码来源:ScriptReplicatorImpl.java


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