DebugDumper.java 2.8 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemfd.docmanager.Document
 */
package com.adobe.fd.output.internal.utils;

import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.output.internal.logging.OutputServiceLogger;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class DebugDumper {
    OutputServiceLogger logger = new OutputServiceLogger(DebugDumper.class);
    File debugDir;
    String timestamp;

    public DebugDumper(String debugDir) {
        if (debugDir != null && !debugDir.trim().isEmpty()) {
            this.debugDir = new File(debugDir);
        }
        this.timestamp = "" + System.nanoTime() + "";
    }

    public void dump(String fileName, Document doc) {
        try {
            if (doc != null && this.debugDir != null && this.debugDir.isDirectory()) {
                doc.copyToFile(new File(this.debugDir, this.timestamp + "_" + fileName));
            }
        }
        catch (IOException e) {
            this.logger.error("AEM_OUT_001_005", new String[]{fileName, this.debugDir + ""}, e);
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    public void dump(String fileName, byte[] contents) {
        if (contents == null) return;
        if (this.debugDir == null) return;
        if (!this.debugDir.isDirectory()) return;
        FileOutputStream fos = null;
        fos = new FileOutputStream(new File(this.debugDir, this.timestamp + "_" + fileName));
        fos.write(contents);
        if (fos == null) return;
        try {
            fos.close();
            return;
        }
        catch (Exception e) {
            this.logger.warn("AEM_OUT_001_003", new String[]{e.getMessage()}, e);
            return;
        }
        catch (Exception e) {
            try {
                this.logger.error("AEM_OUT_001_005", new String[]{fileName, this.debugDir + ""}, e);
                if (fos == null) return;
            }
            catch (Throwable var5_7) {
                if (fos == null) throw var5_7;
                try {
                    fos.close();
                    throw var5_7;
                }
                catch (Exception e) {
                    this.logger.warn("AEM_OUT_001_003", new String[]{e.getMessage()}, e);
                }
                throw var5_7;
            }
            try {
                fos.close();
                return;
            }
            catch (Exception e) {
                this.logger.warn("AEM_OUT_001_003", new String[]{e.getMessage()}, e);
                return;
            }
        }
    }
}