Package org.apache.tuscany.sca.contribution.processor

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


        if (url != null) {
            String path = url.getPath();
            locationFile = new File(path);
        } else {
            throw new ContributionReadException(
                                                "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to find resource file "
                                                    + url);
        }

        if (locationFile.isDirectory()) {
            try {
                manifestFile = new File(locationFile, "META-INF" + File.separator + "MANIFEST.MF");
                if (manifestFile.exists()) {
                    Manifest mf = new Manifest(new FileInputStream(manifestFile));
                    Attributes mainAttrs = mf.getMainAttributes();
                    String appCtxPath = mainAttrs.getValue("Spring-Context");
                    if (appCtxPath != null) {
                        String[] cxtPaths = appCtxPath.split(";");
                        for (String path : cxtPaths) {
                            appXmlFile = new File(locationFile, path.trim());
                            if (appXmlFile.exists()) {
                                appCtxResources.add(appXmlFile.toURI().toURL());
                            }
                        }
                        return appCtxResources;
                    }
                }
                // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
                // xml files available in the META-INF/spring folder.
                appXmlFolder = new File(locationFile, "META-INF" + File.separator + "spring");
                if (appXmlFolder.exists()) {
                    File[] files = appXmlFolder.listFiles();
                    for (File appFile : files) {
                        if (appFile.getName().endsWith(".xml")) {
                            appCtxResources.add(appFile.toURI().toURL());
                        }
                    }
                    return appCtxResources;
                }
            } catch (IOException e) {
                throw new ContributionReadException("Error reading manifest " + manifestFile);
            }
        } else {
            if (locationFile.isFile() && locationFile.getName().endsWith(".jar")) {
                try {
                    JarFile jf = new JarFile(locationFile);
                    JarEntry je;
                    Manifest mf = jf.getManifest();
                    if (mf != null) {
                        Attributes mainAttrs = mf.getMainAttributes();
                        String appCtxPath = mainAttrs.getValue("Spring-Context");
                        if (appCtxPath != null) {
                            String[] cxtPaths = appCtxPath.split(";");
                            for (String path : cxtPaths) {
                                je = jf.getJarEntry(path.trim());
                                if (je != null)
                                    appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL()
                                        + "!/"
                                        + appCtxPath));
                            }
                            return appCtxResources;
                        }
                    }
                    // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
                    // .xml files available in the META-INF/spring folder.
                    Enumeration<JarEntry> entries = jf.entries();
                    while (entries.hasMoreElements()) {
                        je = entries.nextElement();
                        if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
                            appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + je.getName()));
                        }
                    }
                    return appCtxResources;
                } catch (IOException e) {
                    // TODO: create a more appropriate exception type
                    throw new ContributionReadException(
                                                        "SpringXMLComponentTypeLoader getApplicationContextResource: " + " IO exception reading context file.",
                                                        e);
                }
            } else {
                if (locationFile.getName().endsWith(".xml")) {
                    appCtxResources.add(url);
                    return appCtxResources;
                } else {
                    // Deal with the directory inside a jar file, in case the contribution itself is a JAR file.
                    try {
                        if (locationFile.getPath().indexOf(".jar") > 0) {
                            String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
                            JarFile jf = new JarFile(jarPath);
                            JarEntry je =
                                jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
                                    + "META-INF"
                                    + "/"
                                    + "MANIFEST.MF");
                            if (je != null) {
                                Manifest mf = new Manifest(jf.getInputStream(je));
                                Attributes mainAttrs = mf.getMainAttributes();
                                String appCtxPath = mainAttrs.getValue("Spring-Context");
                                if (appCtxPath != null) {
                                    String[] cxtPaths = appCtxPath.split(";");
                                    for (String path : cxtPaths) {
                                        je =
                                            jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
                                                + path.trim());
                                        if (je != null) {
                                            appCtxResources.add(new URL("jar:" + url.getPath() + "/" + path.trim()));
                                        }
                                    }
                                    return appCtxResources;
                                }
                            }
                            // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
                            // .xml files available in the META-INF/spring folder.
                            Enumeration<JarEntry> entries = jf.entries();
                            while (entries.hasMoreElements()) {
                                je = entries.nextElement();
                                if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
                                    appCtxResources.add(new URL("jar:" + url.getPath() + "/" + je.getName()));
                                }
                            }
                            return appCtxResources;
                        }
                    } catch (IOException e) {
                        throw new ContributionReadException("Error reading manifest " + manifestFile);
                    }
                }
            }
        }

        throw new ContributionReadException(
                                            "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to process unknown resource type: "
                                                + url);
    } // end method getApplicationContextResource
