DemdexCookieTraitsServiceImpl.java
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.osgi.service.component.ComponentContext
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.aam.demdex;
import com.adobe.cq.aam.client.spi.AudienceManagerConfiguration;
import com.adobe.cq.aam.client.spi.AudienceManagerItem;
import com.adobe.cq.aam.client.spi.SegmentService;
import com.adobe.cq.aam.client.spi.TraitsService;
import com.adobe.cq.aam.demdex.JsonResponseSegmentIdList;
import com.adobe.cq.aam.demdex.JsonResponseSegmentList;
import com.adobe.cq.aam.demdex.SegmentListException;
import java.util.ArrayList;
import java.util.List;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(immediate=1)
@Service(value={TraitsService.class})
public class DemdexCookieTraitsServiceImpl
implements TraitsService {
private static final Logger LOGGER = LoggerFactory.getLogger(DemdexCookieTraitsServiceImpl.class);
@Reference
private SegmentService segmentService;
@Activate
public void activate(ComponentContext componentContext) {
}
@Override
public List<String[]> updateTraits(AudienceManagerConfiguration config, String[] traits) {
ArrayList<String[]> p = new ArrayList<String[]>();
for (String t : traits) {
p.add(new String[]{"d_sid", t});
}
return p;
}
@Override
public Iterable<AudienceManagerItem> getSegments(AudienceManagerConfiguration config, JSONObject json) {
try {
return new JsonResponseSegmentList(this.segmentService, config, json);
}
catch (SegmentListException e) {
return null;
}
}
@Override
public Iterable<String> getSegmentIds(AudienceManagerConfiguration config, JSONObject json) {
try {
return new JsonResponseSegmentIdList(this.segmentService, config, json);
}
catch (SegmentListException e) {
return null;
}
}
@Override
public boolean containsDestination(JSONObject response, String destination, String domain) {
try {
LOGGER.debug("Got Response {} ", (Object)response.toString(2));
if (response.has("stuff")) {
JSONArray stuff = response.getJSONArray("stuff");
for (int i = 0; i < stuff.length(); ++i) {
JSONObject v = stuff.getJSONObject(i);
if (!v.has("cn") || !v.has("dmn") || !destination.equals(v.getString("cn")) || !domain.equals(v.getString("dmn"))) continue;
return true;
}
}
}
catch (JSONException e) {
LOGGER.error(e.getMessage(), (Throwable)e);
}
return false;
}
protected void bindSegmentService(SegmentService segmentService) {
this.segmentService = segmentService;
}
protected void unbindSegmentService(SegmentService segmentService) {
if (this.segmentService == segmentService) {
this.segmentService = null;
}
}
}