@Override public String call() throws Exception { return DigestUtils.md5Hex(htmlLibrary.getInputStream()); } });
DumplibsHtmlLibrary (HtmlLibrary lib) { this.name = lib.getName(); this.type = lib.getType(); this.path = lib.getPath(); this.minifiedPath = lib.getPath(true); this.libraryPath = lib.getLibraryPath(); this.scripts = lib.getScripts(); }
VersionedClientLibraryMd5CacheKey(HtmlLibrary htmlLibrary) { this.path = htmlLibrary.getLibraryPath(); this.type = htmlLibrary.getType(); }
if (currentJsLibrary != null && lastUpdated < currentJsLibrary.getLastModified()) { String cachePath = configCacheRoot + currentJsLibrary.getPath(); Binary bin = admin.getValueFactory().createBinary(currentJsLibrary.getInputStream()); contentNode.setProperty("jcr:data", bin); contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
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; } } }
VersionedClientLibraryMd5CacheKey(HtmlLibrary htmlLibrary) { this.path = htmlLibrary.getLibraryPath(); this.type = htmlLibrary.getType(); }
private String getVersionedPath(final String originalPath, final LibraryType libraryType) { try { boolean appendMinSelector = false; String libraryPath = StringUtils.substringBeforeLast(originalPath, "."); if (libraryPath.endsWith(MIN_SELECTOR_SEGMENT)) { appendMinSelector = true; libraryPath = StringUtils.substringBeforeLast(libraryPath, "."); } final HtmlLibrary htmlLibrary = htmlLibraryManager.getLibrary(libraryType, libraryPath); if (htmlLibrary != null) { StringBuilder builder = new StringBuilder(); builder.append(htmlLibrary.getLibraryPath()); builder.append("."); if (appendMinSelector) { builder.append(MIN_SELECTOR).append("."); } 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; } }
@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); } }
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, "UTF-8"); getContentHandler().startElement(namespaceURI, STYLE, null, new AttributesImpl()); getContentHandler().characters(NEWLINE, 0, 1); getContentHandler().characters(chars, 0, chars.length); getContentHandler().endElement(namespaceURI, STYLE, null); } } }