Github user brosander commented on a diff in the pull request: https://github.com/apache/nifi-minifi/pull/45#discussion_r84531003 --- Diff: minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ConfigSchema.java --- @@ -142,128 +125,10 @@ public ConfigSchema(Map map) { } } - protected List<ProcessorSchema> getProcessorSchemas(List<Map> processorMaps) { - if (processorMaps == null) { - return null; - } - List<ProcessorSchema> processors = convertListToType(processorMaps, "processor", ProcessorSchema.class, PROCESSORS_KEY); - - Map<String, Integer> idMap = processors.stream().map(ProcessorSchema::getId).filter( - s -> !StringUtil.isNullOrEmpty(s)).collect(Collectors.toMap(Function.identity(), s -> 2, Integer::compareTo)); - - // Set unset ids - processors.stream().filter(connection -> StringUtil.isNullOrEmpty(connection.getId())).forEachOrdered(processor -> processor.setId(getUniqueId(idMap, processor.getName()))); - - return processors; - } - - protected List<ConnectionSchema> getConnectionSchemas(List<Map> connectionMaps) { - if (connectionMaps == null) { - return null; - } - List<ConnectionSchema> connections = convertListToType(connectionMaps, "connection", ConnectionSchema.class, CONNECTIONS_KEY); - Map<String, Integer> idMap = connections.stream().map(ConnectionSchema::getId).filter( - s -> !StringUtil.isNullOrEmpty(s)).collect(Collectors.toMap(Function.identity(), s -> 2, Integer::compareTo)); - - Map<String, String> processorNameToIdMap = new HashMap<>(); - - // We can't look up id by name for names that appear more than once - Set<String> duplicateProcessorNames = new HashSet<>(); - - List<ProcessorSchema> processors = getProcessors(); - if (processors != null) { - processors.stream().forEachOrdered(p -> processorNameToIdMap.put(p.getName(), p.getId())); - - Set<String> processorNames = new HashSet<>(); - processors.stream().map(ProcessorSchema::getName).forEachOrdered(n -> { - if (!processorNames.add(n)) { - duplicateProcessorNames.add(n); - } - }); - } - - Set<String> remoteInputPortIds = new HashSet<>(); - List<RemoteProcessingGroupSchema> remoteProcessingGroups = getRemoteProcessingGroups(); - if (remoteProcessingGroups != null) { - remoteInputPortIds.addAll(remoteProcessingGroups.stream().filter(r -> r.getInputPorts() != null) - .flatMap(r -> r.getInputPorts().stream()).map(RemoteInputPortSchema::getId).collect(Collectors.toSet())); - } - - Set<String> problematicDuplicateNames = new HashSet<>(); - Set<String> missingProcessorNames = new HashSet<>(); - // Set unset ids - connections.stream().filter(connection -> StringUtil.isNullOrEmpty(connection.getId())).forEachOrdered(connection -> connection.setId(getUniqueId(idMap, connection.getName()))); - - connections.stream().filter(connection -> StringUtil.isNullOrEmpty(connection.getSourceId())).forEach(connection -> { - String sourceName = connection.getSourceName(); - if (remoteInputPortIds.contains(sourceName)) { - connection.setSourceId(sourceName); - } else { - if (duplicateProcessorNames.contains(sourceName)) { - problematicDuplicateNames.add(sourceName); - } - String sourceId = processorNameToIdMap.get(sourceName); - if (StringUtil.isNullOrEmpty(sourceId)) { - missingProcessorNames.add(sourceName); - } else { - connection.setSourceId(sourceId); - } - } - }); - - connections.stream().filter(connection -> StringUtil.isNullOrEmpty(connection.getDestinationId())) - .forEach(connection -> { - String destinationName = connection.getDestinationName(); - if (remoteInputPortIds.contains(destinationName)) { - connection.setDestinationId(destinationName); - } else { - if (duplicateProcessorNames.contains(destinationName)) { - problematicDuplicateNames.add(destinationName); - } - String destinationId = processorNameToIdMap.get(destinationName); - if (StringUtil.isNullOrEmpty(destinationId)) { - missingProcessorNames.add(destinationName); - } else { - connection.setDestinationId(destinationId); - } - } - }); - - if (problematicDuplicateNames.size() > 0) { - addValidationIssue(CANNOT_LOOK_UP_PROCESSOR_ID_FROM_PROCESSOR_NAME_DUE_TO_DUPLICATE_PROCESSOR_NAMES - + problematicDuplicateNames.stream().collect(Collectors.joining(", "))); - } - if (missingProcessorNames.size() > 0) { - addValidationIssue(CONNECTIONS_REFER_TO_PROCESSOR_NAMES_THAT_DONT_EXIST + missingProcessorNames.stream().sorted().collect(Collectors.joining(", "))); --- End diff -- I agree we should validate that the connections refer to existing ids, will add that
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---