class urn_perun_resource_attribute_def_def_shells extends ResourceAttributesModuleAbstract implements ResourceAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
		List<String> shells = attribute.valueAsList();

		if (shells == null) {
			throw new WrongReferenceAttributeValueException(attribute, null, resource, null, "Attribute cannot be null.");
		}

		Facility facility = perunSession.getPerunBl().getResourcesManagerBl().getFacility(perunSession, resource);
		Attribute allShellsPerFacility;
		try {
			allShellsPerFacility = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, facility, A_F_shells);
		} catch (AttributeNotExistsException ex) {
			throw new InternalErrorException("Attribute with list of shells from facility " + facility.getId() +" could not obtained.",ex);
		}


		if (allShellsPerFacility.getValue() == null) {
			throw new WrongReferenceAttributeValueException(attribute, allShellsPerFacility, resource, null, facility, null, "Attribute with list of shells from facility cannot be null.");
		}
		if (!(allShellsPerFacility.valueAsList()).containsAll(shells)) {
			throw new WrongReferenceAttributeValueException(attribute, allShellsPerFacility, resource, null, facility, null, "Some shells from specified resource are not at home facility " + facility.getId());
		}
	}

}