use of cz.metacentrum.perun.audit.events.ResourceManagerEvents.ResourceUpdated in project perun by CESNET.
the class ResourcesManagerBlImpl method updateResource.
@Override
public Resource updateResource(PerunSession sess, Resource resource) throws ResourceExistsException {
Facility facility = getFacility(sess, resource);
Vo vo = getVo(sess, resource);
try {
Resource existingResource = getResourcesManagerImpl().getResourceByName(sess, vo, facility, resource.getName());
// if it is the same resource which is updated but the name stayed the same.
if (existingResource.getId() == resource.getId()) {
resource = getResourcesManagerImpl().updateResource(sess, resource);
getPerunBl().getAuditer().log(sess, new ResourceUpdated(resource));
return resource;
}
// because there is already a resource with this name but with different id.
throw new ResourceExistsException(existingResource);
} catch (ResourceNotExistsException e) {
resource = getResourcesManagerImpl().updateResource(sess, resource);
getPerunBl().getAuditer().log(sess, new ResourceUpdated(resource));
}
return resource;
}
Aggregations