Copying and moving folders and documents
A document can be copied to a different folder with the Document
object's copy
method. The copy will be an independent document and it will be of the same type as the original document with the same properties and relationships.
The following code shows how to copy the previously uploaded OpenCMISTest2.pdf
document to the /Company Home/Guest Home
folder in Alfresco:
public void copyDocument(Session session, Document document) { Folder parentFolder = session.getRootFolder(); String destinationFolderName = "Guest Home"; Folder destinationFolder = (Folder) getObject(session, parentFolder, destinationFolderName); if (destinationFolder == null) { logger.error("Cannot copy " + document.getName() + ", could not find folder with the name " + destinationFolderName + ", are you using Alfresco?"); return; } // Check that we got the document, then copy if (document != null) { try { document.copy(destinationFolder);...