Example usage for java.util Properties keySet

List of usage examples for java.util Properties keySet

Introduction

In this page you can find the example usage for java.util Properties keySet.

Prototype

@Override
    public Set<Object> keySet() 

Source Link

Usage

From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java

/**
 * Construct the filters for queries//  w  ww .  j  av  a 2  s .c o m
 *
 * @param ldapfilters
 * @param config
 * @param isOrOperator
 * @return
 */
private ContainerCriteria getQueryFilters(Properties ldapfilters, AbstractConfig config, boolean isOrOperator) {
    ContainerCriteria filterQuery = null;
    if (ldapfilters.containsKey("*")) {
        // Search on all wildcards attributes
        String filterValue = ldapfilters.getProperty("*");
        if (CollectionUtils.isNotEmpty(config.getSearchWildcardsAttributes())) {
            for (String wildcardAttribute : config.getSearchWildcardsAttributes()) {
                if (filterQuery == null) {
                    filterQuery = query().where(wildcardAttribute).like(filterValue);
                } else {
                    addCriteriaToQuery(filterQuery, true, wildcardAttribute).like(filterValue);
                }
            }
        }
    } else {
        // consider the attributes
        Iterator<?> filterKeys = ldapfilters.keySet().iterator();
        while (filterKeys.hasNext()) {
            String filterName = (String) filterKeys.next();
            String filterValue = ldapfilters.getProperty(filterName);

            if (filterQuery == null) {
                filterQuery = query().where(filterName).like(filterValue);
            } else {
                addCriteriaToQuery(filterQuery, isOrOperator, filterName).like(filterValue);
            }
        }
    }
    return filterQuery;
}

From source file:org.apache.maven.plugin.invoker.AbstractInvokerMojo.java

/**
 * Runs the specified project.//from  ww  w. j a  va 2 s. com
 *
 * @param basedir           The base directory of the project, must not be <code>null</code>.
 * @param pomFile           The (already interpolated) POM file, may be <code>null</code> for a POM-less Maven invocation.
 * @param settingsFile      The (already interpolated) user settings file for the build, may be <code>null</code>. Will be
 *                          merged with the settings file of the invoking Maven process.
 * @param invokerProperties The properties to use.
 * @return <code>true</code> if the project was launched or <code>false</code> if the selector script indicated that
 *         the project should be skipped.
 * @throws org.apache.maven.plugin.MojoExecutionException
 *          If the project could not be launched.
 * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException
 *          If either a hook script or the build itself failed.
 */
