Search in sources :

Example 1 with JSONConverterException

use of com.mercedesbenz.sechub.commons.model.JSONConverterException in project sechub by mercedes-benz.

the class ProductExecutorConfigValidationImpl method validate.

@Override
protected void validate(ValidationContext<ProductExecutorConfig> context) {
    validateNotNull(context);
    ProductExecutorConfig config = getObjectToValidate(context);
    String name = config.getName();
    validateNotNull(context, name, "name");
    validateMaxLength(context, name, 30, "name");
    validateMinLength(context, name, 3, "name");
    validateNotNull(context, config.getProductIdentifier(), "productIdentifier");
    validateNotNull(context, config.getExecutorVersion(), "executorVersion");
    ProductExecutorConfigSetup setup = config.getSetup();
    validateNotNull(context, setup, "setup");
    if (setup == null) {
        LOG.error("setup null - not valid");
        return;
    }
    /* just check if can be transformed to json */
    try {
        ValidationResult setupResult = setupValidation.validate(setup);
        context.addErrors(setupResult);
    } catch (JSONConverterException e) {
        LOG.error("setup validation failed - because of JSON conversion failure", e);
        addErrorMessage(context, "setup cannot be deserialized!");
    }
}
Also used : ValidationResult(com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult) JSONConverterException(com.mercedesbenz.sechub.commons.model.JSONConverterException)

Aggregations

JSONConverterException (com.mercedesbenz.sechub.commons.model.JSONConverterException)1 ValidationResult (com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult)1