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 |
|
package info.magnolia.rest.registry; |
35 |
|
|
36 |
|
import static java.util.Collections.emptyList; |
37 |
|
|
38 |
|
import info.magnolia.config.registry.DefinitionMetadata; |
39 |
|
import info.magnolia.config.registry.DefinitionMetadataBuilder; |
40 |
|
import info.magnolia.config.registry.DefinitionProvider; |
41 |
|
import info.magnolia.config.registry.DefinitionRawView; |
42 |
|
import info.magnolia.config.registry.Registry; |
43 |
|
import info.magnolia.config.registry.decoration.DefinitionDecorator; |
44 |
|
import info.magnolia.event.Event; |
45 |
|
import info.magnolia.rest.EndpointDefinition; |
46 |
|
|
47 |
|
import java.util.List; |
48 |
|
|
49 |
|
|
50 |
|
@link |
51 |
|
|
52 |
|
@see |
53 |
|
@see |
54 |
|
|
|
|
| 30% |
Uncovered Elements: 14 (20) |
Complexity: 7 |
Complexity Density: 0.44 |
|
55 |
|
public class EndpointDefinitionRegistryEvent implements Event<EndpointDefinitionRegistryEventHandler> { |
56 |
|
|
57 |
|
private final EndpointDefinitionRegistryEventType type; |
58 |
|
private final DefinitionProvider<EndpointDefinition> endpointDefinitionProvider; |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
60 |
49 |
public EndpointDefinitionRegistryEvent(EndpointDefinitionRegistryEventType type, DefinitionProvider<EndpointDefinition> endpointDefinitionProvider) {... |
61 |
49 |
this.type = type; |
62 |
49 |
this.endpointDefinitionProvider = endpointDefinitionProvider; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
65 |
4 |
public EndpointDefinitionRegistryEvent(EndpointDefinitionRegistryEventType type, String endpointName) {... |
66 |
4 |
this.type = type; |
67 |
4 |
this.endpointDefinitionProvider = new FixedDefinitionProvider(endpointName); |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
@deprecated@link |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
73 |
0 |
@Deprecated... |
74 |
|
public EndpointDefinitionRegistryEvent(EndpointDefinitionRegistryEventType type, EndpointDefinition endpointDefinition) { |
75 |
0 |
this.type = type; |
76 |
0 |
this.endpointDefinitionProvider = new FixedDefinitionProvider(endpointDefinition); |
77 |
|
} |
78 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
79 |
|
public EndpointDefinitionRegistryEventType getType() {... |
80 |
|
return type; |
81 |
|
} |
82 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
83 |
|
public String getEndpointName() {... |
84 |
|
return endpointDefinitionProvider.getMetadata().getReferenceId(); |
85 |
|
} |
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
87 |
|
public DefinitionProvider<EndpointDefinition> getEndpointDefinitionProvider() {... |
88 |
|
return endpointDefinitionProvider; |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
@deprecated@link |
93 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
94 |
|
@Deprecated... |
95 |
|
public EndpointDefinition getEndpointDefinition() { |
96 |
|
return endpointDefinitionProvider.get(); |
97 |
|
} |
98 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.4 |
|
99 |
0 |
@Override... |
100 |
|
public void dispatch(EndpointDefinitionRegistryEventHandler handler) { |
101 |
0 |
switch(type) { |
102 |
0 |
case REGISTERED: |
103 |
0 |
handler.onEndpointRegistered(this); |
104 |
0 |
break; |
105 |
0 |
case REREGISTERED: |
106 |
0 |
handler.onEndpointReregistered(this); |
107 |
0 |
break; |
108 |
0 |
case UNREGISTERED: |
109 |
0 |
handler.onEndpointUnregistered(this); |
110 |
0 |
break; |
111 |
|
} |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
|
|
| 37.5% |
Uncovered Elements: 5 (8) |
Complexity: 3 |
Complexity Density: 0.6 |
|
117 |
|
private static class FixedDefinitionProvider implements DefinitionProvider<EndpointDefinition> { |
118 |
|
private final DefinitionMetadata metadata; |
119 |
|
private final EndpointDefinition endpointDefinition; |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
121 |
0 |
public FixedDefinitionProvider(EndpointDefinition endpointDefinition) {... |
122 |
0 |
this.endpointDefinition = endpointDefinition; |
123 |
0 |
this.metadata = DefinitionMetadataBuilder.usingNameAsId() |
124 |
|
.name(endpointDefinition.getName()) |
125 |
|
.build(); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
128 |
4 |
public FixedDefinitionProvider(String endpointName) {... |
129 |
4 |
this.endpointDefinition = null; |
130 |
4 |
this.metadata = DefinitionMetadataBuilder.usingNameAsId() |
131 |
|
.name(endpointName) |
132 |
|
.build(); |
133 |
|
} |
134 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
135 |
|
@Override... |
136 |
|
public List<DefinitionDecorator<EndpointDefinition>> getDecorators() { |
137 |
|
return emptyList(); |
138 |
|
} |
139 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
140 |
|
@Override... |
141 |
|
public DefinitionMetadata getMetadata() { |
142 |
|
return metadata; |
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
0 |
@Override... |
146 |
|
public EndpointDefinition get() throws Registry.InvalidDefinitionException { |
147 |
0 |
return endpointDefinition; |
148 |
|
} |
149 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
150 |
|
@Override... |
151 |
|
public DefinitionRawView getRaw() { |
152 |
|
return null; |
153 |
|
} |
154 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
155 |
|
@Override... |
156 |
|
public boolean isValid() { |
157 |
|
return endpointDefinition != null; |
158 |
|
} |
159 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
160 |
|
@Override... |
161 |
|
public long getLastModified() { |
162 |
|
return 0; |
163 |
|
} |
164 |
|
} |
165 |
|
} |