// read and delete authorization needed for the source (old path)
if (!AuthorizationUtils.authorize(sourcePath, ActionConstants.GET)) {
String msg = "Resource Move failed. User " + CurrentSession.getUser() +
" is not authorized to read the resource at " + sourcePath + ".";
log.warn(msg);
throw new AuthorizationFailedException(msg);
}
if (!AuthorizationUtils.authorize(sourcePath, ActionConstants.DELETE)) {
String msg = "Resource Move failed. User " + CurrentSession.getUser() +
" is not authorized to delete the resource at " + sourcePath + ".";
log.warn(msg);
throw new AuthorizationFailedException(msg);
}
// check for existence of target path, if target exist delete them
ResourceIDImpl targetExistingResourceID = resourceDAO.getResourceID(targetPath);
ResourceDO targetExistingResourceDO;
if (targetExistingResourceID != null) {
targetExistingResourceDO = resourceDAO.getResourceDO(targetExistingResourceID);
if (targetExistingResourceDO == null && targetExistingResourceID.isCollection()) {
// we have to check the possibility non collection having this path
targetExistingResourceID = resourceDAO.getResourceID(targetPath, false);
if (targetExistingResourceID != null) {
targetExistingResourceDO = resourceDAO.getResourceDO(targetExistingResourceID);
}
}
if (targetExistingResourceDO != null) {
// there has been a resource in this place..
if (!AuthorizationUtils.authorize(targetPath, ActionConstants.PUT)) {
String msg = "Resource Move failed. User " +
CurrentSession.getUser() + " is not authorized to update " +
"the target path " + targetPath + ".";
log.warn(msg);
throw new AuthorizationFailedException(msg);
}
// remove the resource, since we are overwriting that..
removeIndividual(targetExistingResourceID, targetExistingResourceDO);
}