private LibraryType getLibraryType(String typeString) { LibraryType type; try { return LibraryType.valueOf(typeString.toUpperCase()); } catch (Exception e) { return LibraryType.JS; } }
@Override public String toString() { return new StringBuilder(path).append('.').append(type.name().toLowerCase()).toString(); }
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { LibraryType libraryType = null; Resource dataSourceResource = request.getResource().getChild(Config.DATASOURCE); if (dataSourceResource != null) { ValueMap dataSourceValueMap = ResourceUtil.getValueMap(dataSourceResource); if (dataSourceValueMap != null) { String type = dataSourceValueMap.get(PN_LIBRARY_TYPE, String.class); if (type != null) { type = type.toUpperCase(); libraryType = LibraryType.valueOf(type); } } } SimpleDataSource clientLibraryCategoriesDataSource = new SimpleDataSource(getCategoryResourceList(request, libraryType).iterator()); request.setAttribute(DataSource.class.getName(), clientLibraryCategoriesDataSource); }
@Override public String toString() { return new StringBuilder(path).append('.').append(type.name().toLowerCase()).toString(); }
try { Set<String> categories = new TreeSet<String>(); LibraryType libraryType = LibraryType.valueOf(type.toUpperCase()); Map<String, ClientLibrary> libraries = libraryManager.getLibraries(); for (ClientLibrary library : libraries.values()) {
/** * This method must be called from process(..) yourself! This is NOT automatically called to determine if process(..) will be called. * * @param type the ClientLibrary Type * @return true to accept this LibraryType, false to reject. */ @Override public boolean handles(@Nonnull LibraryType type) { // Note this method must be called from process(..) yourself! This is NOT automatically called to determine if process(..) will be called. // Determine if process(..) should be called for this library; The LibraryType in question is passed to make this determination. // https://docs.adobe.com/docs/en/aem/6-3/develop/ref/javadoc/com/adobe/granite/ui/clientlibs/LibraryType.html if (LibraryType.CSS.name().equals(type.name())) { // Compares is the Types are the same // > For CSS this is: CSS // > For JavaScript this is: JS return true; } else if (LibraryType.CSS.contentType.equals(type.contentType)) { // Most often, the Content Type (CSS or JS) is checked. // > For CSS this is: text/css // > For JavaScript this is: application/javascript return true; } else if (LibraryType.CSS.extension.equals(type.extension)) { // Occasionally the extension can be checked. // > For CSS this is: .css // > For JavaScript this is: .js return true; } return false; }
try { Set<String> categories = new TreeSet<String>(); LibraryType libraryType = LibraryType.valueOf(type.toUpperCase()); Map<String, ClientLibrary> libraries = libraryManager.getLibraries(); for (ClientLibrary library : libraries.values()) {