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


##########
nifi-extension-bundles/nifi-compress-bundle/nifi-compress-processors/src/main/java/org/apache/nifi/processors/compress/ModifyCompression.java:
##########
@@ -136,21 +146,21 @@ public class ModifyCompression extends AbstractProcessor {
             .defaultValue(FilenameStrategy.UPDATED)
             .build();
 
-    public static final Relationship REL_SUCCESS = new Relationship.Builder()
-            .name("success")
-            .description("FlowFiles will be transferred to the success 
relationship on compression modification success")
-            .build();
-
-    public static final Relationship REL_FAILURE = new Relationship.Builder()
-            .name("failure")
-            .description("FlowFiles will be transferred to the failure 
relationship on compression modification errors")
+    public static final PropertyDescriptor UNKNOWN_MIME_TYPE_ROUTING = new 
PropertyDescriptor.Builder()
+            .name("Unknown MIME Type Routing")
+            .description("The relationship to send the flowfile to when the 
MIME type is unknown.")
+            .dependsOn(INPUT_COMPRESSION_STRATEGY, 
CompressionStrategy.MIME_TYPE_ATTRIBUTE)
+            .required(true)
+            .allowableValues(REL_SUCCESS.getName(), REL_FAILURE.getName())
+            .defaultValue(REL_FAILURE.getName())

Review Comment:
   This property should depend on the `MIME_TYPE` Input Compression Strategy 
being selected



##########
nifi-extension-bundles/nifi-compress-bundle/nifi-compress-processors/src/test/java/org/apache/nifi/processors/compress/TestModifyCompression.java:
##########
@@ -382,6 +387,36 @@ public void testBrotliDecompress() throws Exception {
         flowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), 
"SampleFile.txt");
     }
 
+    @ParameterizedTest
+    @MethodSource("toRelationshipWhenDecompressionNotNeeded")
+    void testWhereDecompressionNotNeeded(Relationship toRelationship) throws 
Exception {
+        final Relationship expectedRelationship;
+        runner.setProperty(ModifyCompression.INPUT_COMPRESSION_STRATEGY, 
CompressionStrategy.MIME_TYPE_ATTRIBUTE);
+        runner.setProperty(ModifyCompression.OUTPUT_FILENAME_STRATEGY, 
FilenameStrategy.ORIGINAL);
+
+        if (toRelationship != null) {
+            runner.setProperty(ModifyCompression.UNKNOWN_MIME_TYPE_ROUTING, 
toRelationship.getName());
+            expectedRelationship = toRelationship;
+        } else {
+            expectedRelationship = ModifyCompression.REL_FAILURE;
+        }

Review Comment:
   ```suggestion
           if (toRelationship == null) {
               expectedRelationship = ModifyCompression.REL_FAILURE;
           } else {
                runner.setProperty(ModifyCompression.UNKNOWN_MIME_TYPE_ROUTING, 
toRelationship.getName());
               expectedRelationship = toRelationship;
           }
   ```



##########
nifi-extension-bundles/nifi-compress-bundle/nifi-compress-processors/src/main/java/org/apache/nifi/processors/compress/ModifyCompression.java:
##########
@@ -136,21 +146,21 @@ public class ModifyCompression extends AbstractProcessor {
             .defaultValue(FilenameStrategy.UPDATED)
             .build();
 
-    public static final Relationship REL_SUCCESS = new Relationship.Builder()
-            .name("success")
-            .description("FlowFiles will be transferred to the success 
relationship on compression modification success")
-            .build();
-
-    public static final Relationship REL_FAILURE = new Relationship.Builder()
-            .name("failure")
-            .description("FlowFiles will be transferred to the failure 
relationship on compression modification errors")
+    public static final PropertyDescriptor UNKNOWN_MIME_TYPE_ROUTING = new 
PropertyDescriptor.Builder()
+            .name("Unknown MIME Type Routing")
+            .description("The relationship to send the flowfile to when the 
MIME type is unknown.")

Review Comment:
   ```suggestion
               .description("The destination relationship for input FlowFiles 
to when the MIME type does not match a known compression type")
   ```



##########
nifi-extension-bundles/nifi-compress-bundle/nifi-compress-processors/src/main/java/org/apache/nifi/processors/compress/ModifyCompression.java:
##########
@@ -207,7 +217,10 @@ public void onTrigger(final ProcessContext context, final 
ProcessSession session
             inputCompressionStrategy = 
compressionFormatMimeTypeMap.get(mimeType);
             if (inputCompressionStrategy == null) {
                 getLogger().info("Compression Strategy not found for MIME Type 
[{}] {}", mimeType, flowFile);
-                session.transfer(flowFile, REL_FAILURE);
+                final String unknownMimeTypeRouting = 
context.getProperty(UNKNOWN_MIME_TYPE_ROUTING).getValue();
+                final Relationship toRelationShip = 
REL_SUCCESS.getName().equals(unknownMimeTypeRouting) ? REL_SUCCESS : 
REL_FAILURE;

Review Comment:
   ```suggestion
                   final Relationship selectedRelationship = 
REL_SUCCESS.getName().equals(unknownMimeTypeRouting) ? REL_SUCCESS : 
REL_FAILURE;
   ```



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