class ConfigurationResourceValidator {

    public void validateConfigurationResource(Buffer configurationResource, String resourceSchema,
                                              Handler<AsyncResult<ValidationResult>> resultHandler){
        vertx.executeBlocking(future -> {
            if(!JsonUtil.isValidJson(configurationResource)){
                String message = "Unable to parse json";
                log.warn(message);
                future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, message));
                return;
            }

            if(StringUtils.isEmpty(resourceSchema)){
                log.info("validated positive since no schema was provided");
                future.complete(new ValidationResult(ValidationStatus.VALIDATED_POSITIV));
                return;
            }

            JsonObject schemaObject;
            try {
                schemaObject = new JsonObject(resourceSchema);
            } catch(DecodeException ex) {
                String message = "Unable to parse json schema";
                log.warn(message);
                future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, message));
                return;
            }

            if(SCHEMA_DECLARATION.equals(schemaObject.getString("$schema"))) {
                JsonSchema schema;
                try {
                    schema = JsonSchemaFactory.getInstance().getSchema(resourceSchema);
                } catch (Exception e) {
                    String message = "Cannot load schema";
                    log.warn(message, e);
                    future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, message));
                    return;
                }
                try {
                    JsonNode jsonNode = new ObjectMapper().readTree(configurationResource.toString());
                    final Set<ValidationMessage> valMsgs = schema.validate(jsonNode);
                    if(valMsgs.isEmpty()) {
                        log.info("validated positive");
                        future.complete(new ValidationResult(ValidationStatus.VALIDATED_POSITIV));
                    } else {
                        JsonArray validationDetails = extractMessagesAsJson(valMsgs);
                        future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, "Validation failed", validationDetails));
                    }
                } catch (IOException e) {
                    String message = "Cannot read JSON";
                    log.warn(message, e.getMessage());
                    future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, message));
                }
            } else {
                String message = "Invalid schema: Expected property '$schema' with content '"+SCHEMA_DECLARATION+"'";
                log.warn(message);
                future.complete(new ValidationResult(ValidationStatus.VALIDATED_NEGATIV, message));
            }
        }, resultHandler);
    }

    public  ConfigurationResourceValidator(Vertx vertx);

}