This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 2_1_X in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/2_1_X by this push: new bbb8a8f [SYNCOPE-1531] More robust handling in case value for key column is missing bbb8a8f is described below commit bbb8a8f0aa2d371a1489407f9eb6d7ca9e73efba Author: Francesco Chicchiriccò <ilgro...@apache.org> AuthorDate: Wed Feb 26 12:50:58 2020 +0100 [SYNCOPE-1531] More robust handling in case value for key column is missing --- .../java/pushpull/stream/CSVStreamConnector.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/CSVStreamConnector.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/CSVStreamConnector.java index d231966..5f9e994 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/CSVStreamConnector.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/CSVStreamConnector.java @@ -250,20 +250,30 @@ public class CSVStreamConnector implements Connector, AutoCloseable { SearchResult result = new SearchResult(); try { - while (reader().hasNext()) { + for (int record = 1; reader().hasNext(); record++) { Map<String, String> row = reader().next(); - ConnectorObjectBuilder builder = new ConnectorObjectBuilder(); - builder.setObjectClass(objectClass); - builder.setUid(row.get(keyColumn)); - builder.setName(row.get(keyColumn)); + String keyValue = row.get(keyColumn); + if (StringUtils.isBlank(keyValue)) { + keyValue = "Record " + record; + } + + ConnectorObjectBuilder builder = new ConnectorObjectBuilder(). + setObjectClass(objectClass). + setUid(keyValue). + setName(keyValue); row.forEach((key, value) -> builder.addAttribute(arrayElementsSeparator == null ? AttributeBuilder.build(key, value) : AttributeBuilder.build(key, (Object[]) StringUtils.splitByWholeSeparator(value, arrayElementsSeparator)))); - handler.handle(builder.build()); + ConnectorObject obj = builder.build(); + if (filter == null || filter.accept(obj)) { + handler.handle(obj); + } else { + LOG.debug("Found but not passing the provided filter {}: {}", filter, obj); + } } } catch (IOException e) { LOG.error("Could not read CSV from provided stream", e);