martinzink commented on a change in pull request #1225:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1225#discussion_r768718262



##########
File path: extensions/sftp/processors/ListSFTP.cpp
##########
@@ -261,20 +263,19 @@ void ListSFTP::onSchedule(const 
std::shared_ptr<core::ProcessContext> &context,
   }
   context->getProperty(TargetSystemTimestampPrecision.getName(), 
target_system_timestamp_precision_);
   context->getProperty(EntityTrackingInitialListingTarget.getName(), 
entity_tracking_initial_listing_target_);
-  if (!context->getProperty(MinimumFileAge.getName(), value)) {
-    logger_->log_error("Minimum File Age attribute is missing or invalid");
+
+  if (auto minimum_file_age = 
context->getProperty<core::TimePeriodValue>(MinimumFileAge)) {
+    minimum_file_age_ = minimum_file_age->getMilliseconds();
   } else {
-    core::TimeUnit unit;
-    if (!core::Property::StringToTime(value, minimum_file_age_, unit) || 
!core::Property::ConvertTimeUnitToMS(minimum_file_age_, unit, 
minimum_file_age_)) {
-      logger_->log_error("Minimum File Age attribute is invalid");
-    }
+    logger_->log_error("Minimum File Age attribute is missing or invalid");
   }
-  if (context->getProperty(MaximumFileAge.getName(), value)) {
-    core::TimeUnit unit;
-    if (!core::Property::StringToTime(value, maximum_file_age_, unit) || 
!core::Property::ConvertTimeUnitToMS(maximum_file_age_, unit, 
maximum_file_age_)) {
-      logger_->log_error("Maximum File Age attribute is invalid");
-    }
+
+  if (auto maximum_file_age = 
context->getProperty<core::TimePeriodValue>(MaximumFileAge)) {
+    maximum_file_age_ = maximum_file_age->getMilliseconds();
+  } else {
+    logger_->log_error("Maximum File Age attribute is missing or invalid");

Review comment:
       This one calls the
   ```
   template<typename T = std::string>
   std::enable_if_t<std::is_default_constructible<T>::value, std::optional<T>>
   getProperty(const Property& property) const {
     T value;
     try {
       if (!getProperty(property.getName(), value)) return std::nullopt;
     } catch (const utils::internal::ValueException&) {
       return std::nullopt;
     }
     return value;
   }
   ```
   which doesnt throw just returns a nullopt if the value is invalid




-- 
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