use of org.apache.camel.ComponentVerifier in project camel by apache.
the class DefaultConnectorComponent method getVerifier.
@SuppressWarnings("unchecked")
@Override
public ComponentVerifier getVerifier() {
final String scheme = model.getBaseScheme();
final Component component = getCamelContext().getComponent(scheme);
if (component instanceof VerifiableComponent) {
return (scope, map) -> {
Map<String, Object> options;
try {
// A little nasty hack required as verifier uses Map<String, Object>
// to be compatible with all the methods in CamelContext whereas
// catalog deals with Map<String, String>
options = (Map) buildEndpointOptions(null, map);
} catch (URISyntaxException e) {
// and stop the validation step.
return ResultBuilder.withStatusAndScope(ComponentVerifier.Result.Status.OK, scope).error(ResultErrorBuilder.withException(e).build()).build();
}
return ((VerifiableComponent) component).getVerifier().verify(scope, options);
};
} else {
return (scope, map) -> {
return ResultBuilder.withStatusAndScope(ComponentVerifier.Result.Status.UNSUPPORTED, scope).error(ResultErrorBuilder.withCode("unsupported").attribute("camel.connector.name", getConnectorName()).attribute("camel.component.name", getComponentName()).build()).build();
};
}
}
Aggregations