use of org.apache.camel.component.extension.ComponentVerifierExtension in project syndesis by syndesisio.
the class ComponentProxyComponent method getComponentVerifierExtension.
/**
* Build a ComponentVerifierExtension using options bound to this component.
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
private ComponentVerifierExtension getComponentVerifierExtension() {
try {
//
final Component component = getCamelContext().getComponent(componentScheme, true, false);
final Optional<ComponentVerifierExtension> extension = component.getExtension(ComponentVerifierExtension.class);
if (extension.isPresent()) {
return (ComponentVerifierExtension.Scope scope, Map<String, Object> 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.class.cast(buildEndpointOptions(null, map));
} catch (Exception e) {
// and stop the validation step.
return ResultBuilder.withStatusAndScope(ComponentVerifierExtension.Result.Status.OK, scope).error(ResultErrorBuilder.withException(e).build()).build();
}
return extension.get().verify(scope, options);
};
} else {
return (scope, map) -> {
return ResultBuilder.withStatusAndScope(ComponentVerifierExtension.Result.Status.UNSUPPORTED, scope).error(ResultErrorBuilder.withCode(ComponentVerifierExtension.VerificationError.StandardCode.UNSUPPORTED).detail("camel_connector_id", componentId).detail("camel_component_scheme", componentScheme).detail("camel_component_scheme_alias", componentSchemeAlias).build()).build();
};
}
} catch (Exception e) {
return (scope, map) -> {
return ResultBuilder.withStatusAndScope(ComponentVerifierExtension.Result.Status.OK, scope).error(ResultErrorBuilder.withException(e).build()).build();
};
}
}
use of org.apache.camel.component.extension.ComponentVerifierExtension in project syndesis by syndesisio.
the class ComponentVerifier method verify.
// *************************************
// Impl
// *************************************
@Override
public List<VerifierResponse> verify(CamelContext context, String connectorId, Map<String, Object> params) {
final String scheme = getConnectorAction().orElse(connectorId);
final ComponentVerifierExtension verifier = resolveComponentVerifierExtension(context, scheme);
if (verifier == null) {
return Collections.singletonList(createUnsupportedResponse(scheme));
}
customize(params);
return doVerify(verifier, scheme, params);
}
Aggregations