1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.panels.internal; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Provider; |
28 |
|
|
29 |
|
import org.apache.commons.lang3.StringUtils; |
30 |
|
import org.slf4j.Logger; |
31 |
|
import org.xwiki.component.manager.ComponentLookupException; |
32 |
|
import org.xwiki.component.manager.ComponentManager; |
33 |
|
import org.xwiki.configuration.ConfigurationSource; |
34 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
35 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
36 |
|
import org.xwiki.uiextension.UIExtension; |
37 |
|
import org.xwiki.uiextension.UIExtensionManager; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 4 |
Complexity Density: 0.29 |
|
46 |
|
public abstract class AbstractPanelsUIExtensionManager implements UIExtensionManager |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@Inject |
52 |
|
protected ConfigurationSource configurationSource; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@Inject |
58 |
|
private Logger logger; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@Inject |
64 |
|
@Named("currentmixed") |
65 |
|
private DocumentReferenceResolver<String> resolver; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@Inject |
71 |
|
private EntityReferenceSerializer<String> serializer; |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@Inject |
79 |
|
@Named("context") |
80 |
|
private Provider<ComponentManager> contextComponentManagerProvider; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@return |
86 |
|
|
87 |
|
protected abstract String getConfiguration(); |
88 |
|
|
|
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
|
89 |
18 |
@Override... |
90 |
|
public List<UIExtension> get(String extensionPointId) |
91 |
|
{ |
92 |
18 |
List<UIExtension> panels = new ArrayList<UIExtension>(); |
93 |
|
|
94 |
18 |
String panelConfigurationString = getConfiguration(); |
95 |
|
|
96 |
|
|
97 |
18 |
if (!StringUtils.isEmpty(panelConfigurationString)) { |
98 |
18 |
List<String> panelSerializedReferences = new ArrayList<String>(); |
99 |
18 |
for (String serializedReference : getConfiguration().split(",")) { |
100 |
39 |
panelSerializedReferences.add(serializer.serialize(resolver.resolve(serializedReference.trim()))); |
101 |
|
} |
102 |
|
|
103 |
18 |
try { |
104 |
18 |
List<UIExtension> allExtensions = |
105 |
|
contextComponentManagerProvider.get().getInstanceList(UIExtension.class); |
106 |
18 |
for (String panelSerializedReference : panelSerializedReferences) { |
107 |
39 |
for (UIExtension extension : allExtensions) { |
108 |
1337 |
if (extension.getId().equals(panelSerializedReference)) { |
109 |
21 |
panels.add(extension); |
110 |
|
} |
111 |
|
} |
112 |
|
} |
113 |
|
} catch (ComponentLookupException e) { |
114 |
0 |
logger.error("Failed to lookup Panels instances, error: [{}]", e); |
115 |
|
} |
116 |
|
} |
117 |
|
|
118 |
18 |
return panels; |
119 |
|
} |
120 |
|
} |