diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java index 0c11f89f88c..6f01ba794c4 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java @@ -570,25 +570,17 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!super.equals(obj)) { - return false; - } +// if (!super.equals(obj)) { +// return false; +// } if (getClass() != obj.getClass()) { return false; } CompositeRefinedObjectClassDefinition other = (CompositeRefinedObjectClassDefinition) obj; - if (auxiliaryObjectClassDefinitions == null) { - if (other.auxiliaryObjectClassDefinitions != null) { - return false; - } - } else if (!auxiliaryObjectClassDefinitions.equals(other.auxiliaryObjectClassDefinitions)) { + if (!auxiliaryObjectClassDefinitions.equals(other.auxiliaryObjectClassDefinitions)) { return false; } - if (structuralObjectClassDefinition == null) { - if (other.structuralObjectClassDefinition != null) { - return false; - } - } else if (!structuralObjectClassDefinition.equals(other.structuralObjectClassDefinition)) { + if (!structuralObjectClassDefinition.equals(other.structuralObjectClassDefinition)) { return false; } return true; diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinitionImpl.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinitionImpl.java index 4f155591b14..efb56e02b74 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinitionImpl.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinitionImpl.java @@ -171,8 +171,8 @@ public int hashCode() { public boolean equals(Object obj) { if (this == obj) return true; - if (!super.equals(obj)) - return false; +// if (!super.equals(obj)) +// return false; if (getClass() != obj.getClass()) return false; LayerRefinedAttributeDefinitionImpl other = (LayerRefinedAttributeDefinitionImpl) obj; @@ -449,7 +449,7 @@ public String getNamespace() { @Override public int getMinOccurs() { - return refinedAttributeDefinition.getMinOccurs(); + return refinedAttributeDefinition.getMinOccurs(layer); } @Override @@ -459,7 +459,7 @@ public Collection> getAllowedValues() { @Override public int getMaxOccurs() { - return refinedAttributeDefinition.getMaxOccurs(); + return refinedAttributeDefinition.getMaxOccurs(layer); } @Override @@ -479,7 +479,7 @@ public boolean isTolerant() { @Override public boolean isSingleValue() { - return refinedAttributeDefinition.isSingleValue(); + return refinedAttributeDefinition.isSingleValue(layer); } @Override @@ -494,7 +494,7 @@ public boolean isSecondaryIdentifier() { @Override public boolean isMultiValue() { - return refinedAttributeDefinition.isMultiValue(); + return refinedAttributeDefinition.isMultiValue(layer); } @Override @@ -515,12 +515,12 @@ public boolean canAdd(LayerType layer) { @Override public boolean isMandatory() { - return refinedAttributeDefinition.isMandatory(); + return refinedAttributeDefinition.isMandatory(layer); } @Override public boolean isIgnored() { - return refinedAttributeDefinition.isIgnored(); + return refinedAttributeDefinition.isIgnored(layer); } @Override @@ -540,7 +540,7 @@ public boolean isAbstract() { @Override public boolean isOptional() { - return refinedAttributeDefinition.isOptional(); + return refinedAttributeDefinition.isOptional(layer); } @Override diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java index fb5318ae2b8..5044c7f38de 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java @@ -550,8 +550,8 @@ public int hashCode() { public boolean equals(Object obj) { if (this == obj) return true; - if (!super.equals(obj)) - return false; +// if (!super.equals(obj)) +// return false; if (getClass() != obj.getClass()) return false; LayerRefinedObjectClassDefinitionImpl other = (LayerRefinedObjectClassDefinitionImpl) obj; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java index d5f4a966bed..de1bf521248 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java @@ -1058,16 +1058,15 @@ public void applyDefinition(ItemDefinition definition, boolean force) throws Sch applyDefinition((PrismContainerDefinition)definition, force); } - public void applyDefinition(PrismContainerDefinition containerDef, boolean force) throws SchemaException { + public void applyDefinition(@NotNull PrismContainerDefinition containerDef, boolean force) throws SchemaException { checkMutability(); - ComplexTypeDefinition ctd = getComplexTypeDefinition(); - if (ctd == null) { - if (containerDef == null || containerDef.getComplexTypeDefinition() == null) { - return; - } - ctd = containerDef.getComplexTypeDefinition(); - } - if (ctd.isXsdAnyMarker()) { + // Although complexTypeDefinition is cached, its presence means that the parent had a definition before + // parent.applyDefinition() was called. So if !force, we can safely exit here. + if (complexTypeDefinition != null && !force) { + return; // there's a definition already + } + complexTypeDefinition = containerDef.getComplexTypeDefinition(); + if (complexTypeDefinition == null || complexTypeDefinition.isXsdAnyMarker()) { // No point in aplying this. Nothing will change and there may be phantom errors. return; } @@ -1077,7 +1076,7 @@ public void applyDefinition(PrismContainerDefinition containerDef, boolean fo // Item has a definition already, no need to apply it continue; } - ItemDefinition itemDefinition = determineItemDefinition(item.getElementName(), ctd); + ItemDefinition itemDefinition = determineItemDefinition(item.getElementName(), complexTypeDefinition); if (itemDefinition == null && item.getDefinition() != null && item.getDefinition().isDynamic()) { // We will not apply the null definition here. The item has a dynamic definition that we don't // want to destroy as it cannot be reconstructed later.