@Override public Optional<ProcessorDefinition> handle(Choice step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) { final CamelContext context = routeBuilder.getContext(); final ChoiceDefinition choice = route.choice(); List<Filter> filters = ObjectHelper.supplyIfEmpty(step.getFilters(), Collections::<Filter>emptyList); for (Filter filter : filters) { Predicate predicate = JsonSimpleHelpers.getMandatorySimplePredicate(context, filter, filter.getExpression()); ChoiceDefinition when = choice.when(predicate); routeBuilder.addSteps(when, filter.getSteps()); } Otherwise otherwiseStep = step.getOtherwise(); if (otherwiseStep != null) { List<Step> otherwiseSteps = ObjectHelper.supplyIfEmpty(otherwiseStep.getSteps(), Collections::<Step>emptyList); if (!otherwiseSteps.isEmpty()) { routeBuilder.addSteps(choice.otherwise(), otherwiseSteps); } } return Optional.empty(); } }
.convertBodyTo(byte[].class) .doCatch(Throwable.class).end() .choice().when(property(Exchange.EXCEPTION_CAUGHT).isNotNull()) .log(LoggingLevel.DEBUG, "Received exception response to endpoint " + spec.getEndpointUri() + " exception: ${exception}, headers: ${headers}")
} else if (item instanceof Choice) { Choice step = (Choice) item; ChoiceDefinition choice = route.choice(); List<Filter> filters = notNullList(step.getFilters()); for (Filter filter : filters) {
.choice() .when(header("CamelFileName").isEqualTo("simple.json")).process(new Process05()) .when(header("CamelFileName").isEqualTo("simple2.json")).process(new Process06())
.process(origin) .process(destination) .choice() .when(blacklistedDestination) .to(dlq)
.choice() .when(header(EVENT_TYPE).isEqualTo(REPOSITORY + "NODE_REMOVED")) .to("direct:delete") .routeId("JsonLdRouter") .setHeader(FCREPO_IDENTIFIER).simple("${headers[" + HTTP_PATH + "]}") .choice() .when(header(HTTP_METHOD).isEqualTo("GET")).to("direct:get") .when(header(HTTP_METHOD).isEqualTo("PUT")).to("direct:update")
.endChoice() .end() .choice() .when( .choice() .when(PredicateBuilder.and( header(WonCamelConstants.DIRECTION_HEADER).isEqualTo(URI.create(WONMSG.TYPE_FROM_OWNER_STRING)), .choice() .when(isNotEqualTo(header(WonCamelConstants.SUPPRESS_MESSAGE_REACTION), ExpressionBuilder.constantExpression(Boolean.TRUE))) .to("direct:reactToMessage") .endChoice() .end() .choice() .when(isNotEqualTo(header(WonCamelConstants.SUPPRESS_MESSAGE_REACTION), ExpressionBuilder.constantExpression(Boolean.TRUE))) .to("direct:reactToMessage")
.when().simple("${headers.CamelHttpMethod} == 'POST'") .setHeader("type").jsonpath("$.notification.type") .choice() .when().simple("${header.type} == 'email'") .log("[EXAMPLE INBOUND] Received email notification")
.end() .choice() .when(header(MSG_HEADER).isNull())