ImageToPDFTransactionCallback.java 3.59 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.native2pdf.bmc.ConverterAgent
 *  com.adobe.native2pdf.bmc.ConverterAgentHelper
 *  com.adobe.native2pdf.bmc.ResultStruct
 *  com.adobe.pdfg.common.AESProperties
 *  com.adobe.pdfg.common.Utils
 *  com.adobe.pdfg.logging.PDFGLogger
 *  com.adobe.service.ConnectionFactory
 */
package com.adobe.pdfg.callbacks;

import com.adobe.native2pdf.bmc.ConverterAgent;
import com.adobe.native2pdf.bmc.ConverterAgentHelper;
import com.adobe.native2pdf.bmc.ResultStruct;
import com.adobe.pdfg.common.AESProperties;
import com.adobe.pdfg.common.Utils;
import com.adobe.pdfg.logging.PDFGLogger;
import com.adobe.pdfg.transaction.TransactionCallback;
import com.adobe.service.ConnectionFactory;
import org.omg.CORBA.Object;

public class ImageToPDFTransactionCallback
implements TransactionCallback {
    private ConnectionFactory imageToPdfFactory;
    private static final int MAX_RETRY_COUNT = 5;
    private static final long WAIT_TIME = 60000;
    String m_strSourcePath = null;
    String m_strDestinationPath = null;
    Double m_pdfVersion = 1.5;
    int m_iTimeoutSeconds = 270;
    private static PDFGLogger pdfgLogger = PDFGLogger.getPDFGLogger(ImageToPDFTransactionCallback.class);

    public ImageToPDFTransactionCallback(ConnectionFactory imageToPdfFactory) {
        this.imageToPdfFactory = imageToPdfFactory;
        this.imageToPdfFactory.setServiceTimeout((long)AESProperties.getGlobalTimeout());
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public java.lang.Object doInTransaction() {
        ConverterAgent agent = null;
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        StringBuilder debugMsgs = new StringBuilder();
        boolean debugMsgsLogged = false;
        debugMsgs.append("\nInside ImageToPDFTransactionCallback.doInTransaction for job=" + jobIdentityId);
        try {
            debugMsgs.append("\nbefore obtaining a CORBA connection for job=" + jobIdentityId);
            Object connection = (Object)this.imageToPdfFactory.getConnection();
            debugMsgs.append("\nbefore narrowing the CORBA connection for job=" + jobIdentityId);
            agent = ConverterAgentHelper.narrow((Object)connection);
            debugMsgs.append("\nbefore agent.convertImgToPdf for job=" + jobIdentityId);
            pdfgLogger.debug(debugMsgs.toString());
            debugMsgsLogged = true;
            ResultStruct resultStruct = agent.convertImgToPdf(this.m_strSourcePath, this.m_strDestinationPath, this.m_iTimeoutSeconds, this.m_pdfVersion.doubleValue(), jobIdentityId);
            return resultStruct;
        }
        finally {
            if (agent != null) {
                try {
                    agent.cleanUp();
                }
                catch (Exception t) {
                    pdfgLogger.trace(t.getMessage(), null, (Throwable)t);
                }
            }
            if (!debugMsgsLogged) {
                pdfgLogger.debug(debugMsgs.toString());
            }
        }
    }

    public void setTimeoutSeconds(int timeoutSeconds) {
        this.m_iTimeoutSeconds = timeoutSeconds;
    }

    public void setDestinationPath(String destinationPath) {
        this.m_strDestinationPath = destinationPath;
    }

    public void setSourcePath(String sourcePath) {
        this.m_strSourcePath = sourcePath;
    }

    public void setPDFVersion(Double pdfVersion) {
        this.m_pdfVersion = pdfVersion;
    }

    public void setImageToPdfFactory(ConnectionFactory imageToPdfFactory) {
        this.imageToPdfFactory = imageToPdfFactory;
    }
}