Package org.objectweb.celtix.configuration

Examples of org.objectweb.celtix.configuration.ConfigurationException


    @SuppressWarnings("unchecked")
    public List<String> getStringList(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            Method method = obj.getClass().getMethod("getItem", new Class[0]);
            obj = method.invoke(obj, new Object[0]);

            return (List<String>)obj;
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (NoSuchMethodException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (IllegalAccessException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (InvocationTargetException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here


    public Configuration getConfiguration(String namespaceUri, String id) {
        Map<String, Configuration> instances  = configurations.get(namespaceUri);
        if (null == instances) {
            if (null == getModel(namespaceUri)) {
                throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
            }
            return null;
        }
        return instances.get(id);
    }
View Full Code Here

            return null;
        }

        Configuration c = parent.getChild(namespaceUri, id);
        if (null == c && null == getModel(namespaceUri)) {
            throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
        }
        return c;
    }
View Full Code Here

    }

    public Configuration buildConfiguration(String namespaceUri, String id, Configuration parent) {
        ConfigurationMetadata model = getModel(namespaceUri);
        if (null == model) {
            throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
        }
        /*
        if (parent != null && !isValidChildConfiguration(model, parent)) {
            throw new ConfigurationException(new Message("INVALID_CHILD_CONFIGURATION",
                                                         BUNDLE, namespaceUri,
                                                         parent.getModel().getNamespaceURI()));
        }
        */
        if (parent == null && !isValidTopConfiguration(model, parent)) {
            throw new ConfigurationException(new Message("INVALID_TOP_CONFIGURATION",
                                                         BUNDLE, namespaceUri));
        }

        Configuration c = new AbstractConfigurationImpl(model, id, parent);
        if (null == parent) {
View Full Code Here

        InputStream is = null;
        if (resource != null) {
            is = loadResource(resource);
            if (is == null) {
                throw new ConfigurationException(new Message("METADATA_RESOURCE_EXC",
                                                             BUNDLE, resource));
            }
        }

        ConfigurationMetadata model = null;
        ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(true);
        if (null != is) {
            try {
                model = builder.build(is);
            } catch (IOException ex) {
                throw new ConfigurationException(new Message("METADATA_RESOURCE_EXC",
                                                             BUNDLE, resource), ex);
            }
        } else {
            model = new ConfigurationMetadataImpl();
        }
View Full Code Here

        ConfigurationMetadata model = null;

        try {
            model = builder.build(src);
        } catch (IOException ex) {
            throw new ConfigurationException(new Message("FAILED_TO_GENERATE_BEAN_EXC", LOG), ex);
        }
       
        String className = SpringUtils.getBeanClassName(model.getNamespaceURI());
       
        StringBuffer classFileName = new StringBuffer(className);
        for (int i = 0; i < classFileName.length(); i++) {
            if ('.' == classFileName.charAt(i)) {
                classFileName.setCharAt(i, File.separatorChar);
            }
        }
        classFileName.append(".java");       
       
        File classFile = new File(outputDir, classFileName.toString());
        File dir = classFile.getParentFile();
        if (!dir.exists()) {
            dir.mkdirs();
        }
       
        LOG.info("Generating class: " + className + "\n"
            +    "           file:  " + classFile.getPath());
       
        PrintWriter pw = null;
        try {
            pw = new PrintWriter(new FileOutputStream(classFile));
            // pw = new PrintWriter(System.out);
            writeClass(pw, model, className);
        } catch (IOException ex) {
            throw new ConfigurationException(new Message("FAILED_TO_GENERATE_BEAN_EXC", LOG), ex);         
        } finally {
            pw.close();
        }
    }
View Full Code Here

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder parser = factory.newDocumentBuilder();
            document = parser.parse(is);
        } catch (ParserConfigurationException ex) {
            throw new ConfigurationException(new Message("PARSER_CONFIGURATION_ERROR_EXC",
                                                         LOG, location), ex);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("PARSE_ERROR_EXC", LOG), ex);
        } catch (IOException ex) {
            throw new ConfigurationException(new Message("FILE_OPEN_ERROR_EXC", LOG, location), ex);
        }

        deserialize(document);

        Source src = new DOMSource(document);
        src.setSystemId(is.getSystemId());

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        final LSResourceResolver oldResolver = factory.getResourceResolver();
    
        LSResourceResolver resolver = new LSResourceResolver() {

            public LSInput resolveResource(String type, String nsURI,
                                           String publicId, String systemId, String baseURI) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("resolving resource type: " + type + "\n"
                            + "                   namespaceURI:" + nsURI + "\n"
                            + "                   publicId:" + publicId + "\n"
                            + "                   systemId:" + systemId + "\n"
                            + "                   baseURI:" + baseURI);
                }
               
                if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type)) {
                    LSInput lsi = new SchemaInput(type, nsURI, publicId, systemId, baseURI);
                    String resourceName = systemId;
                   
                    InputSource src = getSchemaInputSource(baseURI, resourceName);
                    lsi.setByteStream(src.getByteStream());
                    lsi.setSystemId(src.getSystemId());
                    return lsi;
                }
                return oldResolver == null ? null
                    : oldResolver.resolveResource(type, nsURI, publicId, systemId, baseURI);
            }
        };
       
        factory.setResourceResolver(resolver);       
        try {
            schema = factory.newSchema(src);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG, location), ex);
        }
        document = null;
       
        LOG.fine("Created type schema for namespace " + namespaceURI);
    }
View Full Code Here

        return elementDefinitions.get(typeName);
    }

    public String getXMLSchemaBaseType(String typeName) {
        if (!hasType(typeName)) {
            throw new ConfigurationException(new Message("TYPE_NOT_DEFINED_IN_NAMESPACE_EXC", LOG,
                                                         typeName, namespaceURI));
                                                     
        }
        return typeDefinitions.get(typeName);
    }
View Full Code Here

        try {
            return unmarshal(item.getType(), data, doValidate);
        } catch (JAXBException ex) {
            if (forceDefaults) {
                Message msg = new Message("DEFAULT_VALUE_UNMARSHAL_ERROR_EXC", LOG, item.getName());
                throw new ConfigurationException(msg, ex);
            }
            return null;
        }
    }
View Full Code Here

        } else {
            packageName = JAXBUtils.namespaceURIToPackage(namespaceURI);
        }

        if (null == packageName) {
            throw new ConfigurationException(new Message("MISSING_PACKAGE_NAME_EXC", LOG, namespaceURI));
        }

    }
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.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.