1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.stats.impl.xwiki; |
21 |
|
|
22 |
|
import java.util.Date; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.slf4j.Logger; |
26 |
|
import org.slf4j.LoggerFactory; |
27 |
|
|
28 |
|
import com.xpn.xwiki.XWikiContext; |
29 |
|
import com.xpn.xwiki.XWikiException; |
30 |
|
import com.xpn.xwiki.stats.impl.RefererStats; |
31 |
|
import com.xpn.xwiki.stats.impl.StatsUtil.PeriodType; |
32 |
|
import com.xpn.xwiki.store.XWikiHibernateStore; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.44 |
|
40 |
|
public class RefererStatsStoreItem extends AbstractStatsStoreItem |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(RefererStatsStoreItem.class); |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private String referer; |
51 |
|
|
52 |
|
|
53 |
|
@link |
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
@param |
59 |
|
@param |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
0 |
public RefererStatsStoreItem(String name, Date periodDate, PeriodType periodType, String referer,... |
62 |
|
XWikiContext context) |
63 |
|
{ |
64 |
0 |
super(name, periodDate, periodType, context); |
65 |
|
|
66 |
0 |
this.referer = referer; |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
@Override... |
70 |
|
public String getId() |
71 |
|
{ |
72 |
0 |
return String.format("%s %s %s %s", getClass(), this.name, this.referer, this.period); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
75 |
0 |
@Override... |
76 |
|
public void storeInternal(List<XWikiStatsStoreItem> stats) |
77 |
|
{ |
78 |
0 |
RefererStatsStoreItem lastItem = (RefererStatsStoreItem) stats.get(stats.size() - 1); |
79 |
|
|
80 |
0 |
XWikiHibernateStore store = this.context.getWiki().getHibernateStore(); |
81 |
0 |
if (store == null) { |
82 |
0 |
return; |
83 |
|
} |
84 |
|
|
85 |
0 |
RefererStats refererStat = |
86 |
|
new RefererStats(lastItem.name, lastItem.referer, lastItem.periodDate, lastItem.periodType); |
87 |
|
|
88 |
|
|
89 |
0 |
try { |
90 |
|
|
91 |
0 |
store.loadXWikiCollection(refererStat, this.context, true); |
92 |
|
} catch (XWikiException e) { |
93 |
0 |
if (LOGGER.isDebugEnabled()) { |
94 |
0 |
LOGGER.debug("Failed to load referer statictics object [" + getId() + "]"); |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
0 |
refererStat.setIntValue("pageViews", refererStat.getPageViews() + stats.size()); |
100 |
|
|
101 |
|
|
102 |
0 |
try { |
103 |
|
|
104 |
0 |
store.saveXWikiCollection(refererStat, this.context, true); |
105 |
|
} catch (XWikiException e) { |
106 |
0 |
LOGGER.error("Failed to save referer statictics object [" + getId() + "]"); |
107 |
|
} |
108 |
|
} |
109 |
|
} |