List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key);
From source file:com.boozallen.cognition.ingest.storm.util.ConfigurationMapEntryUtils.java
/** * Extracts map entries from configuration. * * @param conf/* w w w .j ava 2s .c o m*/ * @param mappingEntry * @param fields first field should be unique and exist in all entries, other fields are optional from map * @return */ public static Map<String, Map<String, String>> extractMapList(final Configuration conf, final String mappingEntry, final String... fields) { String keyField = fields[0]; List<Object> keys = conf.getList(mappingEntry + "." + keyField); Map<String, Map<String, String>> maps = new HashMap<>(keys.size()); for (int i = 0; i < keys.size(); i++) { Map<String, String> map = new HashMap<>(); Object key = keys.get(i); map.put(keyField, key.toString()); for (int j = 1; j < fields.length; j++) { String field = fields[j]; String fieldPath = String.format("%s(%s).%s", mappingEntry, i, field); String value = conf.getString(fieldPath); if (value != null) map.put(field, value); } maps.put(key.toString(), map); } return maps; }
From source file:edu.lternet.pasta.client.DataPackageManagerClientTest.java
/** * Initialize objects before any tests are run. *///from ww w .ja v a 2 s .com @BeforeClass public static void setUpClass() { ConfigurationListener.configure(); Configuration options = ConfigurationListener.getOptions(); if (options == null) { fail("Failed to load the DataPortal properties file: 'dataportal.properties'"); } else { testUser = options.getString("eventservice.uid"); if (testUser == null) { fail("No value found for property: 'eventservice.uid'"); } password = options.getString("eventservice.password"); if (password == null) { fail("No value found for property: 'eventservice.password'"); } testScope = options.getString("dataportal.test.scope"); if (testScope == null) { fail("No value found for DataPortal property 'dataportal.test.scope'"); } testIdentifierStr = options.getString("dataportal.test.identifier"); if (testIdentifierStr == null) { fail("No value found for DataPortal property 'dataportal.test.identifier'"); } testRevisionStr = options.getString("dataportal.test.revision"); if (testRevisionStr == null) { fail("No value found for DataPortal property 'dataportal.test.revision'"); } testUpdateRevisionStr = options.getString("dataportal.test.revision.update"); if (testUpdateRevisionStr == null) { fail("No value found for DataPortal property 'dataportal.test.revision.update'"); } testEntityId = options.getString("dataportal.test.entity.id"); if (testEntityId == null) { fail("No value found for DataPortal property 'dataportal.test.entity.id'"); } testEntityName = options.getString("dataportal.test.entity.name"); if (testEntityName == null) { fail("No value found for DataPortal property 'dataportal.test.entity.name'"); } testEntitySize = options.getInteger("dataportal.test.entity.size", null); if (testEntitySize == null) { fail("No value found for DataPortal property 'dataportal.test.entity.size'"); } testPath = options.getString("dataportal.test.path"); if (testPath == null) { fail("No value found for DataPortal property 'dataportal.test.path'"); } else { testEmlFileName = options.getString("dataportal.test.emlFileName"); if (testEmlFileName == null) { fail("No value found for DataPortal property 'dataportal.test.emlFileName'"); } else { testEmlFile = new File(testPath, testEmlFileName); } } } /* * Authenticate the test user */ try { LoginClient loginClient = new LoginClient(testUser, password); System.err.println("User '" + testUser + "' authenticated."); } catch (PastaAuthenticationException e) { fail("User '" + testUser + "' failed to authenticate."); } /* * Determine the test identifier value and modify the test * EML packageId attribute accordingly */ try { dpmClient = new DataPackageManagerClient(testUser); testIdentifier = DataPackageManagerClient.determineTestIdentifier(dpmClient, testScope, testIdentifierStr); String testPackageId = testScope + "." + testIdentifier + "." + testRevisionStr; System.err.println("testPackageId: " + testPackageId); DataPackageManagerClient.modifyTestEmlFile(testEmlFile, testScope, testPackageId); } catch (Exception e) { fail(String.format("%s: %s", "Error encountered while initializing identifier value prior to running JUnit test.", e.getMessage())); } }
From source file:maltcms.ui.fileHandles.properties.tools.SceneParser.java
/** * Supports both absolute and relative paths and also arbitrary combinations * of the two. In case of relative paths, the location of the file * containing the pipeline configuration is used as basedir to resolve the * relative path./* ww w .j ava 2 s.c om*/ * * Example for relative path: * <pre>pipelines.properties = fragmentCommands/myClassName.properties</pre> * Example for absolute path: * <pre>pipelines.properties = /home/juser/myFunkyDir/myClassName.properties</pre> * * <pre>pipeline.properties</pre> accepts multiple entries, separated by a * ',' (comma) character. Example: * <pre>pipeline.properties = fragmentCommands/myClassName.properties,/home/juser/myFunkyDir/myClassName.properties</pre> * * @param filename the filename of the base configuration, which contains * the pipeline= and pipeline.properties keys. * @param cfg the configuration object resembling the content of filename. * @param scene the graph scene into which to load the configuration. */ public static void parseIntoScene(String filename, Configuration cfg, PipelineGraphScene scene) { Logger.getLogger(SceneParser.class.getName()) .info("###################################################################"); Logger.getLogger(SceneParser.class.getName()).info("Creating graph scene from file"); File f = new File(filename); //Get pipeline from configuration cfg.addProperty("config.basedir", f.getParentFile().getAbsoluteFile().toURI().getPath()); String pipelineXml = cfg.getString("pipeline.xml"); FileSystemXmlApplicationContext fsxmac = new FileSystemXmlApplicationContext(new String[] { pipelineXml }, true); ICommandSequence commandSequence = fsxmac.getBean("commandPipeline", cross.datastructures.pipeline.CommandPipeline.class); // String[] pipes = pipeline.toArray(new String[]{}); Logger.getLogger(SceneParser.class.getName()).log(Level.INFO, "Pipeline elements: {0}", commandSequence.getCommands()); PipelineGeneralConfigWidget pgcw = (PipelineGeneralConfigWidget) scene.createGeneralWidget(); pgcw.setProperties(cfg); String lastNode = null; String edge; int edgeCounter = 0; int nodeCounter = 0; Configuration pipeHash = new PropertiesConfiguration(); for (IFragmentCommand command : commandSequence.getCommands()) { Collection<String> configKeys = cross.annotations.AnnotationInspector .getRequiredConfigKeys(command.getClass()); // for (String pipe : pipes) { String nodeId = command.getClass().getCanonicalName() + "" + nodeCounter; PipelineElementWidget node = (PipelineElementWidget) scene.addNode(nodeId); // node.setPropertyFile(); // System.out.println("Parsing pipeline element " + pipeCfg.getAbsolutePath()); node.setBean(command); node.setLabel(command.getClass().getSimpleName()); node.setCurrentClassProperties(); Configuration prop = node.getProperties(); // pipeHash = PropertyLoader.getHash(pipeCfg.getAbsolutePath()); // node.setPropertyFile(pipeCfg.getAbsolutePath()); Iterator iter = pipeHash.getKeys(); while (iter.hasNext()) { String key = (String) iter.next(); prop.setProperty(key, pipeHash.getProperty(key)); } node.setProperties(prop); if (lastNode != null) { edge = "Ledge" + edgeCounter++; scene.addEdge(edge); Logger.getLogger(SceneParser.class.getName()).log(Level.INFO, "Adding edge between lastNode {0} and {1}", new Object[] { lastNode, nodeId }); scene.setEdgeSource(edge, lastNode); scene.setEdgeTarget(edge, nodeId); scene.validate(); } // x += dx; // y += dy; scene.validate(); lastNode = nodeId; nodeCounter++; } scene.validate(); SceneLayouter.layoutVertical(scene); }
From source file:dk.itst.oiosaml.sp.metadata.IdpMetadata.java
public static IdpMetadata getInstance() { if (instance == null) { Configuration conf = SAMLConfiguration.getSystemConfiguration(); String directory = SAMLConfiguration.getStringPrefixedWithBRSHome(conf, METADATA_DIRECTORY); File idpDir = new File(directory); File[] files = idpDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".xml"); }//w w w . j ava2 s . c om }); String protocol = conf.getString(Constants.PROP_PROTOCOL); List<EntityDescriptor> descriptors = new ArrayList<EntityDescriptor>(); for (File md : files) { log.info("Loading " + protocol + " metadata from " + md); try { XMLObject descriptor = SAMLUtil.unmarshallElementFromFile(md.getAbsolutePath()); if (descriptor instanceof EntityDescriptor) { descriptors.add((EntityDescriptor) descriptor); } else if (descriptor instanceof EntitiesDescriptor) { EntitiesDescriptor desc = (EntitiesDescriptor) descriptor; descriptors.addAll(desc.getEntityDescriptors()); } else { throw new RuntimeException("Metadata file " + md + " does not contain an EntityDescriptor. Found " + descriptor.getElementQName() + ", expected " + EntityDescriptor.ELEMENT_QNAME); } } catch (RuntimeException e) { log.error("Unable to load metadata from " + md + ". File must contain valid XML and have EntityDescriptor as top tag", e); throw e; } } if (descriptors.isEmpty()) { throw new IllegalStateException( "No IdP descriptors found in " + directory + "! At least one file is required."); } instance = new IdpMetadata(protocol, descriptors.toArray(new EntityDescriptor[descriptors.size()])); } return instance; }
From source file:com.github.anba.es6draft.util.Resources.java
/** * Filter the initially collected test cases. */// w ww. jav a 2s . co m private static void filterTests(List<? extends TestInfo> tests, Path basedir, Configuration config) throws IOException { if (DISABLE_ALL_TESTS) { for (TestInfo test : tests) { test.setEnabled(false); } } if (config.containsKey("exclude.list")) { InputStream exclusionList = Resources.resource(config.getString("exclude.list"), basedir); filterTests(tests, exclusionList, config); } if (config.containsKey("exclude.xml")) { Set<String> excludes = readExcludeXMLs(config.getList("exclude.xml", emptyList()), basedir); filterTests(tests, excludes); } }
From source file:com.virtualparadigm.packman.processor.JPackageManagerBU.java
private static VelocityContext createVelocityContext(Configuration configuration) { VelocityContext velocityContext = new VelocityContext(); if (configuration != null) { String key = null;//www . jav a2s . c om for (Iterator<String> it = configuration.getKeys(); it.hasNext();) { key = it.next(); velocityContext.put(key, configuration.getString(key)); } } return velocityContext; }
From source file:fr.inria.atlanmod.neoemf.graph.blueprints.neo4j.config.BlueprintsNeo4jConfig.java
@Override public void putDefaultConfiguration(Configuration currentConfiguration, File dbLocation) { if (currentConfiguration.getString("blueprints.neo4j.directory") == null) { currentConfiguration.addProperty("blueprints.neo4j.directory", dbLocation.getAbsolutePath()); }/*w w w .j av a 2s. co m*/ }
From source file:com.boozallen.cognition.ingest.storm.bolt.logic.SkipBlankBolt.java
@Override public void configure(Configuration conf) { field = conf.getString(FIELD); Validate.notBlank(field); }
From source file:dk.itst.oiosaml.sp.service.session.jdbc.JndiFactory.java
public void configure(Configuration config) { name = config.getString("oiosaml-sp.sessionhandler.jndi"); }
From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.AddMetadataBolt.java
@Override public void configure(Configuration conf) { field = conf.getString("field"); value = conf.getString("value"); Validate.notBlank(field);// ww w. ja v a 2 s . c om Validate.notBlank(value); }