/** * Reads the contents of a resource as a string. * * @param resource * @return Contents of the resource. * @throws IOException */ public static String getContent(String resource) throws IOException { InputStream is = openResource(resource); try{ return IOUtils.toString(is, "UTF-8"); } finally { IOUtils.closeQuietly(is); } }
protected String getResourceContent(String resource) { try { return ResourceLoader.getContent(resource); } catch (IOException e) { return null; } }
/** * Read the cache configuration from the specified resource. * This function is intended to be overrideable to allow for programmatic * cache configuration. * @param configPath * @return Configuration * @throws IOException */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
protected String getFileContent(File file) { try { return ResourceLoader.getContent(file); } catch (IOException e) { // This is fine; errors happen downstream. return null; } }
/** * Opens a resource * @param resource * @return An input stream for the given named resource * @throws FileNotFoundException */ public static InputStream openResource(String resource) throws FileNotFoundException { ClassLoader cl = ResourceLoader.class.getClassLoader(); try { return openResource(cl, resource); } catch (FileNotFoundException e) { // If we cannot find the resource using the current classes class loader // try the current threads cl = Thread.currentThread().getContextClassLoader(); return openResource(cl, resource); } }
/** * Read the cache configuration from the specified resource. * This function is intended to be overrideable to allow for programmatic * cache configuration. * @param configPath * @return Configuration * @throws IOException */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
protected String getResourceContent(String resource) { try { return ResourceLoader.getContent(resource); } catch (IOException e) { return null; } }
/** * Reads the contents of a resource as a string. * * @param resource * @return Contents of the resource. * @throws IOException */ public static String getContent(String resource) throws IOException { InputStream is = openResource(resource); try { return IOUtils.toString(is, "UTF-8"); } finally { IOUtils.closeQuietly(is); } }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
public String getResourceContent(String resource) throws IOException { return ResourceLoader.getContent(resource); } }
/** * Opens a resource * @param resource * @return An input stream for the given named resource * @throws FileNotFoundException */ public static InputStream openResource(String resource) throws FileNotFoundException { ClassLoader cl = ResourceLoader.class.getClassLoader(); try { return openResource(cl, resource); } catch (FileNotFoundException e) { // If we cannot find the resource using the current classes class loader // try the current threads cl = Thread.currentThread().getContextClassLoader(); return openResource(cl, resource); } }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
protected String getFileContent(File file) { try { return ResourceLoader.getContent(file); } catch (IOException e) { // This is fine; errors happen downstream. return null; } }
/** * Reads the contents of a resource as a string. * * @param resource * @return Contents of the resource. * @throws IOException */ public static String getContent(String resource) throws IOException { InputStream is = openResource(resource); try { return IOUtils.toString(is, "UTF-8"); } finally { IOUtils.closeQuietly(is); } }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
protected String attemptToLoadResourceFullyQualified(String resource) throws IOException { return ResourceLoader.getContent(resource); } }
/** * Reads the contents of a resource as a string. * * @param resource * @return Contents of the resource. * @throws IOException */ public static String getContent(String resource) throws IOException { InputStream is = openResource(resource); try{ return IOUtils.toString(is, "UTF-8"); } finally { IOUtils.closeQuietly(is); } }
private void loadDefaultKey(String signingKeyFile, String signingKeyName) { BasicOAuthStoreConsumerKeyAndSecret key = null; if (!StringUtils.isBlank(signingKeyFile)) { try { if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "loadDefaultKey", MessageKeys.LOAD_KEY_FILE_FROM, new Object[] {signingKeyFile}); } String privateKey = IOUtils.toString(ResourceLoader.open(signingKeyFile), "UTF-8"); privateKey = BasicOAuthStore.convertFromOpenSsl(privateKey); key = new BasicOAuthStoreConsumerKeyAndSecret(null, privateKey, KeyType.RSA_PRIVATE, signingKeyName, null); } catch (Throwable t) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_KEY_FILE, new Object[] {signingKeyFile}); LOG.logp(Level.WARNING, classname, "loadDefaultKey", "",t); } } } if (key != null) { store.setDefaultKey(key); } else { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_SIGN_KEY, new Object[] {OAUTH_SIGNING_KEY_FILE,OAUTH_SIGNING_KEY_NAME}); } } }
private static String getJSONString(final String location) throws IOException { return ResourceLoader.getContent(location); } }
/** * Opens a resource * @param resource * @return An input stream for the given named resource * @throws FileNotFoundException */ public static InputStream openResource(String resource) throws FileNotFoundException { ClassLoader cl = ResourceLoader.class.getClassLoader(); try { return openResource(cl, resource); } catch (FileNotFoundException e) { // If we cannot find the resource using the current classes class loader // try the current threads cl = Thread.currentThread().getContextClassLoader(); return openResource(cl, resource); } }