boolean acceptFile(File pathname) { try { return accept(pathname, InsightPluginDescriptorParser.extractPluginDescriptor(pathname)); } catch(Exception e) { Logger log=Logger.getLogger(getClass().getName()); log.warning("acceptFile(" + pathname + ") failed (" + e.getClass().getSimpleName() + ")" + " to extract plugin descriptor: " + e.getMessage()); return accept(pathname, createPluginDescriptorPlaceholder(pathname.getName())); } }
public boolean accept(File pathname) { if (pathname == null) { return false; } else if (!pathname.exists()) { return false; } else if (pathname.isFile()) { return acceptFile(pathname); } else if (pathname.isDirectory()) { return acceptFolder(pathname); } else { Logger log=Logger.getLogger(getClass().getName()); log.warning("accept(" + pathname + ") neither folder nor file"); return true; } }
static final String createPluginDescriptorKey (PluginDescriptor desc) { return createPluginDescriptorKey((desc == null) /* OK if no descriptor */ ? null : desc.getName()); }
boolean acceptFolder(File pathname) { return accept(pathname, new PluginDescriptor(pathname.getName(), UNKNOWN_VERSION, pathname.getAbsolutePath(), pathname.toURI().toString())); }
boolean accept(File file, PluginDescriptor desc) { // check if have specific setting String pluginKey=createPluginDescriptorKey(desc); String value=StringUtil.isEmpty(pluginKey) ? null : props.getProperty(pluginKey); // if no specific setting check what is the default if (StringUtil.isEmpty(value)) { // TODO add support for regexp(s)... value = props.getProperty(PLUGIN_FILTER_DEFAULT_SETTING, "false"); } // TODO allow to specify a specific version pattern // if filter=true then accept=false... return (!Boolean.parseBoolean(value)); }