org.apache.ws.commons.schema.XmlSchemaComplexType Java Examples

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaComplexType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Get the DidRefSource for a reference schema type
 */
DidRefSource getRefSource(XmlSchemaComplexType refSchema) {
    DidRefSource refSource = null;
    String schemaName = refSchema.getName();
    if (refSourceCache.containsKey(schemaName)) {
        refSource = refSourceCache.get(schemaName);
        // if a cached refSource is found create return new DidRefSource of same type
        if (refSource != null) {
            DidRefSource cachedRefSource = refSource;
            refSource = new DidRefSource();
            refSource.setEntityType(cachedRefSource.getEntityType());
        }
    } else {
        XmlSchemaAnnotation annotation = refSchema.getAnnotation();
        if (annotation == null) {
            LOG.debug("Annotation missing from refSchema: {}", refSchema.getName());
        } else {
            refSource = parseAnnotationForRef(annotation);
            refSourceCache.put(schemaName, refSource);
        }
    }
    return refSource;
}
 
Example #2
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<XmlSchemaAttributeOrGroupRef> getContentAttributes(XmlSchemaComplexType type) {
    XmlSchemaContentModel model = type.getContentModel();
    if (model == null) {
        return null;
    }
    XmlSchemaContent content = model.getContent();
    if (content == null) {
        return null;
    }
    if (!(content instanceof XmlSchemaComplexContentExtension)) {
        return null;
    }

    XmlSchemaComplexContentExtension ext = (XmlSchemaComplexContentExtension)content;
    return ext.getAttributes();
}
 
Example #3
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<XmlSchemaAnnotated> getContentAttributes(XmlSchemaComplexType type,
                                                            SchemaCollection collection) {
    List<XmlSchemaAnnotated> results = new ArrayList<>();
    QName baseTypeName = getBaseType(type);
    if (baseTypeName != null) {
        XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
        // recurse onto the base type ...
        results.addAll(getContentAttributes(baseType, collection));
        // and now process our sequence.
        List<XmlSchemaAttributeOrGroupRef> extAttrs = getContentAttributes(type);
        results.addAll(extAttrs);
        return results;
    }
    // no base type, the simple case.
    List<XmlSchemaAttributeOrGroupRef> attrs = type.getAttributes();
    results.addAll(attrs);
    return results;
}
 
Example #4
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
private CorbaType processComplexType(XmlSchemaComplexType complex, QName defaultName,
                                         XmlSchemaAnnotation annotation,
                                         boolean anonymous) throws Exception {
    CorbaType corbatype = null;
    if (isLiteralArray(complex)) {
        corbatype = processLiteralArray(complex, defaultName, anonymous);
    } else if (WSDLTypes.isOMGUnion(complex)) {
        corbatype = processOMGUnion(complex, defaultName);
    } else if (WSDLTypes.isUnion(complex)) {
        corbatype = processRegularUnion(complex, defaultName);
    } else if (complex.getQName() != null && isIDLObjectType(complex.getQName())) {
        // process it.
        corbatype = WSDLTypes.processObject(def, complex, annotation, checkPrefix(complex.getQName()),
                                            defaultName, idlNamespace);
    } else {
        // Deal the ComplexType as Struct
        corbatype = processStruct(complex, defaultName);
    }
    return corbatype;
}
 
Example #5
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
public boolean isLiteralArray(XmlSchemaComplexType type) {
    boolean array = false;

    if ((type.getAttributes().isEmpty())
        && (type.getParticle() instanceof XmlSchemaSequence)) {
        XmlSchemaSequence stype = (XmlSchemaSequence)type.getParticle();

        if ((stype.getItems().size() == 1)
            && (stype.getItems().get(0) instanceof XmlSchemaElement)) {
            XmlSchemaElement el = (XmlSchemaElement)stype.getItems().get(0);
            if (el.getMaxOccurs() != 1) {
                // it's a literal array
                array = true;
            }
            if (el.getMaxOccurs() == 1
                && el.getMinOccurs() == 1
                && type.getName() != null
                &&  WSDLTypes.isAnonymous(type.getName())) {
                array = true;
            }
        }
    }
    return array;
}
 
