我能够使用以下内容创建一个新集合:
Resource resource = resourceResolver.resolve(DEFAULT_BASE_JCR_PATH+"/m/mKS6YofYC4-opD0lu2gc");
ResourceCollectionManager managerCollection = resourceResolver.adaptTo(ResourceCollectionManager.class);
ResourceCollection collection = managerCollection.createCollection(resource, collectionName);
创建吊索的最佳方式是:成员和添加资源?
答案 0 :(得分:0)
我能够弄清楚这一点: 输入(collectionMember)来自文本区域:
/content/dam/geometrixx-outdoors/brand/brand_1_c02.jpg,/content/dam/geometrixx-outdoors/brand/brand_3a_ambassdors_c03.png, /content/dam/geometrixx-outdoors/brand/brand_3b_1_c05.jpg
Resource resourcesResource = resourceResolver.resolve(DEFAULT_BASE_JCR_PATH+"/"+session.getUserID()+"/"+collectionName+"/sling:members");
String[] resources = collectionMember.split(",");
for (String img : resources) {
String imgName = img.substring(img.lastIndexOf("/") + 1, img.length());
Node nodeMember = resourcesResource.adaptTo(Node.class);;
Node mem = nodeMember.addNode(imgName, "nt:unstructured");
setBasicProp(mem);
mem.setProperty("sling:resource", img);
}
outside of method.....
private void setBasicProp(Node node) throws Exception {
Calendar lastModified = Calendar.getInstance();
String user = node.getSession().getUserID();
node.setProperty("jcr:createdBy", user);
node.setProperty("jcr:lastModifiedBy", user);
node.setProperty("jcr:lastModified", lastModified);
node.setProperty("jcr:created", lastModified);
node.setProperty("jcr:description", node.getName());
}