Skip to content

Commit

Permalink
Fixing failed test in model-intest.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 16, 2014
1 parent 6166d4e commit 0be2653
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -998,7 +998,7 @@ public PrismObjectDefinition determineDefinitionFromClass(Class type) {
* in the known schemas.
*/
public boolean hasImplicitTypeDefinition(QName elementName, QName typeName) {
elementName = resolveElementNameIfNeeded(elementName);
elementName = resolveElementNameIfNeeded(elementName, false);
if (elementName == null) {
return false;
}
Expand All @@ -1014,10 +1014,14 @@ public boolean hasImplicitTypeDefinition(QName elementName, QName typeName) {
}

private QName resolveElementNameIfNeeded(QName elementName) {
return resolveElementNameIfNeeded(elementName, true);
}

private QName resolveElementNameIfNeeded(QName elementName, boolean exceptionIfAmbiguous) {
if (StringUtils.isNotEmpty(elementName.getNamespaceURI())) {
return elementName;
}
ItemDefinition itemDef = resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class);
ItemDefinition itemDef = resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class, exceptionIfAmbiguous);
if (itemDef != null) {
return itemDef.getName();
} else {
Expand Down Expand Up @@ -1053,6 +1057,10 @@ public ItemDefinition resolveGlobalItemDefinition(QName elementQName) throws Sch
}

private <T extends ItemDefinition> T resolveGlobalItemDefinitionWithoutNamespace(String localPart, Class<T> definitionClass) {
return resolveGlobalItemDefinitionWithoutNamespace(localPart, definitionClass, true);
}

private <T extends ItemDefinition> T resolveGlobalItemDefinitionWithoutNamespace(String localPart, Class<T> definitionClass, boolean exceptionIfAmbiguous) {
ItemDefinition found = null;
for (SchemaDescription schemaDescription : parsedSchemas.values()) {
PrismSchema schema = schemaDescription.getSchema();
Expand All @@ -1063,8 +1071,12 @@ private <T extends ItemDefinition> T resolveGlobalItemDefinitionWithoutNamespace
if (def != null) {
if (found != null) {
// todo change to SchemaException
throw new IllegalArgumentException("Multiple possible resolutions for unqualified element name " + localPart + " (e.g. in " +
if (exceptionIfAmbiguous) {
throw new IllegalArgumentException("Multiple possible resolutions for unqualified element name " + localPart + " (e.g. in " +
def.getNamespace() + " and " + found.getNamespace());
} else {
return null;
}
}
found = def;
}
Expand Down

0 comments on commit 0be2653

Please sign in to comment.