class urn_perun_group_attribute_def_def_groupExtSource extends GroupAttributesModuleAbstract implements GroupAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongReferenceAttributeValueException {
		//prepare groupName value variable
		String extSourceName = null;
		if(attribute.getValue() != null) extSourceName = attribute.valueAsString();

		//if extSourceName is null, attribute can be removed
		if (extSourceName != null) {
			try {
				Vo groupVo = sess.getPerunBl().getVosManagerBl().getVoById(sess, group.getVoId());
				List<ExtSource> allowedExtSources = sess.getPerunBl().getExtSourcesManagerBl().getVoExtSources(sess, groupVo);
				for(ExtSource es: allowedExtSources) {
					if(extSourceName.equals(es.getName())) return;
				}
				throw new WrongReferenceAttributeValueException(attribute, null, group, null, "ExtSourceName " + extSourceName + " is not valid, because VO " + groupVo + " of this group has no such extSource assigned.");
			} catch (VoNotExistsException ex) {
				throw new ConsistencyErrorException("Vo of this group " + group + " not exists!");
			}
		}
	}

}