This is an automated email from the ASF dual-hosted git repository.

pvillard31 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new b46b6411b44 NIFI-16178 Removed unused Unpackage Utility class (#11520)
b46b6411b44 is described below

commit b46b6411b44cf5929b2fddbc69eb1d7173d88554
Author: David Handermann <[email protected]>
AuthorDate: Fri Aug 7 15:50:07 2026 -0500

    NIFI-16178 Removed unused Unpackage Utility class (#11520)
---
 .../main/java/org/apache/nifi/util/Unpackage.java  | 118 ---------------------
 1 file changed, 118 deletions(-)

diff --git 
a/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/Unpackage.java
 
b/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/Unpackage.java
deleted file mode 100644
index b4c096e6d97..00000000000
--- 
a/nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/Unpackage.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.UUID;
-
-public class Unpackage {
-
-    private static void printUsage() {
-        System.out.println("java " + Unpackage.class.getCanonicalName() + " 
<version> <input file 1> [<input file 2> <input file 3> ... <input file N>]");
-        System.out.println("<version> : The version of the FlowFile Package 
format. Valid values are 1, 2, 3");
-        System.out.println("<input file X> : The FlowFile package to unpack");
-        System.out.println();
-    }
-
-    public static void main(final String[] args) throws IOException {
-        if (args.length < 2) {
-            printUsage();
-            return;
-        }
-
-        final String version = args[0];
-
-        int inputFileCount = 0;
-        int outputFileCount = 0;
-
-        for (int i = 1; i < args.length; i++) {
-            final String filename = args[i];
-            final File inFile = new File(filename);
-
-            if (inFile.isDirectory()) {
-                System.out.println("WARNING: input file " + inFile + " is a 
directory; skipping");
-                continue;
-            }
-
-            if (!inFile.exists() || !inFile.canRead()) {
-                System.out.println("ERROR: unable to read file " + inFile);
-                continue;
-            }
-
-            final File outputDir = new File(inFile.getAbsolutePath() + 
".unpacked");
-            if (!outputDir.exists() && !outputDir.mkdir()) {
-                System.out.println("ERROR: Unable to create directory " + 
outputDir);
-                continue;
-            }
-
-            final File tempFile = new File(outputDir, ".temp." + 
UUID.randomUUID() + ".unpackage");
-            inputFileCount++;
-            try (final FileInputStream fis = new FileInputStream(inFile);
-                    final BufferedInputStream bufferedIn = new 
BufferedInputStream(fis)) {
-
-                final FlowFileUnpackager unpackager = 
createUnpackager(version);
-                while (unpackager.hasMoreData()) {
-                    outputFileCount++;
-                    final Map<String, String> attributes;
-
-                    try (final FileOutputStream fos = new 
FileOutputStream(tempFile);
-                            final BufferedOutputStream bufferedOut = new 
BufferedOutputStream(fos)) {
-                        attributes = unpackager.unpackageFlowFile(bufferedIn, 
bufferedOut);
-                    }
-
-                    String outputFilename = attributes.get("filename");
-                    if (outputFilename == null) {
-                        outputFilename = attributes.get("nf.file.name");
-                    }
-
-                    final File outputFile = new File(outputDir, 
outputFilename);
-                    tempFile.renameTo(outputFile);
-
-                    final File attributeFilename = new File(outputDir, 
outputFilename + ".attributes");
-                    try (final FileOutputStream fos = new 
FileOutputStream(attributeFilename);
-                            final BufferedOutputStream bufferedOut = new 
BufferedOutputStream(fos)) {
-
-                        for (final Map.Entry<String, String> entry : 
attributes.entrySet()) {
-                            bufferedOut.write((entry.getKey() + "=" + 
entry.getValue() + "\n").getBytes(StandardCharsets.UTF_8));
-                        }
-                    }
-                }
-            }
-        }
-
-        System.out.println("Unpacked " + inputFileCount + " packages into " + 
outputFileCount + " files");
-    }
-
-    public static FlowFileUnpackager createUnpackager(final String version) {
-        return switch (version) {
-            case "1" -> new FlowFileUnpackagerV1();
-            case "2" -> new FlowFileUnpackagerV2();
-            case "3" -> new FlowFileUnpackagerV3();
-            default -> {
-                System.out.println("ERROR: Invalid version: " + version + "; 
must be 1, 2, or 3");
-                yield null;
-            }
-        };
-    }
-}

Reply via email to