use of org.xwiki.skin.Resource in project xwiki-platform by xwiki.
the class LogoAttachmentExtractor method getLogo.
/**
* @return an attachment holding the logo of the wiki
* @throws Exception if an error happens
*/
public Attachment getLogo() throws Exception {
XWikiContext context = xwikiContextProvider.get();
String colorTheme = configurationSource.getProperty("colorTheme");
if (StringUtils.isNotBlank(colorTheme)) {
DocumentReference colorThemeRef = documentReferenceResolver.resolve(colorTheme);
XWiki xwiki = context.getWiki();
XWikiDocument doc = xwiki.getDocument(colorThemeRef, context);
String logo = doc.getStringValue(LOGO);
if (StringUtils.isBlank(logo)) {
logo = doc.getStringValue("logoImage");
}
if (isLogoAttachementValid(doc, logo)) {
XWikiAttachment attachment = doc.getAttachment(logo);
attachment.setFilename(LOGO);
return new Attachment(new Document(doc, context), attachment, context);
}
}
String skin = configurationSource.getProperty("skin");
if (StringUtils.isNotBlank(skin)) {
DocumentReference skinRef = documentReferenceResolver.resolve(skin);
XWiki xwiki = context.getWiki();
XWikiDocument doc = xwiki.getDocument(skinRef, context);
String logo = doc.getStringValue(LOGO);
if (isLogoAttachementValid(doc, logo)) {
XWikiAttachment attachment = doc.getAttachment(logo);
attachment.setFilename(LOGO);
return new Attachment(new Document(doc, context), attachment, context);
}
}
XWikiAttachment fakeAttachment = new XWikiAttachment();
Resource sourceImageIS = internalSkinManager.getCurrentSkin(true).getResource("logo.png");
InputStream inputStream = environment.getResourceAsStream(sourceImageIS.getPath());
fakeAttachment.setAttachment_content(new XWikiAttachmentContent());
fakeAttachment.getAttachment_content().setContent(inputStream);
fakeAttachment.setFilename(LOGO);
return new Attachment(null, fakeAttachment, context);
}
use of org.xwiki.skin.Resource in project xwiki-platform by xwiki.
the class AbstractLESSSource method relativeSource.
@Override
public LessSource relativeSource(String filename) throws FileNotFound {
String template = folder + "/" + filename;
Resource resource = skin.getResource(template);
if (resource != null) {
return new TemplateLESSSource(templateManager, skin, template);
}
// The file has not been found
throw new FileNotFound();
}
Aggregations