Example #6
Source File: SchemaCollection.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
    // the base type might cross schemas.
    if (schemaType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType;
        XmlSchemaUtils.addImportIfNeeded(schema, complexType.getBaseSchemaTypeName());
        addCrossImports(schema, complexType.getContentModel());
        addCrossImportsAttributeList(schema, complexType.getAttributes());
        // could it be a choice or something else?

        if (complexType.getParticle() instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice)complexType.getParticle();
            addCrossImports(schema, choice);
        } else if (complexType.getParticle() instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll)complexType.getParticle();
            addCrossImports(schema, all);
        } else if (complexType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle();
            addCrossImports(schema, sequence);
        }
    }
}
 
Example #7
Source File: SmooksGenerator.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private void cacheComplexTypeData() {
    for (Entry<String, XmlSchemaComplexType> complexTypeEntry : complexTypes.entrySet()) {
        ComplexTypeData complexData = new ComplexTypeData();

        // add the top level elements and attributes
        addComplexTypeData(complexTypeEntry.getValue(), complexData);

        // add the base level elements and attributes
        String baseTypeName = extractBaseTypeName(complexTypeEntry.getValue());
        while (baseTypeName != null) {
            XmlSchemaComplexType baseType = complexTypes.get(baseTypeName);
            addComplexTypeData(baseType, complexData);
            baseTypeName = extractBaseTypeName(baseType);
        }

        complexTypesData.put(complexTypeEntry.getKey(), complexData);
    }
}
 
Example #8
Source File: MapType.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void writeSchema(XmlSchema root) {
    XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
    complex.setName(getSchemaType().getLocalPart());
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    complex.setParticle(sequence);

    AegisType kType = getKeyType();
    AegisType vType = getValueType();

    XmlSchemaElement element = new XmlSchemaElement(root, false);
    sequence.getItems().add(element);
    element.setName(getEntryName().getLocalPart());
    element.setMinOccurs(0);
    element.setMaxOccurs(Long.MAX_VALUE);

    XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false);
    element.setType(evType);

    XmlSchemaSequence evSequence = new XmlSchemaSequence();
    evType.setParticle(evSequence);

    createElement(root, evSequence, getKeyName(), kType, false);
    createElement(root, evSequence, getValueName(), vType, true);
}
 
Example #9
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void addType(QName typeQName, XmlSchemaType type) {
    // skip built in xml schema types
    if (XML_SCHEMA_NS.equals(typeQName.getNamespaceURI())) {
        return;
    }

    XmlTypeInfo typeInfo = createXmlTypeInfo(typeQName, type);
    xmlTypes.put(typeQName, typeInfo);

    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;

        // process elements nested inside of this element
        List<XmlSchemaElement> elements = getNestedElements(complexType);
        for (XmlSchemaElement element : elements) {
            addNestedElement(element, typeInfo);
        }
    }
}
 
Example #10
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Initialization method, parses XSD for complexTypes and referenceTypes
 */
@PostConstruct
public void setup() {
    complexTypes = new HashMap<String, XmlSchemaComplexType>();

    Resource xsdResource = resourceLoader.getResource(xsdLocation);
    Resource extensionXsdResource = resourceLoader.getResource(extensionXsdLocation);

    // extract complex types from base schema
    cacheComplexTypesFromResource(xsdResource, xsdParentLocation);
    // extract complex types from extension schema
    cacheComplexTypesFromResource(extensionXsdResource, extensionXsdParentLocation);

    // extract and cache the reference types from the complexTypes
    cacheReferenceTypes();

    extractBaseTypesFromCache();

    refSourceCache = new HashMap<String, DidRefSource>();

    // extract the Did configuration objects
    entityConfigs = extractEntityConfigs();
    refConfigs = addExternalKeyFields(extractRefConfigs());
    naturalKeys = extractNaturalKeys();
}
 
