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

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


            if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
                wireFormat.setUseBytesMessage(false);
            }else if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
                wireFormat.setUseBytesMessage(true);
            }else{
                throw new ContributionReadException(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME.toString() +" " +sendFormat + " is not a valid attribute value for " +
                        WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR);
            }
        }

        return wireFormat;
View Full Code Here


            if ("true".equalsIgnoreCase(wrappedSingleInput)) {
                wireFormat.setWrappedSingleInput(true);
            } else if ("false".equalsIgnoreCase(wrappedSingleInput)) {
                wireFormat.setWrappedSingleInput(false);
            } else {
                throw new ContributionReadException(WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME.toString() + ": " + wrappedSingleInput +
                        " is not a valid attribute value for " + WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR);
            }
        }
        return wireFormat;
    }
View Full Code Here

                        if (extension != null) {
                            if (extension instanceof WireFormat) {
                                if (jmsBinding.getRequestWireFormat() == null) {
                                    jmsBinding.setRequestWireFormat((WireFormat) extension);
                                } else {
                                    throw new ContributionReadException("The request wireformat has already been defined. " + "Only one request wire format can be specified.");
                                }
                            } else if (extension instanceof OperationSelector) {
                                if (jmsBinding.getOperationSelector() == null) {
                                    jmsBinding.setOperationSelector((OperationSelector) extension);
                                } else {
                                    throw new ContributionReadException("More than one operation selector has been specified. " + "Only one operation selector can be specified.");
                                }

                            } else {
                                error("UnexpectedElement", reader, extension.toString());
                            }
View Full Code Here

                        if (extension != null) {
                            if (extension instanceof WireFormat) {
                                if (jmsBinding.getResponseWireFormat() == null) {
                                    jmsBinding.setResponseWireFormat((WireFormat)extension);
                                } else {
                                    throw new ContributionReadException("The response wireformat has already been defined. " + "Only one response wire format can be specified.");
                                }
                            } else {
                                error("UnexpectedElement", reader, extension.toString());
                            }
                        }
View Full Code Here

      return contribution;

    } catch (ContributionReadException e) {
      throw e;
    } catch (MalformedURLException e) {
      throw new ContributionReadException(e);
      // } catch (ContributionResolveException e) {
      // throw new ContributionReadException(e);
    } catch (Throwable e) {
      throw new ContributionReadException(e);
    }
  }
View Full Code Here

                    public Boolean run() {
                        return rootFolder.exists();
                    }
                });
                if (!folderExists) {
                    throw new ContributionReadException(rootFolder.getAbsolutePath());
                }

                // Security consideration. This method gathers URIs of enclosed
                // artifacts. The URIs are protected by the policy when a user
                // yries to open those URLs.
                traverse(artifacts, rootFolder, rootFolder);
            }

        } catch (URISyntaxException e) {
            throw new ContributionReadException(packageSourceURL.toExternalForm(), e);
        }

        return artifacts;
    }
