// prepare the target parent path
String targetParentPath = RegistryUtils.getParentPath(newPath);
// first create a parent path for the target if doesn't exist
ResourceIDImpl targetParentResourceID = resourceDAO.getResourceID(targetParentPath, true);
if (targetParentResourceID == null || !resourceDAO.resourceExists(targetParentResourceID)) {
addEmptyCollection(targetParentPath);
if (targetParentResourceID == null) {
targetParentResourceID = resourceDAO.getResourceID(targetParentPath, true);
}
} else if (!AuthorizationUtils.authorize(targetParentPath, ActionConstants.PUT)) {
String msg = "Resource Move failed. User " +
CurrentSession.getUser() + " is not authorized to update " +
"the parent collection of target " + targetParentPath + ".";
log.warn(msg);
throw new AuthorizationFailedException(msg);
}
// get the source resource
ResourceImpl sourceResource = (ResourceImpl) getMetaData(oldPath);
if (sourceResource == null) {
throw new ResourceNotFoundException(oldPath);
}
ResourceIDImpl sourceID = sourceResource.getResourceIDImpl();
if (!(sourceResource instanceof CollectionImpl)) {
prepareMove(oldPath, newPath);
// get the source resource
// just rename the resource + all the community features.
ResourceIDImpl targetID = resourceDAO.getResourceID(newPath, false);
if (targetID == null) {
// create resourceID
targetID = resourceDAO.createResourceID(newPath, targetParentResourceID, false);
}