private boolean runBuild(File basedir, File pomFile, File settingsFile, InvokerProperties invokerProperties)
        throws MojoExecutionException, RunFailureException {
    if (getLog().isDebugEnabled() && !invokerProperties.getProperties().isEmpty()) {
        Properties props = invokerProperties.getProperties();
        getLog().debug("Using invoker properties:");
        for (String key : new TreeSet<String>((Set) props.keySet())) {
            String value = props.getProperty(key);
            getLog().debug("  " + key + " = " + value);
        }
    }

    List<String> goals = getGoals(basedir);

    List<String> profiles = getProfiles(basedir);

    Map<String, Object> context = new LinkedHashMap<String, Object>();

    FileLogger logger = setupLogger(basedir);
    try {
        try {
            scriptRunner.run("selector script", basedir, selectorScript, context, logger,
                    BuildJob.Result.SKIPPED, false);
        } catch (RunErrorException e) {
            throw e;
        } catch (RunFailureException e) {
            return false;
        }

        scriptRunner.run("pre-build script", basedir, preBuildHookScript, context, logger,
                BuildJob.Result.FAILURE_PRE_HOOK, false);

        final InvocationRequest request = new DefaultInvocationRequest();

        request.setLocalRepositoryDirectory(localRepositoryPath);

        request.setInteractive(false);

        request.setShowErrors(showErrors);

        request.setDebug(debug);

        request.setShowVersion(showVersion);

        if (logger != null) {
            request.setErrorHandler(logger);

            request.setOutputHandler(logger);
        }

        if (mavenHome != null) {
            invoker.setMavenHome(mavenHome);
            request.addShellEnvironment("M2_HOME", mavenHome.getAbsolutePath());
        }

        if (mavenExecutable != null) {
            invoker.setMavenExecutable(new File(mavenExecutable));
        }

        if (javaHome != null) {
            request.setJavaHome(javaHome);
        }

        if (environmentVariables != null) {
            for (Map.Entry<String, String> variable : environmentVariables.entrySet()) {
                request.addShellEnvironment(variable.getKey(), variable.getValue());
            }
        }

        for (int invocationIndex = 1;; invocationIndex++) {
            if (invocationIndex > 1 && !invokerProperties.isInvocationDefined(invocationIndex)) {
                break;
            }

            request.setBaseDirectory(basedir);

            request.setPomFile(pomFile);

            request.setGoals(goals);

            request.setProfiles(profiles);

            request.setMavenOpts(mavenOpts);

            request.setOffline(false);

            request.setUserSettingsFile(settingsFile);

            Properties systemProperties = getSystemProperties(basedir,
                    invokerProperties.getSystemPropertiesFile(invocationIndex));
            request.setProperties(systemProperties);

            invokerProperties.configureInvocation(request, invocationIndex);

            if (getLog().isDebugEnabled()) {
                try {
                    getLog().debug("Using MAVEN_OPTS: " + request.getMavenOpts());
                    getLog().debug("Executing: " + new MavenCommandLineBuilder().build(request));
                } catch (CommandLineConfigurationException e) {
                    getLog().debug("Failed to display command line: " + e.getMessage());
                }
            }

            InvocationResult result;

            try {
                result = invoker.execute(request);
            } catch (final MavenInvocationException e) {
                getLog().debug("Error invoking Maven: " + e.getMessage(), e);
                throw new RunFailureException("Maven invocation failed. " + e.getMessage(),
                        BuildJob.Result.FAILURE_BUILD);
            }

            verify(result, invocationIndex, invokerProperties, logger);
        }

        scriptRunner.run("post-build script", basedir, postBuildHookScript, context, logger,
                BuildJob.Result.FAILURE_POST_HOOK, true);
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } finally {
        if (logger != null) {
            logger.close();
        }
    }
    return true;
}

From source file:de.innovationgate.utils.WGUtils.java

/**
 * Converts a {@link Properties} object to a {@link Map} with string generics.
 * Although {@link Properties} is only able to store String keys and values it inherits from Map<Object,Object> for funky reasons.
 * This method is a toolie to convert {@link Properties} to be usable as String map
 * @param props The properties object/*from   w w  w  . j av a  2 s . c  om*/
 */
public static Map<String, String> propertiesToStringMap(Properties props) {

    Map<String, String> map = new HashMap<String, String>();
    for (Object key : props.keySet()) {
        map.put((String) key, props.getProperty((String) key));
    }
    return map;

}

From source file:cn.calm.osgi.conter.FelixOsgiHost.java

