use of cz.metacentrum.perun.core.api.exceptions.VoNotExistsException in project perun by CESNET.
the class urn_perun_group_attribute_def_def_groupStructureResources method checkAttributeSemantics.
@Override
public void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
// Null value is ok, means no settings for group
if (attribute.getValue() == null)
return;
LinkedHashMap<String, String> attrValues = attribute.valueAsMap();
Vo vo;
try {
vo = sess.getPerunBl().getVosManagerBl().getVoById(sess, group.getVoId());
} catch (VoNotExistsException e) {
throw new InternalErrorException("Failed to find group's vo.", e);
}
List<Resource> voResources = sess.getPerunBl().getResourcesManagerBl().getResources(sess, vo);
Set<Integer> voResourceIds = voResources.stream().map(Resource::getId).collect(Collectors.toSet());
for (String rawId : attrValues.keySet()) {
int id = Integer.parseInt(rawId);
if (!voResourceIds.contains(id)) {
throw new WrongReferenceAttributeValueException(attribute, "There is no resource with id '" + id + "' assigned to the groups vo: " + vo);
}
}
}
Aggregations