class urn_perun_user_facility_attribute_def_def_homeMountPoint extends UserFacilityAttributesModuleAbstract implements UserFacilityAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl session, User user, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {

		List<Resource> usersResources = session.getPerunBl().getUsersManagerBl().getAllowedResources(session, facility, user);

		List<String> homeMntPointsOnAllResources = new ArrayList<>();
		for (Resource res : usersResources) {
			Attribute resAttribute;
			try {
				resAttribute = session.getPerunBl().getAttributesManagerBl().getAttribute(session, res, AttributesManager.NS_RESOURCE_ATTR_DEF + ":homeMountPoints");
			} catch (AttributeNotExistsException ex) {
				throw new InternalErrorException("no homemountpoints found on underlying resources", ex);
			}
			List<String> homeMntPoint = resAttribute.valueAsList();
			if (homeMntPoint != null) {
				homeMntPointsOnAllResources.addAll(homeMntPoint);
			}
		}
		if (homeMntPointsOnAllResources.isEmpty()) {
			throw new WrongReferenceAttributeValueException("No homeMountPoints set on associated resources.");
		}
		if (!homeMntPointsOnAllResources.contains(attribute.valueAsString())) {
			throw new WrongReferenceAttributeValueException(attribute, null, user, facility, "User's home mount point is invalid. Valid mount points: " + homeMntPointsOnAllResources);
		}
	}

}