This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push: new f640386 [SYNCOPE-1531] More robust handling in case value for key column is missing f640386 is described below commit f640386145d5269d1ea3a6e28bc7a29fc7a7635d 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 a1e04ef..8d70cea 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 @@ -245,20 +245,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);