Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.ExceptionMapping



    private FaultDesc mapException(String faultName, Fault fault) throws DeploymentException {
        Message message = fault.getMessage();
        QName messageQName = message.getQName();
        ExceptionMapping exceptionMapping = (ExceptionMapping) exceptionMap.get(messageQName);
        if (exceptionMapping == null) {
            throw new DeploymentException("No exception mapping for fault " + faultName + " and fault message " + messageQName + " for operation " + operationName);
        }
        String className = exceptionMapping.getExceptionType();
        //TODO investigate whether there are other cases in which the namespace of faultQName can be determined.
        //this is weird, but I can't figure out what it should be.
        //if part has an element rather than a type, it should be part.getElementName() (see below)
        QName faultQName = new QName("", faultName);
        Part part;
        if (exceptionMapping.getWsdlMessagePartName() != null) {
            //According to schema documentation, this will only be set when several headerfaults use the same message.
            String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName();
            part = message.getPart(headerFaultMessagePartName);
        } else {
            part = (Part) message.getOrderedParts(null).iterator().next();
        }
        QName faultTypeQName;// = part.getElementName() == null ? part.getTypeName() : part.getElementName();
        if (part.getElementName() == null) {
            faultTypeQName = part.getTypeName();
            if (faultTypeQName == null) {
                throw new DeploymentException("Neither type nor element name supplied for part: " + part);
            }
        } else {
            faultQName = part.getElementName();
            faultTypeQName = (QName) schemaInfoBuilder.getElementToTypeMap().get(part.getElementName());
            if (faultTypeQName == null) {
                throw new DeploymentException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfoBuilder.getElementToTypeMap());
            }
        }
        SchemaType complexType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(faultTypeQName);
        boolean isComplex = complexType != null;
        FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);

        //constructor parameters
        if (exceptionMapping.getConstructorParameterOrder() != null) {
            if (!isComplex) {
                throw new DeploymentException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeQName);
            }
            Map elementMap = new HashMap();
            SchemaProperty[] properties = complexType.getProperties();
            for (int i = 0; i < properties.length; i++) {
                SchemaProperty property = properties[i];
                QName elementName = property.getName();
                SchemaType elementType = property.getType();
                elementMap.put(elementName.getLocalPart(), elementType);
            }
            ArrayList parameterTypes = new ArrayList();
            ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
            for (String elementName: constructorParameterOrder.getElementName()) {
                SchemaType elementType = (SchemaType) elementMap.get(elementName);
                Class javaElementType;

                QName elementTypeQName = elementType.getName();
View Full Code Here


        operationInfo.returnJavaType = wsdlReturnValueMapping.getMethodReturnValue();
    }

    private JaxRpcFaultInfo mapFaults(final Fault fault) throws OpenEJBException {
        final Message message = fault.getMessage();
        final ExceptionMapping exceptionMapping = mapping.getExceptionMappingMap().get(message.getQName());
        if (exceptionMapping == null) {
            throw new OpenEJBException("No exception mapping for fault " + fault.getName() + " and fault message " + message.getQName() + " for operation " + operationName);
        }

        // TODO investigate whether there are other cases in which the namespace of faultQName can be determined.
        // this is weird, but I can't figure out what it should be.
        // if part has an element rather than a type, it should be part.getElementName() (see below)
        final Part part;
        if (exceptionMapping.getWsdlMessagePartName() != null) {
            // According to schema documentation, this will only be set when several headerfaults use the same message.
            final String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName();
            part = message.getPart(headerFaultMessagePartName);
        } else {
            part = (Part) message.getOrderedParts(null).iterator().next();
        }

        // Determine the fault qname and xml schema type
        final QName faultQName;
        final XmlTypeInfo faultTypeInfo;
        if (part.getElementName() != null) {
            final XmlElementInfo elementInfo = schemaInfo.elements.get(part.getElementName());
            if (elementInfo == null) {
                throw new OpenEJBException("Can not find element: " + part.getElementName() + ", known elements: " + schemaInfo.elements.keySet());
            }
            faultTypeInfo = schemaInfo.types.get(elementInfo.xmlType);
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type " + elementInfo.xmlType + " for element " + elementInfo.qname + ", known types: " + schemaInfo.types.keySet());
            }

            faultQName = part.getElementName();
        } else if (part.getTypeName() != null) {
            faultTypeInfo = schemaInfo.types.get(part.getTypeName());
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type: " + part.getTypeName() + ", known elements: " + schemaInfo.types.keySet());
            }

            faultQName = new QName("", fault.getName());
        } else {
            throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
        }

        //
        // Build the fault info
        //
        final JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
        faultInfo.qname = faultQName;
        faultInfo.xmlType = faultTypeInfo.qname;
        faultInfo.javaType = exceptionMapping.getExceptionType();
        faultInfo.complex = faultTypeInfo.simpleBaseType == null;

        //
        // Map exception class constructor args
        //
        if (exceptionMapping.getConstructorParameterOrder() != null) {
            if (faultTypeInfo.simpleBaseType != null) {
                throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.qname);
            }

            final Map<String, XmlElementInfo> elements = new HashMap<String, XmlElementInfo>();
            for (final XmlElementInfo element : faultTypeInfo.elements.values()) {
                elements.put(element.qname.getLocalPart(), element);
            }

            final ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
            for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
                final String paramName = constructorParameterOrder.getElementName().get(i);

                // get the parameter element
                final XmlElementInfo paramElementInfo = elements.get(paramName);
