OpenOfficeToPDFTransactionCallback.java 5.4 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 java.util.Map;
import org.omg.CORBA.Object;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class OpenOfficeToPDFTransactionCallback
implements TransactionCallback {
    private ConnectionFactory openOfficeToPdfFactory;
    private static final int MAX_RETRY_COUNT = 5;
    private static final long WAIT_TIME = 60000;
    private String m_strSourcePath;
    private String m_strDestinationPath;
    private byte[] m_openOfficeData;
    private int m_iTimeoutSeconds;
    private static int m_poolSize = 1;
    private static PDFGLogger pdfgLogger = PDFGLogger.getPDFGLogger(OpenOfficeToPDFTransactionCallback.class);

    public OpenOfficeToPDFTransactionCallback(ConnectionFactory openOfficeToPdfFactory) {
        this.openOfficeToPdfFactory = openOfficeToPdfFactory;
        this.openOfficeToPdfFactory.setServiceTimeout((long)AESProperties.getGlobalTimeout());
    }

    public void initOpenOfficeToPdfFactory(Map usersMap) throws Exception {
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        StringBuilder debugMsgs = new StringBuilder();
        debugMsgs.append("\nInside OpenOfficeToPDFTransactionCallback.initOpenOfficeToPdfFactory for job=" + jobIdentityId);
        if (usersMap != null && !usersMap.isEmpty()) {
            m_poolSize = usersMap.size();
            this.openOfficeToPdfFactory.setImpersonationIdentities(usersMap);
        }
        debugMsgs.append("\nabout to exit initPDFMToPDFFactory() for job=" + jobIdentityId);
    }

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

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

    public void setOpenOfficeData(byte[] openOfficeData) {
        this.m_openOfficeData = openOfficeData;
    }

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

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

    public int getPoolSize() {
        return m_poolSize;
    }

    public void setOpenOfficeToPdfFactory(ConnectionFactory openOfficeToPdfFactory) {
        this.openOfficeToPdfFactory = openOfficeToPdfFactory;
    }

    public void modifyUserAccountsMap(Map<String, String> usersMap) throws Exception {
        if (usersMap != null && !usersMap.isEmpty()) {
            this.openOfficeToPdfFactory.setImpersonationIdentities(usersMap);
        }
    }
}