View Full Code Here


            switch (event) {
                case START_ELEMENT: {
                    if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
                        if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) {
                          error(monitor, "MustUseWsdlBinding", reader, wsdlElement);
                            throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
                        }
                       
                        wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
                        endpointSpecifications.add("wsa:EndpointReference");
                    }
View Full Code Here

                    String compositeXML = cd.getAdditionalDeployables().get(uri);
                    Composite composite;
                    try {
                        composite = deployer.loadXMLDocument(new StringReader(compositeXML));
                    } catch (XMLStreamException e) {
                        throw new ContributionReadException(e);
                    }
                    composite.setURI(composite.getName().getLocalPart() + ".composite");
                    contribution.addComposite(composite);
                }
            }
View Full Code Here

                NamespaceContext nsContext = xpathHelper.getNamespaceContext(appliesTo, reader.getNamespaceContext());
                // path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
                XPathExpression expression = xpathHelper.compile(path, nsContext, appliesTo);
                policySet.setAppliesToXPathExpression(expression);
            } catch (XPathExpressionException e) {
                ContributionReadException ce = new ContributionReadException(e);
                error(monitor, "ContributionReadException", policySet, ce);
                //throw ce;
            }
        }

        String attachTo = reader.getAttributeValue(null, ATTACH_TO);
        if (attachTo != null) {
            try {
                XPath path = xpathHelper.newXPath();
                NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
                path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));               
                                          
                attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
                XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
                policySet.setAttachTo(attachTo);
                policySet.setAttachToXPathExpression(expression);
            } catch (XPathExpressionException e) {
                ContributionReadException ce = new ContributionReadException(e);
                error(monitor, "ContributionReadException", policySet, ce);
                //throw ce;
            }

        }
View Full Code Here

                    if (reader.hasNext()) {
                        reader.next();
                    }
                }
            } catch (XMLStreamException e) {
                ContributionReadException ce = new ContributionReadException(e);
                error(monitor, "ContributionReadException", reader, ce);
                throw ce;
            }
        }
    }
View Full Code Here

                }
            }

            return definitions;
        } catch (XMLStreamException e) {
            ContributionReadException ce = new ContributionReadException(e);
            error(monitor, "ContributionReadException", inputFactory, ce);
            throw ce;
        } catch (IOException e) {
            ContributionReadException ce = new ContributionReadException(e);
            error(monitor, "ContributionReadException", inputFactory, ce);
            throw ce;
        } finally {

            try {
View Full Code Here

            }

            return workspace;
           
        } catch (XMLStreamException e) {
          ContributionReadException ce = new ContributionReadException(e);
          error("ContributionReadException", inputFactory, ce);
            throw ce;
        } catch (IOException e) {
          ContributionReadException ce = new ContributionReadException(e);
          error("ContributionReadException", staxProcessor, ce);
            throw ce;
        } finally {
            try {
                if (urlStream != null) {
View Full Code Here

                    reader.next();
                }
            }
        }
        catch (XMLStreamException e) {
            ContributionReadException ex = new ContributionReadException(e);
            error("XMLStreamException", reader, ex);
        }
       
        return javaExport;
    }
View Full Code Here

        File directory = directory(contributionURL);
        File file = new File(directory, artifact);
        try {
            return file.toURI().toURL();
        } catch (MalformedURLException e) {
            throw new ContributionReadException(e);
        }
    }
View Full Code Here

        File directory = directory(contributionURL);
        List<String> artifacts = new ArrayList<String>();
        try {
            traverse(artifacts, directory, directory);
        } catch (IOException e) {
            throw new ContributionReadException(e);
        }
        return artifacts;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.processor.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.