View Full Code Here

        try {
            WSDLDefinition definition = indexRead(artifactURL);
            definition.setURI(artifactURI);
            return definition;
        } catch (Exception e) {
          ContributionReadException ce = new ContributionReadException(e);
          error("ContributionReadException", artifactURL, ce);
            //throw ce;
          return null;
        }
    }
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));
                               
                                //handle extension attributes
                                this.readExtendedAttributes(reader, componentProperty);
   
                                policyProcessor.readPolicies(property, reader);
                                readAbstractProperty(componentProperty, reader);
                               
                                // Read the property value
                                Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                                property.setValue(value);
                               
                                component.getProperties().add(componentProperty);
                            } else {
   
                                // Read a <composite><property>
                                property = assemblyFactory.createProperty();
                                policyProcessor.readPolicies(property, reader);
                                readAbstractProperty(property, reader);
                               
                                // Read the property value
                                Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                                property.setValue(value);
                               
                                composite.getProperties().add(property);
                            }
                           
                            // TUSCANY-1949
                            // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
                            if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
                                property = null;
                                componentProperty = null;
                            }
   
                        } else if (COMPONENT_QNAME.equals(name)) {
   
                            // Read a <component>
                            component = assemblyFactory.createComponent();
                            component.setName(getString(reader, NAME));
                            if (isSet(reader, AUTOWIRE)) {
                                component.setAutowire(getBoolean(reader, AUTOWIRE));
                            }
                            if (isSet(reader, URI)) {
                                component.setURI(getString(reader, URI));
                            }
                           
                            //handle extension attributes
                           this.readExtendedAttributes(reader, component);
                           
                            component.setConstrainingType(readConstrainingType(reader));
                            composite.getComponents().add(component);
                            policyProcessor.readPolicies(component, reader);
   
                        } else if (WIRE_QNAME.equals(name)) {
   
                            // Read a <wire>
                            wire = assemblyFactory.createWire();
                            ComponentReference source = assemblyFactory.createComponentReference();
                            source.setUnresolved(true);
                            source.setName(getString(reader, SOURCE));
                            wire.setSource(source);
   
                            ComponentService target = assemblyFactory.createComponentService();
                            target.setUnresolved(true);
                            target.setName(getString(reader, TARGET));
                            wire.setTarget(target);
   
                            //handle extension attributes
                            this.readExtendedAttributes(reader, wire);
   
                            composite.getWires().add(wire);
                            policyProcessor.readPolicies(wire, reader);
   
                        } else if (CALLBACK_QNAME.equals(name)) {
   
                            // Read a <callback>
                            callback = assemblyFactory.createCallback();
                            contract.setCallback(callback);
                           
                            //handle extension attributes
                            this.readExtendedAttributes(reader, callback);
                           
                            policyProcessor.readPolicies(callback, reader);
   
                        } else if (OPERATION_QNAME.equals(name)) {
   
                            // Read an <operation>
                            ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
                            operation.setName(getString(reader, NAME));
                            operation.setUnresolved(true);
                            if (callback != null) {
                                policyProcessor.readPolicies(operation, reader);
                            } else {
                                policyProcessor.readPolicies(operation, reader);
                            }
                           
                            OperationsConfigurator opConfigurator = null;
                            if ( compositeService != null ) {
                                opConfigurator = compositeService;
                            } else if ( componentService != null ) {
                                opConfigurator = componentService;
                            } else if ( compositeReference != null ) {
                                opConfigurator = compositeReference;
                            } else if ( componentReference != null ) {
                                opConfigurator = componentReference;
                            }
                           
                            opConfigurator.getConfiguredOperations().add(operation);
                        } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
   
                            // Read an implementation.composite
                            Composite implementation = assemblyFactory.createComposite();
                            implementation.setName(getQName(reader, NAME));
                            implementation.setUnresolved(true);
                           
                            //handle extension attributes
                            this.readExtendedAttributes(reader, implementation);
   
                            component.setImplementation(implementation);
                            policyProcessor.readPolicies(implementation, reader);
                        } else {
   
                            // Read an extension element
                            Object extension = extensionProcessor.read(reader);
                            if (extension != null) {
                                if (extension instanceof InterfaceContract) {
   
                                    // <service><interface> and
                                    // <reference><interface>
                                    if (contract != null) {
                                        contract.setInterfaceContract((InterfaceContract)extension);
                                    } else {
                                        if (name.getNamespaceURI().equals(SCA10_NS)) {
                                          error("UnexpectedInterfaceElement", extension);
                                            //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) {
                                    if ( extension instanceof PolicySetAttachPoint ) {
                                        IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
                                        bindingType.setName(name);
                                        bindingType.setUnresolved(true);
                                        ((PolicySetAttachPoint)extension).setType(bindingType);
                                    }
                                    // <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)) {
                                              error("UnexpectedBindingElement", extension);
                                                //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) {
                                    if ( extension instanceof PolicySetAttachPoint ) {
                                        IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
                                        implType.setName(name);
                                        implType.setUnresolved(true);
                                        ((PolicySetAttachPoint)extension).setType(implType);
                                    }
                                    // <component><implementation>
                                    if (component != null) {
                                        component.setImplementation((Implementation)extension);
                                    } else {
                                        if (name.getNamespaceURI().equals(SCA10_NS)) {
                                          error("UnexpectedImplementationElement", extension);
                                            //throw new ContributionReadException("Unexpected <implementation> element found. It should appear inside a <component> element");
                                        } else {
                                            composite.getExtensions().add(extension);
                                        }
                                    }
                                } else {
   
                                    // Add the extension element to the current
                                    // element
                                    if (callback != null) {
                                        callback.getExtensions().add(extension);
                                    } else if (contract != null) {
                                        contract.getExtensions().add(extension);
                                    } else if (property != null) {
                                        property.getExtensions().add(extension);
                                    } else if (component != null) {
                                        component.getExtensions().add(extension);
                                    } else {
                                        composite.getExtensions().add(extension);
                                    }
                                }
                            }
                        }
                        break;
   
                    case XMLStreamConstants.CHARACTERS:
                        break;
   
                    case END_ELEMENT:
                        name = reader.getName();
   
                        // Clear current state when reading reaching end element
                        if (SERVICE_QNAME.equals(name)) {
                            componentService = null;
                            compositeService = null;
                            contract = null;
                        } else if (INCLUDE_QNAME.equals(name)) {
                            include = null;
                        } else if (REFERENCE_QNAME.equals(name)) {
                            componentReference = null;
                            compositeReference = null;
                            contract = null;
                        } else if (PROPERTY_QNAME.equals(name)) {
                            componentProperty = null;
                            property = null;
                        } else if (COMPONENT_QNAME.equals(name)) {
                            component = null;
                        } else if (WIRE_QNAME.equals(name)) {
                            wire = null;
                        } else if (CALLBACK_QNAME.equals(name)) {
                            callback = null;
                        }
                        break;
                }
   
                // Read the next element
                if (reader.hasNext()) {
                    reader.next();
                }
            }
        }
        catch (XMLStreamException e) {
            ContributionReadException ex = new ContributionReadException(e);
            error("ContributionReadException", reader, ex);
        }
       
        return composite;
    }
View Full Code Here

                    error("HttpServerError", url, ((HttpURLConnection)connection).getResponseMessage());
                }
                throw e;
            }
        } catch (IOException e) {
            ContributionReadException ce = new ContributionReadException(e);
            error("ContributionReadException", url, e);
            throw ce;
        }
        return read(uri, scdlStream);
    }
View Full Code Here

                        e.printStackTrace();
                    }
*/                   
                }
            } catch ( IOException e ) {
              ContributionReadException ce = new ContributionReadException(e);
              error("ContributionReadException", scdlStream, e);
              throw ce;
            } catch ( Exception e ) {
              ContributionReadException ce = new ContributionReadException(e);
              error("ContributionReadException", scdlStream, e);
                //throw ce;
            }
           
            XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
           
            reader.nextTag();
           
            // Read the composite model
            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) {
          ContributionReadException ce = new ContributionReadException(e);
          error("ContributionReadException", inputFactory, e);
            throw ce;
        } finally {
            try {
                if (scdlStream != 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.