Search in sources :

Example 1 with ExternalRsrc

use of org.asqatasun.contentadapter.util.ExternalRsrc in project Asqatasun by Asqatasun.

the class CSSJsoupPhlocContentAdapterImpl method getExternalResourceAndAdapt.

/**
     * Downloads an external resource and returns a Resource instance or null
     * if the download has failed
     * @param path
     * @param mediaAttributeValue
     * @return
     */
private boolean getExternalResourceAndAdapt(String path, @Nullable List<CSSMediaQuery> mediaList) {
    if (StringUtils.isBlank(path)) {
        return false;
    }
    // When an external css is found on the html, we start by getting the
    // associated resource from the fetched Stylesheet and we populate the
    // set of relatedExternalCssSet (needed to create the relation between the
    // SSP and the css at the end of the adaptation)
    StylesheetContent stylesheetContent = getExternalStylesheet(path);
    if (stylesheetContent != null) {
        if (stylesheetContent.getAdaptedContent() == null) {
            Resource localResource;
            localResource = new CSSResourceImpl(stylesheetContent.getSource(), 0, new ExternalRsrc());
            currentLocalResourcePath = getCurrentResourcePath(path);
            adaptContent(stylesheetContent, localResource, currentLocalResourcePath, mediaList);
        }
        relatedExternalCssSet.add(stylesheetContent);
        LOGGER.debug("encountered external css :  " + path + " " + relatedExternalCssSet.size() + " in " + getSSP().getURI());
        return true;
    }
    return false;
}
Also used : StylesheetContent(org.asqatasun.entity.audit.StylesheetContent) ExternalRsrc(org.asqatasun.contentadapter.util.ExternalRsrc) Resource(org.asqatasun.contentadapter.Resource)

Aggregations

Resource (org.asqatasun.contentadapter.Resource)1 ExternalRsrc (org.asqatasun.contentadapter.util.ExternalRsrc)1 StylesheetContent (org.asqatasun.entity.audit.StylesheetContent)1