1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.lesscss.internal.skin; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Provider; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.lesscss.compiler.LESSCompilerException; |
28 |
|
import org.xwiki.model.reference.DocumentReference; |
29 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
30 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
31 |
|
import org.xwiki.model.reference.WikiReference; |
32 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
33 |
|
|
34 |
|
import com.xpn.xwiki.XWiki; |
35 |
|
import com.xpn.xwiki.XWikiContext; |
36 |
|
import com.xpn.xwiki.XWikiException; |
37 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@since |
43 |
|
@version |
44 |
|
|
45 |
|
@Component |
46 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
47 |
|
public class DefaultSkinReferenceFactory implements SkinReferenceFactory |
48 |
|
{ |
49 |
|
@Inject |
50 |
|
private Provider<XWikiContext> xcontextProvider; |
51 |
|
|
52 |
|
@Inject |
53 |
|
private DocumentReferenceResolver<String> documentReferenceResolver; |
54 |
|
|
55 |
|
@Inject |
56 |
|
private WikiDescriptorManager wikiDescriptorManager; |
57 |
|
|
58 |
|
@Inject |
59 |
|
private EntityReferenceSerializer<String> entityReferenceSerializer; |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
61 |
2165 |
@Override... |
62 |
|
public SkinReference createReference(String skinName) throws LESSCompilerException |
63 |
|
{ |
64 |
|
|
65 |
2165 |
XWikiContext xcontext = xcontextProvider.get(); |
66 |
2166 |
XWiki xwiki = xcontext.getWiki(); |
67 |
|
|
68 |
2166 |
String currentWikiId = wikiDescriptorManager.getCurrentWikiId(); |
69 |
|
|
70 |
2166 |
DocumentReference skinDocRef = documentReferenceResolver.resolve(skinName, new WikiReference(currentWikiId)); |
71 |
|
|
72 |
2166 |
if (xwiki.exists(skinDocRef, xcontext)) { |
73 |
3 |
try { |
74 |
3 |
XWikiDocument skinDoc = xwiki.getDocument(skinDocRef, xcontext); |
75 |
2 |
DocumentReference skinClassDocRef = new DocumentReference(skinDocRef.getWikiReference().getName(), |
76 |
|
"XWiki", "XWikiSkins"); |
77 |
|
|
78 |
2 |
if (skinDoc.getXObjectSize(skinClassDocRef) > 0) { |
79 |
1 |
return createReference(skinDocRef); |
80 |
|
} |
81 |
|
|
82 |
|
} catch (XWikiException e) { |
83 |
1 |
throw new LESSCompilerException(String.format("Unable to read document [%s]", skinDocRef), e); |
84 |
|
} |
85 |
|
} |
86 |
|
|
87 |
2164 |
return new FSSkinReference(skinName); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
1 |
@Override... |
91 |
|
public SkinReference createReference(DocumentReference documentReference) |
92 |
|
{ |
93 |
1 |
return new DocumentSkinReference(documentReference, entityReferenceSerializer); |
94 |
|
} |
95 |
|
} |