List of usage examples for org.apache.solr.core SolrResourceLoader openResource
@Override public InputStream openResource(String resource) throws IOException
From source file:com.sindicetech.siren.solr.schema.ExtendedJsonField.java
License:Open Source License
/** * Load the datatype analyzer config file specified by the schema. * <br/>//w ww . ja v a 2s.c o m * 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) { } } } }
From source file:com.sindicetech.siren.solr.schema.SirenDatatypeAnalyzerConfig.java
License:Open Source License
/** * 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.//from w ww . jav a2 s.c om * @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); } }
From source file:de.dlr.knowledgefinder.dataimport.utils.transformer.CategoriesSeparatedTransformer.java
License:Apache License
private Map<String, String> initializeNameValues(String filename) { Map<String, String> loadedFile = loadedFiles.get(filename); if (loadedFile == null) { SolrResourceLoader loader = context.getSolrCore().getResourceLoader(); Map<String, String> names = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); try {//from w ww. ja v a 2 s . com InputStream is = loader.openResource(filename); CategoryParser catParser = factory.getParser(filename); for (Entry<String, Object> entry : catParser.getAncestorsField(is, "name").entrySet()) { names.put(entry.getKey(), entry.getValue().toString()); } } catch (FileParserException | IOException e) { LOG.error(e.getLocalizedMessage(), e); } loadedFiles.put(filename, names); } return loadedFiles.get(filename); }
From source file:jp.aegif.nemaki.util.impl.PropertyManagerImpl.java
License:Open Source License
/** * Constructor setting specified properties file and config object * @param propertiesFile//w w w.j ava2s.c om */ public PropertyManagerImpl(String propertiesFile) { this.setPropertiesFile(propertiesFile); Properties config = new Properties(); SolrResourceLoader loader = new SolrResourceLoader(null); try { //Set key values InputStream inputStream = loader.openResource(propertiesFile); if (inputStream != null) { config.load(inputStream); this.setConfig(config); } //Set override files String _overrideFiles = config.getProperty(PropertyKey.OVERRIDE_FILES); if (StringUtils.isNotBlank(_overrideFiles)) { overrideFiles = split(_overrideFiles); } } catch (Exception e) { logger.error("Error occurred during setting of PropertyManager.", e); } finally { try { loader.close(); } catch (Exception e) { logger.error("Error occurred during closing SolrResourceLoader.", e); } } }