use of com.adobe.granite.ui.clientlibs.ClientLibrary in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImpl method getAllClientLibraries.
/**
* Gets all of the client libraries.
*
* @param resourceResolver The resource resolver.
* @return Set of all client libraries.
*/
@NotNull
private Set<ClientLibrary> getAllClientLibraries(@NotNull final ResourceResolver resourceResolver) {
Map<String, ClientLibrary> allLibraries = htmlLibraryManager.getLibraries();
Set<ClientLibrary> clientLibraries = new LinkedHashSet<>();
for (String resourceType : getAllResourceTypes(resourceResolver)) {
Resource resource = resourceResolver.getResource(resourceType);
if (resource != null) {
clientLibraries.addAll(getClientLibraries(resource, allLibraries));
}
}
return clientLibraries;
}
use of com.adobe.granite.ui.clientlibs.ClientLibrary in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImpl method getInline.
/**
* Returns a concatenated string of the content of all the client libraries, given a library type.
*
* @param libraryType - the type of the library
*
* @return The concatenated string of the content of all the client libraries
*/
private String getInline(LibraryType libraryType) {
Collection<ClientLibrary> clientlibs = htmlLibraryManager.getLibraries(categoriesArray, libraryType, true, false);
// Iterate through the clientlibs and aggregate their content.
StringBuilder output = new StringBuilder();
for (ClientLibrary clientlib : clientlibs) {
HtmlLibrary htmlLibrary = htmlLibraryManager.getLibrary(libraryType, clientlib.getPath());
if (htmlLibrary != null) {
try {
output.append(IOUtils.toString(htmlLibrary.getInputStream(htmlLibraryManager.isMinifyEnabled()), StandardCharsets.UTF_8));
} catch (IOException e) {
LOG.error("Error getting input stream from clientlib with path '{}'.", clientlib.getPath());
}
}
}
return output.toString();
}
Aggregations