fgerlits commented on code in PR #1634:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1634#discussion_r1310138180


##########
extensions/smb/SmbConnectionControllerService.cpp:
##########
@@ -0,0 +1,119 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SmbConnectionControllerService.h"
+#include "core/Resource.h"
+#include "utils/OsUtils.h"
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+void SmbConnectionControllerService::initialize() {
+  setSupportedProperties(Properties);
+}
+
+void SmbConnectionControllerService::onEnable()  {
+  std::string hostname;
+  std::string share;
+
+  if (!getProperty(Hostname, hostname))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing hostname");
+
+  if (!getProperty(Share, share))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing share");
+
+  server_path_ = "\\\\" + hostname + "\\" + share;
+
+  auto password = getProperty(Password);
+  auto username = getProperty(Username);
+
+  if (password.has_value() != username.has_value())
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION,  "Either both a username and a 
password, or neither of them should be provided.");
+
+  if (username.has_value())
+    credentials_.emplace(Credentials{.username = *username, .password = 
*password});
+  else
+    credentials_.reset();
+
+  ZeroMemory(&net_resource_, sizeof(net_resource_));
+  net_resource_.dwType = RESOURCETYPE_DISK;
+  net_resource_.lpLocalName = nullptr;
+  net_resource_.lpRemoteName = server_path_.data();
+  net_resource_.lpProvider = nullptr;
+}
+
+void SmbConnectionControllerService::notifyStop() {
+  auto disconnection_result = disconnect();
+  if (!disconnection_result)
+    logger_->log_error("Error while disconnecting from SMB: %s", 
disconnection_result.error().message());
+}
+
+std::shared_ptr<SmbConnectionControllerService> 
SmbConnectionControllerService::getFromProperty(const core::ProcessContext& 
context, const core::PropertyReference& property) {

Review Comment:
   I think `gsl::not_null<std::unique_ptr<SmbConnectionControllerService>>` 
would be a better return type.



##########
extensions/smb/FetchSmb.h:
##########
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class FetchSmb : public core::Processor {
+ public:
+  explicit FetchSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Fetches files from 
a SMB Share. Designed to be used in tandem with ListSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto RemoteFile = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The full path of the file to be retrieved from the 
remote server. Expression language supported. If left empty the path and 
filename attributes will be used.")

Review Comment:
   I don't think we need to add "expression language supported" to the 
description, since there is a separate flag for this.  Also, I would clarify 
the last sentence:
   ```suggestion
         .withDescription("The full path of the file to be retrieved from the 
remote server. If left empty, the path and filename attributes of the incoming 
flow file will be used.")
   ```



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")
+      .isRequired(false)
+      .build();
+  EXTENSIONAPI static constexpr auto RecurseSubdirectories = 
core::PropertyDefinitionBuilder<>::createProperty("Recurse Subdirectories")
+      .withDescription("Indicates whether to list files from subdirectories of 
the directory")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+  EXTENSIONAPI static constexpr auto FileFilter = 
core::PropertyDefinitionBuilder<>::createProperty("File Filter")
+      .withDescription("Only files whose names match the given regular 
expression will be picked up")
+      .build();
+  EXTENSIONAPI static constexpr auto PathFilter = 
core::PropertyDefinitionBuilder<>::createProperty("Path Filter")
+      .withDescription("When Recurse Subdirectories is true, then only 
subdirectories whose path matches the given regular expression will be scanned")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Age")
+      .withDescription("The minimum age that a file must be in order to be 
pulled; any file younger than this amount of time (according to last 
modification date) will be ignored")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::TIME_PERIOD_TYPE)
+      .withDefaultValue("0 sec")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Age")
+      .withDescription("The maximum age that a file must be in order to be 
pulled; any file older than this amount of time (according to last modification 
date) will be ignored")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Size")
+      .withDescription("The minimum size that a file must be in order to be 
pulled")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::DATA_SIZE_TYPE)
+      .withDefaultValue("0 B")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Size")
+      .withDescription("The maximum size that a file can be in order to be 
pulled")
+      .build();
+  EXTENSIONAPI static constexpr auto IgnoreHiddenFiles = 
core::PropertyDefinitionBuilder<>::createProperty("Ignore Hidden Files")
+      .withDescription("Indicates whether or not hidden files should be 
ignored")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+
+  EXTENSIONAPI static constexpr auto Properties = 
std::array<core::PropertyReference, 10>{
+      ConnectionControllerService,
+      InputDirectory,
+      RecurseSubdirectories,
+      FileFilter,
+      PathFilter,
+      MinimumFileAge,
+      MaximumFileAge,
+      MinimumFileSize,
+      MaximumFileSize,
+      IgnoreHiddenFiles
+  };
+
+  EXTENSIONAPI static constexpr auto Success = 
core::RelationshipDefinition{"success", "All FlowFiles that are received are 
routed to success"};
+  EXTENSIONAPI static constexpr auto Relationships = std::array{Success};
+
+  EXTENSIONAPI static constexpr auto Filename = 
core::OutputAttributeDefinition<>{"filename", { Success }, "The name of the 
file that was read from filesystem."};
+  EXTENSIONAPI static constexpr auto Path = 
core::OutputAttributeDefinition<>{"path", { Success },
+      "The path is set to the relative path of the file's directory on the 
remote filesystem compared to the Share root directory. "
+      "For example, for a given remote 
locationsmb://HOSTNAME:PORT/SHARE/DIRECTORY, and a file is being listed from 
smb://HOSTNAME:PORT/SHARE/DIRECTORY/sub/folder/file "
+      "then the path attribute will be set to \"DIRECTORY/sub/folder\"."};

Review Comment:
   isn't the relative path just
   ```suggestion
         "then the path attribute will be set to \"sub/folder\"."};
   ```
   ?



##########
extensions/smb/PutSmb.h:
##########
@@ -0,0 +1,95 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "utils/Enum.h"
+#include "SmbConnectionControllerService.h"
+#include "core/logging/LoggerConfiguration.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class PutSmb : public core::Processor {
+ public:
+  explicit PutSmb(std::string name,  const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  ~PutSmb() override = default;

Review Comment:
   why is this needed?



##########
extensions/smb/ListSmb.cpp:
##########
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ListSmb.h"
+#include <filesystem>
+
+#include "utils/StringUtils.h"
+#include "utils/TimeUtil.h"
+#include "utils/OsUtils.h"
+#include "utils/file/FileUtils.h"
+#include "core/Resource.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+void ListSmb::initialize() {
+  setSupportedProperties(Properties);
+  setSupportedRelationships(Relationships);
+}
+
+void ListSmb::onSchedule(const std::shared_ptr<core::ProcessContext> &context, 
const std::shared_ptr<core::ProcessSessionFactory> &/*sessionFactory*/) {
+  gsl_Expects(context);
+  smb_connection_controller_service_ = 
SmbConnectionControllerService::getFromProperty(*context, 
ListSmb::ConnectionControllerService);
+
+  auto state_manager = context->getStateManager();
+  if (state_manager == nullptr) {
+    throw Exception(PROCESSOR_EXCEPTION, "Failed to get StateManager");
+  }
+  state_manager_ = 
std::make_unique<minifi::utils::ListingStateManager>(state_manager);
+
+  input_directory_ = context->getProperty(InputDirectory).value_or("");
+
+  context->getProperty(RecurseSubdirectories, recurse_subdirectories_);
+
+  std::string value;
+  if (context->getProperty(FileFilter, value) && !value.empty()) {
+    file_filter_.filename_filter = std::regex(value);
+  }
+
+  if (recurse_subdirectories_ && context->getProperty(PathFilter, value) && 
!value.empty()) {
+    file_filter_.path_filter = std::regex(value);
+  }
+
+  if (auto minimum_file_age = 
context->getProperty<core::TimePeriodValue>(MinimumFileAge)) {
+    file_filter_.minimum_file_age =  minimum_file_age->getMilliseconds();
+  }
+
+  if (auto maximum_file_age = 
context->getProperty<core::TimePeriodValue>(MaximumFileAge)) {
+    file_filter_.maximum_file_age =  maximum_file_age->getMilliseconds();
+  }
+
+  uint64_t int_value = 0;
+  if (context->getProperty(MinimumFileSize, value) && !value.empty() && 
core::Property::StringToInt(value, int_value)) {
+    file_filter_.minimum_file_size = int_value;
+  }

Review Comment:
   I think
   ```suggestion
     if (const auto minimum_file_size = 
context->getProperty<core::DataSizeValue>(MinimumFileSize)) {
       minimum_file_size_ = minimum_file_size->getValue();
     }
   ```
   would make it clearer that we are parsing a data size value.



##########
libminifi/src/core/logging/Logger.cpp:
##########
@@ -100,7 +100,7 @@ bool Logger::should_log(const LOG_LEVEL &level) {
 void Logger::log_string(LOG_LEVEL level, std::string str) {
   switch (level) {
     case critical:
-      log_warn(str.c_str());
+      log_critical(str.c_str());

Review Comment:
   wow, good catch -- good thing we don't use `log_critical` much (or at all?)



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")
+      .isRequired(false)
+      .build();
+  EXTENSIONAPI static constexpr auto RecurseSubdirectories = 
core::PropertyDefinitionBuilder<>::createProperty("Recurse Subdirectories")
+      .withDescription("Indicates whether to list files from subdirectories of 
the directory")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+  EXTENSIONAPI static constexpr auto FileFilter = 
core::PropertyDefinitionBuilder<>::createProperty("File Filter")
+      .withDescription("Only files whose names match the given regular 
expression will be picked up")
+      .build();
+  EXTENSIONAPI static constexpr auto PathFilter = 
core::PropertyDefinitionBuilder<>::createProperty("Path Filter")
+      .withDescription("When Recurse Subdirectories is true, then only 
subdirectories whose path matches the given regular expression will be scanned")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Age")
+      .withDescription("The minimum age that a file must be in order to be 
pulled; any file younger than this amount of time (according to last 
modification date) will be ignored")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::TIME_PERIOD_TYPE)
+      .withDefaultValue("0 sec")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Age")
+      .withDescription("The maximum age that a file must be in order to be 
pulled; any file older than this amount of time (according to last modification 
date) will be ignored")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Size")
+      .withDescription("The minimum size that a file must be in order to be 
pulled")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::DATA_SIZE_TYPE)
+      .withDefaultValue("0 B")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Size")
+      .withDescription("The maximum size that a file can be in order to be 
pulled")
+      .build();

Review Comment:
   should this also be of `DATA_SIZE_TYPE`?



##########
extensions/smb/SmbConnectionControllerService.cpp:
##########
@@ -0,0 +1,119 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SmbConnectionControllerService.h"
+#include "core/Resource.h"
+#include "utils/OsUtils.h"
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+void SmbConnectionControllerService::initialize() {
+  setSupportedProperties(Properties);
+}
+
+void SmbConnectionControllerService::onEnable()  {
+  std::string hostname;
+  std::string share;
+
+  if (!getProperty(Hostname, hostname))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing hostname");
+
+  if (!getProperty(Share, share))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing share");
+
+  server_path_ = "\\\\" + hostname + "\\" + share;
+
+  auto password = getProperty(Password);
+  auto username = getProperty(Username);
+
+  if (password.has_value() != username.has_value())
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION,  "Either both a username and a 
password, or neither of them should be provided.");
+
+  if (username.has_value())
+    credentials_.emplace(Credentials{.username = *username, .password = 
*password});
+  else
+    credentials_.reset();
+
+  ZeroMemory(&net_resource_, sizeof(net_resource_));
+  net_resource_.dwType = RESOURCETYPE_DISK;
+  net_resource_.lpLocalName = nullptr;
+  net_resource_.lpRemoteName = server_path_.data();
+  net_resource_.lpProvider = nullptr;

Review Comment:
   I know this is the traditional way of initializing a struct on Windows, but 
I think the C++20 way is nicer:
   ```suggestion
     net_resource_ = {
       .dwType = RESOURCETYPE_DISK,
       .lpLocalName = nullptr,
       .lpRemoteName = server_path_.data(),
       .lpProvider = nullptr,
     };
   ```
   (it does zero out the rest of the fields)



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")

Review Comment:
   typo:
   ```suggestion
         .withDescription("The input directory from which to pull files")
   ```
   or could be:
   ```suggestion
         .withDescription("The input directory to list the contents of")
   ```



##########
extensions/smb/SmbConnectionControllerService.cpp:
##########
@@ -0,0 +1,119 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SmbConnectionControllerService.h"
+#include "core/Resource.h"
+#include "utils/OsUtils.h"
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+void SmbConnectionControllerService::initialize() {
+  setSupportedProperties(Properties);
+}
+
+void SmbConnectionControllerService::onEnable()  {
+  std::string hostname;
+  std::string share;
+
+  if (!getProperty(Hostname, hostname))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing hostname");
+
+  if (!getProperty(Share, share))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing share");
+
+  server_path_ = "\\\\" + hostname + "\\" + share;
+
+  auto password = getProperty(Password);
+  auto username = getProperty(Username);
+
+  if (password.has_value() != username.has_value())
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION,  "Either both a username and a 
password, or neither of them should be provided.");
+
+  if (username.has_value())
+    credentials_.emplace(Credentials{.username = *username, .password = 
*password});
+  else
+    credentials_.reset();
+
+  ZeroMemory(&net_resource_, sizeof(net_resource_));
+  net_resource_.dwType = RESOURCETYPE_DISK;
+  net_resource_.lpLocalName = nullptr;
+  net_resource_.lpRemoteName = server_path_.data();
+  net_resource_.lpProvider = nullptr;
+}
+
+void SmbConnectionControllerService::notifyStop() {
+  auto disconnection_result = disconnect();
+  if (!disconnection_result)
+    logger_->log_error("Error while disconnecting from SMB: %s", 
disconnection_result.error().message());
+}
+
+std::shared_ptr<SmbConnectionControllerService> 
SmbConnectionControllerService::getFromProperty(const core::ProcessContext& 
context, const core::PropertyReference& property) {
+  std::shared_ptr<SmbConnectionControllerService> 
smb_connection_controller_service;
+  if (auto connection_controller_name = context.getProperty(property)) {
+    smb_connection_controller_service = 
std::dynamic_pointer_cast<SmbConnectionControllerService>(context.getControllerService(*connection_controller_name));
+  }
+  if (!smb_connection_controller_service) {
+    minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, "Missing SMB 
Connection Controller Service");

Review Comment:
   missing `throw`



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")
+      .isRequired(false)
+      .build();
+  EXTENSIONAPI static constexpr auto RecurseSubdirectories = 
core::PropertyDefinitionBuilder<>::createProperty("Recurse Subdirectories")
+      .withDescription("Indicates whether to list files from subdirectories of 
the directory")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+  EXTENSIONAPI static constexpr auto FileFilter = 
core::PropertyDefinitionBuilder<>::createProperty("File Filter")
+      .withDescription("Only files whose names match the given regular 
expression will be picked up")
+      .build();
+  EXTENSIONAPI static constexpr auto PathFilter = 
core::PropertyDefinitionBuilder<>::createProperty("Path Filter")
+      .withDescription("When Recurse Subdirectories is true, then only 
subdirectories whose path matches the given regular expression will be scanned")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Age")
+      .withDescription("The minimum age that a file must be in order to be 
pulled; any file younger than this amount of time (according to last 
modification date) will be ignored")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::TIME_PERIOD_TYPE)
+      .withDefaultValue("0 sec")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Age")
+      .withDescription("The maximum age that a file must be in order to be 
pulled; any file older than this amount of time (according to last modification 
date) will be ignored")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Size")
+      .withDescription("The minimum size that a file must be in order to be 
pulled")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::DATA_SIZE_TYPE)
+      .withDefaultValue("0 B")
+      .build();

Review Comment:
   This is not required in NiFi, which makes more sense to me.



##########
extensions/smb/tests/FetchSmbTests.cpp:
##########
@@ -0,0 +1,105 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TestBase.h"
+#include "Catch.h"
+#include "FetchSmb.h"
+#include "SmbConnectionControllerService.h"
+#include "utils/MockSmbConnectionControllerService.h"
+#include "SingleProcessorTestController.h"
+#include "OsUtils.h"
+#include "core/Resource.h"
+
+namespace org::apache::nifi::minifi::extensions::smb::test {
+
+REGISTER_RESOURCE(MockSmbConnectionControllerService, ControllerService);
+
+TEST_CASE("FetchSmb invalid network path") {
+  const auto fetch_smb = std::make_shared<FetchSmb>("FetchSmb");
+  minifi::test::SingleProcessorTestController controller{fetch_smb};
+  auto smb_connection_node = 
controller.plan->addController("MockSmbConnectionControllerService", 
"smb_connection_controller_service");
+  REQUIRE(controller.plan->setProperty(smb_connection_node, 
SmbConnectionControllerService::Hostname, 
utils::OsUtils::getHostName().value_or("localhost")));
+  REQUIRE(controller.plan->setProperty(smb_connection_node, 
SmbConnectionControllerService::Share, "some_share_that_does_not_exists"));

Review Comment:
   sorry to nitpick, but
   ```suggestion
     REQUIRE(controller.plan->setProperty(smb_connection_node, 
SmbConnectionControllerService::Share, "some_share_that_does_not_exist"));
   ```



##########
extensions/smb/SmbConnectionControllerService.cpp:
##########
@@ -0,0 +1,119 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SmbConnectionControllerService.h"
+#include "core/Resource.h"
+#include "utils/OsUtils.h"
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+void SmbConnectionControllerService::initialize() {
+  setSupportedProperties(Properties);
+}
+
+void SmbConnectionControllerService::onEnable()  {
+  std::string hostname;
+  std::string share;
+
+  if (!getProperty(Hostname, hostname))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing hostname");
+
+  if (!getProperty(Share, share))
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Missing share");
+
+  server_path_ = "\\\\" + hostname + "\\" + share;
+
+  auto password = getProperty(Password);
+  auto username = getProperty(Username);
+
+  if (password.has_value() != username.has_value())
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION,  "Either both a username and a 
password, or neither of them should be provided.");
+
+  if (username.has_value())
+    credentials_.emplace(Credentials{.username = *username, .password = 
*password});
+  else
+    credentials_.reset();
+
+  ZeroMemory(&net_resource_, sizeof(net_resource_));
+  net_resource_.dwType = RESOURCETYPE_DISK;
+  net_resource_.lpLocalName = nullptr;
+  net_resource_.lpRemoteName = server_path_.data();
+  net_resource_.lpProvider = nullptr;
+}
+
+void SmbConnectionControllerService::notifyStop() {
+  auto disconnection_result = disconnect();
+  if (!disconnection_result)
+    logger_->log_error("Error while disconnecting from SMB: %s", 
disconnection_result.error().message());
+}
+
+std::shared_ptr<SmbConnectionControllerService> 
SmbConnectionControllerService::getFromProperty(const core::ProcessContext& 
context, const core::PropertyReference& property) {
+  std::shared_ptr<SmbConnectionControllerService> 
smb_connection_controller_service;
+  if (auto connection_controller_name = context.getProperty(property)) {
+    smb_connection_controller_service = 
std::dynamic_pointer_cast<SmbConnectionControllerService>(context.getControllerService(*connection_controller_name));
+  }
+  if (!smb_connection_controller_service) {
+    minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, "Missing SMB 
Connection Controller Service");
+  }
+  return smb_connection_controller_service;
+}
+
+nonstd::expected<void, std::error_code> 
SmbConnectionControllerService::connect() {
+  auto connection_result = WNetAddConnection2A(&net_resource_,
+      credentials_ ? credentials_->password.c_str() : nullptr,
+      credentials_ ? credentials_->username.c_str() : nullptr,
+      CONNECT_TEMPORARY);
+  if (connection_result == NO_ERROR)
+    return {};
+
+  return 
nonstd::make_unexpected(utils::OsUtils::windowsErrorToErrorCode(connection_result));
+}
+
+nonstd::expected<void, std::error_code> 
SmbConnectionControllerService::disconnect() {
+  auto disconnection_result = WNetCancelConnection2A(server_path_.c_str(), 0, 
true);
+  if (disconnection_result == NO_ERROR)
+    return {};
+
+  return 
nonstd::make_unexpected(utils::OsUtils::windowsErrorToErrorCode(disconnection_result));
+}
+
+bool SmbConnectionControllerService::isConnected() {
+  std::error_code error_code;
+  auto exists = std::filesystem::exists(server_path_, error_code);
+  if (error_code) {
+    logger_->log_debug("std::filesystem::exists(%s) failed due to %s", 
server_path_, error_code.message());
+    return false;
+  }
+  return exists;
+}
+
+std::error_code SmbConnectionControllerService::validateConnection() {
+  if (isConnected())
+    return std::error_code();
+  auto connection_result = connect();
+  if (!connection_result) {
+    return connection_result.error();
+  }

Review Comment:
   I would prefer not to mix two code styles (with and without braces around 
the single-line statement block) in the same function



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")
+      .isRequired(false)
+      .build();
+  EXTENSIONAPI static constexpr auto RecurseSubdirectories = 
core::PropertyDefinitionBuilder<>::createProperty("Recurse Subdirectories")
+      .withDescription("Indicates whether to list files from subdirectories of 
the directory")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+  EXTENSIONAPI static constexpr auto FileFilter = 
core::PropertyDefinitionBuilder<>::createProperty("File Filter")
+      .withDescription("Only files whose names match the given regular 
expression will be picked up")
+      .build();
+  EXTENSIONAPI static constexpr auto PathFilter = 
core::PropertyDefinitionBuilder<>::createProperty("Path Filter")
+      .withDescription("When Recurse Subdirectories is true, then only 
subdirectories whose path matches the given regular expression will be scanned")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Age")
+      .withDescription("The minimum age that a file must be in order to be 
pulled; any file younger than this amount of time (according to last 
modification date) will be ignored")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::TIME_PERIOD_TYPE)
+      .withDefaultValue("0 sec")

Review Comment:
   I think NiFi's default value of 5 sec makes sense, to prevent us from 
picking up a file while it is still being created.



##########
extensions/smb/ListSmb.h:
##########
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <regex>
+#include <string>
+#include <utility>
+
+#include "SmbConnectionControllerService.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Property.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "core/OutputAttributeDefinition.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "utils/Enum.h"
+#include "utils/ListingStateManager.h"
+#include "utils/file/ListedFile.h"
+#include "utils/file/FileUtils.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class ListSmb : public core::Processor {
+ public:
+  explicit ListSmb(std::string name, const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing 
of files from an SMB share. For each file that is listed, "
+                                                          "creates a FlowFile 
that represents the file so that it can be fetched in conjunction with 
FetchSmb.";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto InputDirectory = 
core::PropertyDefinitionBuilder<>::createProperty("Input Directory")
+      .withDescription("The input directory from which files to pull files")
+      .isRequired(false)
+      .build();
+  EXTENSIONAPI static constexpr auto RecurseSubdirectories = 
core::PropertyDefinitionBuilder<>::createProperty("Recurse Subdirectories")
+      .withDescription("Indicates whether to list files from subdirectories of 
the directory")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+  EXTENSIONAPI static constexpr auto FileFilter = 
core::PropertyDefinitionBuilder<>::createProperty("File Filter")
+      .withDescription("Only files whose names match the given regular 
expression will be picked up")
+      .build();
+  EXTENSIONAPI static constexpr auto PathFilter = 
core::PropertyDefinitionBuilder<>::createProperty("Path Filter")
+      .withDescription("When Recurse Subdirectories is true, then only 
subdirectories whose path matches the given regular expression will be scanned")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Age")
+      .withDescription("The minimum age that a file must be in order to be 
pulled; any file younger than this amount of time (according to last 
modification date) will be ignored")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::TIME_PERIOD_TYPE)
+      .withDefaultValue("0 sec")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileAge = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Age")
+      .withDescription("The maximum age that a file must be in order to be 
pulled; any file older than this amount of time (according to last modification 
date) will be ignored")
+      .build();
+  EXTENSIONAPI static constexpr auto MinimumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Minimum File Size")
+      .withDescription("The minimum size that a file must be in order to be 
pulled")
+      .isRequired(true)
+      .withPropertyType(core::StandardPropertyTypes::DATA_SIZE_TYPE)
+      .withDefaultValue("0 B")
+      .build();
+  EXTENSIONAPI static constexpr auto MaximumFileSize = 
core::PropertyDefinitionBuilder<>::createProperty("Maximum File Size")
+      .withDescription("The maximum size that a file can be in order to be 
pulled")
+      .build();
+  EXTENSIONAPI static constexpr auto IgnoreHiddenFiles = 
core::PropertyDefinitionBuilder<>::createProperty("Ignore Hidden Files")
+      .withDescription("Indicates whether or not hidden files should be 
ignored")
+      .withPropertyType(core::StandardPropertyTypes::BOOLEAN_TYPE)
+      .withDefaultValue("true")
+      .isRequired(true)
+      .build();
+
+  EXTENSIONAPI static constexpr auto Properties = 
std::array<core::PropertyReference, 10>{
+      ConnectionControllerService,
+      InputDirectory,
+      RecurseSubdirectories,
+      FileFilter,
+      PathFilter,
+      MinimumFileAge,
+      MaximumFileAge,
+      MinimumFileSize,
+      MaximumFileSize,
+      IgnoreHiddenFiles
+  };
+
+  EXTENSIONAPI static constexpr auto Success = 
core::RelationshipDefinition{"success", "All FlowFiles that are received are 
routed to success"};
+  EXTENSIONAPI static constexpr auto Relationships = std::array{Success};
+
+  EXTENSIONAPI static constexpr auto Filename = 
core::OutputAttributeDefinition<>{"filename", { Success }, "The name of the 
file that was read from filesystem."};
+  EXTENSIONAPI static constexpr auto Path = 
core::OutputAttributeDefinition<>{"path", { Success },
+      "The path is set to the relative path of the file's directory on the 
remote filesystem compared to the Share root directory. "
+      "For example, for a given remote 
locationsmb://HOSTNAME:PORT/SHARE/DIRECTORY, and a file is being listed from 
smb://HOSTNAME:PORT/SHARE/DIRECTORY/sub/folder/file "

Review Comment:
   missing space:
   ```suggestion
         "For example, for a given remote location 
smb://HOSTNAME:PORT/SHARE/DIRECTORY, and a file is being listed from 
smb://HOSTNAME:PORT/SHARE/DIRECTORY/sub/folder/file "
   ```



##########
extensions/smb/PutSmb.h:
##########
@@ -0,0 +1,95 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "utils/Enum.h"
+#include "SmbConnectionControllerService.h"
+#include "core/logging/LoggerConfiguration.h"
+
+namespace org::apache::nifi::minifi::extensions::smb {
+
+class PutSmb : public core::Processor {
+ public:
+  explicit PutSmb(std::string name,  const utils::Identifier& uuid = {})
+      : core::Processor(std::move(name), uuid) {
+  }
+
+  ~PutSmb() override = default;
+
+  enum class FileExistsResolutionStrategy {
+    fail,
+    replace,
+    ignore
+  };
+
+  EXTENSIONAPI static constexpr const char* Description = "Writes the contents 
of a FlowFile to an smb network location";
+
+  EXTENSIONAPI static constexpr auto ConnectionControllerService = 
core::PropertyDefinitionBuilder<>::createProperty("SMB Connection Controller 
Service")
+      .withDescription("Specifies the SMB connection controller service to use 
for connecting to the SMB server.")
+      .isRequired(true)
+      .withAllowedTypes<SmbConnectionControllerService>()
+      .build();
+  EXTENSIONAPI static constexpr auto Directory = 
core::PropertyDefinitionBuilder<>::createProperty("Directory")
+      .withDescription("The output directory to which to put files")
+      .supportsExpressionLanguage(true)
+      .withDefaultValue(".")
+      .build();
+  EXTENSIONAPI static constexpr auto ConflictResolution = 
core::PropertyDefinitionBuilder<3>::createProperty("Conflict Resolution 
Strategy")

Review Comment:
   I think it would be better to use `magic_enum::enum_count` instead of `3`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to