class urn_perun_user_facility_attribute_def_virt_preferredUnixGroupName extends UserFacilityVirtualAttributesModuleAbstract implements UserFacilityVirtualAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl sess, User user, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
		try {
			Attribute facilityGroupNameNamespaceAttr = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, A_FACILITY_DEF_UNIX_GROUPNAME_NAMESPACE);
			if(facilityGroupNameNamespaceAttr.getValue() == null) {
				throw new WrongReferenceAttributeValueException(attribute, facilityGroupNameNamespaceAttr, user, facility, facility, null, "GroupName-namespace for racility cannot be null.");
			}
			String namespace = facilityGroupNameNamespaceAttr.valueAsString();

			Attribute preferredUnixGroupNameAttr = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user, A_USER_DEF_PREFERRED_UNIX_GROUPNAME_NAMESPACE + namespace);
			if(attribute.getValue() != null) {
				preferredUnixGroupNameAttr.setValue(attribute.getValue());
				sess.getPerunBl().getAttributesManagerBl().checkAttributeSemantics(sess, user, preferredUnixGroupNameAttr);
			} // Null is ok, can be empty
		} catch (AttributeNotExistsException e) {
			throw new ConsistencyErrorException(e);
		}
	}

}