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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations