From 334df3847e2067e2ebcf2a39c01f739ceb907a44 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 4 Aug 2015 10:40:03 +0200 Subject: [PATCH] Fixed MID-2487: When applying ResolveNames option, invalid reference is now treated as a handled error (not as fatal error). --- .../model/impl/controller/ModelController.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java index 199b4c5718b..bed6c988a5f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java @@ -394,22 +394,28 @@ public void visit(Visitable visitable) { if (visitable instanceof PrismReferenceValue) { PrismReferenceValue refVal = (PrismReferenceValue) visitable; PrismObject refObject = refVal.getObject(); + String name = null; if (refObject == null) { try { // TODO what about security here?! // TODO use some minimalistic get options (e.g. retrieve name only) refObject = objectResolver.resolve(refVal, "", rootOptionsNoResolve, task, result); + if (refObject == null) { // will be used with AllowNotFound above + name = "(object not found)"; + } } catch (ObjectNotFoundException e) { // actually, this won't occur if AllowNotFound is set to true above (however, for now, it is not) result.muteError(); result.muteLastSubresultError(); + name = "(object not found)"; + } catch (RuntimeException e) { + result.muteError(); + result.muteLastSubresultError(); + name = "(object cannot be retrieved)"; } } - String name; if (refObject != null) { name = PolyString.getOrig(refObject.asObjectable().getName()); - } else { - name = "(object not found)"; } if (StringUtils.isNotEmpty(name)) { refVal.setUserData(XNodeSerializer.USER_DATA_KEY_COMMENT, " " + name + " ");