Source:
<code>public void checkAttributeValue(PerunSessionImpl sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { String groupName = (String) attribute.getValue(); if (groupName == null) { throw new WrongAttributeValueException(attribute, group, "Attribute cannot be null."); } Matcher match = pattern.matcher(groupName); if (!match.matches()) { throw new WrongAttributeValueException(attribute, group, "Bad format of attribute freeipaGroupName. It has to match pattern ^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$"); } Facility facility = sess.getPerunBl().getResourcesManagerBl().getFacility(sess, resource); List<Resource> facilityResources = sess.getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility); for(Resource rs : facilityResources){ List<Group> resourceGroups = sess.getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, rs); for(Group gr : resourceGroups){ Attribute freeipaGroupNameAttribute = new Attribute(); try{ freeipaGroupNameAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, rs, gr, A_GR_freeipaGroupName); } catch(AttributeNotExistsException ex) { throw new ConsistencyErrorException("Attribute "+ A_GR_freeipaGroupName +" does not exists for group " + gr + " and resource " + rs ,ex); } <START> if (freeipaGroupNameAttribute != null){ <END> String name = (String) freeipaGroupNameAttribute.getValue(); if (name.toLowerCase().equals(groupName.toLowerCase())){ throw new WrongAttributeValueException(attribute, group, "Attribute has to be unique within one facility (case insensitive)."); } } } } }</code><technical_language>This happen. Attribute null if exists. null</technical_language>

Target:
public void checkAttributeValue(PerunSessionImpl sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { String groupName = (String) attribute.getValue(); if (groupName == null) { throw new WrongAttributeValueException(attribute, group, "Attribute cannot be null."); } Matcher match = pattern.matcher(groupName); if (!match.matches()) { throw new WrongAttributeValueException(attribute, group, "Bad format of attribute freeipaGroupName. It has to match pattern ^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$"); } Facility facility = sess.getPerunBl().getResourcesManagerBl().getFacility(sess, resource); List<Resource> facilityResources = sess.getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility); for(Resource rs : facilityResources){ List<Group> resourceGroups = sess.getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, rs); if (rs.getId() == resource.getId()){ resourceGroups.remove(group); } for(Group gr : resourceGroups){ Attribute freeipaGroupNameAttribute = new Attribute(); try{ freeipaGroupNameAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, rs, gr, A_GR_freeipaGroupName); } catch(AttributeNotExistsException ex) { throw new ConsistencyErrorException("Attribute "+ A_GR_freeipaGroupName +" does not exists for group " + gr + " and resource " + rs ,ex); } if (freeipaGroupNameAttribute.getValue() != null){ String name = (String) freeipaGroupNameAttribute.getValue(); if (name.toLowerCase().equals(groupName.toLowerCase())){ throw new WrongAttributeValueException(attribute, group, "Attribute has to be unique within one facility (case insensitive)."); } } } } }