List of usage examples for org.apache.commons.configuration Configuration containsKey
boolean containsKey(String key);
From source file:org.cesecore.config.OcspConfiguration.java
/** * The default number of milliseconds a response of a revoked certificate is valid, or 0 to disable. See RFC5019. *//* w w w . jav a2s. c o m*/ public static long getRevokedUntilNextUpdate(int certProfileId) { long value = 0; Configuration config = ConfigurationHolder.instance(); String key = "ocsp." + certProfileId + ".revoked.untilNextUpdate"; if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) { key = REVOKED_UNTIL_NEXT_UPDATE; } try { value = (config.getLong(key, value) * 1000); } catch (ConversionException e) { log.warn("\"ocsp.revoked.untilNextUpdate\" is not a decimal integer. Using default value: " + value); } return value; }
From source file:org.cesecore.config.OcspConfiguration.java
/** * The default number of milliseconds a HTTP-response should be cached. See RFC5019. *///from w w w. j av a2 s.com public static long getMaxAge(int certProfileId) { long value = 30; Configuration config = ConfigurationHolder.instance(); String key = "ocsp." + certProfileId + ".maxAge"; if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) { key = MAX_AGE; } try { value = (config.getLong(key, value) * 1000); } catch (ConversionException e) { // Convert default value to milliseconds value = value * 1000; log.warn("\"ocsp.maxAge\" is not a decimal integer. Using default value: " + value); } return value; }
From source file:org.cesecore.config.OcspConfiguration.java
/** * The default number of milliseconds a HTTP-response for a revoked certificater should be cached. See RFC5019. *//* w ww . ja v a2 s . c o m*/ public static long getRevokedMaxAge(int certProfileId) { long value = 30; Configuration config = ConfigurationHolder.instance(); String key = "ocsp." + certProfileId + ".revoked.maxAge"; if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) { key = REVOKED_MAX_AGE; } try { value = (config.getLong(key, value) * 1000); } catch (ConversionException e) { // Convert default value to milliseconds value = value * 1000; log.warn("\"ocsp.revoked.maxAge\" is not a decimal integer. Using default value: " + value); } return value; }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrLogIndexer.java
/** * Pull solr query field parameters from a Properties file and use them to issue a solr query. * * The solr query results are transformed into a Log object and returned. * * The following fields are currently supported and passed through to the solr log index as a query * * fromDate (Types.DateTime) Records with time stamp greater than or equal to (>=) this value will be returned. * Transmitted as a URL query parameter, and so must be escaped accordingly. toDate (Types.DateTime) Records with * a time stamp less than this value will be returned. If not specified, then defaults to now. Transmitted as a URL * query parameter, and so must be escaped accordingly. event (Types.Event) Return only log records for the * specified type of event. Default is all. Transmitted as a URL query parameter, and so must be escaped * accordingly. pidFilter (string) Return only log records for identifiers that start with the supplied identifier * string. Support for this parameter is optional and MAY be ignored by the Member Node implementation with no * warning. Transmitted as a URL query parameter, and so must be escaped accordingly. start=0 (integer) Optional * zero based offset from the first record in the set of matching log records. Used to assist with paging the * response. Transmitted as a URL query parameter, and so must be escaped accordingly. count=1000 (integer) The * maximum number of log records that should be returned in the response. The Member Node may return fewer and the * caller should check the total in the response to determine if further pages may be retrieved. Transmitted as a * URL query parameter, and so must be escaped accordingly. * * * * * @param query// ww w .j a v a 2 s. c o m * @return Log * @throws org.apache.commons.configuration.ConfigurationException * @throws java.io.IOException * @throws org.apache.solr.client.solrj.SolrServerException */ @Override public Log search(Properties query) throws ConfigurationException, IOException, SolrServerException { // since this is the implementation assume the input to be a properties file. Configuration apacheConfiguration = getApacheConfiguration(query); List<LogEntrySolrItem> outputList = new ArrayList(); // may not have to initialize Log log = new Log(); SolrQuery queryParams = new SolrQuery(); queryParams.setQuery(queryStringBuilder(apacheConfiguration)); queryParams.setSortField("dateAggregated", SolrQuery.ORDER.desc); if (apacheConfiguration.containsKey("start")) { queryParams.setStart(apacheConfiguration.getInt("start")); } else { queryParams.setStart(0); } if (apacheConfiguration.containsKey("count")) { queryParams.setRows(apacheConfiguration.getInt("count")); } else { queryParams.setRows(defaultCount); } QueryResponse queryResponse = solrServer.query(queryParams); queryResponse.getResults(); List<LogEntrySolrItem> logEntryList = queryResponse.getBeans(LogEntrySolrItem.class); for (LogEntrySolrItem lesi : logEntryList) { log.addLogEntry(lesi.getLogEntry()); } log.setTotal(Long.valueOf(queryResponse.getResults().getNumFound()).intValue()); log.setStart(Long.valueOf(queryResponse.getResults().getStart()).intValue()); log.setCount(logEntryList.size()); return log; }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrLogIndexer.java
/** * Using the properties passed in the apache configuration file, build and return a valid Solr query string The * query string can take the following arguments: * * fromDate, toDate, event, pidFilter//ww w . j av a2 s .c om * * @param apacheConfiguration * @return String */ private String queryStringBuilder(Configuration apacheConfiguration) { // This should be refactored to use a query builder StringBuilder queryStringBuilder = new StringBuilder(); // first figure out the date parameters for the query if there is any if (apacheConfiguration.containsKey("fromDate")) { if (!apacheConfiguration.containsKey("toDate")) { queryStringBuilder .append("dateLogged:[" + apacheConfiguration.getString("fromDate") + " TO NOW]" + ""); } else { queryStringBuilder.append("dateLogged:[" + apacheConfiguration.getString("fromDate") + " TO " + apacheConfiguration.getString("toDate") + "]"); } } else if (apacheConfiguration.containsKey("toDate")) { queryStringBuilder.append("dateLogged:[* TO " + apacheConfiguration.getString("toDate") + "]"); } // add in the objectformat if (apacheConfiguration.containsKey("pidFilter")) { if (queryStringBuilder.length() > 0) { queryStringBuilder.append(" AND "); } queryStringBuilder.append("pid:\"" + apacheConfiguration.getString("pidFilter") + "\""); } // add in the replicaStatus if (apacheConfiguration.containsKey("event")) { if (queryStringBuilder.length() > 0) { queryStringBuilder.append(" AND "); } queryStringBuilder.append("event:" + apacheConfiguration.getString("event")); } return queryStringBuilder.toString(); }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrQueryIndexer.java
@Override public ObjectList search(Properties query) throws Exception { // since this is the implementation assume the input to be a properties file. Configuration apacheConfiguration = getApacheConfiguration(query); ObjectList objectList = new ObjectList(); SolrQuery queryParams = new SolrQuery(); queryParams.setQuery(queryStringBuilder(apacheConfiguration)); queryParams.setSortField("id", SolrQuery.ORDER.desc); if (apacheConfiguration.containsKey("start")) { queryParams.setStart(apacheConfiguration.getInt("start")); } else {/* w ww . j av a 2 s . com*/ queryParams.setStart(0); } if (apacheConfiguration.containsKey("count")) { queryParams.setRows(apacheConfiguration.getInt("count")); } else { queryParams.setRows(defaultCount); } QueryResponse queryResponse = solrServer.query(queryParams); queryResponse.getResults(); List<ObjectInfoSolrItem> objectInfoList = queryResponse.getBeans(ObjectInfoSolrItem.class); for (ObjectInfoSolrItem lesi : objectInfoList) { objectList.addObjectInfo(lesi.getObjectInfo()); } objectList.setTotal(Long.valueOf(queryResponse.getResults().getNumFound()).intValue()); objectList.setStart(Long.valueOf(queryResponse.getResults().getStart()).intValue()); objectList.setCount(objectInfoList.size()); return objectList; }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrQueryIndexer.java
/** * Using the properties passed in the apache configuration file, build and return a valid Solr query string * * @param apacheConfiguration//w w w . j a v a 2s.c o m * @return String */ private String queryStringBuilder(Configuration apacheConfiguration) { // This should be refactored to use a query builder StringBuilder queryStringBuilder = new StringBuilder(); // first figure out the date parameters for the query if there is any if (apacheConfiguration.containsKey("fromDate")) { if (!apacheConfiguration.containsKey("toDate")) { queryStringBuilder.append( "dateSysMetadataModified:[" + apacheConfiguration.getString("fromDate") + " TO NOW]" + ""); } else { queryStringBuilder.append("dateSysMetadataModified:[" + apacheConfiguration.getString("fromDate") + " TO " + apacheConfiguration.getString("toDate") + "]"); } } else if (apacheConfiguration.containsKey("toDate")) { queryStringBuilder .append("dateSysMetadataModified:[* TO " + apacheConfiguration.getString("toDate") + "]"); } // add in the objectformat if (apacheConfiguration.containsKey("formatId")) { if (queryStringBuilder.length() > 0) { queryStringBuilder.append(" AND "); } queryStringBuilder.append("objectFormatId:\"" + apacheConfiguration.getString("formatId") + "\""); } // add in the replicaStatus if (apacheConfiguration.containsKey("replicaStatus")) { if (queryStringBuilder.length() > 0) { queryStringBuilder.append(" AND "); } queryStringBuilder.append("replicaStatus:" + apacheConfiguration.getString("replicaStatus")); } return queryStringBuilder.toString(); }
From source file:org.ejbca.config.OcspConfiguration.java
/** * The default number of milliseconds a response is valid, or 0 to disable. See RFC5019. *//* w w w . java2 s . com*/ public static long getUntilNextUpdate(int certProfileId) { long value = 0; Configuration config = ConfigurationHolder.instance(); String key = "ocsp." + certProfileId + ".untilNextUpdate"; if ((certProfileId == SecConst.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) { key = "ocsp.untilNextUpdate"; } try { value = (config.getLong(key, value) * 1000); } catch (ConversionException e) { log.warn("\"ocsp.untilNextUpdate\" is not a decimal number. Using default value: " + value); } return value; }
From source file:org.ejbca.config.OcspConfiguration.java
/** * The default number of milliseconds a HTTP-response should be cached. See RFC5019. *//*from ww w .j a va2 s . co m*/ public static long getMaxAge(int certProfileId) { long value = 30; Configuration config = ConfigurationHolder.instance(); String key = "ocsp." + certProfileId + ".maxAge"; if ((certProfileId == SecConst.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) { key = "ocsp.maxAge"; } try { value = (config.getLong(key, value) * 1000); } catch (ConversionException e) { // Convert default value to milliseconds value = value * 1000; log.warn("\"ocsp.maxAge\" is not a decimal number. Using default value: " + value); } return value; }
From source file:org.ff4j.commonsconf.FF4JConfigurationTest.java
@Test public void testSubSet() { // Given//w w w. j a va 2s .com Assert.assertTrue(ff4jConf.containsKey("name")); // When Configuration conf2 = ff4jConf.subset("prop"); // Then Assert.assertTrue(conf2.containsKey("propInt")); Assert.assertFalse(conf2.containsKey("name")); }