package stego.StegoReComposer;

import java.io.File;
import java.util.ArrayList;
import stego.Drivers;

// Referenced classes of package stego.StegoReComposer:
//            StegoReComposer_BatchCreator, StegoReComposer_BatchAnalyzer

public class StegoReComposer_Caller
{

    private static String strMyClassName = "StegoReComposer_Caller";

    public StegoReComposer_Caller(File fleTopDir, ArrayList carrierFles, boolean filesAreEncrypted, File pathToEncryption_JAR, File pathToEncryption_KEY)
    {
        processFiles(fleTopDir, carrierFles, filesAreEncrypted, pathToEncryption_JAR, pathToEncryption_KEY);
    }

    private boolean processFiles(File fleTopFolder, ArrayList alCarrierFiles, boolean useEncryption, File encryption_JAR_Path, File encryption_KEY)
    {
        try
        {
            if(fleTopFolder == null || !fleTopFolder.exists() || alCarrierFiles == null || alCarrierFiles.size() < 1)
            {
                Drivers.jop_Error("Top Folder or Selected Files under Top Folder no longer appear to exist!", "Critical Error");
                throw new Exception("Top Folder or ArrayList of files did not exist");
            }
            StegoReComposer_BatchCreator batchCreator = null;
            for(int i = 0; i < alCarrierFiles.size(); i++)
            {
                batchCreator = new StegoReComposer_BatchCreator((File)alCarrierFiles.get(i), fleTopFolder, useEncryption, encryption_JAR_Path, encryption_KEY);
            }

            analyzeBatchDirectories(fleTopFolder);
        }
        catch(Exception e)
        {
            Drivers.eop("processFiles", strMyClassName, e, e.getLocalizedMessage(), true);
            return false;
        }
        return true;
    }

    public static boolean analyzeBatchDirectories(File fleTopFolderToAnalyze)
    {
        ArrayList alBatchDirectoryPaths;
        alBatchDirectoryPaths = Drivers.getDirectoriesUnderSelectedDirectory(fleTopFolderToAnalyze, true, "Analyzed");
        if(alBatchDirectoryPaths == null)
        {
            Drivers.jop_Message((new StringBuilder("Error caught when attempting to retrieve the directory listing within: \n")).append(fleTopFolderToAnalyze).toString(), "Critical Error");
            throw new Exception("alBatchDirectoryPaths came back as null");
        }
        if(alBatchDirectoryPaths.size() >= 1)
        {
            break MISSING_BLOCK_LABEL_74;
        }
        Drivers.jop_Message((new StringBuilder("No Batch Directories were found under the given location:\n")).append(fleTopFolderToAnalyze).toString(), "No Batch Directories Found");
        return false;
        try
        {
            StegoReComposer_BatchAnalyzer analyzer = null;
            Drivers.sop("Analyzing the following batch directories: ");
            for(int j = 0; j < alBatchDirectoryPaths.size(); j++)
            {
                analyzer = new StegoReComposer_BatchAnalyzer((File)alBatchDirectoryPaths.get(j));
            }

        }
        catch(Exception e)
        {
            Drivers.eop("analyzeBatchDirectories", strMyClassName, e, e.getLocalizedMessage(), true);
            return false;
        }
        return true;
    }

}
