List of usage examples for org.apache.commons.configuration Configuration getStringArray
String[] getStringArray(String key);
From source file:org.apache.wookie.WidgetAdminServlet.java
private void uploadOperation(HttpServletRequest request, Configuration properties, IWidgetAdminManager manager) {//from w w w . j a va2 s . c o m final String WIDGETFOLDER = getServletContext().getRealPath(properties.getString("widget.widgetfolder"));//$NON-NLS-1$ final String UPLOADFOLDER = getServletContext() .getRealPath(properties.getString("widget.useruploadfolder"));//$NON-NLS-1$ Messages localizedMessages = LocaleHandler.localizeMessages(request); request.setAttribute("hasValidated", Boolean.valueOf(false)); //$NON-NLS-1$ request.setAttribute("closeWindow", Boolean.valueOf(true)); //$NON-NLS-1$ File zipFile; try { zipFile = WidgetFileUtils.upload(UPLOADFOLDER, request); } catch (Exception ex) { request.setAttribute("error_value", //$NON-NLS-1$ localizedMessages.getString("WidgetAdminServlet.28") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ return; } try { if (zipFile.exists()) { IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager(); final String[] locales = properties.getStringArray("widget.locales"); W3CWidgetFactory fac = new W3CWidgetFactory(); fac.setLocales(locales); fac.setLocalPath( getServletContext().getContextPath() + properties.getString("widget.widgetfolder")); fac.setOutputDirectory(WIDGETFOLDER); fac.setFeatures(persistenceManager.findServerFeatureNames()); fac.setStartPageProcessor(new StartPageProcessor()); W3CWidget widgetModel = fac.parse(zipFile); WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer( fac.getUnzippedWidgetDirectory()); if (persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null) { // ADD IWidget widget = WidgetFactory.addNewWidget(widgetModel); Object dbkey = widget.getId(); // widget added request.setAttribute("message_value", "'" + widgetModel.getLocalName("en") + "' - " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + localizedMessages.getString("WidgetAdminServlet.19")); retrieveServices(request); request.setAttribute("hasValidated", Boolean.valueOf(true)); //$NON-NLS-1$ request.setAttribute("dbkey", dbkey); //$NON-NLS-1$ } else { // UPDATE // TODO - call the manager to update required resources // widget updated request.setAttribute("message_value", "'" + widgetModel.getLocalName("en") + "' - " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + localizedMessages.getString("WidgetAdminServlet.20")); } } else { // no file found to be uploaded - shouldn't happen request.setAttribute("error_value", localizedMessages.getString("WidgetAdminServlet.24")); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (InvalidStartFileException ex) { _logger.error(ex); request.setAttribute("error_value", //$NON-NLS-1$ localizedMessages.getString("WidgetAdminServlet.27") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } catch (BadManifestException ex) { _logger.error(ex); String message = ex.getMessage(); if (ex.getMessage() == null || ex.getMessage().equals("")) //$NON-NLS-1$ message = localizedMessages.getString("WidgetAdminServlet.28"); if (ex instanceof InvalidContentTypeException) message = localizedMessages.getString("WidgetAdminServlet.30");//$NON-NLS-1$ request.setAttribute("error_value", message); //$NON-NLS-1$ } catch (BadWidgetZipFileException ex) { _logger.error(ex); String message = ex.getMessage(); if (ex.getMessage() == null || ex.getMessage().equals("")) //$NON-NLS-1$ message = localizedMessages.getString("WidgetAdminServlet.29"); request.setAttribute("error_value", message); //$NON-NLS-1$ } catch (Exception ex) { _logger.error(ex); request.setAttribute("error_value", //$NON-NLS-1$ localizedMessages.getString("WidgetAdminServlet.25") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } }
From source file:org.apereo.lap.services.pipeline.KettleBasePipelineProcessor.java
/** * Get the comma-separated value string of database connection names from app.properties * with the key "app.database.connection.names" *///w ww . j a v a 2s .co m private void setDatabaseConnectionNames() { Configuration configuration = configurationService.getConfig(); databaseConnectionNames = configuration.getStringArray("app.database.connection.names"); }
From source file:org.chenillekit.core.tests.TestConfigurationService.java
@Test public void test1() { Resource configResource = new ClasspathResource("test.properties"); Configuration testConfiguration = service.getConfiguration(configResource); assertNotNull(testConfiguration);/*from ww w .j a v a 2s .c o m*/ assertEquals(testConfiguration.getString("test.value1"), "test1"); assertEquals(testConfiguration.getInt("test.value2"), 3); assertEquals(testConfiguration.getStringArray("test.value3"), new String[] { "test1", "test2", "test3", "test4" }); assertEquals(testConfiguration.getString("test.value4"), System.getProperty("java.vendor")); }
From source file:org.core.config.TestCase.java
public static TestCase[] getTestCases(Configuration config) { String[] url_array = config.getStringArray("Tests.TestCase.url"); String[] proxy_array = config.getStringArray("Tests.TestCase.proxy"); String[] browser_array = config.getStringArray("Tests.TestCase.browser"); String[] bandwidth_array = config.getStringArray("Tests.TestCase.network.bandwidth"); String[] delay_array = config.getStringArray("Tests.TestCase.network.delay"); String[] packetLoss_array = config.getStringArray("Tests.TestCase.network.packet-loss"); List<TestCase> tests = new ArrayList<TestCase>(); for (int i = 0; i < url_array.length; i++) { Integer bandwidth = new Integer(bandwidth_array[i]); Integer delay = new Integer(delay_array[i]); Integer packetLoss = new Integer(packetLoss_array[i]); Network network = new Network(bandwidth, delay, packetLoss); TestCase testCase = new TestCase(url_array[i], proxy_array[i], browser_array[i], network); tests.add(testCase);/* w w w .j av a 2s . c om*/ } return tests.toArray(new TestCase[tests.size()]); }
From source file:org.craftercms.engine.util.config.TargetingProperties.java
/** * Returns the list of available target IDs. *///from ww w . ja va2 s . c o m public static String[] getAvailableTargetIds() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getStringArray(AVAILABLE_TARGET_IDS_CONFIG_KEY); } else { return null; } }
From source file:org.craftercms.engine.util.config.TargetingProperties.java
/** * Returns the folders that will be handled for tageted content. *///from w w w.j a va2s .c o m public static String[] getRootFolders() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getStringArray(ROOT_FOLDERS_CONFIG_KEY); } else { return null; } }
From source file:org.eclipse.jubula.documentation.gen.ConfigLoader.java
/** * The constructor.//from w ww . j a v a 2 s . c o m */ private ConfigLoader() { Configuration conf; try { conf = new PropertiesConfiguration(RESOURCES_TEXGEN_PROPERTIES); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } String[] groups = conf.getStringArray(TEX_GEN_GROUPS); for (int i = 0; i < groups.length; i++) { String group = groups[i]; m_groups.add(new ConfigGroup(group, conf)); } m_toolkitConfig = new ToolkitConfig(conf.getString(BASEDIR), conf.getString(XML_PATH), conf.getString(RESOURCE_BUNDLE_PATH), conf.getString(RESOURCE_BUNDLE_FQN), conf.getString(OUTPUTDIR), conf.getList(TOOLKIT_NAMES)); }
From source file:org.eclipse.jubula.documentation.gen.ErrorConfigLoader.java
/** * The constructor.//from ww w . ja va 2s . c o m */ public ErrorConfigLoader() { Configuration conf; try { conf = new PropertiesConfiguration(RESOURCES_TEXGEN_PROPERTIES); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } String[] groups = conf.getStringArray(TEX_GEN_GROUP); for (int i = 0; i < groups.length; i++) { String group = groups[i]; m_groups.add(new ConfigGroup(group, conf)); } }
From source file:org.investovator.core.commons.configuration.ConfigLoader.java
/** * * @param filePath specify path to the properties file * @throws ConfigurationException/* www .ja v a2s . co m*/ */ public static void loadProperties(String filePath) throws ConfigurationException { Configuration configuration = new PropertiesConfiguration(new File(filePath).getAbsolutePath()); Iterator<String> iterator = configuration.getKeys(); while (iterator.hasNext()) { String key = iterator.next(); String[] properties = configuration.getStringArray(key); StringBuilder value = new StringBuilder(properties[0]); for (int i = 1; i < properties.length; i++) { value.append(",").append(properties[i]); } System.setProperty(key, value.toString()); } }
From source file:org.jwebsocket.ldap.Main.java
private static void init() { // set your values here... LDAP_URL = "..."; BASE_DN_GROUPS = "..."; BASE_DN_USERS = "..."; USERNAME = "..."; PASSWORD = "..."; mTestDL0 = "..."; mTestDL1 = "..."; mTestUserNames = new String[] { "...", "...", "...", "..." }; mLog.info("jWebSocket LDAP examples"); Configuration lConfig = null; boolean lConfigLoaded; try {//from w ww. jav a2 s. c o m // loading properties files lConfig = new PropertiesConfiguration("private.properties"); } catch (ConfigurationException ex) { } if (null == lConfig) { mLog.info("Configuration file could not be opened."); return; } LDAP_URL = lConfig.getString("LDAPURL"); BASE_DN_GROUPS = lConfig.getString("BaseDNGroups"); BASE_DN_USERS = lConfig.getString("BaseDNUsers"); USERNAME = lConfig.getString("BindUsername"); PASSWORD = lConfig.getString("BindPassword"); mTestDL0 = lConfig.getString("TestDL0"); mTestDL1 = lConfig.getString("TestDL1"); mTestUserNames = lConfig.getStringArray("TestUserNames"); // TODO: Validate config data here! lConfigLoaded = true; if (!lConfigLoaded) { mLog.error("Config not loaded."); System.exit(1); } }