Search in sources :

Example 16 with FileFilter

use of java.io.FileFilter in project Openfire by igniterealtime.

the class ClusteringPlugin method initializePlugin.

public void initializePlugin(PluginManager manager, File pluginDirectory) {
    // Check if we Enterprise is installed and stop loading this plugin if found
    File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
    File[] jars = pluginDir.listFiles(new FileFilter() {

        public boolean accept(File pathname) {
            String fileName = pathname.getName().toLowerCase();
            return (fileName.equalsIgnoreCase("enterprise.jar") || fileName.equalsIgnoreCase("hazelcast.jar"));
        }
    });
    if (jars.length > 0) {
        // Do not load this plugin since Enterprise is still installed
        System.out.println("Conflicting plugin found. Stopping Clustering Plugin");
        throw new IllegalStateException("This plugin cannot run with the Enterprise or Hazelcast plugin");
    }
    // Make sure that the enteprise folder exists under the home directory
    File enterpriseDir = new File(JiveGlobals.getHomeDirectory() + File.separator + "enterprise");
    if (!enterpriseDir.exists()) {
        enterpriseDir.mkdirs();
    }
    // Check if Coherence libs are installed and stop loading this plugin if NOT found
    //        File libDir = new File(JiveGlobals.getHomeDirectory(), "lib");
    //        jars = libDir.listFiles(new FileFilter() {
    //            public boolean accept(File pathname) {
    //                String fileName = pathname.getName().toLowerCase();
    //                return (fileName.equalsIgnoreCase("coherence.jar"));
    //            }
    //        });
    //        if (jars.length == 0) {
    //            // Do not load this plugin since Coherence libs are not installed
    //            System.out.println("Coherence libs not found. Stopping Clustering Plugin. Copy tangosol.jar, " +
    //                    "coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
    //            throw new IllegalStateException("Coherence libs not found. Stopping Clustering Plugin. Copy " +
    //                    "tangosol.jar, coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
    //        }
    // Delete no longer used COHERENCE_CONFIG file. Java system properties should be used
    // to customize coherence
    File configFile = new File(enterpriseDir, COHERENCE_CONFIG + ".xml");
    if (configFile.exists()) {
        configFile.delete();
    }
    // Delete no longer used COHERENCE_CACHE_CONFIG file. Admins should use system properties
    // to override default values. Same system properties will be used when not using enterprise or not
    // using clustering
    configFile = new File(enterpriseDir, COHERENCE_CACHE_CONFIG + ".xml");
    if (configFile.exists()) {
        configFile.delete();
    }
    try {
        // Add openfireHome/enterprise dir to pluginclassloader
        // Add enterprise plugin dir to pluginclassloader
        URL url = new File(pluginDirectory + File.separator).toURL();
        manager.getPluginClassloader(manager.getPlugin(pluginDirectory.getName())).addURLFile(url);
    } catch (MalformedURLException e) {
        Log.error("Error adding openfireHome/enterprise to the classpath of the enterprise plugin", e);
    }
    CacheFactory.getClusterConfig();
    ClusterManager.startup();
}
Also used : MalformedURLException(java.net.MalformedURLException) FileFilter(java.io.FileFilter) File(java.io.File) URL(java.net.URL)

Example 17 with FileFilter

use of java.io.FileFilter in project Openfire by igniterealtime.

the class ClientControlPlugin method initializePlugin.

// Plugin Interface
public void initializePlugin(PluginManager manager, File pluginDirectory) {
    // Check if we Enterprise is installed and stop loading this plugin if found
    File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
    File[] jars = pluginDir.listFiles(new FileFilter() {

        public boolean accept(File pathname) {
            String fileName = pathname.getName().toLowerCase();
            return (fileName.equalsIgnoreCase("enterprise.jar"));
        }
    });
    if (jars.length > 0) {
        // Do not load this plugin since Enterprise is still installed
        System.out.println("Enterprise plugin found. Stopping Client Control Plugin");
        throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
    }
    taskEngine = TaskEngine.getInstance();
    sparkManager = new SparkManager(taskEngine);
    sparkManager.start();
    // Create and start the Spark version manager
    sparkVersionManager = new SparkVersionManager();
    sparkVersionManager.start();
    fileTransferFilterManager = new FileTransferFilterManager();
    fileTransferFilterManager.start();
}
Also used : SparkManager(org.jivesoftware.openfire.plugin.spark.SparkManager) SparkVersionManager(org.jivesoftware.openfire.plugin.spark.manager.SparkVersionManager) FileTransferFilterManager(org.jivesoftware.openfire.plugin.spark.manager.FileTransferFilterManager) FileFilter(java.io.FileFilter) File(java.io.File)

