}
@Override
public boolean isValid(final Object object, final ConstraintValidatorContext context) {
EntityViolationType violation = null;
try {
if (object != null) {
final String schemaName;
if (object instanceof USchema) {
schemaName = ((USchema) object).getName();
violation = EntityViolationType.InvalidUSchema;
} else if (object instanceof UDerSchema) {
schemaName = ((UDerSchema) object).getName();
violation = EntityViolationType.InvalidUDerSchema;
} else if (object instanceof UVirSchema) {
schemaName = ((UVirSchema) object).getName();
violation = EntityViolationType.InvalidUVirSchema;
} else {
schemaName = null;
}
if (PERMITTED_USCHEMA_NAMES.contains(schemaName)) {
throw new Exception("Schema name not permitted");
}
}
return true;
} catch (Exception e) {
LOG.error("Error saving schema", e);
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(violation.toString()).addNode(object.toString())
.addConstraintViolation();
return false;
}
}