protected void startFelix() {

    // load properties from felix embedded file
    Properties configProps = getProperties("default.properties");

    // Copy framework properties from the system properties.
    FelixPropertiesUtil.copySystemProperties(configProps);
    replaceSystemPackages(configProps);/*from ww w . jav  a2 s . co m*/

    // struts, xwork and felix exported packages
    Properties strutsConfigProps = getProperties("osgi.properties");
    addExportedPackages(strutsConfigProps, configProps);

    // find bundles and adde em to autostart property
    addAutoStartBundles(configProps);

    // Bundle cache
    String storageDir = System.getProperty("java.io.tmpdir") + ".felix-cache";
    configProps.setProperty(Constants.FRAMEWORK_STORAGE, storageDir);
    if (LOG.isDebugEnabled())
        LOG.debug("Storing bundles at [#0]", storageDir);

    String cleanBundleCache = getServletContextParam("struts.osgi.clearBundleCache", "true");
    if ("true".equalsIgnoreCase(cleanBundleCache)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Clearing bundle cache");
        configProps.put(FelixConstants.FRAMEWORK_STORAGE_CLEAN,
                FelixConstants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
    }

    configProps.put(FelixConstants.SERVICE_URLHANDLERS_PROP, "false");
    configProps.put(FelixConstants.LOG_LEVEL_PROP, getServletContextParam("struts.osgi.logLevel", "3"));
    configProps.put(FelixConstants.BUNDLE_CLASSPATH, ".");

    configProps.put("org.osgi.framework.startlevel.beginning",
            getServletContextParam("struts.osgi.runLevel", "3"));
    //
    try {
        Map<String, String> map = new TreeMap<String, String>(new Comparator<String>() {
            public int compare(String obj1, String obj2) {
                // ???
                return obj1.compareTo(obj2);
            }
        });
        for (Object o : configProps.keySet()) {
            map.put(String.valueOf(o), configProps.getProperty(String.valueOf(o)));
        }
        FrameworkFactory ff = new FrameworkFactory();

        f = ff.newFramework(map);
        // f.start();
        f.init();

        AutoProcessor.process(map, f.getBundleContext());
        f.start();

    } catch (Exception ex) {
        throw new RuntimeException("Couldn't start Apache Felix", ex);
    }

    // add the bundle context to the ServletContext
    servletContext.setAttribute(OSGI_BUNDLE_CONTEXT, f.getBundleContext());
}

From source file:org.ohmage.jee.listener.ConfigurationFileImport.java

/**
 * Find the log file, if it exists, and add its properties to the system
 * properties.//from   w  w w . ja v a 2  s  .  c  o  m
 */
@Override
public void contextInitialized(ServletContextEvent event) {
    // An empty Properties object that will be populated with the default
    // configuration.
    Properties defaultProperties = new Properties();
    File defaultConfiguration = new File(event.getServletContext().getRealPath("/") + CONFIG_FILE_DEFAULT);
    try {
        defaultProperties.load(new FileReader(defaultConfiguration));
    }
    // The default properties file didn't exist, which is alarming.
    catch (FileNotFoundException e) {
        LOGGER.log(Level.WARNING,
                "The default properties file is missing: " + defaultConfiguration.getAbsolutePath(), e);
    }
    // There was an error reading the default properties file.
    catch (IOException e) {
        LOGGER.log(Level.WARNING, "There was an error reading the default properties " + "file: "
                + defaultConfiguration.getAbsolutePath(), e);
    }

    // Get a handler for the properties file based on the operating system.
    File propertiesFile;
    if (System.getProperty("os.name").contains("Windows")) {
        propertiesFile = new File(CONFIG_FILE_DEFAULT_WINDOWS);
    } else {
        propertiesFile = new File(CONFIG_FILE_DEFAULT_POSIX);
    }

    // Attempts to retrieve the custom configuration file and store it.
    Properties customProperties = new Properties();
    try {
        customProperties.load(new FileReader(propertiesFile));
        LOGGER.log(Level.INFO, "The properties file was imported: " + propertiesFile.getAbsolutePath());
    }
    // The properties file didn't exist, which is fine.
    catch (FileNotFoundException e) {
        LOGGER.log(Level.INFO, "The properties file does not exist: " + propertiesFile.getAbsolutePath());
    }
    // There was a problem reading the properties.
    catch (IOException e) {
        LOGGER.log(Level.WARNING,
                "There was an error reading the properties file: " + propertiesFile.getAbsolutePath(), e);
    }

    // Set the properties files.
    PROPERTIES_ARRAY[0] = defaultProperties;
    PROPERTIES_ARRAY[1] = customProperties;

    // Create a merged properties and save it.
    for (Object key : defaultProperties.keySet()) {
        PROPERTIES.put(key, defaultProperties.get(key));
    }
    for (Object key : customProperties.keySet()) {
        PROPERTIES.put(key, customProperties.get(key));
    }
}

From source file:com.jaspersoft.jasperserver.api.metadata.olap.service.impl.OlapConnectionServiceImpl.java

public OlapConnection getOlapConnection(ExecutionContext context, OlapClientConnection conn) {
    Util.PropertyList propList = getOlapConnectProperties(context, conn);

    Properties props = new Properties();
    String driverClass = null;/*from w  ww . j a  v  a  2  s  .  c om*/
    String urlPrefix = null;
    for (Pair<String, String> pair : propList) {
        if (pair.getKey().equals(OLAP4J_DRIVER)) {
            driverClass = pair.getValue();
        } else if (pair.getKey().equals(OLAP4J_URL_PREFIX)) {
            urlPrefix = pair.getValue();
        } else {
            props.put(pair.getKey(), pair.getValue());
        }
    }

    //OLAP4J cache configuration
    if (getOLAP4J_CACHE() != null && getOLAP4J_CACHE().length() > 0) {
        props.put("Cache", getOLAP4J_CACHE());
        props.put("Cache.Name", getOLAP4J_CACHE_NAME());
        props.put("Cache.Mode", getOLAP4J_CACHE_MODE());
        props.put("Cache.Timeout", getOLAP4J_CACHE_TIMEOUT());
        props.put("Cache.Size", getOLAP4J_CACHE_SIZE());
    }

    if (log.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();

        sb.append("OlapConnectionProperties Full Set: ");
        for (Pair<String, String> pair : propList) {
            sb.append("key='" + pair.getKey() + "', val='" + pair.getValue() + "', ");
        }

        sb.append("\nOlapConnectionProperties Driver Set: ");
        for (Object key : props.keySet()) {
            sb.append("key='" + key + "', val='" + props.get(key) + "', ");
        }

        sb.append("\nDriver Class='" + (driverClass == null ? "NULL" : driverClass) + "'");
        sb.append("\n   urlPrefix='" + (urlPrefix == null ? "NULL" : urlPrefix) + "'");

        log.debug(sb.toString());
    }

    // load driver  and Connection
    java.sql.Connection rConnection = null;
    try {
        jdbcDriverService.register(driverClass);
        rConnection = java.sql.DriverManager.getConnection(urlPrefix, props);
    } catch (MondrianException e) {
        String dataSource = (String) props.get(OLAP_CONNECTION_JNDI_DATA_SOURCE);

        if (ExceptionUtils.indexOfThrowable(e, NoInitialContextException.class) > 0 && dataSource != null) {
            Map<String, String> jdbcProperties = jndiFallbackResolver.getJdbcPropertiesMap(dataSource);

            try {
                // Remove JNDI reference.
                props.remove(OLAP_CONNECTION_JNDI_DATA_SOURCE);

                // Add JDBC url, username and password.
                props.put(OLAP_CONNECTION_JDBC, jdbcProperties.get(JndiFallbackResolver.JDBC_URL));
                props.put(OLAP_CONNECTION_JDBC_USER, jdbcProperties.get(JndiFallbackResolver.JDBC_USERNAME));
                props.put(OLAP_CONNECTION_JDBC_PASSWORD,
                        jdbcProperties.get(JndiFallbackResolver.JDBC_PASSWORD));

                rConnection = java.sql.DriverManager.getConnection(urlPrefix, props);
            } catch (Throwable t) {
                throw new JSException("Error getting connection from jndi fallback properties.", t);
            }
        } else {
            throw e;
        }
    } catch (Throwable t) {
        throw new JSException("error loading olap4j driver and getting Connection '" + driverClass + "'", t);
    }

    ((OlapConnection) rConnection).setLocale(LocaleContextHolder.getLocale());

    return (OlapConnection) rConnection;
}

From source file:com.ephesoft.dcma.gwt.core.server.BatchClassUtil.java

public static void createSamplePatternDTO(SamplePatternDTO samplePatterns, Properties properties) {
    Set<Object> keys = properties.keySet();
    Map<String, String> patternValueVPatternDesc = new HashMap<String, String>();

    for (Iterator<Object> iterator = keys.iterator(); iterator.hasNext();) {
        String patternValue = (String) iterator.next();
        String patternDescription = properties.getProperty(patternValue);
        patternValueVPatternDesc.put(patternValue, patternDescription);
    }//  www .j  a  v  a  2  s  . com
    samplePatterns.setPatternValueMap(patternValueVPatternDesc);
}

From source file:org.apache.openaz.xacml.admin.jpa.PIPConfiguration.java

@Transient
protected void readProperties(String id, Properties properties) throws PIPException {
    ////from ww  w  .  j  av  a  2  s .  c om
    // Save the id if we don't have one already
    //
    if (this.id == 0) {
        try {
            this.id = Integer.parseInt(id);
        } catch (NumberFormatException e) {
            logger.error("Convert id to integer failed: " + id);
        }
    }
    //
    // Get its classname, this MUST exist.
    //
    this.classname = properties.getProperty(id + ".classname");
    if (this.classname == null) {
        throw new PIPException("PIP Engine defined without a classname");
    }
    //
    // These classes we know for sure require resolvers.
    //
    if (this.classname.equals(JDBCEngine.class.getCanonicalName())) {
        this.setRequiresResolvers(true);
        this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_SQL));
    } else if (this.classname.equals(LDAPEngine.class.getCanonicalName())) {
        this.setRequiresResolvers(true);
        this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_LDAP));
    } else if (this.classname.equals(HyperCSVEngine.class.getCanonicalName())) {
        this.setRequiresResolvers(true);
        this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_HYPERCSV));
    } else if (this.classname.equals(CSVEngine.class.getCanonicalName())) {
        this.setRequiresResolvers(true);
        this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CSV));
    } else {
        //
        // Assume it does not require resolvers for now, if we encounter
        // one then we will change it. The user can always change it via the gui.
        // 
        this.setRequiresResolvers(false);
        this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CUSTOM));
    }
    //
    // Go through each property
    //
    for (Object name : properties.keySet()) {
        if (name.toString().startsWith(id) == false || name.equals(id + ".classname")) {
            continue;
        }
        if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
            this.name = properties.getProperty(name.toString());
        } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
            this.description = properties.getProperty(name.toString());
        } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
            this.issuer = properties.getProperty(name.toString());
        } else if (name.equals(id + ".resolvers")) {
            //
            // It has resolvers, make sure this is set to true if
            // it has been already.
            //
            this.setRequiresResolvers(true);
            //
            // Parse the resolvers
            //
            Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver",
                    properties.getProperty(name.toString()), properties,
                    ((XacmlAdminUI) UI.getCurrent()).getUserid());
            for (PIPResolver resolver : resolvers) {
                this.addPipresolver(resolver);
            }
            // Ignore {id}.resolver: the PIPResolver will parse these values
        } else if (!name.toString().startsWith(id + ".resolver")) {
            //
            // Config Parameter
            //
            this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1),
                    properties.getProperty(name.toString())));
        }
    }
    //
    // Make sure we have a name at least
    //
    if (this.name == null) {
        this.name = id;
    }
}