Example #11
Source File: SchemaJavascriptBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Build the serialization code for a complex type. At the top level, this operates on single items, so it
 * does not pay attention to minOccurs and maxOccurs. However, as it works through the sequence, it
 * manages optional elements and arrays.
 *
 * @param type
 * @param elementPrefix
 * @param bodyUtils
 * @return
 */
protected void complexTypeSerializerBody(XmlSchemaComplexType type, String elementPrefix,
                                         JavascriptUtils bodyUtils) {
    List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
    for (XmlSchemaObject sequenceItem : items) {
        ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem, xmlSchema, xmlSchemaCollection,
                                                          prefixAccumulator, type.getQName());

        // If the item is 'any', it could be ANY of our top-level elements.
        if (itemInfo.isAny()) {
            serializeAny(itemInfo, bodyUtils);
        } else {
            bodyUtils.generateCodeToSerializeElement(itemInfo, "this._", xmlSchemaCollection);
        }
    }
}
 
Example #12
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * extract all complex types from a schema and cache into a map
 */
private void cacheComplexTypes(XmlSchema schema) {
    XmlSchemaObjectCollection schemaItems = schema.getItems();

    int numElements = schemaItems.getCount();

    // Iterate XML Schema items
    for (int i = 0; i < numElements; i++) {
        XmlSchemaObject schemaObject = schemaItems.getItem(i);
        if (schemaObject instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaObject;
            String elementTypeName = complexType.getName();
            complexTypes.put(elementTypeName, complexType);
        }
    }
}
 
Example #13
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Extract a DidEntityConfig for a ComplexType.
 * Returns null if the reference contains no DID references.
 */
private DidEntityConfig extractEntityConfig(XmlSchemaComplexType complexType) {
    DidEntityConfig entityConfig = null;

    List<DidRefSource> refSources = new ArrayList<DidRefSource>();
    parseParticleForRef(extractParticle(complexType), refSources, false);

    // parse base type as well if it has one - we only ever need to go
    if (complexType.getBaseSchemaTypeName() != null) {
        String baseTypeName = complexType.getBaseSchemaTypeName().getLocalPart();
        XmlSchemaComplexType baseType = complexTypes.get(baseTypeName);
        if (baseType != null) {
            parseParticleForRef(extractParticle(baseType), refSources, false);
        } else {
            LOG.error("Failed to parse base entity type " + baseTypeName + " - could not find complex type");
        }
    }

    // if any DidRefSources were found for this complex type, create a DidEntityConfig
    if (refSources.size() > 0) {
        entityConfig = new DidEntityConfig();
        entityConfig.setReferenceSources(refSources);
    }

    return entityConfig;
}
 
Example #14
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Extract a particle from a complex type, respecting both extensions and restrictions
 * returns null if there isn't one.
 */
private String extractBaseTypeName(XmlSchemaComplexType complexType) {
    String baseTypeName = null;

    if (complexType.getBaseSchemaTypeName() != null) {
        baseTypeName = complexType.getBaseSchemaTypeName().getLocalPart();
    } else if (complexType.getContentModel() != null && complexType.getContentModel().getContent() != null) {
        XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentRestriction) {
            XmlSchemaComplexContentRestriction contentRestriction = (XmlSchemaComplexContentRestriction) content;
            if (contentRestriction.getBaseTypeName() != null) {
                baseTypeName = contentRestriction.getBaseTypeName().getLocalPart();
            }
        }
    }

    return baseTypeName;
}
 
Example #15
Source File: JavascriptUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Return true for xsd:base64Binary or simple restrictions of it, as in the xmime stock type.
 * @param type
 * @return
 */
