class urn_perun_facility_attribute_def_def_pbsServer extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException {
		String pbsServer = attribute.valueAsString();

		if (pbsServer == null) throw new WrongReferenceAttributeValueException(attribute, "PbsServer cannot be null.");

		//TODO better method for searching Facility by querry in DB
		List<Facility> allFacilities = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilities(perunSession);
		boolean success = false;
		for(Facility f: allFacilities) {
			if(f.getName().equals(pbsServer)) {
				success = true;
				break;
			}
		}
		try {
			Attribute name = new Attribute(perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, AttributesManager.NS_FACILITY_ATTR_CORE + ":name"));
			name.setValue(pbsServer);
			if(!success) throw new WrongReferenceAttributeValueException(attribute, name, facility, null, "There is no facility with attribute name same as the pbsServer attribute.");
		} catch (AttributeNotExistsException e) {
			throw new ConsistencyErrorException(e);
		}
	}

}