Search in sources :

Example 1 with ExecuteRequest

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

the class TelemetryService method executeMboxCount.

private int executeMboxCount(TargetDeliveryRequest request) {
    int executeMboxCount = 0;
    ExecuteRequest executeRequest = request.getDeliveryRequest().getExecute();
    if (executeRequest != null) {
        executeMboxCount = executeRequest.getMboxes().size();
    }
    return executeMboxCount;
}
Also used : ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest)

Example 2 with ExecuteRequest

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

the class OnDeviceDecisioningService method executeRequest.

public TargetDeliveryResponse executeRequest(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    DeliveryRequest delivRequest = deliveryRequest.getDeliveryRequest();
    String requestId = delivRequest.getRequestId();
    if (requestId == null) {
        requestId = UUID.randomUUID().toString();
    }
    OnDeviceDecisioningRuleSet ruleSet = this.ruleLoader.getLatestRules();
    if (ruleSet == null) {
        DeliveryResponse deliveryResponse = new DeliveryResponse().client(clientConfig.getClient()).requestId(requestId).id(delivRequest.getId()).status(HttpStatus.SC_SERVICE_UNAVAILABLE);
        return new TargetDeliveryResponse(deliveryRequest, deliveryResponse, HttpStatus.SC_SERVICE_UNAVAILABLE, "Local-decisioning rules not available");
    }
    Map<String, Object> requestContext = new HashMap<>(timeParamsCollator.collateParams(deliveryRequest, null));
    geoLookupIfNeeded(deliveryRequest, ruleSet.isGeoTargetingEnabled());
    collateParams(requestContext, REQUEST_PARAMS_COLLATORS, deliveryRequest, null);
    TraceHandler traceHandler = null;
    if (delivRequest.getTrace() != null) {
        traceHandler = new TraceHandler(this.clientConfig, this.ruleLoader, this.mapper, ruleSet, deliveryRequest);
    }
    Set<String> responseTokens = new HashSet<>(ruleSet.getResponseTokens());
    TargetDeliveryResponse targetResponse = buildDeliveryResponse(deliveryRequest, requestId);
    String visitorId = getOrCreateVisitorId(deliveryRequest, targetResponse);
    List<RequestDetails> prefetchRequests = detailsFromPrefetch(delivRequest);
    handleDetails(prefetchRequests, requestContext, deliveryRequest, visitorId, responseTokens, traceHandler, ruleSet, targetResponse.getResponse().getPrefetch(), null, null);
    List<RequestDetails> executeRequests = detailsFromExecute(delivRequest);
    List<Notification> notifications = new ArrayList<>();
    handleDetails(executeRequests, requestContext, deliveryRequest, visitorId, responseTokens, traceHandler, ruleSet, null, targetResponse.getResponse().getExecute(), notifications);
    telemetryService.addTelemetry(deliveryRequest, timer, targetResponse);
    notificationService.buildNotifications(deliveryRequest, targetResponse, notifications);
    if (this.clientConfig.isLogRequests()) {
        logger.debug(targetResponse.toString());
    }
    return targetResponse;
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) RequestDetails(com.adobe.target.delivery.v1.model.RequestDetails) Notification(com.adobe.target.delivery.v1.model.Notification) OnDeviceDecisioningRuleSet(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse)

Example 3 with ExecuteRequest

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

the class OnDeviceDecisioningEvaluator method allMboxNames.

private List<String> allMboxNames(TargetDeliveryRequest request, OnDeviceDecisioningRuleSet ruleSet) {
    if (request == null || ruleSet == null) {
        return Collections.emptyList();
    }
    List<String> mboxNames = new ArrayList<>();
    String globalMbox = ruleSet.getGlobalMbox();
    PrefetchRequest prefetch = request.getDeliveryRequest().getPrefetch();
    if (prefetch != null) {
        if (prefetch.getPageLoad() != null) {
            mboxNames.add(globalMbox);
        }
        mboxNames.addAll(prefetch.getMboxes().stream().map(MboxRequest::getName).collect(Collectors.toList()));
    }
    ExecuteRequest execute = request.getDeliveryRequest().getExecute();
    if (execute != null) {
        if (execute.getPageLoad() != null) {
            mboxNames.add(globalMbox);
        }
        mboxNames.addAll(execute.getMboxes().stream().map(MboxRequest::getName).collect(Collectors.toList()));
    }
    return mboxNames;
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) ArrayList(java.util.ArrayList)

Example 4 with ExecuteRequest

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

the class TargetDeliveryExceptionTest method testTargetDeliveryRequest.

@Test
void testTargetDeliveryRequest() {
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).build();
    TargetRequestException exception = assertThrows(TargetRequestException.class, () -> {
        TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    });
    assertNotNull(exception);
    assertNotNull(exception.getRequest());
    assertNotNull(exception.getRequest().getSessionId());
}
Also used : TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) Context(com.adobe.target.delivery.v1.model.Context) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 5 with ExecuteRequest

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

the class TelemetryService method isExecutePageLoad.

private Boolean isExecutePageLoad(TargetDeliveryRequest request) {
    boolean isExecutePageLoad = false;
    ExecuteRequest executeRequest = request.getDeliveryRequest().getExecute();
    if (executeRequest != null) {
        isExecutePageLoad = executeRequest.getPageLoad() != null;
    }
    return isExecutePageLoad;
}
Also used : ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest)

Aggregations

ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)27 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)26 Test (org.junit.jupiter.api.Test)22 Context (com.adobe.target.delivery.v1.model.Context)19 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)15 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)15 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)15 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)14 TimingTool (com.adobe.target.edge.client.utils.TimingTool)13 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)10 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)8 Property (com.adobe.target.delivery.v1.model.Property)8 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)6 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)6 RequestDetails (com.adobe.target.delivery.v1.model.RequestDetails)5 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)5 OnDeviceDecisioningRuleSet (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)4 ArrayList (java.util.ArrayList)4 Notification (com.adobe.target.delivery.v1.model.Notification)3