Search in sources :

Example 1 with ResourceRepository

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;
}
Also used : ResourceRepository(org.xwiki.skin.ResourceRepository) HashSet(java.util.HashSet)

Example 2 with ResourceRepository

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;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) Skin(org.xwiki.skin.Skin) ResourceRepository(org.xwiki.skin.ResourceRepository)

Aggregations

ResourceRepository (org.xwiki.skin.ResourceRepository)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 HashSet (java.util.HashSet)1 Skin (org.xwiki.skin.Skin)1