-1
我需要獲得一份內部節點樹java代碼[內容/大壩/ img.jpg和子節點[JCR:內容和元數據]中[ETC/mynodes]如何複製AEM中的節點樹?
Source path: conten/dam/img.jp
Destin path: etc/mynodes
我想複製節點: img.jpg> JCR:內容>元
我需要獲得一份內部節點樹java代碼[內容/大壩/ img.jpg和子節點[JCR:內容和元數據]中[ETC/mynodes]如何複製AEM中的節點樹?
Source path: conten/dam/img.jp
Destin path: etc/mynodes
我想複製節點: img.jpg> JCR:內容>元
您可以使用JCR API與內容節點玩,在這裏我用一個例子與workspace.copy移動/內容/大壩/ geometrixx /人像子節點到/etc/mynodes/test
workspace.copy(「/ content/dam/geometrixx/portraits」,「/ etc/mynodes/test」);
package com.org.var.test;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import javax.jcr.Workspace;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.core.TransientRepository;
public class WorkspaceCopyTest {
public static void main(String[] args) throws Exception {
try {
//Create a connection to the CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
//Create a Session
javax.jcr.Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
Workspace workspace = session.getWorkspace();
System.out.println(workspace.getName());
//make sure you doesn't have test folder in /etc/mynodes/test it will create the test folder
workspace.copy("/content/dam/geometrixx/portraits", "/etc/mynodes/test");
System.out.println("workspace copy completed");
session.logout();
}
catch(Exception e){
e.printStackTrace();
}
}
}
其工作的感謝:-) –
@Hanin Jazi,請接受的答案,如果它的工作原理。歡迎 – VAr