List of usage examples for org.apache.commons.collections ExtendedProperties getStringArray
public String[] getStringArray(String key)
From source file:meta.util.I18NMerger.java
/** * @param args the command line arguments *//* w w w .j a v a2s.c om*/ public static void main(String[] args) { if (args.length == 0) { ExtendedProperties properties = PropertiesGetter.getPrivateProperties(); args = properties.getStringArray(I18NMerger.class.getName() + ".args"); } for (int i = 0; i < args.length; i++) { Merger.merge(args[i]); } }
From source file:meta.util.SQLWriter.java
public static void main(String[] args) { if (args.length == 0) { ExtendedProperties properties = PropertiesGetter.getPrivateProperties(); args = properties.getStringArray(SQLWriter.class.getName() + ".args"); }/*from w w w .j a v a 2 s . c o m*/ SqlWriter writer = new SqlWriter(args); if (writer.isInitialised()) { // writer.setSelectTemplatesPath("templates/meta/java/sql"); EntidadesComunes.setAlertLoggingLevel(LoggingLevel.OFF); EntidadesComunes entidadesComunes = new EntidadesComunes(); entidadesComunes.setUserEntityClass(meta.entidad.comun.control.acceso.Usuario.class); if (entidadesComunes.build()) { writer.setTablesExcludeSet(TABLAS_EXCLUIDAS); writer.setTablesInheritMap(entidadesComunes.getTablesMap()); writer.setLoadConfigurationTables(true); writer.write(); } } }
From source file:meta.util.SQLMerger.java
public static void main(String[] args) { if (args.length == 0) { ExtendedProperties properties = PropertiesGetter.getPrivateProperties(); args = properties.getStringArray(SQLMerger.class.getName() + ".args"); }//from w w w . j av a2 s . com SqlMerger merger = new SqlMerger(args); if (merger.isInitialised()) { // Use method setOldDataFolder to specify the absolute path of the folder used by COPY commands. // By default or by specifying a null value, the folder will be a subfolder of the test folder. // PostgreSQL user must be authorized to read and write files in the specified folder. String folder = defaultOldDataFolder(merger); merger.setOldDataFolder(folder); logger.info("oldDataFolder=" + merger.getOldDataFolder()); ConfiguracionBasica.setAlertLoggingLevel(LoggingLevel.OFF); ConfiguracionBasica configuracionBasica = new ConfiguracionBasica(); if (configuracionBasica.build()) { merger.setTablesLoadMap(configuracionBasica.getTablesMap()); merger.merge(); } } }
From source file:adalid.util.Utility.java
private static String[] getArguments(Class<?> clazz, ExtendedProperties properties, Level level) { if (properties == null) { logger.log(level, ARGS_FAILED + "; properties is null"); } else if (properties.isEmpty()) { logger.log(level, ARGS_FAILED + "; properties is empty"); } else {// w ww .ja v a 2 s . com String key = clazz.getName() + ARGS_SUFFIX; try { String[] strings = properties.getStringArray(key); if (strings == null || strings.length == 0) { logger.log(level, ARGS_FAILED + "; property " + key + " not found"); } else { return strings; } } catch (Exception e) { logger.log(level, ARGS_FAILED + "; " + key + " not properly defined (" + e + ")"); } } return null; }
From source file:adalid.commons.properties.PropertiesHandler.java
public static void printExtendedProperties(ExtendedProperties extendedProperties) { ArrayList<String> list = new ArrayList<>(); for (Iterator i = extendedProperties.getKeys(); i.hasNext();) { list.add((String) i.next()); }//from w ww. jav a 2 s.c om String[] names = new String[list.size()]; list.toArray(names); Arrays.sort(names); String[] values; for (String name : names) { values = extendedProperties.getStringArray(name); logger.trace(name + " = " + (StringUtils.containsIgnoreCase(name, "password") ? "***" : getArrayString(values))); } }
From source file:bboss.org.apache.velocity.runtime.resource.loader.URLResourceLoader.java
/** * @see bboss.org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties) */// ww w .j av a 2 s.co m public void init(ExtendedProperties configuration) { log.trace("URLResourceLoader : initialization starting."); roots = configuration.getStringArray("root"); if (log.isDebugEnabled()) { for (int i = 0; i < roots.length; i++) { log.debug("URLResourceLoader : adding root '" + roots[i] + "'"); } } timeout = configuration.getInt("timeout", -1); if (timeout > 0) { try { Class[] types = new Class[] { Integer.TYPE }; Method conn = URLConnection.class.getMethod("setConnectTimeout", types); Method read = URLConnection.class.getMethod("setReadTimeout", types); timeoutMethods = new Method[] { conn, read }; log.debug("URLResourceLoader : timeout set to " + timeout); } catch (NoSuchMethodException nsme) { log.debug("URLResourceLoader : Java 1.5+ is required to customize timeout!", nsme); timeout = -1; } } // init the template paths map templateRoots = new HashMap(); log.trace("URLResourceLoader : initialization complete."); }
From source file:com.xindian.mvc.result.velocity.WebappResourceLoader.java
/** * This is abstract in the base class, so we need it. <br> * NOTE: this expects that the ServletContext has already been placed in the * runtime's application attributes under its full class name (i.e. * "javax.servlet.ServletContext").// w w w .ja va2 s . co m * * @param configuration * the {@link ExtendedProperties} associated with this resource * loader. */ public void init(ExtendedProperties configuration) { log.trace("WebappResourceLoader: initialization starting."); /* get configured paths */ paths = configuration.getStringArray("path"); if (paths == null || paths.length == 0) { paths = new String[1]; paths[0] = "/"; } else { /* make sure the paths end with a '/' */ for (int i = 0; i < paths.length; i++) { if (!paths[i].endsWith("/")) { paths[i] += '/'; } log.info("WebappResourceLoader: added template path :[" + paths[i] + "]"); } } /* get the ServletContext */ Object obj = rsvc.getApplicationAttribute(ServletContext.class.getName()); if (obj instanceof ServletContext) { servletContext = (ServletContext) obj; } else { log.error("WebappResourceLoader: unable to retrieve ServletContext"); } /* init the template paths map */ templatePaths = new HashMap(); log.trace("WebappResourceLoader: initialization complete."); }
From source file:com.alkacon.opencms.formgenerator.CmsFieldFactory.java
/** * Default constructor.<p>// w ww. j a v a 2 s . c o m */ private CmsFieldFactory() { super(); m_registeredFieldTypes = new HashMap<String, String>(20); // register all the standard OpenCms field types registerFieldType(CmsCheckboxField.getStaticType(), CmsCheckboxField.class.getName()); registerFieldType(CmsEmailField.getStaticType(), CmsEmailField.class.getName()); registerFieldType(CmsFileUploadField.getStaticType(), CmsFileUploadField.class.getName()); registerFieldType(CmsHiddenField.getStaticType(), CmsHiddenField.class.getName()); registerFieldType(CmsRadioButtonField.getStaticType(), CmsRadioButtonField.class.getName()); registerFieldType(CmsSelectionField.getStaticType(), CmsSelectionField.class.getName()); registerFieldType(CmsTextField.getStaticType(), CmsTextField.class.getName()); registerFieldType(CmsTextareaField.getStaticType(), CmsTextareaField.class.getName()); registerFieldType(CmsEmptyField.getStaticType(), CmsEmptyField.class.getName()); registerFieldType(CmsPrivacyField.getStaticType(), CmsPrivacyField.class.getName()); registerFieldType(CmsDynamicField.getStaticType(), CmsDynamicField.class.getName()); registerFieldType(CmsTableField.getStaticType(), CmsTableField.class.getName()); registerFieldType(CmsPasswordField.getStaticType(), CmsPasswordField.class.getName()); registerFieldType(CmsPagingField.getStaticType(), CmsPagingField.class.getName()); registerFieldType(CmsDisplayField.getStaticType(), CmsDisplayField.class.getName()); registerFieldType(CmsHiddenDisplayField.getStaticType(), CmsHiddenDisplayField.class.getName()); File propertyFile = null; try { // register all custom field types declared in a property file. // since custom fields are optional, the property file doesn't have to exist necessarily in the file system. // this file should contain a mapping of field type names to a Java classes separated by a colon ":", e.g.: // FIELDS=<fieldtype>:<java class>,...,<fieldtype>:<java class> propertyFile = new File(CUSTOM_FORM_FIELD_PROPERTIES); if (propertyFile.exists()) { ExtendedProperties fieldProperties = new ExtendedProperties(); fieldProperties.load(new FileInputStream(propertyFile)); Iterator<String> i = fieldProperties.keySet().iterator(); while (i.hasNext()) { String key = i.next(); if (!"FIELDS".equalsIgnoreCase(key)) { continue; } String[] values = fieldProperties.getStringArray(key); if ((values == null) || (values.length == 0)) { continue; } for (int j = 0, n = values.length; j < n; j++) { String field = values[j]; int index = field.indexOf(":"); if (index == -1) { continue; } String fieldType = field.substring(0, index); String fieldClass = field.substring(index + 1, field.length()); registerFieldType(fieldType, fieldClass); } } } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_READING_CUSTOM_FORM_FIELD_PROPERTIES_1, propertyFile == null ? CUSTOM_FORM_FIELD_PROPERTIES : propertyFile.getAbsolutePath()), e); } } }
From source file:com.alkacon.opencms.v8.formgenerator.CmsFieldFactory.java
/** * Default constructor.<p>//from w ww . j ava2s . c om */ private CmsFieldFactory() { super(); m_registeredFieldTypes = new HashMap<String, String>(20); // register all the standard OpenCms field types registerFieldType(CmsCheckboxField.getStaticType(), CmsCheckboxField.class.getName()); registerFieldType(CmsEmailField.getStaticType(), CmsEmailField.class.getName()); registerFieldType(CmsFileUploadField.getStaticType(), CmsFileUploadField.class.getName()); registerFieldType(CmsHiddenField.getStaticType(), CmsHiddenField.class.getName()); registerFieldType(CmsRadioButtonField.getStaticType(), CmsRadioButtonField.class.getName()); registerFieldType(CmsSelectionField.getStaticType(), CmsSelectionField.class.getName()); registerFieldType(CmsTextField.getStaticType(), CmsTextField.class.getName()); registerFieldType(CmsTextareaField.getStaticType(), CmsTextareaField.class.getName()); registerFieldType(CmsEmptyField.getStaticType(), CmsEmptyField.class.getName()); registerFieldType(CmsPrivacyField.getStaticType(), CmsPrivacyField.class.getName()); registerFieldType(CmsDynamicField.getStaticType(), CmsDynamicField.class.getName()); registerFieldType(CmsTableField.getStaticType(), CmsTableField.class.getName()); registerFieldType(CmsPasswordField.getStaticType(), CmsPasswordField.class.getName()); registerFieldType(CmsPagingField.getStaticType(), CmsPagingField.class.getName()); registerFieldType(CmsDisplayField.getStaticType(), CmsDisplayField.class.getName()); registerFieldType(CmsHiddenDisplayField.getStaticType(), CmsHiddenDisplayField.class.getName()); registerFieldType(CmsParameterField.getStaticType(), CmsParameterField.class.getName()); File propertyFile = null; try { // register all custom field types declared in a property file. // since custom fields are optional, the property file doesn't have to exist necessarily in the file system. // this file should contain a mapping of field type names to a Java classes separated by a colon ":", e.g.: // FIELDS=<fieldtype>:<java class>,...,<fieldtype>:<java class> propertyFile = new File(CUSTOM_FORM_FIELD_PROPERTIES); if (propertyFile.exists()) { ExtendedProperties fieldProperties = new ExtendedProperties(); fieldProperties.load(new FileInputStream(propertyFile)); @SuppressWarnings("unchecked") Iterator<String> i = fieldProperties.keySet().iterator(); while (i.hasNext()) { String key = i.next(); if (!"FIELDS".equalsIgnoreCase(key)) { continue; } String[] values = fieldProperties.getStringArray(key); if ((values == null) || (values.length == 0)) { continue; } for (int j = 0, n = values.length; j < n; j++) { String field = values[j]; int index = field.indexOf(":"); if (index == -1) { continue; } String fieldType = field.substring(0, index); String fieldClass = field.substring(index + 1, field.length()); registerFieldType(fieldType, fieldClass); } } } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_READING_CUSTOM_FORM_FIELD_PROPERTIES_1, propertyFile.getAbsolutePath()), e); } } }
From source file:adalid.util.meta.sql.MetaPlatformSql.java
private void readPlatform(WriterContext basicWriterContext) { File platformPropertiesFile = platformBean.getPropertiesFile(); logger.info("propertiesFile=" + platformPropertiesFile.getPath()); try {//from www . j a v a 2s. c o m VelocityContext platformContext = basicWriterContext.getVelocityContextClone(); platformContext.put(VC_PLATFORM, platform); TLB.setProgrammers(basicWriterContext.programmers); TLB.setWrapperClasses(basicWriterContext.wrapperClasses); putProperties(platformContext, platformPropertiesFile); Properties properties = mergeProperties(platformContext, platformPropertiesFile); putStrings(platformContext, properties); WriterContext platformWriterContext = newWriterContext(platformContext); File platformsFolder = platformPropertiesFile.getParentFile(); ExtendedProperties platformExtendedProperties = PropertiesHandler .getExtendedProperties(platformPropertiesFile); String[] pathnames = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH); String[] pathfilters = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH_FILTER); Map<String, File> folders = new LinkedHashMap<>(); if (pathnames == null || pathnames.length == 0) { } else { for (File folder : bootstrappingPlatformsFolders) { folders.putAll(FilUtils.directoriesMap(folder, pathnames, folder)); } } if (pathfilters != null && pathfilters.length > 0) { String[] keyArray = folders.keySet().toArray(new String[folders.keySet().size()]); String slashedFilter, slashedPath; for (String pathfilter : pathfilters) { slashedFilter = pathfilter.replace(FILE_SEPARATOR, "/"); for (String key : keyArray) { slashedPath = key.replace(FILE_SEPARATOR, "/") + "/"; if (slashedPath.contains(slashedFilter)) { folders.remove(key); logger.debug(pathfilter + " excludes " + key); } } } } File[] templateFiles; TemplateBean templateBean; String platformsFolderPath = platformsFolder.getPath(); // + FILE_SEPARATOR; for (File folder : folders.values()) { log(_detailLevel, "read", "path=" + StringUtils.removeStart(folder.getPath(), platformsFolderPath)); templateFiles = folder.listFiles(propertiesFileFilter); Arrays.sort(templateFiles); for (File templatePropertiesFile : templateFiles) { templateBean = new TemplateBean(platformBean, templatePropertiesFile); readTemplate(platformWriterContext, templateBean); templates++; } } platforms++; } catch (Throwable throwable) { error(throwable); } printSummary(); }