- super(params, config, DecisionResponse.class, Collections.emptyList());
- this.config = (DecisionConfig) config;
- }
-
- @Override
- public CompletableFuture<OperationOutcome> start() {
- if (!config.isDisabled()) {
- // enabled - do full guard operation
- return super.start();
- }
-
- // guard is disabled, thus it is always treated as a success
- logger.info("{}: guard disabled, always succeeds for {}", getFullName(), params.getRequestId());
-
- final var executor = params.getExecutor();
- final var callbacks = new CallbackManager();
-
- return CompletableFuture.completedFuture(makeOutcome())
- .whenCompleteAsync(callbackStarted(callbacks), executor)
- .whenCompleteAsync(callbackCompleted(callbacks), executor);
- }
-
- @Override
- protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
- DecisionRequest request = makeRequest();
-
- Map<String, Object> headers = makeHeaders();
-
- headers.put("Accept", MediaType.APPLICATION_JSON);
- String url = getUrl();
-
- String strRequest = prettyPrint(request);
- logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
-
- Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
-
- // @formatter:off
- return handleResponse(outcome, url,
- callback -> getClient().post(callback, getPath(), entity, headers));
- // @formatter:on