Package org.apache.avalon.framework.configuration

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


                }

                DefaultAccessController.configureOrParameterize(policyManager, policyManagerConfiguration);
                setPolicyManager((InheritingPolicyManager) policyManager);
            } catch (Exception e) {
                throw new ConfigurationException(
                    "Obtaining policy manager for type [" + type + "] failed: ",
                    e);
            }
        }
    } /**
 
View Full Code Here


     */
    protected void initialize() throws ConfigurationException {
       try {
            readProperties(super.getConfigurationDirectory());
        } catch (final IOException ioe) {
            throw new ConfigurationException("Reading cifs.properties file in ["+
                        super.getConfigurationDirectory()+"] failed", ioe);
        }
    }
View Full Code Here

            String publicHref = publics[i].getValue(null);

            try {
                publicMatchers.add(preparePattern(publicHref));
            } catch (PatternException pe) {
                throw new ConfigurationException("invalid pattern for public hrefs", pe);
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("CONFIGURATION: public: " + publicHref);
            }
View Full Code Here

            FileGroupManager manager = null;

            try {
                manager = FileGroupManager.instance(configurationDirectory);
            } catch (AccessControlException e) {
                throw new ConfigurationException(
                    "Exception when trying to fetch GroupManager for directory: [" +
                    configurationDirectory + "]", e);
            }

            for (int i = 0; i < groups.length; i++) {
                String groupId = groups[i].getValue();
                Group group = manager.getGroup(groupId);

                if (group == null) {
                    throw new ConfigurationException("Couldn't find Group for group name [" + groupId + "]");
                }
               
                if (!group.contains(this)) {
                    group.add(this);
                }
View Full Code Here

        try {
            startupManager.addComponent(Parser.ROLE, ClassUtils.loadClass(parser), null);
        } catch (Exception e) {
            getLogger().error("Could not load parser, Cocoon object not created.", e);
            throw new ConfigurationException("Could not load parser " + parser, e);
        }

        try {
            getLogger().debug("Creating Repository with this directory: " + this.workDir);
            FilesystemStore repository = new FilesystemStore();
            repository.setLogger(getLogger());
            repository.setDirectory(this.workDir);
            this.componentManager.addComponentInstance(Store.ROLE + "/Filesystem", repository);
        } catch (IOException e) {
            getLogger().error("Could not create repository!", e);
            throw new ConfigurationException("Could not create the repository!", e);
        }

        getLogger().debug("Classpath = " + classpath);
        getLogger().debug("Work directory = " + workDir.getCanonicalPath());
        startupManager.initialize();

        Configuration conf = this.configure(startupManager);
        startupManager.dispose();

        this.componentManager.initialize();

        getLogger().debug("Setting up the sitemap.");
        // Create the sitemap
        Configuration sconf = conf.getChild("sitemap");
        this.sitemapManager = new Manager();
        this.sitemapManager.setLogger(getLogger());
        this.sitemapManager.contextualize(this.context);
        this.sitemapManager.compose(this.componentManager);
        this.sitemapManager.configure(conf);
        this.sitemapFileName = sconf.getAttribute("file");
        if (this.sitemapFileName == null) {
            getLogger().error("No sitemap file name");
            throw new ConfigurationException("No sitemap file name\n" + conf.toString());
        }
        String value = sconf.getAttribute("check-reload", "yes");
        this.checkSitemapReload = !(value != null && value.equalsIgnoreCase("no") == true);
        value = sconf.getAttribute("reload-method", "asynchron");
        this.reloadSitemapAsynchron = !(value != null && value.equalsIgnoreCase("synchron") == true);
View Full Code Here

            p.setContentHandler(b);
            p.parse(is);
            roleConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            if (p != null) startupManager.release(p);
        }

        DefaultRoleManager drm = new DefaultRoleManager();
        drm.setLogger(getLogger());
        drm.configure(roleConfig);
        roleConfig = null;

        try {
            this.configurationFile.refresh();
            p = (Parser)startupManager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/sitemap/sitemap.roles").openStream();
            InputSource is = new InputSource(inputStream);
            is.setSystemId(this.configurationFile.getSystemId());
            p.setContentHandler(b);
            p.parse(is);
            sitemapConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            if (p != null) startupManager.release(p);
        }

        DefaultRoleManager sitemapRoleManager = new DefaultRoleManager();
        sitemapRoleManager.setLogger(getLogger());
        sitemapRoleManager.configure(sitemapConfig);

        try {
            p = (Parser)startupManager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputSource is = this.configurationFile.getInputSource();
            p.setContentHandler(b);
            p.parse(is);
            this.configuration = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations",e);
        } finally {
            if (p != null) startupManager.release(p);
        }

        Configuration conf = this.configuration;

        AbstractSitemap.setRoleManager(sitemapRoleManager, conf);
        AbstractSitemap.setLogKitManager(this.logKitManager);

        getLogger().debug("Root configuration: " + conf.getName());
        if (! "cocoon".equals(conf.getName())) {
            throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
        }
        getLogger().debug("Configuration version: " + conf.getAttribute("version"));
        if (Constants.CONF_VERSION.equals(conf.getAttribute("version")) == false) {
            throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
        }

        String userRoles = conf.getAttribute("user-roles", "");
        if ("".equals(userRoles) == false) {
            try {
                p = (Parser)startupManager.lookup(Parser.ROLE);
                SAXConfigurationHandler b = new SAXConfigurationHandler();
                org.apache.cocoon.environment.Context context =
                    (org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
                URL url = context.getResource(userRoles);
                InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
                is.setSystemId(this.configurationFile.getSystemId());
                p.setContentHandler(b);
                p.parse(is);
                roleConfig = b.getConfiguration();
            } catch (Exception e) {
                getLogger().error("Could not configure Cocoon environment", e);
                throw new ConfigurationException("Error trying to load configurations", e);
            } finally {
                if (p != null) startupManager.release(p);
            }

            DefaultRoleManager urm = new DefaultRoleManager(drm);
View Full Code Here

          getLogger().debug("Use XSLTProcessor of role " + xsltRole);
         
          try {
            this.xsltProcessor = (XSLTProcessor)this.manager.lookup(xsltRole);
          } catch(Exception e) {
            throw new ConfigurationException("Cannot load XSLT processor", e);
          }
        }
    }
