Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.SchemaType


                }
            } else {
                throw new DeploymentException("either root type qname or anonymous type qname must be set");
            }

            SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
            if (schemaType == null) {
                // if it is a built-in type, then one assumes a redundant mapping.
                if (null != TypeMappingLookup.getFactoryPair(key.getqName())) {
                    continue;
                }
//              throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
                log.warn("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
                continue;
            }
            mappedTypeQNames.add(key.getqName());

            String className = javaXmlTypeMapping.getJavaType();
            Class clazz = null;
            try {
                clazz = ClassLoading.loadClass(className, bundle);
            } catch (ClassNotFoundException e2) {
                throw new DeploymentException("Could not load java type", e2);
            }

            TypeInfo.UpdatableTypeInfo internalTypeInfo = defineSerializerPair(schemaType, clazz);

            populateInternalTypeInfo(clazz, key, schemaType, javaXmlTypeMapping, internalTypeInfo);

            typeInfoList.add(internalTypeInfo.buildTypeInfo());
        }

        Map qNameToKey = new HashMap();
        for (Iterator iter = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iter.hasNext();) {
            SchemaTypeKey key = (SchemaTypeKey) iter.next();
            qNameToKey.put(key.getqName(), key);
        }

        for (Iterator iter = operations.iterator(); iter.hasNext();) {
            OperationDesc operationDesc = (OperationDesc) iter.next();
            ArrayList parameters = new ArrayList(operationDesc.getParameters());
            ParameterDesc returnParameterDesc = operationDesc.getReturnParamDesc();
            if (null != returnParameterDesc.getTypeQName() &&
                    false == returnParameterDesc.getTypeQName().equals(XMLType.AXIS_VOID)) {
                parameters.add(returnParameterDesc);
            }
            for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
                ParameterDesc parameterDesc = (ParameterDesc) iterator.next();
                QName typeQName = parameterDesc.getTypeQName();
                if (null == typeQName) {
                    continue;
                } else if (mappedTypeQNames.contains(typeQName)) {
                    continue;
                } else if (typeQName.getNamespaceURI().equals(XML_SCHEMA_NS) ||
                        typeQName.getNamespaceURI().equals(SOAP_ENCODING_NS)) {
                    continue;
                }

                SchemaTypeKey key = (SchemaTypeKey) qNameToKey.get(typeQName);
                if (null == key) {
                    log.warn("Type QName [" + typeQName + "] defined by operation [" +
                            operationDesc + "] has not been found in schema: " + schemaTypeKeyToSchemaTypeMap);
                    continue;
                }
                SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
                mappedTypeQNames.add(key.getqName());

                if (false == schemaType.isSimpleType()) {
                    if (false == parameterDesc.getJavaType().isArray()) {
                        if (false == mappedTypeQNames.contains(schemaType.getName())) {
                            // TODO: this lookup is not enough: the jaxrpc mapping file may define an anonymous
                            // mapping.
                            log.warn("Operation [" + operationDesc + "] uses XML type [" + schemaType +
                                    "], whose mapping is not declared by the jaxrpc mapping file.\n Continuing deployment; " +
                                    "yet, the deployment is not-portable.");
View Full Code Here


        }

        if (wrappedStyle) {
            Part inputPart = getWrappedPart(input);
            QName name = inputPart.getElementName();
            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedInParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //parametersType can be null if the element has empty content such as
//            <element name="getMarketSummary">
//             <complexType>
//              <sequence/>
//             </complexType>
//            </element>

            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedInParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
                    SchemaParticle[] parameters = parametersType.getParticleChildren();
                    for (int i = 0; i < parameters.length; i++) {
                        expectedInParams.add(parameters[i].getName().getLocalPart());
                    }
                }
            }
            if (!inParamNames.equals(expectedInParams)) {
                throw new DeploymentException("Not all wrapper children were mapped for operation name" + operationName);
            }
        } else {
            //check that all input message parts are mapped
            if (!inParamNames.equals(input.getParts().keySet())) {
                throw new DeploymentException("Not all input message parts were mapped for operation name" + operationName);
            }
        }

        Class[] paramTypes = new Class[parameterDescriptions.length];
        for (int i = 0; i < parameterDescriptions.length; i++) {
            ParameterDesc parameterDescription = parameterDescriptions[i];
            if (parameterDescription == null) {
                throw new DeploymentException("There is no mapping for parameter number " + i + " for operation " + operationName);
            }
            operationDesc.addParameter(parameterDescription);
            paramTypes[i] = parameterDescription.getJavaType();
        }

        String methodName = methodMapping.getJavaMethodName();
        Method method = null;
        try {
            method = serviceEndpointInterface.getMethod(methodName, paramTypes);
        } catch (NoSuchMethodException e) {
            String args = "(";
            for (int i = 0; i < paramTypes.length; i++) {
                args += paramTypes[i].getName();
                if (i < paramTypes.length - 1) {
                    args += ",";
                }
            }
            args += ")";

            throw new DeploymentException("Mapping references non-existent method in service-endpoint: " + methodName + args);
        }

        operationDesc.setMethod(method);

        // MAP RETURN TYPE
        operationDesc.setMep(operation.getStyle());
        if (methodMapping.getWsdlReturnValueMapping() != null) {
            mapReturnType();
        } else if (operation.getStyle() == OperationType.REQUEST_RESPONSE) {
            //TODO WARNING THIS APPEARS TO SUBVERT THE COMMENT IN j2ee_jaxrpc_mapping_1_1.xsd IN service-endpoint-method-mappingType:
            //The wsdl-return-value-mapping is not specified for one-way operations.
            operationDesc.setReturnQName(null);             //??
            operationDesc.setReturnType(XMLType.AXIS_VOID);
            operationDesc.setReturnClass(void.class);
        }

        if (null != output && wrappedStyle) {
            Part inputPart = getWrappedPart(output);
            QName name = inputPart.getElementName();
            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedOutParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //again, no output can give null parametersType
            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedOutParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
View Full Code Here

            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();
                if (elementTypeQName != null) {
                    if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(elementType)) {
                        String javaClassName = (String) publicTypes.get(elementTypeQName);
                        if (javaClassName == null) {
                            throw new DeploymentException("No class mapped for element type: " + elementType);
                        }
                        javaElementType = getJavaClass(javaClassName);
                    } else {
                        javaElementType = (Class) qnameToClassMap.get(elementTypeQName);
                        if (javaElementType == null) {
                            throw new DeploymentException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + elementTypeQName);
                        }
                    }
                } else {
                    //anonymous type
                    //anonymous type qname is constructed using rules 1.b and 2.b
                    String anonymousQName = complexType.getName().getNamespaceURI() + ":>" + complexType.getName().getLocalPart() + ">" + elementName;
                    String javaClassName = (String) anonymousTypes.get(anonymousQName);
                    if (javaClassName == null) {
                        if (elementType.isSimpleType()) {
                            //maybe it's a restriction of a built in simple type
                            SchemaType baseType = elementType.getBaseType();
                            QName simpleTypeQName = baseType.getName();
                            javaElementType = (Class) qnameToClassMap.get(simpleTypeQName);
                            if (javaElementType == null) {
                                throw new DeploymentException("Unknown simple type: " + elementType + " of name: " + elementName + " and QName: " + simpleTypeQName);
                            }
                        } else {
View Full Code Here

    private SchemaParticle getWrapperChild(Part part, String wsdlMessagePartName) throws DeploymentException {
        QName name = part.getElementName();

        wrapperElementQNames.add(name);

        SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);
        if (null == operationType) {
            throw new DeploymentException("No global element named " + name + " for operation " + operationName);
        }

        // schemaType should be complex using xsd:sequence compositor
        SchemaParticle parametersType = operationType.getContentModel();
        if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
            if (parametersType.getName().getLocalPart().equals(wsdlMessagePartName)) {
                return parametersType;
            }
            throw new DeploymentException("Global element named " + name +
View Full Code Here

        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
            if (!key.isSimpleType() && !key.isAnonymous()) {
                QName qName = key.getqName();
                SchemaType schemaType = (SchemaType) entry.getValue();
                complexTypeMap.put(qName, schemaType);
            }
        }
        return complexTypeMap;
    }
View Full Code Here

        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
            if (key.isElement()) {
                QName elementQName = key.getqName();
                SchemaType schemaType = (SchemaType) entry.getValue();
                QName typeQName = schemaType.getName();
                elementToTypeMap.put(elementQName, typeQName);
            }
        }
        return elementToTypeMap;
    }
