private HtmlLibrary getLibrary(LibraryType libraryType, String libraryPath, ResourceResolver resourceResolver) { String resolvedLibraryPath = resolvePathIfProxied(libraryType, libraryPath, resourceResolver); return resolvedLibraryPath == null ? null : htmlLibraryManager.getLibrary(libraryType, resolvedLibraryPath); }
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; } }
/** * Handles request to get clientlib info by path */ private void handlePathRequest(SlingHttpServletRequest request, SlingHttpServletResponse response, DumplibsParams p) throws IOException { HtmlLibrary lib = libraryManager.getLibrary(p.getType(), p.getPath()); response.setContentType(CONTENT_TYPE_JSON); JsonObject jsonObject = lib == null ? new JsonObject() : (JsonObject) htmlLibraryToJSON(lib); response.getWriter().print(jsonObject.toString()); }
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); } } }
HtmlLibrary currentJsLibrary = htmlLibraryManager.getLibrary(LibraryType.JS, currentClientLibrary.getPath());