public static Predicate<Plugin> isPluginWithResourceType(@Nonnull final String pluginResourceType) { return (Plugin plugin) -> { final Stream<ResourceDescriptor> resourceDescriptors = Stream.concat(plugin.getResourceDescriptors().stream(), plugin.getModuleDescriptors().stream().flatMap(module -> module.getResourceDescriptors().stream())); return resourceDescriptors.map(ResourceDescriptor::getType).anyMatch(pluginResourceType::equals); }; }}
/** * {@inheritDoc} */ public ThemeDefinition[] listBuiltinThemes() { Plugin plugin = pluginAccessor.getPlugin(Constants.PLUGIN_KEY); Collection<ModuleDescriptor<?>> descriptors = plugin.getModuleDescriptors(); List<ThemeDefinition> result = new ArrayList<>(); for (ModuleDescriptor<?> descriptor : descriptors) { if (descriptor.getKey().startsWith(THEME_DESCRIPTOR_PREFIX)) { List<ResourceDescriptor> resources = descriptor.getResourceDescriptors(); ResourceDescriptor first = resources.get(0); String location = first.getLocation(); String webResourceId = descriptor.getCompleteKey(); // Get panel look and feel Map<String, String> panelLookAndFeel = new HashMap<>(); for (Map.Entry<String, String> param : descriptor.getParams().entrySet()) { if (param.getKey().startsWith(LAYOUT_PREFIX)) { panelLookAndFeel.put(param.getKey(), param.getValue()); } } result.add(new ThemeDefinition(location, webResourceId, panelLookAndFeel)); } } return result.toArray(new ThemeDefinition[result.size()]); }
private Collection<ResourceDescriptor> getResourceBundleLocations(final Plugin plugin) { final List<ResourceDescriptor> locations = Lists.newArrayList(); Iterables.addAll(locations, Iterables.filter(plugin.getResourceDescriptors(), filter)); for (final ModuleDescriptor<?> moduleDescriptor : plugin.getModuleDescriptors()) { try { Iterables.addAll(locations, Iterables.filter(moduleDescriptor.getResourceDescriptors(), filter)); } catch (final RuntimeException re) { if (log.isDebugEnabled()) { log.debug(format("FAILED plugin module resource descriptors: pluginKey: %s; moduleKey: %s; mode: %s", plugin.getKey(), moduleDescriptor.getCompleteKey(), getModeString()), re); } } } return locations; }
/** * {@inheritDoc} */ public BrushDefinition[] listBuiltinBrushes() { ModuleDescriptor<?> descriptor = getDescriptor("syntaxhighlighter-brushes"); List<ResourceDescriptor> resources = descriptor.getResourceDescriptors(); BrushDefinition[] result = new BrushDefinition[resources.size()]; int i = 0; for (ResourceDescriptor resource : resources) { result[i] = new BrushDefinition(resource.getLocation(), descriptor.getCompleteKey()); i++; } return result; }
for (Iterator iterator1 = moduleDescriptor.getResourceDescriptors("i18n").iterator(); iterator1 .hasNext();)
for (Iterator iterator1 = moduleDescriptor.getResourceDescriptors("i18n").iterator(); iterator1 .hasNext();)
private void addSoyTemplateResources(ModuleDescriptor<?> moduleDescriptor) throws IOException { for (ResourceDescriptor resource : moduleDescriptor.getResourceDescriptors()) { if (isSoyTemplate(resource)) { URL url = getSoyResourceURL(moduleDescriptor, resource); if (url != null) { if (isDevMode()) { try (Reader reader = Resources.asCharSource(url, Charsets.UTF_8).openStream()) { if (!reader.ready()) { throw new IOException("Empty file for resource " + resource.getLocation() + " in module descriptor " + moduleDescriptor.getCompleteKey()); } } } this.fileSet.add(url); } } } }
@Override public DimensionAwareTransformerUrlBuilder makeUrlBuilder(TransformerParameters params) { List<URI> resources = new ArrayList<>(); if (params.isAmdModule()) { resources.add(UriUtils.resolvePluginUri(params.getPluginKey(), params.getAmdModuleLocation())); } else { String webResourceKey = params.getPluginKey() + ":" + params.getModuleKey(); ModuleDescriptor descriptor = pluginAccessor.getEnabledPluginModule(webResourceKey); for (ResourceDescriptor resourceDescriptor : descriptor.getResourceDescriptors()) { if (resourceDescriptor.getLocation().endsWith(".less")) { resources.add(UriUtils.resolveUri( descriptor.getPluginKey(), resourceDescriptor.getResourceLocationForName(null) )); } } } return new LessTransformerUrlBuilder(resources, uriStateManager); }
List<ResourceDescriptor> resourceDescriptors = moduleDescriptor.getResourceDescriptors(); if (resourceDescriptors.size() == 0) { log.error("Failed to register new code macro language " +