Package org.apache.avalon.framework.configuration

Examples of org.apache.avalon.framework.configuration.Configuration


        ArrayList list = new ArrayList();

        if (configurations.length < 1) return (list);

        for (int x = 0; x < configurations.length; x++) {
            Configuration configuration = configurations[x];
            String name = configuration.getAttribute("name", null);
            if (name == null) {
                throw new ConfigurationException("No name specified for parameter at "
                        + configuration.getLocation());
            }

            String value = configuration.getAttribute("value", null);
            if (value != null) list.add(new NameValuePair(name, value));

            Configuration subconfigurations[] = configuration.getChildren("value");
            for (int y = 0; y < subconfigurations.length; y++) {
                value = subconfigurations[y].getValue(null);
                if (value != null) list.add(new NameValuePair(name, value));
            }
        }
View Full Code Here


            synchronized (configuredConfigurations) {
                if (!configuredConfigurations.contains(conf)) {
                    configuredConfigurations.add( conf );

                    // test for handlers
                    Configuration handlersWrapper = conf.getChild("handlers", false);
                    if ( null != handlersWrapper ) {
                        Configuration[] handlers = handlersWrapper.getChildren("handler");
                        if ( null != handlers ) {
                            ArrayList al = new ArrayList(4);
                            for(int i=0; i<handlers.length;i++) {
                                // check unique name
                                final String name = handlers[i].getAttribute("name");
View Full Code Here

     * Add to available handlers
     */
    public void addAvailableHandlers(Configuration  conf)
    throws ConfigurationException {
        if ( null != conf ) {
            final Configuration handlersConf = conf.getChild("handlers", false);
            if ( null != handlersConf ) {
                Configuration[] handlers = handlersConf.getChildren("handler");
                if ( null != handlers ) {
                    for(int i=0; i < handlers.length; i++) {
                        final String name = handlers[i].getAttribute("name");
                        final Object o = configuredHandlers.get(name);
                        if ( null == o)
View Full Code Here

     *
     * @param  configuration               Description of Parameter
     * @exception  ConfigurationException  Description of Exception
     */
    public void configure(Configuration configuration) throws ConfigurationException {
        Configuration child;

        child = configuration.getChild("follow-links");
        this.followLinks = child.getValueAsBoolean();

        /* FIXME (SM): the code below is dead. What was it supposed to do?
        child = configuration.getChild("headers");
        Parameters headers = Parameters.fromConfiguration(child);
        */
 
View Full Code Here

     * Configurable interface.
     */
    public void configure(Configuration myConfiguration)
    throws ConfigurationException {
        // no sync required
        Configuration mediaConf = myConfiguration.getChild("mediatypes", false);
        if (mediaConf == null) {
            // default configuration
            this.defaultMediaType = "html";
        } else {
            this.defaultMediaType = mediaConf.getAttribute("default", "html");
        }
        this.mediaTypeNames = new String[1];
        this.mediaTypeNames[0] = this.defaultMediaType;
        boolean found;
        int     i;
        String  name;

        Configuration[] childs = mediaConf.getChildren("media");
        PreparedMediaType[] array = new PreparedMediaType[0];
        PreparedMediaType[] copy;
        Configuration current;
        if (childs != null) {
            for(int x = 0; x < childs.length; x++) {
                current = childs[x];
                copy = new PreparedMediaType[array.length + 1];
                System.arraycopy(array, 0, copy, 0, array.length);
                array = copy;
                name = current.getAttribute("name");
                array[array.length-1] = new PreparedMediaType(name, current.getAttribute("useragent"));
                found = false;
                i = 0;
                while ( i < this.mediaTypeNames.length && found == false) {
                    found = this.mediaTypeNames[i].equals(name);
                    i++;
View Full Code Here

            synchronized (session) {
                result = (Map)session.getAttribute(PortalConstants.ATTRIBUTE_CONFIGURATION + handlerName + ':' + appName);
                if (result == null) {

                    try {
                        Configuration config;

                        Configuration conf = this.getAuthenticationManager().getModuleConfiguration(PortalConstants.AUTHENTICATION_MODULE_NAME);
                        if (conf == null) {
                            throw new ProcessingException("portal: Configuration for application '" + appName + "' not found.");
                        }
                        result = new HashMap(10, 2);
                        // auth-redirect (optional)
                        config = conf.getChild("auth-redirect", false);
                        if (config != null) {
                            result.put(PortalConstants.CONF_AUTH_REDIRECT, config.getValue());
                        }

                        // portal-uri (required)
                        config = conf.getChild("portal-uri", false);
                        if (config == null) {
                            throw new ProcessingException("portal: portal-uri required for application '"+appName+"'");
                        }
                        result.put(PortalConstants.CONF_PORTAL_URI, config.getValue());

                        // profile-cache (optional)
                        config = conf.getChild("profile-cache", false);
                        if (config != null && config.getValueAsBoolean() == true) {
                            result.put(PortalConstants.CONF_PROFILE_CACHE, appName);
                        }

                        // parallel coplets
                        config = conf.getChild("process-coplets-parallel", false);
                        if (config != null) {
                            result.put(PortalConstants.CONF_PARALLEL_COPLETS, new Boolean(config.getValueAsBoolean(false)));
                        } else {
                            result.put(PortalConstants.CONF_PARALLEL_COPLETS, new Boolean(false));
                        }

                        // timeout
                        config = conf.getChild("default-coplet-timeout", false);
                        if (config != null) {
                            result.put(PortalConstants.CONF_COPLET_TIMEOUT, new Long(config.getValueAsLong(600000)));
                        } else {
                            result.put(PortalConstants.CONF_COPLET_TIMEOUT, new Long(600000));
                        }

                        // and now the profile
                        config = conf.getChild("profile", false);
                        if (config == null) throw new ProcessingException("portal: profile configuration required for application '" + appName + "'");
                        Configuration child;

                        // build resource (optional)
                        child = config.getChild("buildprofile", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_BUILD_RESOURCE, child.getAttribute("uri"));
                        }

                        // base resource, type is optional
                        child = config.getChild("layout-base", false);
                        if (child == null) {
                            throw new ProcessingException("portal: layout-base required for application '" + appName + "'");
                        }
                        result.put(PortalConstants.CONF_LAYOUTBASE_RESOURCE, child.getAttribute("uri"));
                        child = config.getChild("coplet-base", false);
                        if (child == null) {
                            throw new ProcessingException("portal: coplet-base required for application '" + appName + "'");
                        }
                        result.put(PortalConstants.CONF_COPLETBASE_RESOURCE, child.getAttribute("uri"));
                        child = config.getChild("type-base", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_TYPEBASE_RESOURCE, child.getAttribute("uri"));
                        }

                        // coplet base save (is optional)
                        child = config.getChild("coplet-base-save", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_COPLETBASE_SAVE_RESOURCE, child.getAttribute("uri"));
                        }

                        // global delta (load required)
                        child = config.getChild("global-delta-load", false);
                        if (child == null) {
                            throw new ProcessingException("portal: global-delta-load required for application '" + appName + "'");
                        }
                        result.put(PortalConstants.CONF_GLOBALDELTA_LOADRESOURCE, child.getAttribute("uri"));
                        child = config.getChild("global-delta-save", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_GLOBALDELTA_SAVERESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("global-type-delta", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_GLOBALDELTA_TYPERESOURCE, child.getAttribute("uri"));
                        }

                        // role delta (optional)
                        child = config.getChild("role-delta-load", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_ROLEDELTA_LOADRESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("role-delta-save", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_ROLEDELTA_SAVERESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("role-type-delta", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_ROLEDELTA_TYPERESOURCE, child.getAttribute("uri"));
                        }

                        // User delta
                        child = config.getChild("user-delta-load", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_USERDELTA_LOADRESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("user-delta-save", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_USERDELTA_SAVERESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("user-type-delta", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_USERDELTA_TYPERESOURCE, child.getAttribute("uri"));
                        }

                        // Personal information
                        child = config.getChild("user-status-load", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_STATUS_LOADRESOURCE, child.getAttribute("uri"));
                        }
                        child = config.getChild("user-status-save", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_STATUS_SAVERESOURCE, child.getAttribute("uri"));
                        }

                        // Admin Type profil
                        child = config.getChild("admin-type-base", false);
                        if (child != null) {
                            result.put(PortalConstants.CONF_ADMIN_TYPE_BASE, child.getAttribute("uri"));
                        }

                        // store the config in the session
                        session.setAttribute(PortalConstants.ATTRIBUTE_CONFIGURATION + handlerName + ':' + appName, result);
                    } catch (ConfigurationException conf) {
View Full Code Here

    public void configure(SourceResolver resolver,
                          Request        request,
                          Configuration  conf)
    throws ProcessingException, SAXException, IOException, ConfigurationException {
        // get login (required)
        Configuration child = conf.getChild("redirect-to", false);
        if (child == null)
            throw new ConfigurationException("Handler '"+this.name+"' needs a redirect-to URI.");
        this.redirectURI = child.getAttribute("uri");
        if ( this.redirectURI.startsWith("cocoon:") ) {
            final int pos = this.redirectURI.indexOf('/');
            if ( pos != -1 && this.redirectURI.length() > pos) {
                if (this.redirectURI.charAt(pos+1) == '/') {
                    this.redirectURI = this.redirectURI.substring(pos+2).trim();
                    this.redirectURI = request.getContextPath()+"/"+this.redirectURI;
                } else {
                    this.redirectURI = this.redirectURI.substring(pos+1).trim();
                }
            }
        }

        this.redirectParameters = SourceParameters.create(child);

        // get load resource (required)
        child = conf.getChild("authentication", false);
        if (child == null)
            throw new ConfigurationException("Handler '"+this.name+"' needs authentication configuration");
        this.authenticationResource = child.getAttribute("uri");
        this.authenticationResourceParameters = SourceParameters.create(child);

        // get load resource (optional)
        child = conf.getChild("load", false);
        if (child != null) {
            this.loadResource = child.getAttribute("uri");
            this.loadResourceParameters = SourceParameters.create(child);
        }

        // get save resource (optional)
        child = conf.getChild("save", false);
        if (child != null) {
            this.saveResource = child.getAttribute("uri");
            this.saveResourceParameters = SourceParameters.create(child);
        }

        // And now: Applications
        child = conf.getChild("applications", false);
        if (child != null) {
            Configuration[] appConfs = child.getChildren("application");
            Configuration appconf;

            if (appConfs != null) {
                for(int i = 0; i < appConfs.length; i++) {
                    appconf = appConfs[i];

                    // get name
                    String appName = appconf.getAttribute("name");

                    // test if handler is unique
                    if (this.applications.get(appName) != null) {
                        throw new ConfigurationException("Application names must be unique: " + appName);
                    }
View Full Code Here

        // calling method is syned
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN getUsers role="+role+", ID="+ID);
        }
        Document frag = null;
        Configuration conf = this.getAuthenticationManager().getModuleConfiguration("single-role-user-management");
        if (conf != null) {

            // get load-users resource (optional)
            Configuration child = conf.getChild("load-users", false);
            if (child != null) {
                String loadUsersResource = child.getAttribute("uri", null);
                SourceParameters loadUsersResourceParameters = SourceParameters.create(child);
   
                if (loadUsersResource != null) {
                    SourceParameters parameters = (loadUsersResourceParameters == null) ? new SourceParameters()
                                                                             : loadUsersResourceParameters;
View Full Code Here

        format.put(OutputKeys.INDENT, "no");
        format.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
    }

    public void configure(Configuration configuration) throws ConfigurationException {
        Configuration driver = configuration.getChild("driver");
        if (driver == null || driver.getValue() == null)
            throw new ConfigurationException("Required driver parameter is missing.");
        this.driver = driver.getValue();

        Configuration default_base = configuration.getChild("base");
        if (default_base != null)
            this.default_base = default_base.getValue();
    }
View Full Code Here

     * Create a new handler object.
     */
    public UserManagementHandler(Configuration   conf,
                                  String          appName)
    throws ProcessingException, SAXException, IOException, ConfigurationException {
        Configuration child;
       
        this.applicationName = appName;
       
        // get load-users resource (optional)
        child = conf.getChild("load-users", false);
        if (child != null) {
            this.loadUsersResource = child.getAttribute("uri");
            this.loadUsersResourceParameters = SourceParameters.create(child);
        }

        // get load-roles resource (optional)
        child = conf.getChild("load-roles", false);
        if (child != null) {
            this.loadRolesResource = child.getAttribute("uri");
            this.loadRolesResourceParameters = SourceParameters.create(child);
        }

        // get new user resource (optional)
        child = conf.getChild("new-user", false);
        if (child != null) {
            this.newUserResource = child.getAttribute("uri");
            this.newUserResourceParameters = SourceParameters.create(child);
        }

        // get new role resource (optional)
        child = conf.getChild("new-role", false);
        if (child != null) {
            this.newRoleResource = child.getAttribute("uri");
            this.newRoleResourceParameters = SourceParameters.create(child);
        }

        // get delete user resource (optional)
        child = conf.getChild("delete-user", false);
        if (child != null) {
            this.deleteUserResource = child.getAttribute("uri");
            this.deleteUserResourceParameters = SourceParameters.create(child);
        }

        // get delete role resource (optional)
        child = conf.getChild("delete-role", false);
        if (child != null) {
            this.deleteRoleResource = child.getAttribute("uri");
            this.deleteRoleResourceParameters = SourceParameters.create(child);
        }

        // get change user resource (optional)
        child = conf.getChild("change-user", false);
        if (child != null) {
            this.changeUserResource = child.getAttribute("uri");
            this.changeUserResourceParameters = SourceParameters.create(child);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.