当前位置: 首页>>代码示例>>Java>>正文


Java HtmlLibrary类代码示例

本文整理汇总了Java中com.adobe.granite.ui.clientlibs.HtmlLibrary的典型用法代码示例。如果您正苦于以下问题:Java HtmlLibrary类的具体用法?Java HtmlLibrary怎么用?Java HtmlLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HtmlLibrary类属于com.adobe.granite.ui.clientlibs包,在下文中一共展示了HtmlLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inlineSheet

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
private void inlineSheet(final String namespaceURI, String s) throws IOException, SAXException {
    InputStream inputStream = null;
    
    String withoutExtension = s.substring(0, s.indexOf(LibraryType.CSS.extension));
    HtmlLibrary library = htmlLibraryManager.getLibrary(LibraryType.CSS, withoutExtension);
    if (library != null) {
        inputStream = library.getInputStream();
    } else {
        Resource resource = slingRequest.getResourceResolver().getResource(s);
        
        if (resource != null) {
            inputStream = resource.adaptTo(InputStream.class);
        }
    }
    
    if (inputStream != null) {
        char[] chars = IOUtils.toCharArray(inputStream);
        
        getContentHandler().startElement(namespaceURI, STYLE, null, new AttributesImpl());
        getContentHandler().characters(NEWLINE, 0, 1);
        getContentHandler().characters(chars, 0, chars.length);
        getContentHandler().endElement(namespaceURI, STYLE, null);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:25,代码来源:StylesheetInlinerTransformerFactory.java

示例2: getLibrary

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
private HtmlLibrary getLibrary(LibraryType libraryType, String libraryPath, ResourceResolver resourceResolver) {
    HtmlLibrary htmlLibrary = null;
    if (libraryPath.startsWith(PROXY_PREFIX)) {
        final String relativePath = libraryPath.substring(PROXY_PREFIX.length());

        for (final String prefix : resourceResolver.getSearchPath()) {
            final String absolutePath = prefix + relativePath;
            htmlLibrary = htmlLibraryManager.getLibrary(libraryType, absolutePath);
            if (htmlLibrary != null) {
                break;
            }
        }

    } else {
        htmlLibrary = htmlLibraryManager.getLibrary(libraryType, libraryPath);
    }
    return htmlLibrary;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:VersionedClientlibsTransformerFactory.java

示例3: getUriInfo

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Nonnull
UriInfo getUriInfo(@Nullable final String uri, @Nonnull ResourceResolver resourceResolver) {
    if (uri != null) {
        Matcher matcher = FILTER_PATTERN.matcher(uri);
        if (matcher.matches()) {
            final String libraryPath = matcher.group(1);
            final String md5 = matcher.group(2);
            final String extension = matcher.group(3);

            LibraryType libraryType;
            if (LibraryType.CSS.extension.substring(1).equals(extension)) {
                libraryType = LibraryType.CSS;
            } else {
                libraryType = LibraryType.JS;
            }
            final HtmlLibrary htmlLibrary = getLibrary(libraryType, libraryPath, resourceResolver);
            return new UriInfo(libraryPath + "." + extension, md5, libraryType, htmlLibrary);
        }
    }

    return new UriInfo("", "", null, null);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:23,代码来源:VersionedClientlibsTransformerFactory.java

示例4: getVersionedPath

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
private String getVersionedPath(final String originalPath, final LibraryType libraryType, final ResourceResolver resourceResolver) {
    try {
        boolean appendMinSelector = false;
        String libraryPath = StringUtils.substringBeforeLast(originalPath, ".");
        if (libraryPath.endsWith(MIN_SELECTOR_SEGMENT)) {
            appendMinSelector = true;
            libraryPath = StringUtils.substringBeforeLast(libraryPath, ".");
        }

        final HtmlLibrary htmlLibrary = getLibrary(libraryType, libraryPath, resourceResolver);

        if (htmlLibrary != null) {
            StringBuilder builder = new StringBuilder();
            builder.append(libraryPath);
            builder.append(".");

            if (appendMinSelector) {
                builder.append(MIN_SELECTOR).append(".");
            }
            if (enforceMd5) {
                builder.append(MD5_PREFIX);
            }
            builder.append(getMd5(htmlLibrary));
            builder.append(libraryType.extension);

            return builder.toString();
        } else {
            log.debug("Could not find HtmlLibrary at path: {}", libraryPath);
            return null;
        }
    } catch (Exception ex) {
        // Handle unexpected formats of the original path
        log.error("Attempting to get a versioned path for [ {} ] but could not because of: {}", originalPath,
                ex.getMessage());
        return originalPath;
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:38,代码来源:VersionedClientlibsTransformerFactory.java

示例5: getMd5

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Nonnull private String getMd5(@Nonnull final HtmlLibrary htmlLibrary) throws IOException, ExecutionException {
    return md5Cache.get(new VersionedClientLibraryMd5CacheKey(htmlLibrary), new Callable<String>() {

        @Override
        public String call() throws Exception {
            return calculateMd5(htmlLibrary, htmlLibraryManager.isMinifyEnabled());
        }
    });
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:10,代码来源:VersionedClientlibsTransformerFactory.java

示例6: calculateMd5

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Nonnull private String calculateMd5(@Nonnull final HtmlLibrary htmlLibrary, boolean isMinified) throws IOException {
    // make sure that the minified version is being request in case minification is globally enabled
    // as this will reset the dirty flag on the clientlib
    try (InputStream input = htmlLibrary.getInputStream(isMinified)) {
        return DigestUtils.md5Hex(input);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:8,代码来源:VersionedClientlibsTransformerFactory.java

示例7: UriInfo

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
UriInfo(String cleanedUri, String md5, LibraryType libraryType, HtmlLibrary htmlLibrary) {
    this.cleanedUri = cleanedUri;
    this.md5 = md5;
    this.htmlLibrary = htmlLibrary;
    if (libraryType != null && htmlLibrary != null) {
        cacheKey = htmlLibrary.getLibraryPath() + libraryType.extension;
    } else {
        cacheKey = null;
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:11,代码来源:VersionedClientlibsTransformerFactory.java

示例8: doFilter_notFoundInCache_md5Match

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_notFoundInCache_md5Match() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.min.ACSHASH" + INPUTSTREAM_MD5 + ".js");

    HtmlLibrary library = mock(HtmlLibrary.class);
    when(library.getInputStream(false)).thenReturn(INPUTSTREAM);
    when(library.getLibraryPath()).thenReturn("/etc/clientlibs/some.js");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some")).thenReturn(library);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verifyNo404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例9: doFilter_notFoundInCache_md5MisMatch

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_notFoundInCache_md5MisMatch() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.min.ACSHASHfoobar.js");

    HtmlLibrary library = mock(HtmlLibrary.class);
    when(library.getInputStream(false)).thenReturn(INPUTSTREAM );
    when(library.getLibraryPath()).thenReturn("/etc/clientlibs/some.js");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some")).thenReturn(library);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verify404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例10: doFilter_notFoundInCacheWithDot_md5MisMatch

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_notFoundInCacheWithDot_md5MisMatch() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.path.min.ACSHASHfoobar.js");

    HtmlLibrary library = mock(HtmlLibrary.class);
    when(library.getInputStream(false)).thenReturn(INPUTSTREAM );
    when(library.getLibraryPath()).thenReturn("/etc/clientlibs/some.path.js");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some.path")).thenReturn(library);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verify404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例11: doFilter_foundInCache_md5Match

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_foundInCache_md5Match() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.min.ACSHASH" + INPUTSTREAM_MD5 + ".js");
    factory.getCache().put(new VersionedClientLibraryMd5CacheKey("/etc/clientlibs/some", LibraryType.JS), INPUTSTREAM_MD5);

    HtmlLibrary htmlLibrary = mock(HtmlLibrary.class);
    when(htmlLibrary.getLibraryPath()).thenReturn("/etc/clientlibs/some");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some")).thenReturn(htmlLibrary);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verifyNo404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例12: doFilter_foundInCacheWithDot_md5Match

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_foundInCacheWithDot_md5Match() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.path.min.ACSHASH" + INPUTSTREAM_MD5 + ".js");
    factory.getCache().put(new VersionedClientLibraryMd5CacheKey("/etc/clientlibs/some.path", LibraryType.JS), INPUTSTREAM_MD5);

    HtmlLibrary htmlLibrary = mock(HtmlLibrary.class);
    when(htmlLibrary.getLibraryPath()).thenReturn("/etc/clientlibs/some.path");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some.path")).thenReturn(htmlLibrary);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verifyNo404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例13: doFilter_foundInCache_md5MisMatch

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_foundInCache_md5MisMatch() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.min.ACSHASHfoobar.js");
    factory.getCache().put(new VersionedClientLibraryMd5CacheKey("/etc/clientlibs/some", LibraryType.JS), INPUTSTREAM_MD5);

    HtmlLibrary htmlLibrary = mock(HtmlLibrary.class);
    when(htmlLibrary.getLibraryPath()).thenReturn("/etc/clientlibs/some");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some")).thenReturn(htmlLibrary);

    filter.doFilter(slingRequest, slingResponse, filterChain);

    verify404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例14: doFilter_foundInCacheWithDot_md5MisMatch

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Test
public void doFilter_foundInCacheWithDot_md5MisMatch() throws Exception {
    when(slingRequest.getRequestURI()).thenReturn("/etc/clientlibs/some.path.min.ACSHASHfoobar.js");
    factory.getCache().put(new VersionedClientLibraryMd5CacheKey("/etc/clientlibs/some.path", LibraryType.JS), INPUTSTREAM_MD5);

    HtmlLibrary htmlLibrary = mock(HtmlLibrary.class);
    when(htmlLibrary.getLibraryPath()).thenReturn("/etc/clientlibs/some.path");
    when(htmlLibraryManager.getLibrary(LibraryType.JS, "/etc/clientlibs/some.path")).thenReturn(htmlLibrary);


    filter.doFilter(slingRequest, slingResponse, filterChain);

    verify404();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:15,代码来源:VersionedClientlibsTransformerFactoryTest.java

示例15: getLibrary

import com.adobe.granite.ui.clientlibs.HtmlLibrary; //导入依赖的package包/类
@Override
public HtmlLibrary getLibrary(LibraryType libraryType, String s) {
    return null;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:5,代码来源:MockHtmlLibraryManager.java


注:本文中的com.adobe.granite.ui.clientlibs.HtmlLibrary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。