From source file:org.apache.jackrabbit.core.RepositoryImpl.java

/**
 * Initializes the repository descriptors by executing the following steps:
 * <ul>//from  w ww.  j av a 2 s.c  om
 * <li>Sets standard descriptors</li>
 * <li>{@link #getCustomRepositoryDescriptors()} is called
 * afterwards in order to add custom/overwrite standard repository descriptors.</li>
 * </ul>
 *
 * @throws RepositoryException
 */
protected void initRepositoryDescriptors() throws RepositoryException {

    ValueFactory valFactory = ValueFactoryImpl.getInstance();
    Value valTrue = valFactory.createValue(true);
    Value valFalse = valFactory.createValue(false);

    setDescriptor(Repository.REP_NAME_DESC, "Jackrabbit");
    setDescriptor(Repository.REP_VENDOR_DESC, "Apache Software Foundation");
    setDescriptor(Repository.REP_VENDOR_URL_DESC, "http://jackrabbit.apache.org/");
    setDescriptor(Repository.SPEC_NAME_DESC, "Content Repository API for Java(TM) Technology Specification");
    setDescriptor(Repository.SPEC_VERSION_DESC, "2.0");

    setDescriptor(Repository.IDENTIFIER_STABILITY, Repository.IDENTIFIER_STABILITY_INDEFINITE_DURATION);
    setDescriptor(Repository.LEVEL_1_SUPPORTED, valTrue);
    setDescriptor(Repository.LEVEL_2_SUPPORTED, valTrue);
    setDescriptor(Repository.WRITE_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_INHERITANCE,
            Repository.NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, valFalse);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, valTrue);

    Value[] types = new Value[] { valFactory.createValue(PropertyType.BINARY),
            valFactory.createValue(PropertyType.BOOLEAN), valFactory.createValue(PropertyType.DATE),
            valFactory.createValue(PropertyType.DECIMAL), valFactory.createValue(PropertyType.DOUBLE),
            valFactory.createValue(PropertyType.LONG), valFactory.createValue(PropertyType.NAME),
            valFactory.createValue(PropertyType.PATH), valFactory.createValue(PropertyType.REFERENCE),
            valFactory.createValue(PropertyType.STRING), valFactory.createValue(PropertyType.URI),
            valFactory.createValue(PropertyType.WEAKREFERENCE),
            valFactory.createValue(PropertyType.UNDEFINED) };
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, types);

    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, valTrue);
    setDescriptor(Repository.NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, valFalse);
    setDescriptor(Repository.OPTION_ACCESS_CONTROL_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_JOURNALED_OBSERVATION_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_LIFECYCLE_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_LOCKING_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_QUERY_SQL_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_RETENTION_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_SHAREABLE_NODES_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_SIMPLE_VERSIONING_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_TRANSACTIONS_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_UNFILED_CONTENT_SUPPORTED, valFalse);
    setDescriptor(Repository.OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_VERSIONING_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_XML_EXPORT_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_XML_IMPORT_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_ACTIVITIES_SUPPORTED, valTrue);
    setDescriptor(Repository.OPTION_BASELINES_SUPPORTED, valTrue);

    setDescriptor(Repository.QUERY_FULL_TEXT_SEARCH_SUPPORTED, valTrue);
    setDescriptor(Repository.QUERY_JOINS, Repository.QUERY_JOINS_INNER_OUTER);

    Value[] languages = new Value[] { valFactory.createValue("javax.jcr.query.JCR-JQOM"),
            valFactory.createValue("javax.jcr.query.JCR-SQL2") };
    setDescriptor(Repository.QUERY_LANGUAGES, languages);

    setDescriptor(Repository.QUERY_STORED_QUERIES_SUPPORTED, valTrue);
    setDescriptor(Repository.QUERY_XPATH_POS_INDEX, valTrue);
    // Disabled since in default configuration document order is not supported.
    // See https://issues.apache.org/jira/browse/JCR-1237 for details
    setDescriptor(Repository.QUERY_XPATH_DOC_ORDER, valFalse);

    // now set customized repository descriptor values (if any exist)
    Properties props = getCustomRepositoryDescriptors();
    if (props != null) {
        for (Object o : props.keySet()) {
            String key = (String) o;
            setDescriptor(key, props.getProperty(key));
        }
    }
}

