Repository: incubator-nifi Updated Branches: refs/heads/NIFI-250 f71588065 -> 975db1a7b
NIFI-250: - Addressing issues setting reporting task comments. - Including properties and descriptors in controller service referencing components. Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/17b0fa7d Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/17b0fa7d Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/17b0fa7d Branch: refs/heads/NIFI-250 Commit: 17b0fa7df170fa50f33236863481f008356cb1b4 Parents: f715880 Author: Matt Gilman <[email protected]> Authored: Wed Mar 25 15:03:39 2015 -0400 Committer: Matt Gilman <[email protected]> Committed: Wed Mar 25 15:03:39 2015 -0400 ---------------------------------------------------------------------- .../nifi/web/api/ReportingTaskResource.java | 5 ++- .../org/apache/nifi/web/api/dto/DtoFactory.java | 41 +++++++++++++++++++- .../web/dao/impl/StandardReportingTaskDAO.java | 4 ++ 3 files changed, 48 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/17b0fa7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java index be06e7b..5f5ce42 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java @@ -418,6 +418,7 @@ public class ReportingTaskResource extends ApplicationResource { * @param state The updated scheduled state * @param schedulingStrategy The scheduling strategy for this reporting task * @param schedulingPeriod The scheduling period for this reporting task + * @param comments The comments for this reporting task * @param formParams Additionally, the processor properties and styles are * specified in the form parameters. Because the property names and styles * differ from processor to processor they are specified in a map-like @@ -447,7 +448,8 @@ public class ReportingTaskResource extends ApplicationResource { @PathParam("availability") String availability, @PathParam("id") String id, @FormParam("name") String name, @FormParam("annotationData") String annotationData, @FormParam("markedForDeletion[]") List<String> markedForDeletion, @FormParam("state") String state, @FormParam("schedulingStrategy") String schedulingStrategy, - @FormParam("schedulingPeriod") String schedulingPeriod, MultivaluedMap<String, String> formParams) { + @FormParam("schedulingPeriod") String schedulingPeriod, @FormParam("comments") String comments, + MultivaluedMap<String, String> formParams) { // create collections for holding the reporting task properties final Map<String, String> updatedProperties = new LinkedHashMap<>(); @@ -481,6 +483,7 @@ public class ReportingTaskResource extends ApplicationResource { reportingTaskDTO.setSchedulingStrategy(schedulingStrategy); reportingTaskDTO.setSchedulingPeriod(schedulingPeriod); reportingTaskDTO.setAnnotationData(annotationData); + reportingTaskDTO.setComments(comments); // only set the properties when appropriate if (!updatedProperties.isEmpty()) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/17b0fa7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 060790c..2ec8b68 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -985,7 +985,8 @@ public final class DtoFactory { final ControllerServiceReferencingComponentDTO dto = new ControllerServiceReferencingComponentDTO(); dto.setId(component.getIdentifier()); dto.setName(component.getName()); - + + List<PropertyDescriptor> propertyDescriptors = null; Collection<ValidationResult> validationErrors = null; if (component instanceof ProcessorNode) { final ProcessorNode node = ((ProcessorNode) component); @@ -995,6 +996,7 @@ public final class DtoFactory { dto.setType(node.getProcessor().getClass().getName()); dto.setReferenceType(Processor.class.getSimpleName()); + propertyDescriptors = node.getProcessor().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } else if (component instanceof ControllerServiceNode) { final ControllerServiceNode node = ((ControllerServiceNode) component); @@ -1008,6 +1010,7 @@ public final class DtoFactory { dto.setReferencingComponents(createControllerServiceReferencingComponentsDto(node.getReferences(), visited)); } + propertyDescriptors = node.getControllerServiceImplementation().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } else if (component instanceof ReportingTask) { final ReportingTaskNode node = ((ReportingTaskNode) component); @@ -1016,9 +1019,45 @@ public final class DtoFactory { dto.setType(node.getReportingTask().getClass().getName()); dto.setReferenceType(ReportingTask.class.getSimpleName()); + propertyDescriptors = node.getReportingTask().getPropertyDescriptors(); validationErrors = node.getValidationErrors(); } + if (propertyDescriptors != null && !propertyDescriptors.isEmpty()) { + final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>(new Comparator<PropertyDescriptor>() { + @Override + public int compare(PropertyDescriptor o1, PropertyDescriptor o2) { + return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); + } + }); + sortedProperties.putAll(component.getProperties()); + + final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); + for (PropertyDescriptor descriptor : propertyDescriptors) { + orderedProperties.put(descriptor, null); + } + orderedProperties.putAll(sortedProperties); + + // build the descriptor and property dtos + dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); + dto.setProperties(new LinkedHashMap<String, String>()); + for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { + final PropertyDescriptor descriptor = entry.getKey(); + + // store the property descriptor + dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor)); + + // determine the property value - don't include sensitive properties + String propertyValue = entry.getValue(); + if (propertyValue != null && descriptor.isSensitive()) { + propertyValue = "********"; + } + + // set the property value + dto.getProperties().put(descriptor.getName(), propertyValue); + } + } + if (validationErrors != null && !validationErrors.isEmpty()) { final List<String> errors = new ArrayList<>(); for (final ValidationResult validationResult : validationErrors) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/17b0fa7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java index 1252924..d9fd74c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java @@ -314,6 +314,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT final String schedulingStrategy = reportingTaskDTO.getSchedulingStrategy(); final String schedulingPeriod = reportingTaskDTO.getSchedulingPeriod(); final String annotationData = reportingTaskDTO.getAnnotationData(); + final String comments = reportingTaskDTO.getComments(); final Map<String, String> properties = reportingTaskDTO.getProperties(); // ensure scheduling strategy is set first @@ -330,6 +331,9 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT if (isNotNull(annotationData)) { reportingTask.setAnnotationData(annotationData); } + if (isNotNull(comments)) { + reportingTask.setComments(comments); + } if (isNotNull(properties)) { for (final Map.Entry<String, String> entry : properties.entrySet()) { final String propName = entry.getKey();
