Example usage for org.apache.shiro.io ResourceUtils getInputStreamForPath

List of usage examples for org.apache.shiro.io ResourceUtils getInputStreamForPath

Introduction

In this page you can find the example usage for org.apache.shiro.io ResourceUtils getInputStreamForPath.

Prototype

public static InputStream getInputStreamForPath(String resourcePath) throws IOException 

Source Link

Document

Returns the InputStream for the resource represented by the specified path, supporting scheme prefixes that direct how to acquire the input stream ( #CLASSPATH_PREFIX CLASSPATH_PREFIX , #URL_PREFIX URL_PREFIX , or #FILE_PREFIX FILE_PREFIX ).

Usage

From source file:com.github.zbiljic.shiro.cache.infinispan.InfinispanCacheManager.java

License:Open Source License

/**
 * Acquires the InputStream for the Infinispan configuration file using {@link
 * ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} with the
 * path returned from {@link #getCacheManagerConfigFile() getCacheManagerConfigFile()}.
 *
 * @return the InputStream for the Infinispan configuration file.
 *///from ww w. j av  a2  s .  c o m
protected InputStream getCacheManagerConfigFileInputStream() {
    String configFile = getCacheManagerConfigFile();
    try {
        return ResourceUtils.getInputStreamForPath(configFile);
    } catch (IOException e) {
        throw new ConfigurationException(
                "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e);
    }
}

From source file:org.apache.jena.fuseki.server.ShiroEnvironmentLoader.java

License:Apache License

/** Look for a Shiro ini file, or return null */
private static String huntForShiroIni(String[] locations) {
    FusekiEnv.setEnvironment();/*from  w w w.ja  va2s.co  m*/
    Fuseki.init();
    for (String loc : locations) {
        // If file:, look for that file.
        // If a relative name without scheme, look in FUSEKI_BASE, FUSEKI_HOME, webapp. 
        String scheme = FileUtils.getScheme(loc);

        // Covers C:\\ as a "scheme name"
        if (scheme != null) {
            if (scheme.equalsIgnoreCase(FILE)) {
                // Test file: for exists
                Path p = Paths.get(loc.substring(FILE.length() + 1));
                if (!p.toFile().exists())
                    continue;
                // Fall through.
            }
            // Can't test - try 
            return loc;
        }
        // No scheme .
        Path p = Paths.get(loc);

        String fn = resolve(FusekiEnv.FUSEKI_BASE, p);
        if (fn != null)
            return "file://" + fn;
        fn = resolve(FusekiEnv.FUSEKI_HOME, p);
        if (fn != null)
            return "file://" + fn;

        // Try in webapp.

        try (InputStream is = ResourceUtils.getInputStreamForPath(loc);) {
            boolean exists = (is != null);
            return loc;
        } catch (IOException e) {
        }
    }
    return null;
}

From source file:uk.co.q3c.v7.base.navigate.TextReaderSitemapProvider.java

License:Apache License

@Override
public void parse(String resourcePath) {
    source = resourcePath;//from   w  w w.  java 2  s.co m
    log.info("Loading sitemap from {}", source);
    InputStream is;
    try {
        is = ResourceUtils.getInputStreamForPath(resourcePath);
        InputStreamReader isr = new InputStreamReader(is);
        Scanner scanner = new Scanner(isr);
        List<String> lines = new ArrayList<>();
        try {
            while (scanner.hasNextLine()) {
                lines.add(scanner.nextLine());
            }
        } finally {
            scanner.close();
        }
        processLines(lines);

    } catch (Exception e) {
        log.error("Unable to load site map ", e);
        String report = (parsed) ? getReport().toString() : "failed to parse input, unable to generate report";
        log.debug(report);
    }

}