BMCCaller.java 30.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemfd.docmanager.Document
 *  com.adobe.native2pdf.bmc.ResultStruct
 *  com.adobe.native2pdf.xml.FiletypeSettings
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$AutoCAD
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$Image
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$MSExcel
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$MSPowerpoint
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$MSProject
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$MSVisio
 *  com.adobe.native2pdf.xml.FiletypeSettings$Settings$MSWord
 *  com.adobe.native2pdf.xml.InitialView
 *  com.adobe.native2pdf.xml.JobOptions
 *  com.adobe.native2pdf.xml.JobOptions$JobOption
 *  com.adobe.native2pdf.xml.PDFMaker
 *  com.adobe.native2pdf.xml.SecuritySettings
 *  com.adobe.native2pdf.xml.SecuritySettings$Settings
 *  com.adobe.pdfg.common.AESProperties
 *  com.adobe.pdfg.common.FileUtilities
 *  com.adobe.pdfg.common.JobConfiguration
 *  com.adobe.pdfg.common.PDFGGlobalCache
 *  com.adobe.pdfg.common.SettingValidator
 *  com.adobe.pdfg.common.Utils
 *  com.adobe.pdfg.exception.ConfigException
 *  com.adobe.pdfg.exception.ConversionException
 *  com.adobe.pdfg.exception.FileFormatNotSupportedException
 *  com.adobe.pdfg.exception.InvalidParameterException
 *  com.adobe.pdfg.exception.JobOptionsParseException
 *  com.adobe.pdfg.logging.PDFGLogCodes
 *  com.adobe.pdfg.logging.PDFGLogger
 *  com.adobe.pdfg.service.api.PDFGConfigService
 *  com.adobe.service.InvalidSourceException
 */
package com.adobe.pdfg.impl;

