12-22-2010 10:20 AM
String newParentDir = "/app:company_home/cm:divisionB";
ParentReference folderParentRef = new ParentReference();
folderParentRef.setStore(storeRef);
folderParentRef.setPath(newParentDir);
folderParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
// create ref to current dir
String currentDir = "/app:company_home/cm:divisionA/cm:productDetails";
Reference curr = new Reference();
curr.setStore(storeRef);
curr.setPath(currentDir);
CMLMove move = new CMLMove();
move.setAssociationType(Constants.ASSOC_CONTAINS);
move.setChildName("productDetails");
move.setTo(folderParentRef);
move.setWhere(new Predicate(new Reference[]{curr}, null, null));
CML cml = new CML();
cml.setMove(new CMLMove[]{move});
WebServiceFactory.getRepositoryService().update(cml);
12-27-2010 03:45 AM
01-04-2011 12:06 PM
01-05-2011 09:31 AM
private static Store WORKSPACE_STORE = new Store(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
public static void main(String[] args) throws RepositoryFault, RemoteException {
…
alfSoap.startSession(); // Start session
Reference refA = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:divisionB"); // Where to move
Reference refB = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:divisionA/cm:productDetails"); // What to move
try {
// Move
UpdateResult[] results = alfSoap.moveNode(refA, refB, "productDetails"); // important to send wanted nodeName because the new node will have path refA.getPath + "cm:/" + nodeName
// Return to original location
refA = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:divisionA"); // Where to move
refB = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:divisionB/cm:productDetails"); // What to move
results = moveNode(refA, refB, "productDetails"); // important to send wanted nodeName because the new node will have path refA.getPath + "cm:/" + nodeName
} finally {
// End session
alfSoap.endSession();
}
}
public UpdateResult[] moveNode(Reference toReference, Reference whatReference, String nodeName) throws RepositoryFault, RemoteException {
ParentReference toParentReference = referenceToParent(toReference);
toParentReference.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, nodeName)); // Should be the same as whatReference nodeName
CMLMove move = new CMLMove();
move.setTo(toParentReference);
move.setWhere(new Predicate(new Reference[] { whatReference }, WORKSPACE_STORE, null));
CML cml = new CML();
cml.setMove(new CMLMove[] { move });
return getRepositoryService().update(cml);
}
private ParentReference referenceToParent(Reference spaceReference) {
ParentReference parent = new ParentReference();
parent.setStore(WORKSPACE_STORE);
parent.setPath(spaceReference.getPath());
parent.setUuid(spaceReference.getUuid());
parent.setAssociationType(Constants.ASSOC_CONTAINS);
return parent;
}
toParentReference.setChildName(…) is the key.Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.