public static boolean mtomCandidateType(XmlSchemaType type) {
    if (type == null) {
        return false;
    }
    if (Constants.XSD_BASE64.equals(type.getQName())) {
        return true;
    }
    // there could be some disagreement whether the following is a good enough test.
    // what if 'base64binary' was extended in some crazy way? At runtime, either it has
    // an xop:Include or it doesn't.
    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
        if (complexType.getContentModel() instanceof XmlSchemaSimpleContent) {
            XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)complexType.getContentModel();
            if (content.getContent() instanceof XmlSchemaSimpleContentExtension) {
                XmlSchemaSimpleContentExtension extension =
                    (XmlSchemaSimpleContentExtension)content.getContent();
                if (Constants.XSD_BASE64.equals(extension.getBaseTypeName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #16
Source File: Xsd2CobolTypesModelBuilder.java    From legstar-core2 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Process each element in the input Schema.
 * <p/>
 * 
 * @param xmlSchema the XML schema with COBOL annotations
 * @return a map of root elements in the XML schema, each one mapped to its
 *         composite types constituents
 * @throws Xsd2ConverterException if parsing the XML schema fails
 */
public Map < String, RootCompositeType > build(XmlSchema xmlSchema)
        throws Xsd2ConverterException {

    log.debug("visit XML Schema started");
    Map < String, RootCompositeType > rootComplexTypes = new LinkedHashMap < String, RootCompositeType >();

    for (Entry < QName, XmlSchemaElement > entry : xmlSchema.getElements()
            .entrySet()) {
        if (entry.getValue().getSchemaType() instanceof XmlSchemaComplexType) {
            CobolAnnotations cobolAnnotations = new CobolAnnotations(
                    entry.getValue());
            XmlSchemaComplexType xsdComplexType = (XmlSchemaComplexType) entry
                    .getValue().getSchemaType();
            RootCompositeType compositeTypes = new RootCompositeType(
                    cobolAnnotations.getCobolName());
            String complexTypeName = getComplexTypeName(xsdComplexType);
            rootComplexTypes.put(complexTypeName, compositeTypes);
            visit(xsdComplexType, compositeTypes, complexTypeName);
        }
    }

    log.debug("visit XML Schema ended");
    return rootComplexTypes;
}
 
Example #17
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Extract a particle from a complex type
 * returns null if it can't be extracted.
 */
private XmlSchemaParticle extractParticle(XmlSchemaComplexType complexType) {
    XmlSchemaParticle particle = complexType.getParticle();

    // handle case where the complexType is an extension
    if (particle == null && complexType.getContentModel() != null
            && complexType.getContentModel().getContent() != null) {
        XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentExtension) {
            XmlSchemaComplexContentExtension complexContent = (XmlSchemaComplexContentExtension) content;
            particle = complexContent.getParticle();
        }
    }

    return particle;
}
 
Example #18
Source File: SmooksGenerator.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
public SmooksGenerator() {
    complexTypes = new HashMap<String, XmlSchemaComplexType>();
    simpleTypes = new HashMap<String, XmlSchemaSimpleType>();
    complexTypesData = new HashMap<String, ComplexTypeData>();

    resourceLoader = new DefaultResourceLoader();
    Resource xsdResource = resourceLoader.getResource(xsdLocation);
    Resource extensionXsdResource = resourceLoader.getResource(extensionXsdLocation);

    // extract complex types from base schema
    cacheTypesFromResource(xsdResource, xsdParentLocation);
    // extract complex types from extension schema
    cacheTypesFromResource(extensionXsdResource, extensionXsdParentLocation);

    // extract data from complex data including hierarchy
    cacheComplexTypeData();
}
 
Example #19
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Remove parent types from the complexTypes cache.
 * We are only interested in the leaf node extended types.
 */
private void extractBaseTypesFromCache() {
    // find all the parent types
    Set<String> baseTypeSet = new HashSet<String>();

    for (XmlSchemaComplexType complexType : complexTypes.values()) {
        // this needs to also respect restriction
        String baseName = extractBaseTypeName(complexType);
        if (baseName != null) {
            baseTypeSet.add(baseName);
        }
    }

    // remove all the baseTypes from reference Cache
    for (String baseType : baseTypeSet) {
        referenceTypes.remove(baseType);
    }
}
 
Example #20
Source File: Xsd2UmlConvert.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private static final List<Attribute> parseFields(final XmlSchemaComplexType schemaComplexType,
        final XmlSchema schema, final Xsd2UmlConfig context) {
    final List<Attribute> attributes = new LinkedList<Attribute>();
    
    final XmlSchemaObjectCollection schemaItems = schemaComplexType.getAttributes();
    for (int i = 0, count = schemaItems.getCount(); i < count; i++) {
        final XmlSchemaObject schemaObject = schemaItems.getItem(i);
        if (schemaObject instanceof XmlSchemaAttribute) {
            final XmlSchemaAttribute schemaAttribute = (XmlSchemaAttribute) schemaObject;
            attributes.add(parseAttribute(schemaAttribute, schema, context));
            
        } else {
            throw new AssertionError(schemaObject);
        }
    }
    // parseAttributes(schemaComplexType.getAttributes(), schema);
    attributes.addAll(parseParticle(schemaComplexType.getParticle(), schema, context));
    
    return Collections.unmodifiableList(attributes);
}
 
Example #21
Source File: ServiceJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaSequence getTypeSequence(XmlSchemaComplexType type,
                                          QName parentName) {
    if (!(type.getParticle() instanceof XmlSchemaSequence)) {
        unsupportedConstruct("NON_SEQUENCE_PARTICLE",
                             type.getQName() != null ? type.getQName()
                                 :
                                 parentName);
    }
    return (XmlSchemaSequence)type.getParticle();
}
 
Example #22
Source File: ServiceJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private String getElementObjectName(ParticleInfo element) {
    XmlSchemaType type = element.getType();

    if (!element.isEmpty()) {
        if (type instanceof XmlSchemaComplexType) {
            return nameManager.getJavascriptName(element.getControllingName());
        }
        return "type " + type.getQName(); // could it be anonymous?
    }
    return "empty element?";
}
 
Example #23
Source File: SchemaJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Generate a JavaScript function that takes an element for a complex type and walks through its children
 * using them to fill in the values for a JavaScript object.
 *
 * @param type schema type for the process
 * @return the string contents of the JavaScript.
 */
public void domDeserializerFunction(QName name, XmlSchemaComplexType type) {
    utils = new JavascriptUtils(code);

    List<XmlSchemaObject> contentElements = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
    String typeObjectName = nameManager.getJavascriptName(name);
    code.append("function " + typeObjectName + "_deserialize (cxfjsutils, element) {\n");
    // create the object we are deserializing into.
    utils.appendLine("var newobject = new " + typeObjectName + "();");
    utils.appendLine("cxfjsutils.trace('element: ' + cxfjsutils.traceElementName(element));");
    utils.appendLine("var curElement = cxfjsutils.getFirstElementChild(element);");

    utils.appendLine("var item;");

    int nContentElements = contentElements.size();
    for (int i = 0; i < contentElements.size(); i++) {
        XmlSchemaObject contentElement = contentElements.get(i);
        utils.appendLine("cxfjsutils.trace('curElement: ' + cxfjsutils.traceElementName(curElement));");
        ParticleInfo itemInfo = ParticleInfo.forLocalItem(contentElement, xmlSchema, xmlSchemaCollection,
                                                          prefixAccumulator, type.getQName());
        if (itemInfo.isAny()) {
            ParticleInfo nextItem = null;
            if (i != nContentElements - 1) {
                XmlSchemaObject nextThing = contentElements.get(i + 1);
                nextItem = ParticleInfo.forLocalItem(nextThing, xmlSchema, xmlSchemaCollection,
                                                     prefixAccumulator, type.getQName());
                // theoretically, you could have two anys with different
                // namespaces.
                if (nextItem.isAny()) {
                    unsupportedConstruct("MULTIPLE_ANY", type.getQName());
                }
            }
            deserializeAny(type, itemInfo, nextItem);
        } else {
            deserializeElement(type, itemInfo);
        }
    }
    utils.appendLine("return newobject;");
    code.append("}\n\n");
}
 
Example #24
Source File: SchemaJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void constructItem(XmlSchemaComplexType type, final String elementPrefix,
                           String typeObjectName, ParticleInfo itemInfo) {
    if (!itemInfo.isGroup()) {
        constructOneItem(type, elementPrefix, typeObjectName, itemInfo);
        return;
    }

    for (ParticleInfo childInfo : itemInfo.getChildren()) {
        constructItem(type, elementPrefix, typeObjectName, childInfo);
    }
}
 
Example #25
Source File: CorbaHandlerUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean isAnonType(XmlSchemaObject schemaObj) {
    boolean result = false;
    if ((schemaObj != null) && !(schemaObj instanceof XmlSchemaElement)
         && !(schemaObj instanceof XmlSchemaComplexType)) {
        result = true;
    }
    return result;
}
 
Example #26
Source File: ServiceJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isEmptyType(XmlSchemaType type, QName parentName) {
    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
        if (complexType.getParticle() == null) {
            return true;
        }
        XmlSchemaSequence sequence = getTypeSequence(complexType, parentName);
        if (sequence.getItems().isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #27
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Extract a particle from a complex type
 * returns null if it can't be extracted.
 */
private XmlSchemaParticle extractParticleWithRestriction(XmlSchemaComplexType complexType) {
    XmlSchemaParticle particle = complexType.getParticle();

    if (particle == null && complexType.getContentModel() != null
            && complexType.getContentModel().getContent() != null) {
        XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentRestriction) {
            XmlSchemaComplexContentRestriction complexContent = (XmlSchemaComplexContentRestriction) content;
            particle = complexContent.getParticle();
        }
    }
    return particle;
}
 
Example #28
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Extract entity configs
 */
private Map<String, DidEntityConfig> extractEntityConfigs() {
    Map<String, DidEntityConfig> extractedEntityConfigs = new HashMap<String, DidEntityConfig>();

    // Iterate XML Schema items
    for (Entry<String, XmlSchemaComplexType> complexType : complexTypes.entrySet()) {

        // exclude IdentityTypes which may also contain referenceTypes but shouldn't result in
        // an EntityConfig
        if (complexType.getKey().contains(IDENTITY_TYPE)) {
            continue;
        }

        DidEntityConfig entityConfig = extractEntityConfig(complexType.getValue());
        if (entityConfig != null) {
            // extract the entity annotations
            XmlSchemaAnnotation annotation = complexType.getValue().getAnnotation();
            if (annotation != null) {
                String recordType = parseAnnotationForRecordType(annotation);
                if (recordType != null) {
                    extractedEntityConfigs.put(recordType, entityConfig);
                } else {
                    LOG.error("Failed to extract DidEntityConfig for type " + complexType.getKey()
                            + ", couldn't find recordType annotation");
                }
            } else {
                LOG.error("Failed to extract DidEntityConfig for type " + complexType.getKey()
                        + " - null annotation");
            }
        }
    }

    return extractedEntityConfigs;
}
 
Example #29
Source File: SmooksGenerator.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Extract a particle from a complex type, respecting both extensions and restrictions
 * returns null if there isn't one.
 */
private String extractBaseTypeName(XmlSchemaComplexType complexType) {
    String baseTypeName = null;

    if (complexType.getBaseSchemaTypeName() != null) {
        baseTypeName = complexType.getBaseSchemaTypeName().getLocalPart();
        // don't go as far as ComplexObjectType or ReferenceType - we never map these
        if (baseTypeName.equals(COMPLEX_OBJECT_TYPE) || baseTypeName.equals(REFERENCE_TYPE)) {
            baseTypeName = null;
        }
    }

    return baseTypeName;
}
 
Example #30
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static boolean isSoapArray(XmlSchemaComplexType complexType) {
    // Soap arrays are based on complex content restriction
    XmlSchemaContentModel contentModel = complexType.getContentModel();
    if (contentModel == null) {
        return false;
    }
    XmlSchemaContent content = contentModel.getContent();
    if (!(content instanceof XmlSchemaComplexContentRestriction)) {
        return false;
    }

    XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
    return SOAP_ARRAY.equals(restriction.getBaseTypeName());
}