From d88afe05ae66ff4c1aa5085ec7fcc14bf6e98bac Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 16 Jul 2014 18:34:14 +0200 Subject: [PATCH] Fixing MID-1995 (superfluous xsi:type). --- .../midpoint/prism/parser/PrismBeanConverter.java | 14 +++++++++----- .../midpoint/prism/schema/SchemaRegistry.java | 2 +- .../test/resources/common/task-bulk-action-1.xml | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/PrismBeanConverter.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/PrismBeanConverter.java index ca10d2e9c73..0a3606ad244 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/PrismBeanConverter.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/PrismBeanConverter.java @@ -710,13 +710,17 @@ public XNode marshall(T bean) throws SchemaException { } ListXNode xlist = new ListXNode(); - for (Object element: col) { + + // elementName will be determined from the first item on the list + // TODO make sure it will be correct with respect to other items as well! + if (getterResultValue instanceof JAXBElement && ((JAXBElement) getterResultValue).getName() != null) { + elementName = ((JAXBElement) getterResultValue).getName(); + } + + for (Object element: col) { QName fieldTypeName = inspector.findFieldTypeName(field, element.getClass(), namespace); Object elementToMarshall = element; if (element instanceof JAXBElement){ - if (((JAXBElement) element).getName() != null){ - elementName = ((JAXBElement) element).getName(); - } elementToMarshall = ((JAXBElement) element).getValue(); } XNode marshalled = marshallValue(elementToMarshall, fieldTypeName, isAttribute); @@ -725,7 +729,7 @@ public XNode marshall(T bean) throws SchemaException { // Fix it in 3.1. [med] if (fieldTypeName == null && element instanceof JAXBElement && marshalled != null) { QName typeName = inspector.determineTypeForClass(elementToMarshall.getClass()); - if (typeName != null) { + if (typeName != null && !getSchemaRegistry().hasImplicitTypeDefinition(elementName, typeName)) { marshalled.setExplicitTypeDeclaration(true); marshalled.setTypeQName(typeName); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java index 64c86e5e35f..1acf8154f4e 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java @@ -1014,7 +1014,7 @@ public boolean hasImplicitTypeDefinition(QName elementName, QName typeName) { } private QName resolveElementNameIfNeeded(QName elementName) { - if (elementName.getNamespaceURI() != null) { + if (StringUtils.isNotEmpty(elementName.getNamespaceURI())) { return elementName; } ItemDefinition itemDef = resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class); diff --git a/infra/schema/src/test/resources/common/task-bulk-action-1.xml b/infra/schema/src/test/resources/common/task-bulk-action-1.xml index c8e16dcbea0..a034588e7b5 100644 --- a/infra/schema/src/test/resources/common/task-bulk-action-1.xml +++ b/infra/schema/src/test/resources/common/task-bulk-action-1.xml @@ -33,6 +33,9 @@ AAAAA + + log +