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

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


                   
                    // Read <export.resource>
                    if (EXPORT_RESOURCE.equals(element)) {
                        String uri = reader.getAttributeValue(null, URI);
                        if (uri == null) {
                            throw new ContributionReadException("Attribute 'uri' is missing");
                        }
                        resourceExport.setURI(uri);
                    }
                   
                    break;
View Full Code Here


                    // Read <import.java>
                    if (IMPORT_JAVA.equals(element)) {
                        String packageName = reader.getAttributeValue(null, PACKAGE);
                        if (packageName == null) {
                            throw new ContributionReadException("Attribute 'package' is missing");
                        }
                       
                        String location = reader.getAttributeValue(null, LOCATION);
                        javaImport.setPackage(packageName);
                        javaImport.setLocation(location);
View Full Code Here

            }
            if (alwaysAppliesTo != null) {
                policySet.setAlwaysAppliesToXPathExpression(path.compile(alwaysAppliesTo));
            }
        } catch (XPathExpressionException e) {
            throw new ContributionReadException(e);
       
       
        readProvidedIntents(policySet, reader);
       
        int event = reader.getEventType();
        QName name = null;
        reader.next();
        while (reader.hasNext()) {
            event = reader.getEventType();
            switch (event) {
                case START_ELEMENT : {
                    name = reader.getName();
                    if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
                        Intent mappedIntent = policyFactory.createIntent();
                        mappedIntent.setName(getQName(reader, PROVIDES));
                        if ( policySet.getProvidedIntents().contains(mappedIntent) ) {
                            readIntentMap(reader, policySet, mappedIntent);
                        } else {
                            throw new ContributionReadException("Intent Map provides for Intent not spcified as provided by parent PolicySet - " + policySetName);
                        }
                    } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) )  {
                        PolicySet referredPolicySet = policyFactory.createPolicySet();
                        referredPolicySet.setName(getQName(reader, NAME));
                        policySet.getReferencedPolicySets().add(referredPolicySet);
View Full Code Here

                            } else if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
                                QName providedIntent = getQName(reader, PROVIDES);
                                if ( qualifierName.equals(providedIntent.getLocalPart()) ) {
                                    readIntentMap(reader, policySet, qualifiedIntent);
                                } else {
                                    throw new ContributionReadException("Intent provided by IntentMap " +
                                                                    providedIntent + " does not match parent qualifier " + qualifierName +
                                                                    " in policyset - " + policySet);
                                }
                            }/* else if ( WS_POLICY_QNAME.equals(name) )  {
                                OMElement policyElement = loadElement(reader);
                                Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
                                policySet.getPolicies().add(wsPolicy);
                               
                                List<Object> policyList = mappedPolicies.get(qualifiedIntent);
                                if ( policyList == null ) {
                                    policyList = new ArrayList<Object>();
                                    mappedPolicies.put(qualifiedIntent, policyList);
                                   
                                    if (qualifierName.equals(defaultQualifier)) {
                                        mappedPolicies.put(mappedIntent, policyList);
                                    }
                                }
                                policyList.add((Policy)wsPolicy);
                            }*/ else {
                                Object extension = extensionProcessor.read(reader);
                                if ( extension != null ) {
                                    List<Object> policyList = mappedPolicies.get(qualifiedIntent);
                                    if ( policyList == null ) {
                                        policyList = new ArrayList<Object>();
                                        mappedPolicies.put(qualifiedIntent, policyList);
                                       
                                        if (qualifierName.equals(defaultQualifier)) {
                                            mappedPolicies.put(mappedIntent, policyList);
                                        }
                                    }
                                    policyList.add(extension);
                                }
                            }
                            break;
                        }
                        case END_ELEMENT : {
                            if ( POLICY_INTENT_MAP_QNAME.equals(reader.getName()) ) {
                                if ( defaultQualifier != null ) {
                                    String qualifiedIntentName = mappedIntent.getName().getLocalPart() + QUALIFIER + defaultQualifier;
                                    Intent defaultQualifiedIntent = policyFactory.createIntent();
                                    defaultQualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
                                                                             qualifiedIntentName));
                                    List<Object> policyList = mappedPolicies.get(defaultQualifiedIntent);
                                    if ( policyList != null ) {
                                        mappedPolicies.put(mappedIntent, policyList);
                                    } else {
                                        throw new ContributionReadException("Unable to map policies for default qualifier in IntentMap for - " +
                                                                            mappedIntent + " in policy set - " + policySet);
                                    }
                                    defaultQualifier = null;
                                }
                            }
                            break;
                        }
                    }
                    if ( event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName()) ) {
                        break;
                    }
                    //Read the next element
                    if (reader.hasNext()) {
                        reader.next();
                    }
                }
            }  catch (XMLStreamException e) {
                throw new ContributionReadException(e);
            }
        }
    }
View Full Code Here

                   
                    // Read <export.java>
                    if (EXPORT_JAVA.equals(element)) {
                        String packageName = reader.getAttributeValue(null, PACKAGE);
                        if (packageName == null) {
                            throw new ContributionReadException("Attribute 'package' is missing");
                        }
                       
                        javaExport.setPackage(packageName);
                    }
                    break;
View Full Code Here

    private void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
        String value = reader.getAttributeValue(null, CONSTRAINS);
        if ( policyIntent instanceof QualifiedIntent && value != null) {
            String errorMsg =
                "Error in PolicyIntent Definition - " + policyIntent.getName() + QUALIFIED_INTENT_CONSTRAINS_ERROR;
            throw new ContributionReadException(errorMsg);
        } else {
            if (value != null) {
                List<QName> constrainedArtifacts = policyIntent.getConstrains();
                for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                    QName qname = getQNameValue(reader, tokens.nextToken());
View Full Code Here

               
                readAlwaysProvidedIntents(implType, reader);
                readMayProvideIntents(implType, reader);
                return implType;
            } else {
                throw new ContributionReadException("Unrecognized IntentAttachPointType - " + type);
            }
        } else {
            throw new ContributionReadException("Required attribute '" + TYPE +
                                                "' missing from BindingType Definition");
        }
    }
View Full Code Here

            }

            return workspace;
           
        } catch (XMLStreamException e) {
            throw new ContributionReadException(e);
        } catch (IOException e) {
            throw new ContributionReadException(e);
        } finally {
            try {
                if (urlStream != null) {
                    urlStream.close();
                    urlStream = null;
View Full Code Here

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

//            }
           
            return constrainingType;
           
        } catch (XMLStreamException e) {
            throw new ContributionReadException(e);
        } catch (IOException e) {
            throw new ContributionReadException(e);
        } finally {
            try {
                if (urlStream != null) {
                    urlStream.close();
                    urlStream = 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.