From 8c93b31886fdf6283bcf8600b11ea72e356f975b Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 20 Jan 2020 11:21:21 +0100 Subject: [PATCH] Fix writing traces with dynamically-defined PCs ItemType couldn't be created for PrismContainers with no compile time class, as .getRealValues() obviously cannot be executed. TODO This situation probably occurs at more places in the code. Review. --- .../prism/xml/ns/_public/types_3/ItemType.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/ItemType.java b/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/ItemType.java index e757123ba22..fffb3df4c4d 100644 --- a/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/ItemType.java +++ b/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/ItemType.java @@ -94,11 +94,18 @@ public String toString() { '}'; } - public static ItemType fromItem(Item item) { + public static ItemType fromItem(Item item) { if (item != null) { ItemType rv = new ItemType(); rv.setName(item.getElementName()); - rv.value.addAll(item.getRealValues()); + if (item instanceof PrismContainer && (item.getDefinition() == null || ((PrismContainerDefinition) item.getDefinition()).getCompileTimeClass() == null)) { + // a special case -- item.getRealValues() does not work here (TODO generalize this) + for (PrismContainerValue value : ((PrismContainer) item).getValues()) { + rv.value.add(new RawType(value, null, item.getPrismContext())); + } + } else { + rv.value.addAll(item.getRealValues()); + } return rv; } else { return null;