Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.ConfigurationException


        // QPID-3249.  Support for specifying authentication name at vhost level is no longer supported.
        if (getListValue("security.authentication.name").size() > 0)
        {
            String message = "Validation error : security/authentication/name is no longer a supported element within the configuration xml."
                    + " It appears in virtual host definition : " + _name;
            throw new ConfigurationException(message);
        }

        // QPID-3266.  Tidy up housekeeping configuration option for scheduling frequency
        if (contains("housekeeping.expiredMessageCheckPeriod"))
        {
            String message = "Validation error : housekeeping/expiredMessageCheckPeriod must be replaced by housekeeping/checkPeriod."
                    + " It appears in virtual host definition : " + _name;
            throw new ConfigurationException(message);
        }
    }
View Full Code Here


    {
        try
        {
            if (!containsPositiveLong(property))
            {
                throw new ConfigurationException(this.getClass().getSimpleName()
                                                 + ": '" + property +
                                                 "' must be a Positive Long value.");
            }
        }
        catch (Exception e)
        {
            Throwable last = e;

            // Find the first cause
            if (e instanceof ConversionException)
            {
                Throwable t = e.getCause();
                while (t != null)
                {
                    last = t;
                    t = last.getCause();
                }
            }

            throw new ConfigurationException(this.getClass().getSimpleName() +
                                             ": unable to configure invalid " +
                                             property + ":" +
                                             _config.getString(property),
                                             last);
        }
View Full Code Here

        String exchangeName = queueConfiguration.getExchange();

        Exchange exchange = _exchangeRegistry.getExchange(exchangeName);
        if (exchange == null)
        {
            throw new ConfigurationException("Attempt to bind queue '" + queueName + "' to unknown exchange:" + exchangeName);
        }

        Exchange defaultExchange = _exchangeRegistry.getDefaultExchange();

        //get routing keys in configuration (returns empty list if none are defined)
        List<?> routingKeys = queueConfiguration.getRoutingKeys();

        for (Object routingKeyNameObj : routingKeys)
        {
            String routingKey = String.valueOf(routingKeyNameObj);

            if (exchange.equals(defaultExchange))
            {
                if(!queueName.equals(routingKey))
                {
                    throw new ConfigurationException("Illegal attempt to bind queue '" + queueName +
                                                     "' to the default exchange with a key other than the queue name: " + routingKey);
                }
            }
            else
            {
View Full Code Here

    private void checkKeyStorePath(String keyStorePath) throws ConfigurationException
    {
        if (keyStorePath == null)
        {
            throw new ConfigurationException("Management SSL keystore path not defined, unable to start SSL protected HTTP connector");
        }
        else
        {
            File ksf = new File(keyStorePath);
            if (!ksf.exists())
            {
                throw new ConfigurationException("Cannot find management SSL keystore file: " + ksf);
            }
            if (!ksf.canRead())
            {
                throw new ConfigurationException("Cannot read management SSL keystore file: " + ksf + ". Check permissions.");
            }
        }
    }
View Full Code Here

            parser.getXMLReader().setContentHandler(handler);
            parser.getXMLReader().parse(new InputSource(in));
        }
        catch (Exception e)
        {
            throw new ConfigurationException("Unable to parse the configuration file", e);
        }
    }
View Full Code Here

            HierarchicalConfiguration config = parser.parse();
            setRoot(config.getRoot());
        }
        catch (ParseException e)
        {
            throw new ConfigurationException(e);
        }
    }
