Search in sources :

Example 1 with XmlSchemaType

use of javax.xml.bind.annotation.XmlSchemaType in project midpoint by Evolveum.

the class PrismBeanInspector method findTypeNameUncached.

private QName findTypeNameUncached(Field field, Class contentClass, String schemaNamespace) {
    if (field != null) {
        XmlSchemaType xmlSchemaType = field.getAnnotation(XmlSchemaType.class);
        if (xmlSchemaType != null) {
            return new QName(xmlSchemaType.namespace(), xmlSchemaType.name());
        }
    }
    QName typeName = XsdTypeMapper.getJavaToXsdMapping(contentClass);
    if (typeName != null) {
        return typeName;
    }
    // TODO the following code is similar to determineTypeForClass
    XmlType xmlType = (XmlType) contentClass.getAnnotation(XmlType.class);
    if (xmlType != null) {
        String propTypeLocalPart = xmlType.name();
        String propTypeNamespace = xmlType.namespace();
        if (propTypeNamespace.equals(BeanMarshaller.DEFAULT_PLACEHOLDER)) {
            PrismSchema schema = prismContext.getSchemaRegistry().findSchemaByCompileTimeClass(contentClass);
            if (schema != null && schema.getNamespace() != null) {
                // should be non-null for properly initialized schemas
                propTypeNamespace = schema.getNamespace();
            } else {
                // schemaNamespace is only a poor indicator of required namespace (consider e.g. having c:UserType in apit:ObjectListType)
                // so we use it only if we couldn't find anything else
                propTypeNamespace = schemaNamespace;
            }
        }
        return new QName(propTypeNamespace, propTypeLocalPart);
    }
    return null;
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) QName(javax.xml.namespace.QName) XmlSchemaType(javax.xml.bind.annotation.XmlSchemaType) XmlType(javax.xml.bind.annotation.XmlType)

Aggregations

PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)1 XmlSchemaType (javax.xml.bind.annotation.XmlSchemaType)1 XmlType (javax.xml.bind.annotation.XmlType)1 QName (javax.xml.namespace.QName)1