Package org.objectweb.celtix.configuration

Examples of org.objectweb.celtix.configuration.ConfigurationException


                    resolved = null;
                }
            }
        } catch (URISyntaxException ex) {
            Message msg = new Message("SCHEMA_LOCATION_ERROR_EXC", LOG, location);
            throw new ConfigurationException(msg, ex);
        }

        if (!uri.isAbsolute() && resolved != null && resolved.isAbsolute()) {
            uri = resolved;
        }

        if (uri.isAbsolute()) {
            if ("file".equals(uri.getScheme())) {
                String path = uri.getPath();
                if (null == path) {
                    Message msg = new Message("FILE_OPEN_ERROR_EXC", LOG, location);
                    throw new ConfigurationException(msg);
                }
                File file = new File(path);
                if (file.exists()) {
                    return new InputSource(file.toURI().toString());
                }
            } else {
                //TODO - other protocols like HTTP?               
            }
        }
       
        // uri path is a system resource            
        URL url = DefaultResourceManager.instance().resolveResource(location, URL.class);
        if (null != url) {
            return new InputSource(url.toString());
        }
       
        //ok, try URL resolving
        if (baseURI != null) {
            try {
                url = new URL(baseURI);
                url = new URL(url, location);
                InputStream ins = url.openStream();
                if (ins != null) {
                    InputSource src = new InputSource(ins);
                    src.setSystemId(url.toString());
                    return src;
                }
            } catch (MalformedURLException e) {
                //ignore
            } catch (IOException e) {
                //ignore
            }
        }
       
        /*
        System.out.println(baseURI);
        System.out.println(location);
        System.out.println(uri);
        if (baseURI != null) {
            System.out.println(base);
            System.out.println(resolved);
        }
        */
       
        throw new ConfigurationException(new Message("SCHEMA_LOCATION_ERROR_EXC", LOG, location));
    }
View Full Code Here


                    if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type.getNamespaceURI())) {
                        continue;
                    }
                    TypeSchema ts = new TypeSchemaHelper(forceDefaults).get(type.getNamespaceURI());
                    if (ts == null) {
                        throw new ConfigurationException(new Message("NO_TYPESCHEMA_FOR_NAMESPACE_EXC", LOG,
                                                                     type.getNamespaceURI()));
                    }
                    if (!ts.hasType(type.getLocalPart())) {
                        throw new ConfigurationException(new Message("TYPE_NOT_DEFINED_IN_NAMESPACE_EXC",
                                                                     LOG, type.getLocalPart(), type
                                                                         .getNamespaceURI()));
                    }
                }
            } else if ("description".equals(nd.getLocalName())) {
View Full Code Here

        if (null == ts || null == type) {
            System.err.println(elementName);
            System.err.println(namespaceURI);
            System.err.println(ts);
            System.err.println(type);
            throw new ConfigurationException(new Message("INVALID_ELEMENT_FOR_DEFAULT_VALUE_EXC", LOG,
                                                         item.getName(), item.getType()));
        }
        if (!type.equals(item.getType())) {
            throw new ConfigurationException(new Message("INVALID_TYPE_FOR_DEFAULT_VALUE_EXC", LOG,
                                                       item.getName(), item.getType()));
        }
        unmarshalDefaultValue(item, data);
    }
View Full Code Here

            InputStream is =
                DefaultResourceManager.instance()
                    .getResourceAsStream("schemas/configuration/metadata.xsd");

            if (null == is) {
                throw new ConfigurationException(new Message("CANNOT_FIND_CONFIG_METADATA_SCHEMA_MSG", LOG));
            }

            try {
                metadataSchema = getSchema(is);
            } catch (ConfigurationException ex) {
View Full Code Here

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = null;
        try {
            schema = factory.newSchema(schemaFile);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG), ex);
        }
        return schema;
    }
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), ex);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("PARSE_ERROR_EXC", LOG), ex);
        }

        if (doValidate) {
            try {
                Validator v = getMetadataValidator();
                v.validate(new DOMSource(document));
            } catch (SAXException ex) {
                Message msg = new Message("METADATA_VALIDATION_ERROR_EXC", LOG);
                throw new ConfigurationException(msg, ex);
            }
        }

        deserializeImports(document);
        deserializeConfig(document);
View Full Code Here

       
        int index = s.indexOf(":");
        if (index < 0) {
            return new QName(s);
        } else if (index == 0) {
            throw new ConfigurationException(new Message("ILLEGAL_QNAME_EXC", LOG, s));
        }
        String prefix = s.substring(0, index);
        String nsAttr = "xmlns:" + prefix;
        String uri = null;
        Element el = element;
        while (null == uri || "".equals(uri)) {
            uri = el.getAttribute(nsAttr);
            if (null != uri && !"".equals(uri)) {
                break;
            }
            if (el == document.getDocumentElement()) {
                break;
            }
            el = (Element)el.getParentNode();
        }
        if (null == uri || "".equals(uri)) {
            throw new ConfigurationException(new Message("ILLEGAL_PREFIX_EXC", LOG, s));
        }
        if (index >= (s.length() - 1)) {
            throw new ConfigurationException(new Message("ILLEGAL_QNAME_EXC", LOG, s));
        }
       
        String localPart = s.substring(index + 1);
        return new QName(uri, localPart);
    }
View Full Code Here

      
        try {
            bf.getBean("top4");
            fail("Expected BeanCreationException not thrown.");          
        } catch (BeanCreationException ex) {
            ConfigurationException cause = (ConfigurationException)ex.getCause();
            assertEquals("JAXB_PROPERTY_EDITOR_EXC", cause.getCode());
        }
    }
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.