StoredObject[] sos = validator.moveObject(context, repositoryId, objectId, targetFolderId, sourceFolderId, extension);
StoredObject so = sos[0];
Folder targetFolder = null;
Folder sourceFolder = null;
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
Filing spo = null;
String user = context.getUsername();
if (null == so) {
throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
} else if (so instanceof Filing) {
spo = (Filing) so;
} else {
throw new CmisInvalidArgumentException("Object must be folder or document: " + objectId.getValue());
}
StoredObject soTarget = objectStore.getObjectById(targetFolderId);
if (null == soTarget) {
throw new CmisObjectNotFoundException("Unknown target folder: " + targetFolderId);
} else if (soTarget instanceof Folder) {
targetFolder = (Folder) soTarget;
} else {
throw new CmisNotSupportedException("Destination " + targetFolderId
+ " of a move operation must be a folder");
}
StoredObject soSource = objectStore.getObjectById(sourceFolderId);
if (null == soSource) {
throw new CmisObjectNotFoundException("Unknown source folder: " + sourceFolderId);
} else if (soSource instanceof Folder) {
sourceFolder = (Folder) soSource;
} else {
throw new CmisNotSupportedException("Source " + sourceFolderId + " of a move operation must be a folder");
}
boolean foundOldParent = false;
for (Folder parent : spo.getParents(user)) {
if (parent.getId().equals(soSource.getId())) {
foundOldParent = true;
break;
}
}
if (!foundOldParent) {
throw new CmisNotSupportedException("Cannot move object, source folder " + sourceFolderId
+ "is not a parent of object " + objectId.getValue());
}
if (so instanceof Folder && hasDescendant((Folder) so, targetFolder)) {
throw new CmisNotSupportedException("Destination of a move cannot be a subfolder of the source");
}
spo.move(sourceFolder, targetFolder);
objectId.setValue(so.getId());
LOG.debug("stop moveObject()");
TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
ObjectData od = PropertyCreationHelper.getObjectData(td, so, null, user, false,