1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.repository.internal; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Provider; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
32 |
|
import org.xwiki.model.reference.EntityReference; |
33 |
|
|
34 |
|
import com.xpn.xwiki.XWikiContext; |
35 |
|
import com.xpn.xwiki.XWikiException; |
36 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
37 |
|
import com.xpn.xwiki.objects.BaseObject; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Singleton |
|
|
| 70.6% |
Uncovered Elements: 5 (17) |
Complexity: 6 |
Complexity Density: 0.67 |
|
47 |
|
public class DefaultRepositoryConfiguration implements RepositoryConfiguration |
48 |
|
{ |
49 |
|
|
50 |
|
@link |
51 |
|
|
52 |
|
@Inject |
53 |
|
private Provider<XWikiContext> xcontextProvider; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@Inject |
59 |
|
@Named("current") |
60 |
|
private DocumentReferenceResolver<EntityReference> resolver; |
61 |
|
|
62 |
|
|
63 |
|
@return |
64 |
|
@throws |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
66 |
45 |
private BaseObject getConfigurationObject() throws XWikiException... |
67 |
|
{ |
68 |
45 |
XWikiContext xcontext = this.xcontextProvider.get(); |
69 |
|
|
70 |
45 |
XWikiDocument document = |
71 |
|
xcontext.getWiki().getDocument(this.resolver.resolve(XWikiRepositoryModel.CONFIGURATION_REFERENCE), |
72 |
|
xcontext); |
73 |
|
|
74 |
45 |
return document.getXObject(XWikiRepositoryModel.CONFIGURATION_CLASSREFERENCE); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
77 |
0 |
@Override... |
78 |
|
public String getDefaultIdPrefix() throws XWikiException |
79 |
|
{ |
80 |
0 |
BaseObject obj = getConfigurationObject(); |
81 |
|
|
82 |
0 |
return obj != null ? obj.getStringValue(XWikiRepositoryModel.PROP_CONFIGURATION_DEFAULTIDPREFIX) : ""; |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
85 |
45 |
@Override... |
86 |
|
public List<String> getValidTypes() throws XWikiException |
87 |
|
{ |
88 |
45 |
BaseObject obj = getConfigurationObject(); |
89 |
|
|
90 |
45 |
return obj != null ? obj.getListValue(XWikiRepositoryModel.PROP_CONFIGURATION_VALIDTYPEs) : Collections |
91 |
|
.<String> emptyList(); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
94 |
45 |
@Override... |
95 |
|
public boolean isValidType(String type) throws XWikiException |
96 |
|
{ |
97 |
45 |
List<String> types = getValidTypes(); |
98 |
|
|
99 |
45 |
return types.isEmpty() || types.contains(type); |
100 |
|
} |
101 |
|
|
102 |
|
} |