Example 18 with FileFilter

use of java.io.FileFilter in project promoted-builds-plugin by jenkinsci.

the class CopyListener method onCopied.

/**
     * Copy promotion definitions from existing job.
     */
@Override
public void onCopied(Item src, Item item) {
    JobPropertyImpl prop;
    if (src instanceof Job && (prop = ((Job<?, ?>) src).getProperty(JobPropertyImpl.class)) != null) {
        File[] subdirs = prop.getRootDir().listFiles(new FileFilter() {

            public boolean accept(File child) {
                return child.isDirectory();
            }
        });
        if (subdirs != null) {
            prop = ((Job<?, ?>) item).getProperty(JobPropertyImpl.class);
            for (File subdir : subdirs) try {
                Util.copyFile(new File(subdir, "config.xml"), new File(prop.getRootDirFor(subdir.getName()), "config.xml"));
            } catch (Exception e) {
                Logger.getLogger(CopyListener.class.getName()).log(Level.WARNING, "Failed to copy/load promotion " + subdir + " into new job", e);
            }
            // Trigger loading of these files
            prop.setOwner(prop.getOwner());
        }
    }
}
Also used : Job(hudson.model.Job) FileFilter(java.io.FileFilter) File(java.io.File)

Example 19 with FileFilter

use of java.io.FileFilter in project promoted-builds-plugin by jenkinsci.

the class JobPropertyImpl method loadAllProcesses.

private void loadAllProcesses(File rootDir) throws IOException {
    File[] subdirs = rootDir.listFiles(new FileFilter() {

        public boolean accept(File child) {
            return child.isDirectory();
        }
    });
    loadProcesses(subdirs);
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Example 20 with FileFilter

use of java.io.FileFilter in project jphp by jphp-compiler.

the class DocGenerator method main.

public static void main(String[] args) throws IOException {
    File root = new File(".").getCanonicalFile();
    DocGenerator generator = new DocGenerator();
    for (File file : root.listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    })) {
        File sdkFile1 = new File(file, "resources/JPHP-INF/sdk/");
        File sdkFile2 = new File(file, "src/main/resources/JPHP-INF/sdk/");
        if (sdkFile1.isDirectory()) {
            generator.addDirectory(sdkFile1, true);
        } else if (sdkFile2.isDirectory()) {
            generator.addDirectory(sdkFile2, true);
        }
    }
    for (Map.Entry<String, String> entry : languages.entrySet()) {
        generator.generate(new File("./docs/api_" + entry.getKey()), entry.getKey());
    }
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File) HashedMap(php.runtime.common.collections.map.HashedMap) Map(java.util.Map)

Aggregations

FileFilter (java.io.FileFilter)232 File (java.io.File)218 ArrayList (java.util.ArrayList)50 IOException (java.io.IOException)40 Test (org.junit.Test)13 FilenameFilter (java.io.FilenameFilter)11 URL (java.net.URL)10 HashMap (java.util.HashMap)10 FileInputStream (java.io.FileInputStream)8 FileNotFoundException (java.io.FileNotFoundException)8 HashSet (java.util.HashSet)8 JarFile (java.util.jar.JarFile)8 Pattern (java.util.regex.Pattern)8 Map (java.util.Map)7 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)7 NotNull (org.jetbrains.annotations.NotNull)7 Treebank (edu.stanford.nlp.trees.Treebank)6 Pair (edu.stanford.nlp.util.Pair)6 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)6 EvaluateTreebank (edu.stanford.nlp.parser.lexparser.EvaluateTreebank)5