You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ai...@apache.org on 2018/07/25 15:14:37 UTC

nifi-minifi-cpp git commit: MINIFICPP-514 Incorporated regex property validation information into agent manifest

Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master a507e3cc6 -> 4fe38ccdf


MINIFICPP-514 Incorporated regex property validation information into agent manifest

This closes #347.

Signed-off-by: Andrew I. Christianson <an...@andyic.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/4fe38ccd
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/4fe38ccd
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/4fe38ccd

Branch: refs/heads/master
Commit: 4fe38ccdf38b9522a422c24b0da75888f65ffcab
Parents: a507e3c
Author: Andrew I. Christianson <an...@andyic.org>
Authored: Tue May 29 13:08:56 2018 -0400
Committer: Andrew I. Christianson <an...@andyic.org>
Committed: Wed Jul 25 11:04:30 2018 -0400

----------------------------------------------------------------------
 extensions/http-curl/processors/InvokeHTTP.cpp  |  1 +
 libminifi/include/core/Property.h               | 16 ++++++++++------
 .../include/core/state/nodes/AgentInformation.h |  6 +++++-
 libminifi/src/core/ConfigurableComponent.cpp    |  2 +-
 libminifi/src/core/Property.cpp                 |  4 ++++
 libminifi/src/processors/GetFile.cpp            |  2 +-
 libminifi/src/processors/PutFile.cpp            |  1 +
 .../unit/PropertyValidationAgentInfoTests.cpp   | 20 +++++++++++++++++++-
 libminifi/test/unit/YamlConfigurationTests.cpp  | 16 ++++++++--------
 9 files changed, 50 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/extensions/http-curl/processors/InvokeHTTP.cpp
