MVTStatisticsImpl.java
3.93 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.statistics.StatisticsService
* com.day.cq.wcm.api.Page
* com.day.cq.wcm.api.WCMException
* com.day.crx.statistics.Report
* javax.jcr.RepositoryException
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.ReferencePolicy
* org.apache.felix.scr.annotations.Service
* org.osgi.service.component.ComponentContext
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.wcm.core.mvt;
import com.day.cq.statistics.StatisticsService;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.core.mvt.CTRReport;
import com.day.cq.wcm.core.mvt.MVTStatistics;
import com.day.crx.statistics.Report;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Iterator;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
@Component(metatype=1, label="%mvtstatistics.name", description="%mvtstatistics.description")
@Service
public class MVTStatisticsImpl
implements MVTStatistics {
private static final Logger log = LoggerFactory.getLogger(MVTStatisticsImpl.class);
@Property
private static final String TRACKING_URL_PROPERTY = "mvtstatistics.trackingurl";
@Reference(policy=ReferencePolicy.STATIC)
private StatisticsService statistics;
private String trackingUrl;
private String dataPath;
@Override
public URL getTrackingURL() {
return this.getURL(this.trackingUrl);
}
@Override
public URI getTrackingURI() {
return this.getURI(this.trackingUrl);
}
@Override
public Iterable<Object[]> report(Page page) throws WCMException {
try {
ArrayList<Object[]> result = new ArrayList<Object[]>();
CTRReport report = new CTRReport(this.dataPath, page);
Iterator it = this.statistics.runReport((Report)report);
while (it.hasNext()) {
result.add((Object[])it.next());
}
return result;
}
catch (RepositoryException e) {
throw new WCMException((Throwable)e);
}
}
protected void activate(ComponentContext context) {
Dictionary props = context.getProperties();
this.trackingUrl = (String)props.get("mvtstatistics.trackingurl");
this.dataPath = this.statistics.getPath() + "/mvt";
}
private URL getURL(String urlProperty) {
if (urlProperty != null) {
try {
return new URL(urlProperty);
}
catch (MalformedURLException e) {
log.error("Configuration contained URL that is not valid{}: {}", (Object)urlProperty, (Object)e);
}
}
return null;
}
private URI getURI(String urlProperty) {
if (urlProperty != null) {
try {
return new URI(urlProperty);
}
catch (URISyntaxException e) {
log.error("Configuration contained URI that is not valid{}: {}", (Object)urlProperty, (Object)e);
}
}
return null;
}
protected void bindStatistics(StatisticsService statisticsService) {
this.statistics = statisticsService;
}
protected void unbindStatistics(StatisticsService statisticsService) {
if (this.statistics == statisticsService) {
this.statistics = null;
}
}
}