View Full Code Here

                String transcoderName = parameters[i].getAttribute("value");
                try {
                    this.transcoder = (Transcoder)ClassUtils.newInstance(transcoderName);
                } catch (Exception ex) {
                    log.error("Cannot load  class " + transcoderName, ex);
                    throw new ConfigurationException("Cannot load class " + transcoderName, ex);
                }
            }
        }
        // Do we have a transcoder yet?
        if (this.transcoder == null ) {
            throw new ConfigurationException(
                "Could not autodetect transcoder for SVGSerializer and "
                + "no transcoder was specified in the sitemap configuration."
            );
        }

        // Now run through the other parameters, using them as hints
        // to the transcoder
        for (int i = 0; i < parameters.length; i++ ) {
            String name = parameters[i].getAttribute("name");
            // Skip over the parameters we've dealt with. Ensure this
            // is kept in sync with the above list!
            if ("transcoder".equals(name)) continue;
            // Now try and get the hints out
            try {
                // Turn it into a key name (assume the current Batik style continues!
                name = ("KEY_" + name).toUpperCase();
                // Use reflection to get a reference to the key object
                TranscodingHints.Key key = (TranscodingHints.Key)
                    (transcoder.getClass().getField(name).get(transcoder));
                Object value;
                String keyType = parameters[i].getAttribute("type", "STRING").toUpperCase();
                if ("FLOAT".equals(keyType)) {
                    // Can throw an exception.
                    value = new Float(parameters[i].getAttributeAsFloat("value"));
                } else if ("INTEGER".equals(keyType)) {
                    // Can throw an exception.
                    value = new Integer(parameters[i].getAttributeAsInteger("value"));
                } else if ("BOOLEAN".equals(keyType)) {
                    // Can throw an exception.
                    value = new Boolean(parameters[i].getAttributeAsBoolean("value"));
                } else if ("COLOR".equals(keyType)) {
                  // Can throw an exception
                  String stringValue = parameters[i].getAttribute("value");
                  if (stringValue.startsWith("#")) {
                    stringValue = stringValue.substring(1);
                  }
                  value = new Color(Integer.parseInt(stringValue, 16));
                } else {
                    // Assume String, and get the value. Allow an empty string.
                    value = parameters[i].getValue("");
                }
                // TODO: if (logger.isDebug())
                log.debug("SVG Serializer: adding hint \"" + name + "\" with value \"" + value.toString() + "\"");
                transcoder.addTranscodingHint(key, value);
            } catch (ClassCastException ex) {
                // This is only thrown from the String keyType... line
                throw new ConfigurationException("Specified key (" + name + ") is not a valid Batik Transcoder key.", ex);
            } catch (ConfigurationException ex) {
                throw new ConfigurationException("Name or value not specified.", ex);
            } catch (IllegalAccessException ex) {
                throw new ConfigurationException("Cannot access the key for parameter \"" + name + "\"", ex);
            } catch (NoSuchFieldException ex) {
                throw new ConfigurationException("No field available for parameter \"" + name + "\"", ex);
            }
        }
    }
View Full Code Here

            catalogueLocation = child.getValue( null );
            debug( "Default catalogue location is " + catalogueLocation );

            // check our mandatory parameters
            if ( catalogueName == null || catalogueLocation == null )
                throw new ConfigurationException(
                        "I18nTransformer requires the name and location of " +
                        "the message catalogues"
                );

            // obtain default text to use for untranslated messages
View Full Code Here

                userConfigFile = new java.io.File(userConfig);
                options = new Options(userConfigFile);
                getLogger().debug("Using config file " + userConfig);
            } catch (Exception ex) {
                getLogger().error("Cannot load  config " + userConfig, ex);
                throw new ConfigurationException("Cannot load config " + userConfig, ex);
            }
        } else {
            try {
                options = new Options();
                getLogger().debug("Using default config file");
            } catch (Exception e) {
                getLogger().error("Cannot load default config ", e);
            }
        }

    // Get the mime type.
        this.mimetype = conf.getAttribute("mime-type");
        getLogger().debug("FOPSerializer mime-type:" + mimetype);

        // Using the Renderer Factory, get the default renderer
        // for this MIME type.
        this.renderer = factory.createRenderer(mimetype);
        // Iterate through the parameters, looking for a renderer reference
        Configuration[] parameters = conf.getChildren("parameter");
        for (int i = 0; i < parameters.length; i++) {
            String name = parameters[i].getAttribute("name");
            if ("renderer".equals(name)) {
                this.rendererName = parameters[i].getAttribute("value");
                try {
                    this.renderer = (Renderer)ClassUtils.newInstance(rendererName);
                } catch (Exception ex) {
                    getLogger().error("Cannot load  class " + rendererName, ex);
                    throw new ConfigurationException("Cannot load class " + rendererName, ex);
                }
            }
        }
       
        // Do we have a renderer yet?
        if (this.renderer == null ) {
            throw new ConfigurationException(
                "Could not autodetect renderer for FOPSerializer and "
                + "no renderer was specified in the sitemap configuration."
            );
        }
    }
View Full Code Here

TOP

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

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.