View Full Code Here

                        // pull out the first token from the bottom of the stack and check arguments exist
                        String first = stack.firstElement();
                        stack.removeElementAt(0);
                        if (stack.isEmpty())
                        {
                            throw new ConfigurationException(String.format(NOT_ENOUGH_TOKENS_MSG, getLine()));
                        }

                        // check for and parse optional initial number for ACL lines
                        Integer number = null;
                        if (StringUtils.isNumeric(first))
                        {
                            // set the acl number and get the next element
                            number = Integer.valueOf(first);
                            first = stack.firstElement();
                            stack.removeElementAt(0);
                        }

                        if (StringUtils.equalsIgnoreCase(ACL, first))
                        {
                            parseAcl(number, stack);
                        }
                        else if (number == null)
                        {
                            if(StringUtils.equalsIgnoreCase("GROUP", first))
                            {
                                throw new ConfigurationException(String.format("GROUP keyword not supported. Groups should defined via a Group Provider, not in the ACL file.", getLine()));
                            }
                            else if (StringUtils.equalsIgnoreCase(CONFIG, first))
                            {
                                parseConfig(stack);
                            }
                            else
                            {
                                throw new ConfigurationException(String.format(UNRECOGNISED_INITIAL_MSG, first, getLine()));
                            }
                        }
                        else
                        {
                            throw new ConfigurationException(String.format(NUMBER_NOT_ALLOWED_MSG, first, getLine()));
                        }

                        // reset stack, start next line
                        stack.clear();
                        break;
                    case StreamTokenizer.TT_NUMBER:
                        stack.push(Integer.toString(Double.valueOf(_st.nval).intValue()));
                        break;
                    case StreamTokenizer.TT_WORD:
                        stack.push(_st.sval); // token
                        break;
                    default:
                        if (_st.ttype == CONTINUATION)
                        {
                            int next = _st.nextToken();
                            if (next == StreamTokenizer.TT_EOL)
                            {
                              break; // continue reading next line
                            }

                            // invalid location for continuation character (add one to line beacuse we ate the EOL)
                            throw new ConfigurationException(String.format(PREMATURE_CONTINUATION_MSG, getLine() + 1));
                        }
                        else if (_st.ttype == '\'' || _st.ttype == '"')
                        {
                            stack.push(_st.sval); // quoted token
                        }
                        else
                        {
                            stack.push(Character.toString((char) _st.ttype)); // single character
                        }
                }
            } while (current != StreamTokenizer.TT_EOF);

            if (!stack.isEmpty())
            {
                throw new ConfigurationException(String.format(PREMATURE_EOF_MSG, getLine()));
            }
        }
        catch (IllegalArgumentException iae)
        {
            throw new ConfigurationException(String.format(PARSE_TOKEN_FAILED_MSG, getLine()), iae);
        }
        catch (FileNotFoundException fnfe)
        {
            throw new ConfigurationException(String.format(CONFIG_NOT_FOUND_MSG, file.getName()), fnfe);
        }
        catch (IOException ioe)
        {
            throw new ConfigurationException(String.format(CANNOT_LOAD_MSG, file.getName()), ioe);
        }
        finally
        {
            if(fileReader != null)
            {
                try
                {
                    fileReader.close();
                }
                catch (IOException e)
                {
                    throw new ConfigurationException(String.format(CANNOT_CLOSE_MSG, file.getName()), e);
                }
            }
        }

View Full Code Here

    private void parseAcl(Integer number, List<String> args) throws ConfigurationException
    {
        if (args.size() < 3)
        {
            throw new ConfigurationException(String.format(NOT_ENOUGH_ACL_MSG, getLine()));
        }

        Permission permission = Permission.parse(args.get(0));
        String identity = args.get(1);
        Operation operation = Operation.parse(args.get(2));

        if (number != null && !getConfiguration().isValidNumber(number))
        {
            throw new ConfigurationException(String.format(BAD_ACL_RULE_NUMBER_MSG, getLine()));
        }

        if (args.size() == 3)
        {
            getConfiguration().grant(number, identity, permission, operation);
View Full Code Here

    private void parseConfig(List<String> args) throws ConfigurationException
    {
        if (args.size() < 3)
        {
            throw new ConfigurationException(String.format(NOT_ENOUGH_CONFIG_MSG, getLine()));
        }

        Map<String, Boolean> properties = toPluginProperties(args);

        getConfiguration().configure(properties);
View Full Code Here

        while (i.hasNext())
        {
            String key = i.next();
            if (!i.hasNext())
            {
                throw new ConfigurationException(String.format(PROPERTY_KEY_ONLY_MSG, getLine()));
            }
            if (!"=".equals(i.next()))
            {
                throw new ConfigurationException(String.format(PROPERTY_NO_EQUALS_MSG, getLine()));
            }
            if (!i.hasNext())
            {
                throw new ConfigurationException(String.format(PROPERTY_NO_VALUE_MSG, getLine()));
            }
            String value = i.next();

            predicates.parse(key, value);
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.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.