Skip to content

Commit

Permalink
A couple of fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 19, 2016
1 parent fdc202b commit 89a72c5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
Expand Up @@ -528,7 +528,7 @@ protected void diffInternal(Item<V,D> other, Collection<? extends ItemDelta> del
// No need to process this value again
iterator.remove();
break;
}
}
}
if (!found) {
// We have the value and the other does not, this is delete of the entire value
Expand Down
Expand Up @@ -103,7 +103,7 @@ private static <ID extends ItemDefinition> ID augmentWithType(ID definition, Cla
}
ItemDefinition rawDefFromType = schemaRegistry.findItemDefinitionByType(typeName);
if (rawDefFromType == null) {
throw new SchemaException("Unknown type name " + typeName);
return definition; // TODO warning if wrong type?
}
if (!definitionClass.isAssignableFrom(rawDefFromType.getClass())) {
throw new SchemaException("Wrong type name " + typeName + " (not a " + definitionClass.getClass().getSimpleName() + ")"); // TODO context of error
Expand Down
Expand Up @@ -321,11 +321,11 @@ private static <T,C extends Containerable> ObjectFilter parseComparisonFilter(QN
Entry<QName,XNode> expressionEntry = clauseXMap.getSingleEntryThatDoesNotMatch(
ELEMENT_VALUE, ELEMENT_MATCHING, ELEMENT_PATH);
if (expressionEntry != null) {
RootXNode expressionRoot = clauseXMap.getEntryAsRoot(expressionEntry.getKey());
PrismPropertyValue expressionPropertyValue = prismContext.parserFor(expressionRoot).parseItemValue();
if (preliminaryParsingOnly) {
return null;
} else {
RootXNode expressionRoot = clauseXMap.getEntryAsRoot(expressionEntry.getKey());
PrismPropertyValue expressionPropertyValue = prismContext.parserFor(expressionRoot).parseItemValue();
ExpressionWrapper expressionWrapper = new ExpressionWrapper();
expressionWrapper.setExpression(expressionPropertyValue.getValue());
if (isEq) {
Expand Down Expand Up @@ -432,15 +432,15 @@ private static <C extends Containerable> RefFilter parseRefFilter(MapXNode claus

XNode valueXnode = clauseXMap.get(ELEMENT_VALUE);
if (valueXnode != null) {
if (preliminaryParsingOnly) {
return null;
}
RootXNode valueRoot = new RootXNode(ELEMENT_VALUE, valueXnode);
Item<?,?> item = prismContext.parserFor(valueRoot)
.name(itemName)
.definition(itemDefinition)
.context(ParsingContext.allowMissingRefTypes())
.parseItem();
if (preliminaryParsingOnly) {
return null;
}
PrismReference ref = (PrismReference)item;
if (item.getValues().size() < 1) {
throw new IllegalStateException("No values to search specified for item " + itemName);
Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.evolveum.midpoint.util.exception.SystemException;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
Expand Down Expand Up @@ -82,7 +83,8 @@ public PrismContext getPrismContext() {

//region Parsing and serialization
// itemDefinition may be null; in that case we do the best what we can
public <IV extends PrismValue,ID extends ItemDefinition> IV getParsedValue(ItemDefinition itemDefinition, QName itemName) throws SchemaException {
public <IV extends PrismValue,ID extends ItemDefinition> IV getParsedValue(@Nullable ItemDefinition itemDefinition, @Nullable QName itemName) throws SchemaException {
Validate.isTrue(itemDefinition != null || itemName != null);
if (parsed != null) {
return (IV) parsed;
} else if (xnode != null) {
Expand All @@ -99,6 +101,7 @@ public <IV extends PrismValue,ID extends ItemDefinition> IV getParsedValue(ItemD
value = null;
}
} else {
assert itemName != null;
PrismProperty subItem = PrismProperty.createRaw(xnode, itemName, prismContext);
value = (IV) subItem.getValue();
}
Expand Down
Expand Up @@ -274,7 +274,7 @@ public void testProtectedStringObjectDelta() throws Exception {
RawType val = valueElements.get(0);
MapXNode valXNode = (MapXNode) val.serializeToXNode();
PrimitiveXNode clearValueNode = (PrimitiveXNode) valXNode.get(ProtectedStringType.F_CLEAR_VALUE);
val.getParsedValue(null, null);
val.getParsedValue(null, new QName("dummy"));
// System.out.println("clear value " + clearValueNode);
assertEquals("Wrong element value", protectedString.getClearValue(), clearValueNode.getParsedValue(DOMUtil.XSD_STRING));
// List<Object> values = val.getContent();
Expand Down
Expand Up @@ -32,6 +32,7 @@
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.schema.SchemaRegistryImpl;
import com.evolveum.midpoint.schema.constants.SchemaConstants;

Expand All @@ -40,14 +41,6 @@
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismReferenceDefinition;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;
Expand Down Expand Up @@ -145,7 +138,7 @@ public void testReferenceInExtension() throws SchemaException, SAXException, IOE
System.out.println("UserRef definition:");
System.out.println(itemDefinition.debugDump());

assertEquals("Wrong userRef definition class", PrismReferenceDefinition.class, itemDefinition.getClass());
assertEquals("Wrong userRef definition class", PrismReferenceDefinitionImpl.class, itemDefinition.getClass());
}

@Test
Expand Down

0 comments on commit 89a72c5

Please sign in to comment.