From source file:org.apache.maven.archetype.creator.FilesetArchetypeCreator.java

private void processFileSet(File basedir, File archetypeFilesDirectory, String directory,
        List<String> fileSetResources, boolean packaged, String packageName, Properties reverseProperties,
        String defaultEncoding) throws IOException {
    String packageAsDirectory = StringUtils.replace(packageName, ".", File.separator);

    getLogger().debug("Package as Directory: Package:" + packageName + "->" + packageAsDirectory);

    for (String inputFileName : fileSetResources) {
        String initialFilename = packaged
                ? StringUtils.replace(inputFileName, packageAsDirectory + File.separator, "")
                : inputFileName;//from   w w w  . ja v  a  2 s .  c  o  m

        getLogger().debug("InputFileName:" + inputFileName);

        File inputFile = new File(basedir, inputFileName);

        FileCharsetDetector detector = new FileCharsetDetector(inputFile);

        String fileEncoding = detector.isFound() ? detector.getCharset() : defaultEncoding;

        String initialcontent = IOUtil.toString(new FileInputStream(inputFile), fileEncoding);

        for (Iterator<?> properties = reverseProperties.keySet().iterator(); properties.hasNext();) {
            String property = (String) properties.next();

            if (initialcontent.indexOf("${" + property + "}") > 0) {
                getLogger().warn("Archetype uses ${" + property + "} for internal processing, but file "
                        + inputFile + " contains this property already");
            }
        }

        String content = getReversedContent(initialcontent, reverseProperties);
        String outputFilename = getReversedFilename(initialFilename, reverseProperties);

        getLogger().debug("OutputFileName:" + outputFilename);

        File outputFile = new File(archetypeFilesDirectory, outputFilename);
        outputFile.getParentFile().mkdirs();

        org.apache.commons.io.IOUtils.write(content, new FileOutputStream(outputFile), fileEncoding);
    }
}