// existence of the resource id doesn't mean the existence of the
// resource, so need to verify resource existence
// load the meta data for the existing resource
ResourceDO oldResourceDO = resourceDAO.getResourceDO(resourceID);
if (oldResourceDO != null) {
// the resource does exists
resourceExists = true;
prepareUpdate(resource, resourceID, oldResourceDO);
update(resourceID, (ResourceImpl) resource, oldResourceDO);
}
}
if (!resourceExists) {
// now we are checking whether there is an entry with the inverse type
ResourceIDImpl inverseResourceID = resourceDAO.getResourceID(purePath,
!(resource instanceof CollectionImpl));
if (inverseResourceID != null) {
ResourceDO inverseResourceDO = resourceDAO.getResourceDO(inverseResourceID);
if (inverseResourceDO != null) {
// well, in fact there is an inverse type => we are deleting the resource
deleteSubTree(inverseResourceID, inverseResourceDO, false);
}
}