use of org.xwiki.skin.ResourceRepository in project xwiki-platform by xwiki.
the class AbstractSkin method getResource.
@Override
public Resource<?> getResource(String resourceName) {
Resource<?> resource = getLocalResource(resourceName);
if (resource == null) {
// Make sure to not try several times the same skin
Set<String> skins = new HashSet<String>();
skins.add(getId());
for (ResourceRepository parent = getParent(); parent != null && resource == null && !skins.contains(parent.getId()); parent = parent.getParent()) {
resource = parent.getLocalResource(resourceName);
skins.add(parent.getId());
}
}
return resource;
}
use of org.xwiki.skin.ResourceRepository in project xwiki-platform by xwiki.
the class InternalSkinManager method getCurrentParentSkinId.
public String getCurrentParentSkinId(boolean testRights) {
// From the context
String baseSkin = getContextParentId();
// From the skin
if (baseSkin == null) {
Skin skin = getCurrentSkin(testRights);
if (skin != null) {
ResourceRepository parent = skin.getParent();
if (parent != null) {
baseSkin = parent.getId();
}
}
}
// From the configuration
if (baseSkin == null) {
baseSkin = getDefaultParentSkinId();
}
XWikiContext xcontext = this.xcontextProvider.get();
if (xcontext != null) {
// TODO: shouldn't we make sure anyone see the skin whatever right he have ?
if (testRights) {
XWikiDocument document = this.wikiSkinUtils.getSkinDocument(baseSkin);
if (document != null) {
if (!this.authorization.hasAccess(Right.VIEW, document.getDocumentReference())) {
this.logger.debug("Cannot access configured wiki skin [{}] due to access rights, using the default skin.", baseSkin);
baseSkin = getDefaultParentSkinId();
}
}
}
// Set found skin in the context
xcontext.put(CKEY_PARENTSKIN, baseSkin);
}
return baseSkin;
}
Aggregations