exceptionfactory commented on code in PR #7458:
URL: https://github.com/apache/nifi/pull/7458#discussion_r1263766777


##########
nifi-nar-bundles/nifi-extension-utils/nifi-resource-transfer/src/main/java/org/apache/nifi/processors/transfer/ResourceTransferUtils.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.processors.transfer;
+
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.fileresource.service.api.FileResource;
+import org.apache.nifi.fileresource.service.api.FileResourceService;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.exception.ProcessException;
+
+import java.io.InputStream;
+import java.util.Optional;
+
+import static 
org.apache.nifi.processors.transfer.ResourceTransferProperties.FILE_RESOURCE_SERVICE;
+
+public final class ResourceTransferUtils {
+
+    private ResourceTransferUtils() {}
+
+    /**
+     * Get File Resource from File Resource Service based on provided Source 
otherwise return empty
+     *
+     * @param resourceTransferSource type of the data upload
+     * @param context process context with properties
+     * @param flowFile FlowFile with attributes to use in expression language
+     * @return Optional FileResource retrieved from FileResourceService if 
Source is File Resource Service, otherwise empty
+     * @throws ProcessException Thrown if Source is File Resource but 
FileResourceService is not provided in the context
+     */
+    public static Optional<FileResource> getFileResource(final 
ResourceTransferSource resourceTransferSource, final ProcessContext context, 
final FlowFile flowFile) {

Review Comment:
   With this as a public utility method, I wanted to make it clear that it may 
not return a `FileResource`, so I changed it to use the `Optional` wrapper. I 
considered adjusting the calling code, and I will take another look at that in 
light of your comments.



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