class RangerServiceDefValidator extends RangerValidator {

	boolean isValidResourceGraph(RangerServiceDef serviceDef, List<ValidationFailureDetails> failures) {
		if(LOG.isDebugEnabled()) {
			LOG.debug(String.format("==> RangerServiceDefValidator.isValidResourceGraph(%s, %s)", serviceDef, failures));
		}
		boolean valid = true;
		// We don't want this helper to get into the cache or to use what is in the cache!!
		RangerServiceDefHelper defHelper = _factory.createServiceDefHelper(serviceDef, false);
		if (!defHelper.isResourceGraphValid()) {
			ValidationErrorCode error = ValidationErrorCode.SERVICE_DEF_VALIDATION_ERR_RESOURCE_GRAPH_INVALID;
			failures.add(new ValidationFailureDetailsBuilder()
				.field("resource graph")
				.isSemanticallyIncorrect()
				.errorCode(error.getErrorCode())
				.becauseOf(error.getMessage())
				.build());
			valid = false;
		}
		// resource level should be unique within a hierarchy
		Set<List<RangerResourceDef>> hierarchies = defHelper.getResourceHierarchies();
		for (List<RangerResourceDef> aHierarchy : hierarchies) {
			Set<Integer> levels = new HashSet<Integer>(aHierarchy.size());
			for (RangerResourceDef resourceDef : aHierarchy) {
				valid = isUnique(resourceDef.getLevel(), levels, "resource level", "resources", failures) && valid;
			}
		}

		if(LOG.isDebugEnabled()) {
			LOG.debug(String.format("<== RangerServiceDefValidator.isValidResourceGraph(%s, %s): %s", serviceDef, failures, valid));
		}
		return valid;
	}

	public  RangerServiceDefValidator(ServiceStore store);

}