View Full Code Here

        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
            if (key.isSimpleType() && !key.isAnonymous()) {
                QName qName = key.getqName();
                SchemaType schemaType = (SchemaType) entry.getValue();
                simpleTypeMap.put(qName, schemaType);
            }
        }
        return simpleTypeMap;
    }
View Full Code Here

     */
    private Map buildSchemaTypeKeyToSchemaTypeMap(SchemaTypeSystem schemaTypeSystem) {
        Map qnameMap = new HashMap();
        SchemaType[] globalTypes = schemaTypeSystem.globalTypes();
        for (int i = 0; i < globalTypes.length; i++) {
            SchemaType globalType = globalTypes[i];
            QName typeQName = globalType.getName();
            addSchemaType(typeQName, globalType, false, qnameMap);
        }
        SchemaGlobalElement[] globalElements = schemaTypeSystem.globalElements();
        for (int i = 0; i < globalElements.length; i++) {
            SchemaGlobalElement globalElement = globalElements[i];
View Full Code Here

            String enclosingTypeLocalName = enclosingTypeQName.getLocalPart();
            elementQNameLocalName = enclosingTypeLocalName + ">" + elementName.getLocalPart();
            QName subElementName = new QName(elementNamespace, elementQNameLocalName);
            elementKey = new SchemaTypeKey(subElementName, true, false, true, elementName);
        }
        SchemaType schemaType = element.getType();
        qnameMap.put(elementKey, schemaType);
//        new Exception("Adding: " + elementKey.getqName().getLocalPart()).printStackTrace();
        //check if it's an array. maxOccurs is null if unbounded
        //element should always be a SchemaParticle... this is a workaround for XMLBEANS-137
        if (element instanceof SchemaParticle) {
View Full Code Here

    }


    private void addSchemaParticle(SchemaParticle schemaParticle, SchemaTypeKey key, Map qnameMap) {
        if (schemaParticle.getParticleType() == SchemaParticle.ELEMENT) {
            SchemaType elementType = schemaParticle.getType();
            SchemaField element = elementType.getContainerField();
            //element will be null if the type is defined elsewhere, such as a built in type.
            if (element != null) {
                addElement(element, key, qnameMap);
            } else {
                QName keyQName = key.getqName();
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.SchemaType

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.