List of usage examples for org.apache.commons.collections ExtendedProperties convertProperties
public static ExtendedProperties convertProperties(Properties props)
From source file:com.arcbees.plugin.velocity.RuntimeInstanceCustom.java
/** * Initialize the Velocity Runtime with a Properties * object./*from w w w. jav a 2s.c o m*/ * * @param p * @throws Exception When an error occurs during initialization. */ public void init(Properties p) throws Exception { overridingProperties = ExtendedProperties.convertProperties(p); init(); }
From source file:bboss.org.apache.velocity.runtime.RuntimeInstance.java
/** * Initialize the Velocity Runtime with a Properties * object.//from w ww . ja va 2 s .c om * * @param p Velocity properties for initialization */ public void init(Properties p) { setProperties(ExtendedProperties.convertProperties(p)); init(); }
From source file:org.dspace.app.xmlui.aspect.discovery.json.JSONSolrSearcher.java
@Override public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { //Retrieve all the given parameters Request request = ObjectModelHelper.getRequest(objectModel); this.response = ObjectModelHelper.getResponse(objectModel); query = request.getParameter(CommonParams.Q); if (query == null) { query = "*:*"; }/* ww w .j av a 2 s.c om*/ //Retrieve all our filter queries filterQueries = request.getParameterValues(CommonParams.FQ); //Retrieve our facet fields facetFields = request.getParameterValues(FacetParams.FACET_FIELD); //Retrieve our facet limit (if any) if (request.getParameter(FacetParams.FACET_LIMIT) != null) { try { facetLimit = Integer.parseInt(request.getParameter(FacetParams.FACET_LIMIT)); } catch (Exception e) { //Should an invalid value be supplied use -1 facetLimit = -1; } } else { facetLimit = -1; } //Retrieve our sorting value facetSort = request.getParameter(FacetParams.FACET_SORT); //Make sure we have a valid sorting value if (!FacetParams.FACET_SORT_INDEX.equals(facetSort) && !FacetParams.FACET_SORT_COUNT.equals(facetSort)) { facetSort = null; } //Retrieve our facet min count facetMinCount = 1; try { facetMinCount = Integer.parseInt(request.getParameter(FacetParams.FACET_MINCOUNT)); } catch (Exception e) { facetMinCount = 1; } jsonWrf = request.getParameter("json.wrf"); //Retrieve our discovery solr path ExtendedProperties props = null; //Method that will retrieve all the possible configs we have props = ExtendedProperties.convertProperties(ConfigurationManager.getProperties()); InputStream is = null; try { File config = new File(props.getProperty("dspace.dir") + "/config/dspace-solr-search.cfg"); if (config.exists()) { props.combine(new ExtendedProperties(config.getAbsolutePath())); } else { is = SolrServiceImpl.class.getResourceAsStream("dspace-solr-search.cfg"); ExtendedProperties defaults = new ExtendedProperties(); defaults.load(is); props.combine(defaults); } } catch (Exception e) { log.error("Error while retrieving solr url", e); e.printStackTrace(); } finally { if (is != null) { is.close(); } } if (props.getProperty("solr.search.server") != null) { this.solrServerUrl = props.getProperty("solr.search.server").toString(); } }
From source file:org.openflexo.velocity.FlexoVelocity.java
/** * @throws Exception// w w w .j a v a 2 s . c o m * */ public synchronized static void init() throws Exception { if (!isInitialized) { // 1. We load properties with the Java object because it loads property files correctly unlike ExtendedProperties (which does // not handle properly "\ " as value " ") Properties p = new Properties(); p.load(new FileInputStream(new FileResource("Config/velocity.properties"))); for (Entry<Object, Object> e : p.entrySet()) { String value = e.getValue().toString(); if (value.indexOf("${") > -1) { for (Entry<Object, Object> sp : System.getProperties().entrySet()) { value = value.replace("${" + sp.getKey() + "}", sp.getValue().toString()); } p.setProperty(e.getKey().toString(), value); } } // 2. We convert properties to extended properties (this conversion only handles values of type String (i.e., a VelocityLogger // cannot be set directly in the Properties, see 3.) ExtendedProperties ep = ExtendedProperties.convertProperties(p); VelocityLogger vl = new VelocityLogger(); // 3. We set our logger so that it does not try to use its own ep.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, vl); // 4. We force our configuration to be loaded RuntimeSingleton.getRuntimeServices().setConfiguration(ep); // 5. We initialize properly Velocity passing no properties at all! Velocity.init(); isInitialized = true; if (logger.isLoggable(Level.FINE)) { logger.fine("Velocity Engine started"); } } }