@Override public InputStream openResource(String resourceName) { ByteBuffer resourceValue = null; try { resourceValue = SolandraCoreContainer.readCoreResource(coreName, resourceName); } catch (Exception e) { throw new RuntimeException("Error opening " + resourceName, e); } //fallback to solr.home if (resourceValue == null) { return super.openResource(resourceName); } else { return new ByteArrayInputStream(ByteBufferUtil.getArray(resourceValue)); } } }
/** Opens a schema resource by its name. * Override this method to customize loading schema resources. *@return the stream for the named schema */ public InputStream openSchema(String name) { return openResource(name); }
/** Opens a config resource by its name. * Override this method to customize loading config resources. *@return the stream for the named configuration */ public InputStream openConfig(String name) { return openResource(name); }
public InputStream getResourceStream(String template_name) throws ResourceNotFoundException { return loader.openResource(template_name); }
/** * @deprecated Use {@link SolrResourceLoader#openResource(String)} instead. */ @Deprecated public InputStream openResource(String resource) { return loader.openResource(resource); }
/** * Direct access to the InputStream for the schemaFile used by this instance. * @see Config#openResource * @deprecated Use {@link #getSolrConfig()} and open a resource input stream * for {@link #getResourceName()} instead. */ @Deprecated public InputStream getInputStream() { return loader.openResource(resourceName); }
@Override public InputStream getResourceStream(String template_name) throws ResourceNotFoundException { try { return loader.openResource("velocity/" + template_name); } catch (IOException ioe) { throw new ResourceNotFoundException(ioe); } }
@Override public void inform(SolrCore core) { // need to leverage SolrResourceLoader, so load init.properties.file here instead of init() if (initPropertiesFileName != null) { InputStream is = null; try { velocityInitProps.load(new InputStreamReader(core.getResourceLoader().openResource(initPropertiesFileName), StandardCharsets.UTF_8)); } catch (IOException e) { log.warn("Error loading " + PROPERTIES_FILE + " specified property file: " + initPropertiesFileName, e); } } }
@Override public InputStream openResource(String resource) { InputStream in = classLoader.getResourceAsStream(resource); if ( in == null ) { try { in = super.openResource(resource); } catch (IOException e) { log.error("openResource",e); } } return in; } }
public List<String> getLines(String resource, Charset charset) throws IOException{ BufferedReader input = null; ArrayList<String> lines; try { input = new BufferedReader(new InputStreamReader(openResource(resource), charset)); lines = new ArrayList<String>(); for (String word=null; (word=input.readLine())!=null;) { // skip comments if (word.startsWith("#")) continue; word=word.trim(); // skip blank lines if (word.length()==0) continue; lines.add(word); } } finally { if (input != null) input.close(); } return lines; }
final byte [] asBytes; try { resourceStream = resourceLoader.openResource(resourceName); asBytes = IOUtils.toByteArray(resourceStream); } catch (IOException e) {
/** * This is a utility function that lets you get the contents of an admin file * * It is only used so that we can get rid of "/admin/get-file.jsp" and include * "admin-extra.html" in "/admin/index.html" using jsp scriptlets * * @deprecated This functionality is implemented in * {@link #handleRequestBody(SolrQueryRequest, SolrQueryResponse)}. */ @Deprecated public static String getFileContents( String path ) { if( instance != null && instance.hiddenFiles != null ) { if( instance.hiddenFiles.contains( path ) ) { return ""; // ignore it... } } try { SolrCore core = SolrCore.getSolrCore(); InputStream input = core.getResourceLoader().openResource(path); return IOUtils.toString( input ); } catch( Exception ex ) {} // ignore it return ""; }
/** * Load the datatype analyzer config file specified by the schema. * <br/> * This should be called whenever the datatype analyzer configuration file changes. */ private void loadDatatypeConfig(final SolrResourceLoader resourceLoader) { InputStream is; log.info("Loading datatype analyzer configuration file at " + datatypeAnalyzerConfigPath); try { is = resourceLoader.openResource(datatypeAnalyzerConfigPath); } catch (final IOException e) { log.error("Error loading datatype analyzer configuration file at " + datatypeAnalyzerConfigPath, e); throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } try { final SirenDatatypeAnalyzerConfig newConfig = new SirenDatatypeAnalyzerConfig(resourceLoader, datatypeAnalyzerConfigPath, new InputSource(is), this.luceneDefaultVersion); log.info("Read new datatype analyzer configuration " + newConfig); datatypeConfigRef.set(newConfig); } finally { if (is != null) { try { is.close(); } catch (final IOException ignored) { } } } }
/** * Constructs a config using the specified resource name and stream. * If the is stream is null, the resource loader will load the resource * by name. * @see SolrResourceLoader#openConfig * By default, this follows the normal config path directory searching rules. * @see SolrResourceLoader#openResource */ public SirenDatatypeAnalyzerConfig(final SolrResourceLoader loader, final String name, InputSource is, final Version luceneMatchVersion) { this.luceneMatchVersion = luceneMatchVersion; this.resourceName = name; this.loader = loader; try { if (is == null) { is = new InputSource(loader.openResource(name)); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name)); } this.readConfig(is); } catch (final IOException e) { throw new RuntimeException(e); } }
/** * Constructs a config using the specified resource name and stream. * If the is stream is null, the resource loader will load the resource * by name. * @see SolrResourceLoader#openConfig * By default, this follows the normal config path directory searching rules. * @see SolrResourceLoader#openResource */ public SirenDatatypeAnalyzerConfig(final SolrResourceLoader loader, final String name, InputSource is, final Version luceneMatchVersion) { this.luceneMatchVersion = luceneMatchVersion; this.resourceName = name; this.loader = loader; try { if (is == null) { is = new InputSource(loader.openResource(name)); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name)); } this.readConfig(is); } catch (final IOException e) { throw new RuntimeException(e); } }
/** * Load the datatype analyzer config file specified by the schema. * <p/> * This should be called whenever the datatype analyzer configuration file changes. */ private void loadDatatypeConfig(final IndexSchema schema) { InputStream is; log.info("Loading datatype analyzer configuration file at " + datatypeAnalyzerConfigPath); try { is = schema.getResourceLoader().openResource(datatypeAnalyzerConfigPath); } catch (final IOException e) { log.error("Error loading datatype analyzer configuration file at " + datatypeAnalyzerConfigPath, e); throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } try { final SirenDatatypeAnalyzerConfig newConfig = new SirenDatatypeAnalyzerConfig(schema.getResourceLoader(), datatypeAnalyzerConfigPath, new InputSource(is), schema.getDefaultLuceneMatchVersion()); log.info("Read new datatype analyzer configuration " + newConfig); datatypeConfigRef.set(newConfig); } finally { if (is != null) { try { is.close(); } catch (final IOException ignored) { } } } }
for(int i = 0; i < files.length; i++){ Reader reader = new InputStreamReader( core.getResourceLoader().openResource(files[i]),IOUtils.UTF_8); readers[i] = reader; core.getResourceLoader().openResource(sourceLocation), IOUtils.UTF_8));
for(int i = 0; i < files.length; i++){ Reader reader = new InputStreamReader( core.getResourceLoader().openResource(files[i]),IOUtils.UTF_8); readers[i] = reader; core.getResourceLoader().openResource(sourceLocation), IOUtils.UTF_8));
dictionary = new PlainTextDictionary(loader.openResource(sourceLocation)); } else { dictionary = new PlainTextDictionary(new InputStreamReader(loader.openResource(sourceLocation), characterEncoding));
is = new InputSource(new StringReader(dataConfigText)); } else if(dataconfigFile!=null) { is = new InputSource(core.getResourceLoader().openResource(dataconfigFile)); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(dataconfigFile)); log.info("Loading DIH Configuration: " + dataconfigFile);