View Full Code Here

        operationInfo.returnJavaType = wsdlReturnValueMapping.getMethodReturnValue();
    }

    private JaxRpcFaultInfo mapFaults(Fault fault) throws OpenEJBException {
        Message message = fault.getMessage();
        ExceptionMapping exceptionMapping = mapping.getExceptionMappingMap().get(message.getQName());
        if (exceptionMapping == null) {
            throw new OpenEJBException("No exception mapping for fault " + fault.getName() + " and fault message " + message.getQName() + " for operation " + operationName);
        }

        // TODO investigate whether there are other cases in which the namespace of faultQName can be determined.
        // this is weird, but I can't figure out what it should be.
        // if part has an element rather than a type, it should be part.getElementName() (see below)
        Part part;
        if (exceptionMapping.getWsdlMessagePartName() != null) {
            // According to schema documentation, this will only be set when several headerfaults use the same message.
            String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName();
            part = message.getPart(headerFaultMessagePartName);
        } else {
            part = (Part) message.getOrderedParts(null).iterator().next();
        }

        // Determine the fault qname and xml schema type
        QName faultQName;
        XmlTypeInfo faultTypeInfo;
        if (part.getElementName() != null) {
            XmlElementInfo elementInfo = schemaInfo.elements.get(part.getElementName());
            if (elementInfo == null) {
                throw new OpenEJBException("Can not find element: " + part.getElementName() + ", known elements: " + schemaInfo.elements.keySet());
            }
            faultTypeInfo = schemaInfo.types.get(elementInfo.xmlType);
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type " + elementInfo.xmlType + " for element " + elementInfo.qname + ", known types: " + schemaInfo.types.keySet());
            }

            faultQName = part.getElementName();
        } else if (part.getTypeName() != null) {
            faultTypeInfo = schemaInfo.types.get(part.getTypeName());
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type: " + part.getTypeName() + ", known elements: " + schemaInfo.types.keySet());
            }

            faultQName = new QName("", fault.getName());
        } else {
            throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
        }

        //
        // Build the fault info
        //
        JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
        faultInfo.qname = faultQName;
        faultInfo.xmlType = faultTypeInfo.qname;
        faultInfo.javaType = exceptionMapping.getExceptionType();
        faultInfo.complex = faultTypeInfo.simpleBaseType == null;

        //
        // Map exception class constructor args
        //
        if (exceptionMapping.getConstructorParameterOrder() != null) {
            if (faultTypeInfo.simpleBaseType != null) {
                throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.qname);
            }

            Map<String, XmlElementInfo> elements = new HashMap<String, XmlElementInfo>();
            for (XmlElementInfo element : faultTypeInfo.elements.values()) {
                elements.put(element.qname.getLocalPart(), element);
            }

            ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
            for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
                String paramName = constructorParameterOrder.getElementName().get(i);

                // get the parameter element
                XmlElementInfo paramElementInfo = elements.get(paramName);
View Full Code Here

        operationInfo.returnJavaType = wsdlReturnValueMapping.getMethodReturnValue();
    }

    private JaxRpcFaultInfo mapFaults(Fault fault) throws OpenEJBException {
        Message message = fault.getMessage();
        ExceptionMapping exceptionMapping = mapping.getExceptionMappingMap().get(message.getQName());
        if (exceptionMapping == null) {
            throw new OpenEJBException("No exception mapping for fault " + fault.getName() + " and fault message " + message.getQName() + " for operation " + operationName);
        }

        // TODO investigate whether there are other cases in which the namespace of faultQName can be determined.
        // this is weird, but I can't figure out what it should be.
        // if part has an element rather than a type, it should be part.getElementName() (see below)
        Part part;
        if (exceptionMapping.getWsdlMessagePartName() != null) {
            // According to schema documentation, this will only be set when several headerfaults use the same message.
            String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName();
            part = message.getPart(headerFaultMessagePartName);
        } else {
            part = (Part) message.getOrderedParts(null).iterator().next();
        }

        // Determine the fault qname and xml schema type
        QName faultQName;
        XmlTypeInfo faultTypeInfo;
        if (part.getElementName() != null) {
            XmlElementInfo elementInfo = schemaInfo.elements.get(part.getElementName());
            if (elementInfo == null) {
                throw new OpenEJBException("Can not find element: " + part.getElementName() + ", known elements: " + schemaInfo.elements.keySet());
            }
            faultTypeInfo = schemaInfo.types.get(elementInfo.xmlType);
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type " + elementInfo.xmlType + " for element " + elementInfo.qname + ", known types: " + schemaInfo.types.keySet());
            }

            faultQName = part.getElementName();
        } else if (part.getTypeName() != null) {
            faultTypeInfo = schemaInfo.types.get(part.getTypeName());
            if (faultTypeInfo == null) {
                throw new OpenEJBException("Can not find type: " + part.getTypeName() + ", known elements: " + schemaInfo.types.keySet());
            }

            faultQName = new QName("", fault.getName());
        } else {
            throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
        }

        //
        // Build the fault info
        //
        JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
        faultInfo.qname = faultQName;
        faultInfo.xmlType = faultTypeInfo.qname;
        faultInfo.javaType = exceptionMapping.getExceptionType();
        faultInfo.complex = faultTypeInfo.simpleBaseType == null;

        //
        // Map exception class constructor args
        //
        if (exceptionMapping.getConstructorParameterOrder() != null) {
            if (faultTypeInfo.simpleBaseType != null) {
                throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.qname);
            }

            Map<String, XmlElementInfo> elements = new HashMap<String, XmlElementInfo>();
            for (XmlElementInfo element : faultTypeInfo.elements.values()) {
                elements.put(element.qname.getLocalPart(), element);
            }

            ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
            for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
                String paramName = constructorParameterOrder.getElementName().get(i);

                // get the parameter element
                XmlElementInfo paramElementInfo = elements.get(paramName);
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.ExceptionMapping

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.