Search in sources :

Example 1 with ProtoParser

use of com.squareup.wire.schema.internal.parser.ProtoParser in project thingsboard by thingsboard.

the class DeviceProfileDataValidator method validateTransportProtoSchema.

private void validateTransportProtoSchema(String schema, String schemaName) throws IllegalArgumentException {
    ProtoParser schemaParser = new ProtoParser(LOCATION, schema.toCharArray());
    ProtoFileElement protoFileElement;
    try {
        protoFileElement = schemaParser.readProtoFile();
    } catch (Exception e) {
        throw new IllegalArgumentException("[Transport Configuration] failed to parse " + schemaName + " due to: " + e.getMessage());
    }
    checkProtoFileSyntax(schemaName, protoFileElement);
    checkProtoFileCommonSettings(schemaName, protoFileElement.getOptions().isEmpty(), " Schema options don't support!");
    checkProtoFileCommonSettings(schemaName, protoFileElement.getPublicImports().isEmpty(), " Schema public imports don't support!");
    checkProtoFileCommonSettings(schemaName, protoFileElement.getImports().isEmpty(), " Schema imports don't support!");
    checkProtoFileCommonSettings(schemaName, protoFileElement.getExtendDeclarations().isEmpty(), " Schema extend declarations don't support!");
    checkTypeElements(schemaName, protoFileElement);
}
Also used : ProtoParser(com.squareup.wire.schema.internal.parser.ProtoParser) ProtoFileElement(com.squareup.wire.schema.internal.parser.ProtoFileElement) DeviceCredentialsValidationException(org.thingsboard.server.dao.exception.DeviceCredentialsValidationException) DataValidationException(org.thingsboard.server.dao.exception.DataValidationException)

Aggregations

ProtoFileElement (com.squareup.wire.schema.internal.parser.ProtoFileElement)1 ProtoParser (com.squareup.wire.schema.internal.parser.ProtoParser)1 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)1 DeviceCredentialsValidationException (org.thingsboard.server.dao.exception.DeviceCredentialsValidationException)1