1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.observation.remote.converter; |
21 |
|
|
22 |
|
import java.io.Serializable; |
23 |
|
import java.util.HashSet; |
24 |
|
import java.util.Set; |
25 |
|
|
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.xwiki.bridge.event.WikiCreatedEvent; |
30 |
|
import org.xwiki.bridge.event.WikiDeletedEvent; |
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
import org.xwiki.observation.event.Event; |
33 |
|
import org.xwiki.observation.remote.LocalEventData; |
34 |
|
import org.xwiki.observation.remote.RemoteEventData; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWikiContext; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
46 |
|
@Component |
47 |
|
@Singleton |
48 |
|
@Named("wiki") |
|
|
| 44% |
Uncovered Elements: 14 (25) |
Complexity: 6 |
Complexity Density: 0.38 |
|
49 |
|
public class WikiEventConverter extends AbstractXWikiEventConverter |
50 |
|
{ |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private Set<Class<? extends Event>> events = new HashSet<Class<? extends Event>>() |
55 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
8 |
{... |
57 |
8 |
add(WikiDeletedEvent.class); |
58 |
8 |
add(WikiCreatedEvent.class); |
59 |
|
} |
60 |
|
}; |
61 |
|
|
|
|
| 37.5% |
Uncovered Elements: 5 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
62 |
1043 |
@Override... |
63 |
|
public boolean toRemote(LocalEventData localEvent, RemoteEventData remoteEvent) |
64 |
|
{ |
65 |
1042 |
if (this.events.contains(localEvent.getEvent().getClass())) { |
66 |
|
|
67 |
0 |
remoteEvent.setEvent((Serializable) localEvent.getEvent()); |
68 |
0 |
remoteEvent.setSource((String) localEvent.getSource()); |
69 |
0 |
remoteEvent.setData(serializeXWikiContext((XWikiContext) localEvent.getData())); |
70 |
|
|
71 |
0 |
return true; |
72 |
|
} |
73 |
|
|
74 |
1042 |
return false; |
75 |
|
} |
76 |
|
|
|
|
| 25% |
Uncovered Elements: 9 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
77 |
1 |
@Override... |
78 |
|
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) |
79 |
|
{ |
80 |
1 |
if (this.events.contains(remoteEvent.getEvent().getClass())) { |
81 |
|
|
82 |
0 |
XWikiContext context = unserializeXWikiContext(remoteEvent.getData()); |
83 |
|
|
84 |
0 |
if (context != null) { |
85 |
0 |
localEvent.setEvent((Event) remoteEvent.getEvent()); |
86 |
0 |
localEvent.setSource(remoteEvent.getSource()); |
87 |
0 |
localEvent.setData(unserializeXWikiContext(remoteEvent.getData())); |
88 |
|
} |
89 |
|
|
90 |
0 |
return true; |
91 |
|
} |
92 |
|
|
93 |
1 |
return false; |
94 |
|
} |
95 |
|
} |