----------------------------------------------------------------------
diff --git a/extensions/http-curl/processors/InvokeHTTP.cpp b/extensions/http-curl/processors/InvokeHTTP.cpp
index f316c92..7ad5aef 100644
--- a/extensions/http-curl/processors/InvokeHTTP.cpp
+++ b/extensions/http-curl/processors/InvokeHTTP.cpp
@@ -70,6 +70,7 @@ core::Property InvokeHTTP::SSLContext("SSL Context Service",
                                       "information for TLS/SSL (https) connections.",
                                       "",
                                       false,
+                                      "",
                                       {},
                                       {{"Remote URL", "^http:.*$"}});
 core::Property InvokeHTTP::ProxyHost("Proxy Host", "The fully qualified hostname or IP address of the proxy server", "");

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/include/core/Property.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/Property.h b/libminifi/include/core/Property.h
index b90423d..50f5896 100644
--- a/libminifi/include/core/Property.h
+++ b/libminifi/include/core/Property.h
@@ -53,15 +53,17 @@ class Property {
   /*!
    * Create a new property
    */
-  Property(const std::string name,
-           const std::string description,
+  Property(std::string name,
+           std::string description,
            std::string value,
            bool is_required,
-           std::vector<std::string> &&dependent_properties,
-           std::vector<std::pair<std::string, std::string>> &&exclusive_of_properties)
-      : name_(name),
-        description_(description),
+           std::string valid_regex,
+           std::vector<std::string> dependent_properties,
+           std::vector<std::pair<std::string, std::string>> exclusive_of_properties)
+      : name_(std::move(name)),
+        description_(std::move(description)),
         is_required_(is_required),
+        valid_regex_(std::move(valid_regex)),
         dependent_properties_(std::move(dependent_properties)),
         exclusive_of_properties_(std::move(exclusive_of_properties)),
         is_collection_(false) {
@@ -97,6 +99,7 @@ class Property {
   std::string getDescription() const;
   std::string getValue() const;
   bool getRequired() const;
+  std::string getValidRegex() const;
   std::vector<std::string> getDependentProperties() const;
   std::vector<std::pair<std::string, std::string>> getExclusiveOfProperties() const;
   std::vector<std::string> &getValues();
@@ -375,6 +378,7 @@ class Property {
   std::string name_;
   std::string description_;
   bool is_required_;
+  std::string valid_regex_;
   std::vector<std::string> dependent_properties_;
   std::vector<std::pair<std::string, std::string>> exclusive_of_properties_;
   bool is_collection_;

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/include/core/state/nodes/AgentInformation.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/state/nodes/AgentInformation.h b/libminifi/include/core/state/nodes/AgentInformation.h
index 5797ed8..14e30db 100644
--- a/libminifi/include/core/state/nodes/AgentInformation.h
+++ b/libminifi/include/core/state/nodes/AgentInformation.h
@@ -131,6 +131,10 @@ class ComponentManifest : public DeviceInformation {
             descriptorRequired.name = "required";
             descriptorRequired.value = prop.second.getRequired();
 
+            SerializedResponseNode descriptorValidRegex;
+            descriptorValidRegex.name = "validRegex";
+            descriptorValidRegex.value = prop.second.getValidRegex();
+
             SerializedResponseNode descriptorDependentProperties;
             descriptorDependentProperties.name = "dependentProperties";
 
@@ -153,6 +157,7 @@ class ComponentManifest : public DeviceInformation {
             child.children.push_back(descriptorName);
             child.children.push_back(descriptorDescription);
             child.children.push_back(descriptorRequired);
+            child.children.push_back(descriptorValidRegex);
             child.children.push_back(descriptorDependentProperties);
             child.children.push_back(descriptorExclusiveOfProperties);
 
@@ -391,7 +396,6 @@ class AgentMonitor {
   std::shared_ptr<state::StateMonitor> monitor_;
 };
 
-
 /**
  * Justification and Purpose: Provides available extensions for the agent information block.
  */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/src/core/ConfigurableComponent.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/core/ConfigurableComponent.cpp b/libminifi/src/core/ConfigurableComponent.cpp
index 05180fc..ff6d1e5 100644
--- a/libminifi/src/core/ConfigurableComponent.cpp
+++ b/libminifi/src/core/ConfigurableComponent.cpp
@@ -190,7 +190,7 @@ bool ConfigurableComponent::createDynamicProperty(const std::string &name, const
     return false;
   }
 
-  Property new_property(name, DEFAULT_DYNAMIC_PROPERTY_DESC, value, false, {}, {});
+  Property new_property(name, DEFAULT_DYNAMIC_PROPERTY_DESC, value, false, "", {}, {});
   logger_->log_info("Processor %s dynamic property '%s' value '%s'", name.c_str(), new_property.getName().c_str(), value.c_str());
   dynamic_properties_[new_property.getName()] = new_property;
   onDynamicPropertyModified({}, new_property);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/src/core/Property.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/core/Property.cpp b/libminifi/src/core/Property.cpp
index 03bbc84..d5ff13a 100644
--- a/libminifi/src/core/Property.cpp
+++ b/libminifi/src/core/Property.cpp
@@ -42,6 +42,10 @@ bool Property::getRequired() const {
   return is_required_;
 }
 
+std::string Property::getValidRegex() const {
+  return valid_regex_;
+}
+
 std::vector<std::string> &Property::getValues() {
   return values_;
 }

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/src/processors/GetFile.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/processors/GetFile.cpp b/libminifi/src/processors/GetFile.cpp
index 3fe3eeb..4261d1a 100644
--- a/libminifi/src/processors/GetFile.cpp
+++ b/libminifi/src/processors/GetFile.cpp
@@ -45,7 +45,7 @@ namespace minifi {
 namespace processors {
 
 core::Property GetFile::BatchSize("Batch Size", "The maximum number of files to pull in each iteration", "10");
-core::Property GetFile::Directory("Input Directory", "The input directory from which to pull files", ".", true, {}, {});
+core::Property GetFile::Directory("Input Directory", "The input directory from which to pull files", ".", true, "", {}, {});
 core::Property GetFile::IgnoreHiddenFile("Ignore Hidden Files", "Indicates whether or not hidden files should be ignored", "true");
 core::Property GetFile::KeepSourceFile("Keep Source File", "If true, the file is not deleted after it has been copied to the Content Repository", "false");
 core::Property GetFile::MaxAge("Maximum File Age", "The minimum age that a file must be in order to be pulled;"

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/src/processors/PutFile.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/processors/PutFile.cpp b/libminifi/src/processors/PutFile.cpp
index ce747cd..0a45c68 100644
--- a/libminifi/src/processors/PutFile.cpp
+++ b/libminifi/src/processors/PutFile.cpp
@@ -53,6 +53,7 @@ core::Property PutFile::CreateDirs(
         "If false, flowfiles are penalized and sent to failure.",
     "true",
     true,
+    "",
     {"Directory"},
     {});
 core::Property PutFile::MaxDestFiles(

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/test/unit/PropertyValidationAgentInfoTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/PropertyValidationAgentInfoTests.cpp b/libminifi/test/unit/PropertyValidationAgentInfoTests.cpp
index 61fc95f..291f500 100644
--- a/libminifi/test/unit/PropertyValidationAgentInfoTests.cpp
+++ b/libminifi/test/unit/PropertyValidationAgentInfoTests.cpp
@@ -44,6 +44,24 @@ TEST_CASE("Test Required", "[required]") {
   REQUIRE(!std::dynamic_pointer_cast<minifi::state::response::BoolValue>(prop_0_required.value.getValue())->getValue());
 }
 
+TEST_CASE("Test Valid Regex", "[validRegex]") {
+  minifi::state::response::ComponentManifest manifest("default");
+  auto serialized = manifest.serialize();
+  REQUIRE(serialized.size() > 0);
+  const auto &resp = serialized[0];
+  REQUIRE(resp.children.size() > 0);
+  const auto &processors = resp.children[0];
+  REQUIRE(processors.children.size() > 0);
+  const auto &proc_0 = processors.children[0];
+  REQUIRE(proc_0.children.size() > 0);
+  const auto &prop_descriptors = proc_0.children[0];
+  REQUIRE(prop_descriptors.children.size() > 0);
+  const auto &prop_0 = prop_descriptors.children[0];
+  REQUIRE(prop_0.children.size() >= 3);
+  const auto &prop_0_valid_regex = prop_0.children[3];
+  REQUIRE("validRegex" == prop_0_valid_regex.name);
+}
+
 TEST_CASE("Test Dependent", "[dependent]") {
   minifi::state::response::ComponentManifest manifest("default");
   auto serialized = manifest.serialize();
@@ -63,7 +81,7 @@ TEST_CASE("Test Dependent", "[dependent]") {
   REQUIRE(prop_descriptors.children.size() > 0);
   const auto &prop_0 = prop_descriptors.children[1];
   REQUIRE(prop_0.children.size() >= 3);
-  const auto &prop_0_dependent = prop_0.children[3];
+  const auto &prop_0_dependent = prop_0.children[4];
   REQUIRE("dependentProperties" == prop_0_dependent.name);
   const auto &prop_0_dependent_0 = prop_0_dependent.children[0];
   REQUIRE("Directory" == prop_0_dependent_0.name);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/4fe38ccd/libminifi/test/unit/YamlConfigurationTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/YamlConfigurationTests.cpp b/libminifi/test/unit/YamlConfigurationTests.cpp
index 6cd67ac..febf923 100644
--- a/libminifi/test/unit/YamlConfigurationTests.cpp
+++ b/libminifi/test/unit/YamlConfigurationTests.cpp
@@ -480,8 +480,8 @@ TEST_CASE("Test Dependent Property", "[YamlConfigurationDependentProperty]") {
   core::YamlConfiguration yamlConfig(testProvRepo, testFlowFileRepo, content_repo, streamFactory, configuration);
   const auto component = std::make_shared<DummyComponent>();
   std::set<core::Property> props;
-  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, {}, {}));
-  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, {"Prop A"}, {}));
+  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, "", {}, {}));
+  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, "", {"Prop A"}, {}));
   component->setSupportedProperties(std::move(props));
   yamlConfig.validateComponentProperties(component, "component A", "section A");
   REQUIRE(true);  // Expected to get here w/o any exceptions
@@ -503,8 +503,8 @@ TEST_CASE("Test Dependent Property 2", "[YamlConfigurationDependentProperty2]")
   core::YamlConfiguration yamlConfig(testProvRepo, testFlowFileRepo, content_repo, streamFactory, configuration);
   const auto component = std::make_shared<DummyComponent>();
   std::set<core::Property> props;
-  props.emplace(core::Property("Prop A", "Prop A desc", "", false, {}, {}));
-  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, {"Prop A"}, {}));
+  props.emplace(core::Property("Prop A", "Prop A desc", "", false, "", {}, {}));
+  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, "", {"Prop A"}, {}));
   component->setSupportedProperties(std::move(props));
   bool config_failed = false;
   try {
@@ -535,8 +535,8 @@ TEST_CASE("Test Exclusive Property", "[YamlConfigurationExclusiveProperty]") {
   core::YamlConfiguration yamlConfig(testProvRepo, testFlowFileRepo, content_repo, streamFactory, configuration);
   const auto component = std::make_shared<DummyComponent>();
   std::set<core::Property> props;
-  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, {}, {}));
-  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, {}, {{"Prop A", "^abcd.*$"}}));
+  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, "", {}, {}));
+  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, "", {}, {{"Prop A", "^abcd.*$"}}));
   component->setSupportedProperties(std::move(props));
   yamlConfig.validateComponentProperties(component, "component A", "section A");
   REQUIRE(true);  // Expected to get here w/o any exceptions
@@ -558,8 +558,8 @@ TEST_CASE("Test Exclusive Property 2", "[YamlConfigurationExclusiveProperty2]")
   core::YamlConfiguration yamlConfig(testProvRepo, testFlowFileRepo, content_repo, streamFactory, configuration);
   const auto component = std::make_shared<DummyComponent>();
   std::set<core::Property> props;
-  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, {}, {}));
-  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, {}, {{"Prop A", "^val.*$"}}));
+  props.emplace(core::Property("Prop A", "Prop A desc", "val A", true, "", {}, {}));
+  props.emplace(core::Property("Prop B", "Prop B desc", "val B", true, "", {}, {{"Prop A", "^val.*$"}}));
   component->setSupportedProperties(std::move(props));
   bool config_failed = false;
   try {