Package org.apache.tuscany.sca.contribution.service

Examples of org.apache.tuscany.sca.contribution.service.ContributionReadException


                } catch (IOException e) {
                    // ignore
                }
            }
        } catch (XMLStreamException e) {
            ContributionReadException ce = new ContributionReadException(e);
            error("ContributionReadException", inputFactory, ce);
            throw ce;
        }
    }
View Full Code Here


                                XPath xpath = xPathFactory.newXPath();
                                xpath.setNamespaceContext(reader.getNamespaceContext());
                                try {
                                    componentProperty.setSourceXPathExpression(xpath.compile(source));
                                } catch (XPathExpressionException e) {
                                  ContributionReadException ce = new ContributionReadException(e);
                                  error("ContributionReadException", xpath, ce);
                                    //throw ce;
                                }
                            }
                            componentProperty.setFile(getString(reader, FILE));
View Full Code Here

                    // Read <import>
                    if (IMPORT.equals(element)) {
                        String ns = reader.getAttributeValue(null, NAMESPACE);
                        if (ns == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        namespaceImport.setNamespace(ns);

                        String location = reader.getAttributeValue(null, LOCATION);
                        if (location != null) {
View Full Code Here

                   
                    // Read <export>
                    if (EXPORT.equals(element)) {
                        String ns = reader.getAttributeValue(null, NAMESPACE);
                        if (ns == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        namespaceExport.setNamespace(ns);
                    }
                   
                    break;
View Full Code Here

        throws ContributionReadException, XMLStreamException {

        /* Read the location attribute for the xquery implementation  */
        String xqueryLocation = reader.getAttributeValue(null, LOCATION);
        if (xqueryLocation == null) {
            throw new ContributionReadException(MSG_LOCATION_MISSING);
        }
        /* Create the XQuery implementation and set the location into it */
        XQueryImplementation xqueryImplementation =
            XQueryImplementationFactory.INSTANCE.createXQueryImplementation();
        xqueryImplementation.setLocation(xqueryLocation);
View Full Code Here

                documentBuilderFactory = DocumentBuilderFactory.newInstance();
                documentBuilderFactory.setNamespaceAware(true);
            }
            document = documentBuilderFactory.newDocumentBuilder().newDocument();
        } catch (ParserConfigurationException e) {
            throw new ContributionReadException(e);
        }

        // root element has no namespace and local name "value"
        Element root = document.createElementNS(null, "value");
        if (type != null) {
View Full Code Here

            //so it's ok to set resolved for now
            processDefinition = indexRead(artifactURL);
            processDefinition.setURI(artifactURI);
            processDefinition.setUnresolved(false);
        } catch (Exception e) {
            throw new ContributionReadException(e);
        }
       
        return processDefinition;
    }
View Full Code Here

                            if (contract != null) {
                                contract
                                        .setInterfaceContract((InterfaceContract) extension);
                            } else {
                                if (name.getNamespaceURI().equals(SCA10_NS)) {
                                    throw new ContributionReadException(
                                            "Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
                                } else {
                                    composite.getExtensions().add(extension);
                                }
                            }

                        } else if (extension instanceof Binding) {
                            // <service><binding> and
                            // <reference><binding>
                            if (callback != null) {
                                callback.getBindings().add((Binding) extension);
                            } else {
                                if (contract != null) {
                                    contract.getBindings().add(
                                            (Binding) extension);
                                } else {
                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
                                        throw new ContributionReadException(
                                                "Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
                                    } else {
                                        composite.getExtensions()
                                                .add(extension);
                                    }
                                }
                            }

                        } else if (extension instanceof Implementation) {

                            // <component><implementation>
                            if (component != null) {
                                component
                                        .setImplementation((Implementation) extension);
                            } else {
                                if (name.getNamespaceURI().equals(SCA10_NS)) {
                                    throw new ContributionReadException(
                                            "Unexpected <implementation> element found. It should appear inside a <component> element");
                                } else {
                                    composite.getExtensions().add(extension);
                                }
                            }
View Full Code Here

                    URLConnection connection = url.openConnection();
                    connection.setUseCaches(false);
                    scdlStream = connection.getInputStream();
                }
            } catch ( Exception e ) {
                throw new ContributionReadException(e);
            }
           
            XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
           
            reader.nextTag();
           
            // Read the composite model
            Composite composite = (Composite)extensionProcessor.read(reader);
            if (composite != null) {
                composite.setURI(uri.toString());
            }

            // For debugging purposes, write it back to XML
//            if (composite != null) {
//                try {
//                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
//                    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
//                    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
//                    extensionProcessor.write(composite, outputFactory.createXMLStreamWriter(bos));
//                    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
//                    OutputFormat format = new OutputFormat();
//                    format.setIndenting(true);
//                    format.setIndent(2);
//                    XMLSerializer serializer = new XMLSerializer(System.out, format);
//                    serializer.serialize(document);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
           
            return composite;
           
        } catch (XMLStreamException e) {
            throw new ContributionReadException(e);
        } finally {
            try {
                if (scdlStream != null) {
                    scdlStream.close();
                    scdlStream = null;
View Full Code Here

                    // Read <import>
                    if (IMPORT_RESOURCE.equals(element)) {
                        String uri = reader.getAttributeValue(null, URI);
                        if (uri == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        resourceImport.setURI(uri);

                        String location = reader.getAttributeValue(null, LOCATION);
                        if (location != null) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.service.ContributionReadException

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.