use of org.mule.runtime.core.api.exception.SingleErrorTypeMatcher in project mule by mulesoft.
the class SingleErrorTypeMatcherTestCase method doesNotMatchSibling.
@Test
public void doesNotMatchSibling() {
ErrorTypeMatcher transformationMatcher = new SingleErrorTypeMatcher(transformationErrorType);
assertThat(transformationMatcher.match(expressionErrorType), is(false));
}
use of org.mule.runtime.core.api.exception.SingleErrorTypeMatcher in project mule by mulesoft.
the class SingleErrorTypeMatcherTestCase method doesNotMatchParent.
@Test
public void doesNotMatchParent() {
ErrorTypeMatcher transformationMatcher = new SingleErrorTypeMatcher(transformationErrorType);
assertThat(transformationMatcher.match(anyErrorType), is(false));
}
use of org.mule.runtime.core.api.exception.SingleErrorTypeMatcher in project mule by mulesoft.
the class CausedByFunction method call.
@Override
public Object call(Object[] parameters, BindingContext context) {
Error error = (Error) parameters[0];
checkArgument(error != null, "There's no error to match against.");
String errorIdentifier = (String) parameters[1];
ErrorTypeMatcher errorTypeMatcher = new SingleErrorTypeMatcher(resolveErrorType(errorIdentifier));
return errorTypeMatcher.match(error.getErrorType());
}
use of org.mule.runtime.core.api.exception.SingleErrorTypeMatcher in project mule by mulesoft.
the class OnErrorContinueHandler method doInitialise.
@Override
protected void doInitialise(MuleContext muleContext) throws InitialisationException {
super.doInitialise(muleContext);
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
sourceErrorMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getSourceResponseErrorType());
if (errorType != null) {
String[] errors = errorType.split(",");
for (String error : errors) {
// Since the partial initialisation was successful, we know this error ids are safe
String sanitizedError = error.trim();
ErrorType errorType = errorTypeRepository.lookupErrorType(buildFromStringRepresentation(sanitizedError)).get();
if (sourceErrorMatcher.match(errorType)) {
throw new InitialisationException(getInitialisationError(sanitizedError), this);
}
}
} else if (when == null) {
// No error type and no expression, force ANY matcher
errorTypeMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getAnyErrorType());
}
}
use of org.mule.runtime.core.api.exception.SingleErrorTypeMatcher in project mule by mulesoft.
the class BeanDefinitionFactory method resolveComponent.
private BeanDefinition resolveComponent(ComponentModel parentComponentModel, SpringComponentModel componentModel, BeanDefinitionRegistry registry, BiConsumer<ComponentModel, BeanDefinitionRegistry> componentDefinitionModelProcessor, SpringConfigurationComponentLocator componentLocator) {
if (isComponentIgnored(componentModel.getIdentifier())) {
return null;
}
if (!componentModel.isEnabled()) {
// Just register the location, for support of lazyInit scenarios
componentLocator.addComponentLocation(componentModel.getComponentLocation());
return null;
}
resolveComponentBeanDefinition(parentComponentModel, componentModel);
componentDefinitionModelProcessor.accept(componentModel, registry);
// TODO MULE-9638: Once we migrate all core definitions we need to define a mechanism for customizing
// how core constructs are processed.
processMuleConfiguration(componentModel, registry);
processMuleSecurityManager(componentModel, registry);
processRaiseError(componentModel);
componentBuildingDefinitionRegistry.getBuildingDefinition(componentModel.getIdentifier()).ifPresent(componentBuildingDefinition -> {
if ((componentModel.getType() != null) && Component.class.isAssignableFrom(componentModel.getType())) {
addAnnotation(ANNOTATION_NAME, componentModel.getIdentifier(), componentModel);
// We need to use a mutable map since spring will resolve the properties placeholder present in the value if needed
// and it will be done by mutating the same map.
addAnnotation(ANNOTATION_PARAMETERS, new HashMap<>(componentModel.getParameters()), componentModel);
// add any error mappings if present
List<ComponentModel> errorMappingComponents = componentModel.getInnerComponents().stream().filter(innerComponent -> ERROR_MAPPING_IDENTIFIER.equals(innerComponent.getIdentifier())).collect(toList());
if (!errorMappingComponents.isEmpty()) {
addAnnotation(ANNOTATION_ERROR_MAPPINGS, errorMappingComponents.stream().map(innerComponent -> {
Map<String, String> parameters = innerComponent.getParameters();
ComponentIdentifier source = buildFromStringRepresentation(parameters.get(SOURCE_TYPE));
ErrorType errorType = errorTypeRepository.lookupErrorType(source).orElseThrow(() -> new MuleRuntimeException(createStaticMessage("Could not find error '%s'.", source)));
ErrorTypeMatcher errorTypeMatcher = new SingleErrorTypeMatcher(errorType);
ErrorType targetValue = resolveErrorType(parameters.get(TARGET_TYPE));
return new ErrorMapping(errorTypeMatcher, targetValue);
}).collect(toList()), componentModel);
}
componentLocator.addComponentLocation(componentModel.getComponentLocation());
}
});
addAnnotation(LOCATION_KEY, componentModel.getComponentLocation(), componentModel);
BeanDefinition beanDefinition = componentModel.getBeanDefinition();
return beanDefinition;
}
Aggregations