import com.adobe.aemfd.docmanager.Document;
import com.adobe.native2pdf.bmc.ResultStruct;
import com.adobe.native2pdf.xml.FiletypeSettings;
import com.adobe.native2pdf.xml.InitialView;
import com.adobe.native2pdf.xml.JobOptions;
import com.adobe.native2pdf.xml.PDFMaker;
import com.adobe.native2pdf.xml.SecuritySettings;
import com.adobe.pdfg.common.AESProperties;
import com.adobe.pdfg.common.FileUtilities;
import com.adobe.pdfg.common.JobConfiguration;
import com.adobe.pdfg.common.PDFGGlobalCache;
import com.adobe.pdfg.common.SettingValidator;
import com.adobe.pdfg.common.Utils;
import com.adobe.pdfg.exception.ConfigException;
import com.adobe.pdfg.exception.ConversionException;
import com.adobe.pdfg.exception.FileFormatNotSupportedException;
import com.adobe.pdfg.exception.InvalidParameterException;
import com.adobe.pdfg.exception.JobOptionsParseException;
import com.adobe.pdfg.impl.GeneratePDFServiceImpl;
import com.adobe.pdfg.impl.GeneratePDFUtil;
import com.adobe.pdfg.logging.PDFGLogCodes;
import com.adobe.pdfg.logging.PDFGLogger;
import com.adobe.pdfg.postprocess.PdfPostProcessorImpl;
import com.adobe.pdfg.postprocess.PostProcessFileInfo;
import com.adobe.pdfg.service.api.PDFGConfigService;
import com.adobe.pdfg.transaction.TransactionCallback;
import com.adobe.pdfg.transaction.TransactionTemplate;
import com.adobe.service.InvalidSourceException;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.naming.NamingException;
import javax.xml.bind.JAXBException;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public abstract class BMCCaller
implements PDFGLogCodes {
    protected JobConfiguration config = null;
    protected SecuritySettings.Settings securityConfig = null;
    protected JobOptions.JobOption jobOptionConfig = null;
    protected String jobOptionName = null;
    protected FiletypeSettings.Settings filetypeSettings = null;
    protected InitialView initialViewConfig = null;
    protected Serializable appConfig = null;
    protected int startPage = 1;
    protected int endPage = -1;
    protected String ocrLanguageChosen;
    protected static final int DEFAULT_CONVERSION_TIMEOUT_MIN = 10;
    protected PDFGLogger pdfgLogger = PDFGLogger.getPDFGLogger(BMCCaller.class);
    protected static final String RESERVED_JOBOPTION_FILENAME = "#PDFGJobOption";
    protected int timeoutSeconds = AESProperties.getMaximumTimeout();
    protected Map distillerParameters = null;
    private GeneratePDFServiceImpl generatePDF;

    public BMCCaller() {
        this.timeoutSeconds = Math.max(10, this.timeoutSeconds);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected int doPostProcess(String serviceName, String appName, File xmpFile, String destinationPath, GeneratePDFServiceImpl coreSvcImpl, File jobOptionFile, int errCode, PostProcessFileInfo filePaths, boolean bImage2PdfByAcrobat, boolean bImage2PdfByJava, String pdfProducerString, int pdfColorSpace, boolean applyWaterMark) throws Exception {
        int doLinearizarion;
        block19 : {
            boolean doImagePostProcessing;
            String jobIdentityId;
            StringBuilder debugMsgs;
            int errorCode;
            boolean debugMsgsLogged;
            block17 : {
                int n;
                block18 : {
                    errorCode = errCode;
                    debugMsgsLogged = false;
                    doImagePostProcessing = bImage2PdfByAcrobat || bImage2PdfByJava;
                    jobIdentityId = (String)Utils.threadLocalValue.get();
                    debugMsgs = new StringBuilder();
                    try {
                        debugMsgs.append("\nInside BMCCaller.doPostProcess() for job=" + jobIdentityId);
                        if (!"PDFExportConverterService".equals(serviceName)) break block17;
                        n = errorCode;
                        Object var29_21 = null;
                        if (debugMsgsLogged) break block18;
                    }
                    catch (Throwable var28_33) {
                        Object var29_23 = null;
                        if (!debugMsgsLogged) {
                            this.pdfgLogger.debug(debugMsgs.toString());
                        }
                        throw var28_33;
                    }
                    this.pdfgLogger.debug(debugMsgs.toString());
                }
                return n;
            }
            boolean doPDFAProcessing = Utils.isPDFAComplianceOn((Map)this.distillerParameters);
            boolean attachJobOptions = false;
            if (!"GenericConverterService".equals(serviceName) && !this.isPDFMakerApp(appName)) {
                debugMsgs.append("\nThis is a non-PDFMaker Application for job=" + jobIdentityId);
                Boolean bEmbedJobOptions = (Boolean)this.distillerParameters.get("EmbedJobOptions");
                if (bEmbedJobOptions != null && bEmbedJobOptions.booleanValue()) {
                    attachJobOptions = true;
                }
            }
            String targetPdfVersion = "";
            boolean forcePdfVersion = false;
            if ("AcrobatOCR".equals(appName)) {
                Double dVersion = (Double)this.distillerParameters.get("CompatibilityLevel");
                if (dVersion != null) {
                    targetPdfVersion = dVersion.toString();
                } else {
                    targetPdfVersion = "1.5";
                    forcePdfVersion = true;
                }
            }
            boolean shouldApplySecurity = Utils.shouldApplySecurity((SecuritySettings.Settings)this.securityConfig);
            if (pdfProducerString == null || "".equals(pdfProducerString)) {
                pdfProducerString = "PDF generator";
            }
            boolean doPostProcess = attachJobOptions || xmpFile != null || this.initialViewConfig != null || shouldApplySecurity || doPDFAProcessing || doImagePostProcessing || this.checkLinearizationForPostProcessing() || !targetPdfVersion.equals("") || pdfProducerString != null && !"".equals(pdfProducerString) || applyWaterMark;
            debugMsgs.append("\ndoPostProcess= " + doPostProcess + " for job=" + jobIdentityId);
            if (doPostProcess) {
                this.pdfgLogger.debug("001-008", "Beginning PDF Post-Processing");
                errorCode = 1013;
                if (shouldApplySecurity) {
                    debugMsgs.append("\nshouldApplySecurity is true for job=" + jobIdentityId);
                    GeneratePDFUtil.updateSecuritySettings(coreSvcImpl.getConfigService(), this.securityConfig);
                    if (bImage2PdfByJava) {
                        targetPdfVersion = "1." + (this.securityConfig.getAcrobatVersion() - 1);
                    }
                }
                doLinearizarion = 0;
                Boolean isLinearize = (Boolean)this.distillerParameters.get("Optimize");
                if (isLinearize != null) {
                    doLinearizarion = (int)isLinearize.booleanValue() ? 1 : 0;
                }
                if (attachJobOptions) {
                    debugMsgs.append("\nattachJobOptions is true for job=" + jobIdentityId);
                    File attachmentFile = jobOptionFile;
                    debugMsgs.append("\nbefore calling this.pdfPostProcess for job=" + jobIdentityId);
                    this.pdfgLogger.debug(debugMsgs.toString());
                    debugMsgsLogged = true;
                    errorCode = this.pdfPostProcess(destinationPath, xmpFile, attachmentFile, this.config.getJobOptionName() + ".joboptions", this.initialViewConfig, this.securityConfig, (boolean)doLinearizarion, doPDFAProcessing, doImagePostProcessing, filePaths, targetPdfVersion, forcePdfVersion, pdfProducerString, pdfColorSpace, applyWaterMark);
                } else {
                    debugMsgs.append("\nattachJobOptions is false for job=" + jobIdentityId);
                    debugMsgs.append("\nbefore calling this.pdfPostProcess for job=" + jobIdentityId);
                    this.pdfgLogger.debug(debugMsgs.toString());
                    debugMsgsLogged = true;
                    errorCode = this.pdfPostProcess(destinationPath, xmpFile, null, null, this.initialViewConfig, this.securityConfig, (boolean)doLinearizarion, doPDFAProcessing, doImagePostProcessing, filePaths, targetPdfVersion, forcePdfVersion, pdfProducerString, pdfColorSpace, applyWaterMark);
                }
                this.pdfgLogger.debug("error code =" + errorCode + " for job=" + jobIdentityId);
                if (errorCode != 0) {
                    throw new ConversionException(errorCode);
                }
                this.pdfgLogger.debug("001-009", "Finishing PDF Post-Processing");
            }
            doLinearizarion = errorCode;
            Object var29_22 = null;
            if (debugMsgsLogged) break block19;
            this.pdfgLogger.debug(debugMsgs.toString());
        }
        return doLinearizarion;
    }

    protected int initializeConfiguration(GeneratePDFServiceImpl coreSvcImpl, Document jobConfigDoc, String jobConfigurationString, int errCode) throws ConversionException, InvalidParameterException {
        int errorCode = errCode;
        try {
            if (jobConfigurationString == null) {
                jobConfigurationString = GeneratePDFUtil.getJobConfigurationString(coreSvcImpl.getConfigService(), jobConfigDoc, null, null, null);
            }
            this.config = PDFGGlobalCache.getJobConfiguration((String)jobConfigurationString);
        }
        catch (JAXBException e) {
            throw new InvalidParameterException(1001, (Throwable)e);
        }
        this.securityConfig = this.config.getSecuritySettings();
        this.filetypeSettings = this.config.getFiletypeSettings();
        if (this.filetypeSettings != null && this.filetypeSettings.getImage() != null) {
            this.ocrLanguageChosen = this.filetypeSettings.getImage().getOcrLanguage();
        }
        if (this.ocrLanguageChosen == null) {
            this.ocrLanguageChosen = "";
        }
        this.timeoutSeconds = this.config.getConversionTimeoutSetting(10, this.timeoutSeconds, this.timeoutSeconds);
        this.jobOptionName = this.config.getJobOptionName();
        this.jobOptionConfig = this.config.getJobOptions();
        if (this.filetypeSettings == null || this.jobOptionConfig == null) {
            throw new InvalidParameterException(errorCode);
        }
        String jobOptionsString = this.jobOptionConfig.getOptionData();
        try {
            jobOptionsString = Utils.checkJobOptionsPageNumbers((String)jobOptionsString);
            Map jobOptionsMap = PDFGGlobalCache.getJobOptionsMap((String)jobOptionsString);
            Map ditillerParametersMap = (Map)jobOptionsMap.get("setdistillerparams");
            this.startPage = (Integer)ditillerParametersMap.get("StartPage");
            this.endPage = (Integer)ditillerParametersMap.get("EndPage");
        }
        catch (JobOptionsParseException e) {
            throw new InvalidParameterException(1001, (Throwable)e);
        }
        this.jobOptionConfig.setOptionData(jobOptionsString);
        this.initialViewConfig = this.jobOptionConfig.getInitialView();
        return errorCode;
    }

    private static String processJobOptionsData(String jobOptionData) throws ConversionException {
        int indexOfStartPage = jobOptionData.indexOf("StartPage");
        if (indexOfStartPage == -1) {
            throw new ConversionException(1012);
        }
        Map<String, Object> startPageAttr = BMCCaller.getAttributesOfPageNumber(indexOfStartPage, jobOptionData);
        int startPageNo = (Integer)startPageAttr.get("PageNum");
        int indexOfEndPage = jobOptionData.indexOf("EndPage");
        if (indexOfStartPage == -1) {
            throw new ConversionException(1012);
        }
        Map<String, Object> endPageAttr = BMCCaller.getAttributesOfPageNumber(indexOfEndPage, jobOptionData);
        int endPageNo = (Integer)endPageAttr.get("PageNum");
        if (startPageNo > endPageNo) {
            String startPageStr = (String)startPageAttr.get("PageString");
            String endPageStr = (String)endPageAttr.get("PageString");
            jobOptionData = jobOptionData.replace(startPageStr, "StartPage " + endPageNo);
            jobOptionData = jobOptionData.replace(endPageStr, "EndPage " + startPageNo);
        }
        return jobOptionData;
    }

    private static Map<String, Object> getAttributesOfPageNumber(int indexOfPageString, String jobOptionData) throws ConversionException {
        HashMap<String, Object> attrMap = new HashMap<String, Object>();
        int indexOfFirstSpace = jobOptionData.indexOf(" ", indexOfPageString + 1);
        if (indexOfFirstSpace == -1) {
            throw new ConversionException(1012);
        }
        int indexOfSecondSpace = jobOptionData.indexOf(" ", indexOfFirstSpace + 1);
        if (indexOfSecondSpace == -1) {
            throw new ConversionException(1012);
        }
        Integer num = Integer.valueOf(jobOptionData.substring(indexOfFirstSpace + 1, indexOfSecondSpace));
        attrMap.put("PageNum", num);
        attrMap.put("PageString", jobOptionData.substring(indexOfPageString, indexOfSecondSpace));
        return attrMap;
    }

    protected int checkResult(ResultStruct results, int errCode) throws ConversionException {
        int errorCode = errCode;
        if (!results.success) {
            String appmonErrorKeyString;
            errorCode = 1011;
            String errorMessage = null;
            try {
                appmonErrorKeyString = new String(results.appMonErrorKey, "UTF-8");
            }
            catch (UnsupportedEncodingException e) {
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                appmonErrorKeyString = new String(results.appMonErrorKey);
            }
            if (appmonErrorKeyString.length() > 0) {
                try {
                    errorCode = Integer.parseInt(appmonErrorKeyString.trim());
                }
                catch (NumberFormatException e1) {
                    this.pdfgLogger.trace(e1.getMessage(), null, (Throwable)e1);
                    errorCode = results.conversionErrorKey;
                    errorMessage = appmonErrorKeyString;
                }
            } else if (results.conversionErrorKey != 0) {
                errorCode = results.conversionErrorKey;
            }
            if (errorCode == 0) {
                errorCode = 1011;
            }
            if (errorMessage == null) {
                if (results.errorMsgParams != null && results.errorMsgParams.length != 0) {
                    throw new ConversionException(errorCode, results.errorMsgParams);
                }
                throw new ConversionException(errorCode);
            }
            throw new ConversionException(errorCode, errorMessage);
        }
        return errorCode;
    }

    protected boolean isPDFMakerApp(String appName) {
        String lcAppName;
        boolean result = false;
        if (appName != null && ",autocad,excel,powerpoint,project,publisher,visio,word,".indexOf(lcAppName = "," + appName.toLowerCase() + ",") != -1) {
            result = true;
        }
        return result;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected int pdfPostProcess(String sourcePdfPath, File xmpFile, File attachmentFile, String attachmentName, InitialView initialView, SecuritySettings.Settings encryptionSettings, boolean linearize, boolean doPdfAProcessing, boolean doImagePostProcessing, PostProcessFileInfo filePaths, String targetPdfVersion, boolean forcePdfVersion, String pdfProducerString, int pdfColorSpace, boolean applyWatermark) throws FileNotFoundException, IOException, NamingException, ConfigException, InvalidSourceException {
        String jobIdentityId;
        int errorCode;
        block10 : {
            boolean debugMsgsLogged;
            boolean shouldApplySecurity;
            StringBuilder debugMsgs;
            block8 : {
                int n;
                block9 : {
                    debugMsgsLogged = false;
                    jobIdentityId = (String)Utils.threadLocalValue.get();
                    debugMsgs = new StringBuilder();
                    errorCode = 0;
                    try {
                        debugMsgs.append("\nInside BMCCaller.pdfPostProcess() for job=" + jobIdentityId);
                        boolean isImageConversionWithOCR = doImagePostProcessing && this.config.getFiletypeSettings().getImage().isUseOCR();
                        boolean bl = shouldApplySecurity = Utils.shouldApplySecurity((SecuritySettings.Settings)encryptionSettings) && !isImageConversionWithOCR;
                        if (shouldApplySecurity || xmpFile != null || initialView != null || attachmentFile != null || linearize || doImagePostProcessing || !targetPdfVersion.equals("") || pdfProducerString != null && !"".equals(pdfProducerString) || applyWatermark) break block8;
                        debugMsgs.append("\nreturning from pdfPostProcess() as nothing to do for job=" + jobIdentityId);
                        n = 0;
                        Object var28_24 = null;
                        if (debugMsgsLogged) break block9;
                    }
                    catch (Throwable var27_31) {
                        Object var28_26 = null;
                        if (!debugMsgsLogged) {
                            this.pdfgLogger.debug(debugMsgs.toString());
                        }
                        this.pdfgLogger.debug("error code =" + errorCode + " for job=" + jobIdentityId);
                        throw var27_31;
                    }
                    this.pdfgLogger.debug(debugMsgs.toString());
                }
                this.pdfgLogger.debug("error code =" + errorCode + " for job=" + jobIdentityId);
                return n;
            }
            PdfPostProcessorImpl pdfPostProcessor = new PdfPostProcessorImpl();
            String xmpFilePath = "";
            if (xmpFile != null) {
                xmpFilePath = xmpFile.getAbsolutePath();
            }
            String attachmentFilePath = "";
            if (attachmentFile != null) {
                attachmentFilePath = attachmentFile.getAbsolutePath();
            }
            if (!shouldApplySecurity) {
                encryptionSettings = null;
            }
            String attachmentParam = attachmentName != null ? attachmentName : "";
            String pdfProducerStr = pdfProducerString != null ? pdfProducerString : "";
            filePaths.pdfFilePath = sourcePdfPath;
            filePaths.xmpFilePath = xmpFilePath;
            filePaths.attachmentFilePath = attachmentFilePath;
            filePaths.tempPdfFilePath = "";
            debugMsgs.append("\nbefore calling pdfPostProcessor.doPostProcess for job=" + jobIdentityId);
            this.pdfgLogger.debug(debugMsgs.toString());
            debugMsgsLogged = true;
            errorCode = pdfPostProcessor.doPostProcess(filePaths, attachmentParam, initialView, encryptionSettings, linearize, doPdfAProcessing, doImagePostProcessing, targetPdfVersion, forcePdfVersion, pdfProducerStr, pdfColorSpace, applyWatermark);
            if (errorCode != 0) {
                this.pdfgLogger.debug("002-003", new Object[]{"" + errorCode + ""});
            }
            Object var28_25 = null;
            if (debugMsgsLogged) break block10;
            this.pdfgLogger.debug(debugMsgs.toString());
        }
        this.pdfgLogger.debug("error code =" + errorCode + " for job=" + jobIdentityId);
        {
        }
        return errorCode;
    }

    protected String getJobOptionNameFromFile(File jobOptionFile, String suffix) {
        String jobOptionName = jobOptionFile.getName();
        int suffixStart = jobOptionName.indexOf(suffix);
        jobOptionName = jobOptionName.substring(0, suffixStart);
        return jobOptionName;
    }

    protected void cleanJobOptionsFiles() {
        File customJobOptionDir = this.getAcrobatCustomJobOptionsDir();
        if (!customJobOptionDir.exists()) {
            return;
        }
        File[] jobOptFiles = customJobOptionDir.listFiles(new FileFilter(){

            public boolean accept(File pathname) {
                if (pathname.isDirectory()) {
                    return false;
                }
                String fileName = pathname.getName();
                if (fileName.startsWith("#PDFGJobOption")) {
                    return true;
                }
                return false;
            }
        });
        for (int i = 0; i < jobOptFiles.length; ++i) {
            jobOptFiles[i].delete();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected File validateConfigAndWriteJobOptions(GeneratePDFServiceImpl coreSvcImpl, JobConfiguration config, String jobOptionName, String suffix, boolean useReservedName, Serializable appConfig, File pdfgTmpDir) throws ConversionException, InvalidParameterException, FileFormatNotSupportedException {
        File jobOptionFile;
        String jobOptionData = null;
        jobOptionFile = null;
        try {
            JobOptions.JobOption xmlJobOption = config.getJobOptions();
            jobOptionData = xmlJobOption.getOptionData();
            FiletypeSettings.Settings fileTypeSettings = config.getFiletypeSettings();
            boolean isPDFACompliant = false;
            if (appConfig instanceof FiletypeSettings.Settings.AutoCAD) {
                if (fileTypeSettings.getAutoCAD().getPDFMaker().isCreatePDFACompliant()) {
                    isPDFACompliant = true;
                }
            } else if (appConfig instanceof FiletypeSettings.Settings.MSExcel) {
                if (fileTypeSettings.getMSExcel().getPDFMaker().isCreatePDFACompliant()) {
                    isPDFACompliant = true;
                }
            } else if (appConfig instanceof FiletypeSettings.Settings.MSPowerpoint) {
                if (fileTypeSettings.getMSPowerpoint().getPDFMaker().isCreatePDFACompliant()) {
                    isPDFACompliant = true;
                }
            } else if (appConfig instanceof FiletypeSettings.Settings.MSProject) {
                if (fileTypeSettings.getMSProject().getPDFMaker().isCreatePDFACompliant()) {
                    isPDFACompliant = true;
                }
            } else if (appConfig instanceof FiletypeSettings.Settings.MSVisio) {
                if (fileTypeSettings.getMSVisio().getPDFMaker().isCreatePDFACompliant()) {
                    isPDFACompliant = true;
                }
            } else if (appConfig instanceof FiletypeSettings.Settings.MSWord && fileTypeSettings.getMSWord().getPDFMaker().isCreatePDFACompliant()) {
                isPDFACompliant = true;
            }
            if (isPDFACompliant) {
                jobOptionName = "PDFA1b 2005 RGB";
                try {
                    jobOptionData = coreSvcImpl.getConfigService().getJobOptionStringByName(jobOptionName);
                }
                catch (Exception e) {
                    this.pdfgLogger.severe(e.getMessage(), "");
                    this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                    throw new ConversionException(1000, (Throwable)e);
                }
            }
            this.validateSettings(jobOptionData, config.getSecuritySettings(), appConfig);
            if (useReservedName) {
                jobOptionFile = File.createTempFile("#PDFGJobOption ", suffix, pdfgTmpDir);
            } else {
                String prefix = AESProperties.getProperty((String)"server.acrobat.job.options.prefix", (String)"pdfg");
                if (prefix.length() > 0 && !prefix.endsWith(" ")) {
                    prefix = prefix + " ";
                }
                jobOptionFile = File.createTempFile(prefix + jobOptionName + " ", suffix, pdfgTmpDir);
            }
            BufferedOutputStream out = null;
            try {
                out = new BufferedOutputStream(new FileOutputStream(jobOptionFile));
                FileUtilities.copyStreams((InputStream)new ByteArrayInputStream(jobOptionData.getBytes("UTF-8")), (OutputStream)out);
                Object var15_16 = null;
            }
            catch (Throwable var14_18) {
                Object var15_17 = null;
                FileUtilities.closeStream((OutputStream)out);
                throw var14_18;
            }
            FileUtilities.closeStream((OutputStream)out);
            {
            }
        }
        catch (IOException e) {
            throw new InvalidParameterException(1012, (Throwable)e);
        }
        return jobOptionFile;
    }

    protected boolean validateSettings(String jobOptionsString, SecuritySettings.Settings security, Serializable appConfig) throws ConversionException, InvalidParameterException {
        Map jobOptionsMap = null;
        try {
            jobOptionsMap = PDFGGlobalCache.getJobOptionsMap((String)jobOptionsString);
        }
        catch (JobOptionsParseException je) {
            throw new InvalidParameterException(1012, (Throwable)je);
        }
        SettingValidator validator = new SettingValidator(jobOptionsMap, security);
        if (!validator.areJobOptionsCompatible()) {
            throw new InvalidParameterException(80010);
        }
        if (validator.areEncryptionPasswordsIdentical()) {
            throw new InvalidParameterException(80009);
        }
        if (validator.isSecurityVersionExceedsPdfVersion()) {
            throw new InvalidParameterException(80008);
        }
        if (!validator.areSecuritySettingsCompatible()) {
            throw new InvalidParameterException(80007);
        }
        if (!validator.isAppConfigCompliant(appConfig)) {
            throw new InvalidParameterException(80006);
        }
        return true;
    }

    protected File getAcrobatCustomJobOptionsDir() {
        File result = new File(AESProperties.getProperty((String)"server.acrobat.user.job.options.dir"));
        if (!result.exists()) {
            result.mkdirs();
        }
        return result;
    }

    protected int setDistillerParams(GeneratePDFServiceImpl coreSvcImpl, String serviceName, int errCode) throws Exception {
        int errorCode = errCode;
        if (!"PDFExportConverterService".equals(serviceName)) {
            errorCode = 1012;
            String jobOptionData = this.jobOptionConfig.getOptionData();
            Map jobOptionsMap = PDFGGlobalCache.getJobOptionsMap((String)jobOptionData);
            this.distillerParameters = (Map)jobOptionsMap.get("setdistillerparams");
        }
        return errorCode;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    protected byte[] objectToByteArray(Object appConfig) throws IOException {
        ByteArrayOutputStream appConfigStream;
        byte[] arrby;
        block5 : {
            if (appConfig == null || !(appConfig instanceof Serializable)) {
                return new byte[0];
            }
            appConfigStream = new ByteArrayOutputStream();
            ObjectOutputStream objectStream = null;
            try {
                byte[] appConfigBytes;
                objectStream = new ObjectOutputStream(appConfigStream);
                objectStream.writeObject(appConfig);
                objectStream.flush();
                arrby = appConfigBytes = appConfigStream.toByteArray();
                Object var7_6 = null;
                if (objectStream == null) break block5;
            }
            catch (Throwable var6_8) {
                Object var7_7 = null;
                if (objectStream != null) {
                    objectStream.close();
                    throw var6_8;
                } else {
                    appConfigStream.close();
                }
                throw var6_8;
            }
            objectStream.close();
            return arrby;
        }
        appConfigStream.close();
        return arrby;
    }

    protected abstract boolean checkLinearizationForPostProcessing();

    public ResultStruct invokeInSMT(TransactionCallback transactionCallback, GeneratePDFServiceImpl coreSvcImpl) {
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        TransactionTemplate _txTemplate = coreSvcImpl.getTransactionTemplate();
        _txTemplate.setPropagationBehavior(0);
        _txTemplate.setTimeout(this.timeoutSeconds + 200);
        this.pdfgLogger.debug("before calling _txTemplate.execute for job=" + jobIdentityId);
        return (ResultStruct)_txTemplate.execute(transactionCallback);
    }

    protected Document getDocument(File file, boolean ownFile) {
        return new Document(file, ownFile);
    }

}