Search in sources :

Example 21 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class HttpBasicAuthURLConnector method init.

protected void init() {
    if (inited.compareAndSet(false, true)) {
        mappings.clear();
        StringTokenizer tokenizer = new StringTokenizer(configFileList, ",");
        while (tokenizer.hasMoreTokens()) {
            String configFileName = tokenizer.nextToken().trim();
            File file = new File(configFileName);
            if (file.exists()) {
                Properties props = new UTF8Properties();
                try (InputStream stream = IO.stream(file)) {
                    props.load(stream);
                    for (Object key : props.keySet()) {
                        String name = (String) key;
                        if (name.startsWith(PREFIX_PATTERN)) {
                            String id = name.substring(PREFIX_PATTERN.length());
                            Glob glob = new Glob(props.getProperty(name));
                            String uid = props.getProperty(PREFIX_USER + id);
                            String pwd = props.getProperty(PREFIX_PASSWORD + id);
                            mappings.add(new Mapping(id, glob, uid, pwd));
                        }
                    }
                } catch (IOException e) {
                    if (reporter != null)
                        reporter.error("Failed to load %s", configFileName);
                }
            }
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) InputStream(java.io.InputStream) Glob(aQute.libg.glob.Glob) IOException(java.io.IOException) Properties(java.util.Properties) UTF8Properties(aQute.lib.utf8properties.UTF8Properties) File(java.io.File) UTF8Properties(aQute.lib.utf8properties.UTF8Properties)

Example 22 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class AbstractIndexedRepo method list.

public List<String> list(String pattern) throws Exception {
    init();
    Glob glob = pattern != null ? new Glob(pattern) : null;
    List<String> result = new LinkedList<String>();
    for (String bsn : identityMap.getIdentities()) {
        if (glob == null || glob.matcher(bsn).matches())
            result.add(bsn);
    }
    return result;
}
Also used : Glob(aQute.libg.glob.Glob) LinkedList(java.util.LinkedList)

Aggregations

Glob (aQute.libg.glob.Glob)22 ArrayList (java.util.ArrayList)11 File (java.io.File)7 Parameters (aQute.bnd.header.Parameters)3 Description (aQute.lib.getopt.Description)3 IOException (java.io.IOException)3 Project (aQute.bnd.build.Project)2 Attrs (aQute.bnd.header.Attrs)2 Domain (aQute.bnd.osgi.Domain)2 Jar (aQute.bnd.osgi.Jar)2 CommandData (aQute.jpm.lib.CommandData)2 Service (aQute.jpm.lib.Service)2 ServiceData (aQute.jpm.lib.ServiceData)2 ExtList (aQute.lib.collections.ExtList)2 InputStream (java.io.InputStream)2 SocketException (java.net.SocketException)2 URL (java.net.URL)2 Matcher (java.util.regex.Matcher)2 Container (aQute.bnd.build.Container)1 PomFromManifest (aQute.bnd.maven.PomFromManifest)1