use of org.xwiki.lesscss.compiler.LESSCompilerException in project xwiki-platform by xwiki.
the class DefaultColorThemeReferenceFactory method createReference.
@Override
public ColorThemeReference createReference(String colorThemeName) throws LESSCompilerException {
// Get the XWiki Object
XWikiContext xcontext = xcontextProvider.get();
XWiki xwiki = xcontext.getWiki();
String currentWikiId = wikiDescriptorManager.getCurrentWikiId();
DocumentReference colorThemeDocRef = documentReferenceResolver.resolve(colorThemeName, new WikiReference(currentWikiId));
if (xwiki.exists(colorThemeDocRef, xcontext)) {
try {
XWikiDocument colorThemeDoc = xwiki.getDocument(colorThemeDocRef, xcontext);
// Is there any color theme?
DocumentReference colorThemeClassRef = new DocumentReference(colorThemeDocRef.getWikiReference().getName(), "ColorThemes", "ColorThemeClass");
if (colorThemeDoc.getXObjectSize(colorThemeClassRef) > 0) {
return createReference(colorThemeDocRef);
}
// Is there any flamingo theme?
DocumentReference flamingoThemeClassRef = new DocumentReference(colorThemeDocRef.getWikiReference().getName(), "FlamingoThemesCode", "ThemeClass");
if (colorThemeDoc.getXObjectSize(flamingoThemeClassRef) > 0) {
return createReference(colorThemeDocRef);
}
} catch (XWikiException e) {
throw new LESSCompilerException(String.format("Unable to read document [%s]", colorThemeDocRef));
}
}
// Not an XWiki page so probably a file system color theme
return new NamedColorThemeReference(colorThemeName);
}
Aggregations