More robust ConnObjectKey handling
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/ad7bb322 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/ad7bb322 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/ad7bb322 Branch: refs/heads/master Commit: ad7bb3225531b0382f3625fc6d4ed197c38325ce Parents: 3d4f233 Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Mon Nov 6 09:08:33 2017 +0100 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Mon Nov 6 13:52:18 2017 +0100 ---------------------------------------------------------------------- .../provisioning/java/MappingManagerImpl.java | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/ad7bb322/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java index a19d37f..dada9f1 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java @@ -190,18 +190,18 @@ public class MappingManagerImpl implements MappingManager { } } - Attribute connObjectKeyExtAttr = - AttributeUtil.find(MappingUtils.getConnObjectKeyItem(provision).get().getExtAttrName(), attributes); - if (connObjectKeyExtAttr != null) { - attributes.remove(connObjectKeyExtAttr); - attributes.add(AttributeBuilder.build( - MappingUtils.getConnObjectKeyItem(provision).get().getExtAttrName(), connObjectKey)); - } - Name name = MappingUtils.evaluateNAME(any, provision, connObjectKey); - attributes.add(name); - if (connObjectKey != null && !connObjectKey.equals(name.getNameValue()) && connObjectKeyExtAttr == null) { - attributes.add(AttributeBuilder.build( - MappingUtils.getConnObjectKeyItem(provision).get().getExtAttrName(), connObjectKey)); + Optional<MappingItem> connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision); + if (connObjectKeyItem.isPresent()) { + Attribute connObjectKeyExtAttr = AttributeUtil.find(connObjectKeyItem.get().getExtAttrName(), attributes); + if (connObjectKeyExtAttr != null) { + attributes.remove(connObjectKeyExtAttr); + attributes.add(AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey)); + } + Name name = MappingUtils.evaluateNAME(any, provision, connObjectKey); + attributes.add(name); + if (connObjectKey != null && !connObjectKey.equals(name.getNameValue()) && connObjectKeyExtAttr == null) { + attributes.add(AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey)); + } } if (enable != null) {