Search in sources :

Example 1 with PrefetchResponse

use of com.adobe.target.delivery.v1.model.PrefetchResponse in project target-java-sdk by adobe.

the class OnDeviceDecisioningService method buildDeliveryResponse.

private TargetDeliveryResponse buildDeliveryResponse(TargetDeliveryRequest deliveryRequest, String requestId) {
    OnDeviceDecisioningEvaluation localEvaluation = evaluateLocalExecution(deliveryRequest);
    int status = localEvaluation.isAllLocal() ? HttpStatus.SC_OK : HttpStatus.SC_PARTIAL_CONTENT;
    DeliveryResponse deliveryResponse = new DeliveryResponse().client(clientConfig.getClient()).requestId(requestId).id(deliveryRequest.getDeliveryRequest().getId()).status(status);
    PrefetchResponse prefetchResponse = new PrefetchResponse();
    ExecuteResponse executeResponse = new ExecuteResponse();
    deliveryResponse.setPrefetch(prefetchResponse);
    deliveryResponse.setExecute(executeResponse);
    TargetDeliveryResponse targetResponse = new TargetDeliveryResponse(deliveryRequest, deliveryResponse, status, localEvaluation.isAllLocal() ? "Local-decisioning response" : localEvaluation.getReason());
    ResponseStatus responseStatus = targetResponse.getResponseStatus();
    responseStatus.setGlobalMbox(localEvaluation.getGlobalMbox());
    responseStatus.setRemoteMboxes(localEvaluation.getRemoteMBoxes());
    responseStatus.setRemoteViews(localEvaluation.getRemoteViews());
    return targetResponse;
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) PrefetchResponse(com.adobe.target.delivery.v1.model.PrefetchResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ExecuteResponse(com.adobe.target.delivery.v1.model.ExecuteResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) OnDeviceDecisioningEvaluation(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation)

Example 2 with PrefetchResponse

use of com.adobe.target.delivery.v1.model.PrefetchResponse in project target-java-sdk by adobe.

the class OnDeviceDecisioningService method handleDetails.

private void handleDetails(List<RequestDetails> detailsList, Map<String, Object> requestContext, TargetDeliveryRequest deliveryRequest, String visitorId, Set<String> responseTokens, TraceHandler traceHandler, OnDeviceDecisioningRuleSet ruleSet, PrefetchResponse prefetchResponse, ExecuteResponse executeResponse, List<Notification> notifications) {
    for (RequestDetails details : detailsList) {
        Map<String, Object> detailsContext = new HashMap<>(requestContext);
        collateParams(detailsContext, DETAILS_PARAMS_COLLATORS, deliveryRequest, details);
        this.decisionHandler.executeDetails(deliveryRequest, this.onDeviceAllMatchingRulesMboxes, detailsContext, visitorId, responseTokens, traceHandler, ruleSet, details, prefetchResponse, executeResponse, notifications);
    }
}
Also used : RequestDetails(com.adobe.target.delivery.v1.model.RequestDetails)

Example 3 with PrefetchResponse

use of com.adobe.target.delivery.v1.model.PrefetchResponse in project target-java-sdk by adobe.

the class TargetAttributesResponse method toMap.

private static Map<String, Map<String, Object>> toMap(TargetDeliveryResponse targetResponse) {
    if (targetResponse == null) {
        return null;
    }
    Map<String, Map<String, Object>> result = new HashMap<>();
    String globalMbox = getGlobalMbox(targetResponse);
    DeliveryResponse response = targetResponse.getResponse();
    PrefetchResponse prefetchResponse = response.getPrefetch();
    ExecuteResponse executeResponse = response.getExecute();
    processPrefetch(result, prefetchResponse, globalMbox);
    processExecute(result, executeResponse, globalMbox);
    return toReadOnlyMap(result);
}
Also used : PrefetchResponse(com.adobe.target.delivery.v1.model.PrefetchResponse) HashMap(java.util.HashMap) ExecuteResponse(com.adobe.target.delivery.v1.model.ExecuteResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)2 ExecuteResponse (com.adobe.target.delivery.v1.model.ExecuteResponse)2 PrefetchResponse (com.adobe.target.delivery.v1.model.PrefetchResponse)2 RequestDetails (com.adobe.target.delivery.v1.model.RequestDetails)1 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)1 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)1 OnDeviceDecisioningEvaluation (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1