@Override public void move(String pathOrigin, String documentNameOrigin, String pathDestination, String documentNameDestination, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); // Fetch the object FileableCmisObject fileableCmisObject = (FileableCmisObject) FileUtils.getObject(pathOrigin + documentNameOrigin, session); // ECM folder paths does not end with "/" if (pathOrigin.endsWith("/")) pathOrigin = pathOrigin.substring(0, pathOrigin.length()-1); if (pathDestination.endsWith("/")) pathDestination = pathDestination.substring(0, pathDestination.length()-1); // Fetch source folder CmisObject sourceObject = FileUtils.getObject(pathOrigin, session); // Fetch the destination folder // We need to make sure the target folder exists createFolder(pathDestination); CmisObject targetObject = FileUtils.getObject(pathDestination, session); if (documentNameDestination != documentNameOrigin){ fileableCmisObject.rename(documentNameDestination, true); } // Move the object fileableCmisObject.move(sourceObject, targetObject); // Enable cache session.getDefaultContext().setCacheEnabled(true); }
public FileableCmisObject moveObject(FileableCmisObject cmisObject, String objectId, String sourceFolderId, String targetFolderId) { validateObjectOrId(cmisObject, objectId); validateRedundantIdentifier(cmisObject, objectId); Validate.notEmpty(sourceFolderId, "sourceFolderId is empty"); Validate.notEmpty(targetFolderId, "targetFolderId is empty"); FileableCmisObject target = getCmisObject(cmisObject, objectId, FileableCmisObject.class); if (target != null) { return target.move(new ObjectIdImpl(sourceFolderId), new ObjectIdImpl(targetFolderId)); } else { logger.error("Unable to obtain the object reference in order to perform the object move."); } return null; }
CmisObject destination = session.getObject(delta.getParentChanges().getNewPrimaryParent()); object.move(source, destination);