DumplibsClientLibrary(ClientLibrary lib) { this.path = lib.getPath(); this.types = lib.getTypes(); this.categories = lib.getCategories(); this.channels = lib.getChannels(); }
private boolean hasProxyClientLibrary(final LibraryType type, final String path) { ClientLibrary clientLibrary = getClientLibrary(path); return clientLibrary != null && clientLibrary.allowProxy() && clientLibrary.getTypes().contains(type); }
public String toString() { return library.getPath() + "[cat:" + StringUtils.join(library.getCategories()) + ", embed:"+ isEmbed +", type: "+ library.getTypes() +"]"; } }
log.debug("Giving out dependencies for {}", getStackTrace(parent, library.getPath())); if (library.getTypes().contains(type)) { for (String category : requestedCategories) { if (categories.contains(category)) { log.debug("Category {} already in list, not adding twice!", category, library.getPath()); if (currentPosition < categories.indexOf(category)) { log.debug("Not considering categories of this client library because they have the wrong type {}, request was type {}", library.getTypes(), type); log.debug("Processing embedded JS libraries of library with path {}", library.getPath()); addLibraries(categories, true, library.getEmbedded(LibraryType.JS), library.getEmbeddedCategories(), currentPosition); log.debug("Processing embedded CSS libraries of library with path {}", library.getPath()); addLibraries(categories, true, library.getEmbedded(LibraryType.CSS), library.getEmbeddedCategories(), currentPosition); log.debug("Processing dependent libraries of library with path {}", library.getPath()); addLibraries(categories, false, library.getDependencies(false), library.getDependentCategories(), currentPosition); return categories;
Map<String, ClientLibrary> libraries = libraryManager.getLibraries(); for (ClientLibrary library : libraries.values()) { if (library.getTypes() != null && library.getTypes().contains(libraryType)) { String[] libraryCats = library.getCategories(); if (libraryCats != null) { for (String cat : libraryCats) {
public ClientLibraryDependency(ClientLibraryDependency parent, ClientLibrary library, Set<String> requestedCategories, boolean isEmbed, LibraryType type) { this.library = library; this.parent = parent; if (isDependencyLoop(parent, library.getPath())) { throw new DependencyLoopException("Dependency loop detected: " + getStackTrace(parent, library.getPath())); } this.type = type; this.isEmbed = isEmbed; this.requestedCategories = new TreeSet<String>(java.util.Collections.reverseOrder()); // only the requested categories are relevant (from all the categories of this library) for (String category : library.getCategories()) { if (requestedCategories.contains(category)) { this.requestedCategories.add(category); } } }
public void handleEvent(Event event) { try { boolean minified = htmlLibraryManager.isMinifyEnabled(); String path = (String) event.getProperty(SlingConstants.PROPERTY_PATH); log.info("Client Library at {} invalidated. Sending reload.", path); ClientLibrary library = htmlLibraryManager.getLibraries().get(path); if (library != null) { for (LibraryType type : library.getTypes()) { String includePath = library.getIncludePath(type, minified); server.triggerReload(includePath); } } } catch (JSONException e) { log.info("Unable to send reload", e); } }
private String getProxyPath(ClientLibrary lib) { String path = lib.getPath(); if (lib.allowProxy()) { for (String searchPath : request.getResourceResolver().getSearchPath()) { if (path.startsWith(searchPath)) { path = request.getContextPath() + "/etc.clientlibs/" + path.replaceFirst(searchPath, ""); } } } else { if (request.getResourceResolver().getResource(lib.getPath()) == null) { path = null; } } if (path != null) { path = path + "/resources"; } return path; }
private List<Resource> getCategoryResourceList(@Nonnull SlingHttpServletRequest request, LibraryType libraryType) { List<Resource> categoryResourceList = new ArrayList<>(); HashSet<String> clientLibraryCategories = new HashSet<String>(); for (ClientLibrary library: htmlLibraryManager.getLibraries().values()) { for (String category: library.getCategories()) { clientLibraryCategories.add(category); } } if (libraryType != null) { Collection<ClientLibrary> clientLibraries = htmlLibraryManager .getLibraries(clientLibraryCategories.toArray(new String[clientLibraryCategories.size()]), libraryType, true, true); clientLibraryCategories.clear(); for (ClientLibrary library: clientLibraries) { for (String category: library.getCategories()) { clientLibraryCategories.add(category); } } } for (String category: clientLibraryCategories) { categoryResourceList.add(new CategoryResource(category, request.getResourceResolver())); } return categoryResourceList; }
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { ResourceResolver resourceResolver = request.getResourceResolver(); response.setContentType("application/json"); JsonWriter writer = new JsonWriter(response.getWriter()); writer.beginObject(); writer.name("js"); writer.beginArray(); if (!excludeAll) { Collection<ClientLibrary> libraries = htmlLibraryManager.getLibraries(categories, LibraryType.JS, true, true); for (ClientLibrary library : libraries) { writer.value(resourceResolver.map(request, library.getIncludePath(LibraryType.JS, htmlLibraryManager.isMinifyEnabled()))); } } writer.endArray(); writer.name("css"); writer.beginArray(); if (!excludeAll) { Collection<ClientLibrary> libraries = htmlLibraryManager.getLibraries(categories, LibraryType.CSS, true, true); for (ClientLibrary library : libraries) { writer.value(resourceResolver.map(request, library.getIncludePath(LibraryType.CSS, htmlLibraryManager.isMinifyEnabled()))); } } writer.endArray(); writer.endObject(); }
Map<String, ClientLibrary> libraries = libraryManager.getLibraries(); for (ClientLibrary library : libraries.values()) { if (library.getTypes() != null && library.getTypes().contains(libraryType)) { String[] libraryCats = library.getCategories(); if (libraryCats != null) { for (String cat : libraryCats) {
public void handleEvent(Event event) { try { boolean minified = htmlLibraryManager.isMinifyEnabled(); String path = (String) event.getProperty(SlingConstants.PROPERTY_PATH); log.info("Client Library at {} invalidated. Sending reload.", path); ClientLibrary library = htmlLibraryManager.getLibraries().get(path); if (library != null) { for (LibraryType type : library.getTypes()) { String includePath = library.getIncludePath(type, minified); server.triggerReload(includePath); } } } catch (JSONException e) { log.info("Unable to send reload", e); } }
public static boolean isDependencyLoop(ClientLibraryDependency parent, String path) { while (parent != null) { if (path.equals(parent.library.getPath())) { return true; } parent = parent.parent; } return false; }
HtmlLibrary currentJsLibrary = htmlLibraryManager.getLibrary(LibraryType.JS, currentClientLibrary.getPath());