Search in sources :

Example 31 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 32 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 33 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 34 with FileFilter

use of java.io.FileFilter in project hadoop by apache.

the class JournalNode method getJournalsStatus.

// JournalNodeMXBean
@Override
public String getJournalsStatus() {
    // jid:{Formatted:True/False}
    Map<String, Map<String, String>> status = new HashMap<String, Map<String, String>>();
    synchronized (this) {
        for (Map.Entry<String, Journal> entry : journalsById.entrySet()) {
            Map<String, String> jMap = new HashMap<String, String>();
            jMap.put("Formatted", Boolean.toString(entry.getValue().isFormatted()));
            status.put(entry.getKey(), jMap);
        }
    }
    // It is possible that some journals have been formatted before, while the 
    // corresponding journals are not in journalsById yet (because of restarting
    // JN, e.g.). For simplicity, let's just assume a journal is formatted if
    // there is a directory for it. We can also call analyzeStorage method for
    // these directories if necessary.
    // Also note that we do not need to check localDir here since
    // validateAndCreateJournalDir has been called before we register the
    // MXBean.
    File[] journalDirs = localDir.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.isDirectory();
        }
    });
    for (File journalDir : journalDirs) {
        String jid = journalDir.getName();
        if (!status.containsKey(jid)) {
            Map<String, String> jMap = new HashMap<String, String>();
            jMap.put("Formatted", "true");
            status.put(jid, jMap);
        }
    }
    return JSON.toString(status);
}
Also used : HashMap(java.util.HashMap) FileFilter(java.io.FileFilter) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 35 with FileFilter

use of java.io.FileFilter in project ansj_seg by NLPchina.

the class File2Stream method multiple.

private InputStream multiple(String path) throws FileNotFoundException {
    File[] libs = new File[0];
    File file = new File(path);
    if (file.exists() && file.canRead()) {
        if (file.isFile()) {
            libs = new File[1];
            libs[0] = file;
        } else if (file.isDirectory()) {
            File[] files = file.listFiles(new FileFilter() {

                public boolean accept(File file) {
                    return file.canRead() && !file.isHidden() && !file.isDirectory();
                }
            });
            if (files != null && files.length > 0) {
                libs = files;
            }
        }
    }
    if (libs.length == 0) {
        throw new LibraryException("not find any file in path : " + path);
    }
    if (libs.length == 1) {
        return new FileInputStream(libs[0]);
    }
    Vector<InputStream> vector = new Vector<>(libs.length);
    for (int i = 0; i < libs.length; i++) {
        vector.add(new FileInputStream(libs[i]));
    }
    return new SequenceInputStream(vector.elements());
}
Also used : SequenceInputStream(java.io.SequenceInputStream) SequenceInputStream(java.io.SequenceInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) LibraryException(org.ansj.exception.LibraryException) FileFilter(java.io.FileFilter) File(java.io.File) Vector(java.util.Vector) FileInputStream(java.io.FileInputStream)

Aggregations

FileFilter (java.io.FileFilter)281 File (java.io.File)267 ArrayList (java.util.ArrayList)59 IOException (java.io.IOException)53 JarFile (java.util.jar.JarFile)22 URL (java.net.URL)17 Test (org.junit.Test)16 HashMap (java.util.HashMap)15 FileNotFoundException (java.io.FileNotFoundException)11 FilenameFilter (java.io.FilenameFilter)11 HashSet (java.util.HashSet)11 FileInputStream (java.io.FileInputStream)10 Pattern (java.util.regex.Pattern)10 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)10 MalformedURLException (java.net.MalformedURLException)9 URI (java.net.URI)9 Map (java.util.Map)7 Path (org.apache.hadoop.fs.Path)7 NotNull (org.jetbrains.annotations.NotNull)7 Treebank (edu.stanford.nlp.trees.Treebank)6