DistillerServiceImpl.java 51.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 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemds.bedrock.CoreConfigService
 *  com.adobe.aemfd.docmanager.Document
 *  com.adobe.aemfd.docmanager.TempFileManager
 *  com.adobe.native2pdf.xml.InitialView
 *  com.adobe.native2pdf.xml.JobOptions
 *  com.adobe.native2pdf.xml.JobOptions$JobOption
 *  com.adobe.native2pdf.xml.SecuritySettings
 *  com.adobe.native2pdf.xml.SecuritySettings$Settings
 *  com.adobe.pdfg.common.AESProperties
 *  com.adobe.pdfg.common.FileTypeAnalyzer
 *  com.adobe.pdfg.common.FileUtilities
 *  com.adobe.pdfg.common.Guid
 *  com.adobe.pdfg.common.JobConfiguration
 *  com.adobe.pdfg.common.PDFGGlobalCache
 *  com.adobe.pdfg.common.SettingValidator
 *  com.adobe.pdfg.common.Utils
 *  com.adobe.pdfg.common.Utils$ValidateOption
 *  com.adobe.pdfg.config.PDFGConfigUtility
 *  com.adobe.pdfg.exception.ConversionException
 *  com.adobe.pdfg.exception.FileFormatNotSupportedException
 *  com.adobe.pdfg.exception.InvalidParameterException
 *  com.adobe.pdfg.exception.PDFGBaseException
 *  com.adobe.pdfg.logging.ErrorCodeConversion
 *  com.adobe.pdfg.logging.PDFGLogger
 *  com.adobe.pdfg.result.CreatePDFResult
 *  com.adobe.pdfg.service.api.DistillerService
 *  com.adobe.pdfg.service.api.PDFGConfigService
 *  com.adobe.ps2pdf.PsToPdfFailureException
 *  com.adobe.ps2pdf.PsToPdfFilePaths
 *  com.adobe.ps2pdf.PsToPdfFontPaths
 *  com.adobe.service.ConnectionFactory
 *  com.day.cq.dam.handler.gibson.fontmanager.FontManagerService
 *  javax.transaction.TransactionManager
 *  org.apache.commons.io.FileUtils
 *  org.apache.commons.io.IOUtils
 *  org.apache.felix.scr.annotations.Activate
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.commons.osgi.OsgiUtil
 */
package com.adobe.pdfg.impl;

import com.adobe.aemds.bedrock.CoreConfigService;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.aemfd.docmanager.TempFileManager;
import com.adobe.native2pdf.xml.InitialView;
import com.adobe.native2pdf.xml.JobOptions;
import com.adobe.native2pdf.xml.SecuritySettings;
import com.adobe.pdfg.callbacks.PsToPDFTransactionCallback;
import com.adobe.pdfg.common.AESProperties;
import com.adobe.pdfg.common.FileTypeAnalyzer;
import com.adobe.pdfg.common.FileUtilities;
import com.adobe.pdfg.common.Guid;
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.config.PDFGConfigUtility;
import com.adobe.pdfg.exception.ConversionException;
import com.adobe.pdfg.exception.FileFormatNotSupportedException;
import com.adobe.pdfg.exception.InvalidParameterException;
import com.adobe.pdfg.exception.PDFGBaseException;
import com.adobe.pdfg.impl.utils.AdjustableSemaphore;
import com.adobe.pdfg.impl.utils.PsToPdfUtils;
import com.adobe.pdfg.logging.ErrorCodeConversion;
import com.adobe.pdfg.logging.PDFGLogger;
import com.adobe.pdfg.postprocess.PdfPostProcessorImpl;
import com.adobe.pdfg.postprocess.PostProcessFileInfo;
import com.adobe.pdfg.result.CreatePDFResult;
import com.adobe.pdfg.service.api.DistillerService;
import com.adobe.pdfg.service.api.PDFGConfigService;
import com.adobe.pdfg.transaction.TransactionCallback;
import com.adobe.pdfg.transaction.TransactionTemplate;
import com.adobe.ps2pdf.PsToPdfFailureException;
import com.adobe.ps2pdf.PsToPdfFilePaths;
import com.adobe.ps2pdf.PsToPdfFontPaths;
import com.adobe.service.ConnectionFactory;
import com.day.cq.dam.handler.gibson.fontmanager.FontManagerService;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import javax.naming.NameNotFoundException;
import javax.transaction.TransactionManager;
import javax.xml.bind.JAXBException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.OsgiUtil;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
@Component(metatype=1, immediate=0, label="%pdfg.distiller.name", description="%pdfg.distiller.description")
@Service(value={DistillerService.class})
public class DistillerServiceImpl
implements DistillerService {
    protected PDFGLogger pdfgLogger = PDFGLogger.getPDFGLogger(DistillerServiceImpl.class);
    private static final int DEFAULT_CONVERSION_TIMEOUT_MIN = 5;
    private static Map m_productInfo = null;
    private static long lastTriggerTime = 0;
    private static long WAIT_TIME_FOR_EVAL = 120000;
    private static boolean applyWaterMarkVal = true;
    private String m_securitySettings = null;
    private String m_adobePDFSettings = null;
    static final String IN_FILE_NAME = "in-ps";
    private static int timeoutSeconds = -1;
    @Reference(target="(bmc.service.name=PsToPdfSvc)")
    private ConnectionFactory psToPdfFactory;
    @Reference
    private PDFGConfigService configService;
    @Reference
    private FontManagerService fontManager;
    @Reference
    private CoreConfigService coreConfigService;
    @Reference
    private TempFileManager tfm;
    @Reference
    private TransactionManager transactionManager;
    @Property
    private static final String ADOBE_PDF_SETTINGS = "pdfg.distiller.adobePDFSettings";
    @Property
    private static final String SECURITY_SETTINGS = "pdfg.distiller.securitySettings";
    private static AdjustableSemaphore psToPdfConversionLock = null;
    private static int m_PsToPdfPoolSize = 4;
    private static final int DEFAULT_PS_TO_PDF_POOL_SIZE = 4;
    @Property(intValue={4})
    private static final String PS_TO_PDF_POOL_SIZE = "pdfg.distiller.psToPDFPoolSize";
    private long waitTime = 0;

    @Activate
    private void activate(Map<String, Object> config) {
        timeoutSeconds = AESProperties.getMaximumTimeout();
        timeoutSeconds = Math.max(5, timeoutSeconds);
        String adobePDFSettings = OsgiUtil.toString((Object)config.get("pdfg.distiller.adobePDFSettings"), (String)null);
        String securitySettings = OsgiUtil.toString((Object)config.get("pdfg.distiller.securitySettings"), (String)null);
        int psToPdfPoolSize = OsgiUtil.toInteger((Object)config.get("pdfg.distiller.psToPDFPoolSize"), (int)4);
        this.setAdobePDFSettings(adobePDFSettings);
        this.setSecuritySettings(securitySettings);
        if (psToPdfConversionLock == null) {
            this.setPsToPdfPoolSize(psToPdfPoolSize);
            this.initializePsToPdfConversionLock();
        } else {
            if (psToPdfPoolSize > this.getPsToPdfPoolSize()) {
                psToPdfConversionLock.release(psToPdfPoolSize - this.getPsToPdfPoolSize());
            } else if (psToPdfPoolSize < this.getPsToPdfPoolSize()) {
                psToPdfConversionLock.reducePermits(this.getPsToPdfPoolSize() - psToPdfPoolSize);
            }
            this.setPsToPdfPoolSize(psToPdfPoolSize);
        }
    }

    private void initializePsToPdfConversionLock() {
        psToPdfConversionLock = new AdjustableSemaphore(this.getPsToPdfPoolSize(), true);
    }

    public Map createPDF(Document inputDoc, String inputFilenameOrExtension, String pdfSettings, String securitySettings, Document settingsDoc, Document xmpDoc) throws InvalidParameterException, ConversionException, FileFormatNotSupportedException {
        return this.createPDFCommon(inputDoc, inputFilenameOrExtension, pdfSettings, securitySettings, settingsDoc, xmpDoc, Utils.ValidateOption.VALIDATE_FILENAME);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public CreatePDFResult createPDF2(Document inputDoc, String inputFilenameOrExtension, String pdfSettings, String securitySettings, Document settingsDoc, Document xmpDoc) throws InvalidParameterException, ConversionException, FileFormatNotSupportedException {
        Map res = this.createPDFCommon(inputDoc, inputFilenameOrExtension, pdfSettings, securitySettings, settingsDoc, xmpDoc, Utils.ValidateOption.VALIDATE_FILE_EXTENSION);
        CreatePDFResult ret = new CreatePDFResult();
        ret.setCreatedDocument((Document)res.get("ConvertedDoc"));
        Document logDoc = (Document)res.get("LogDoc");
        ret.setLogDocument(logDoc);
        InputStream is = null;
        try {
            block4 : {
                try {
                    if (logDoc == null) break block4;
                    is = logDoc.getInputStream();
                    StringWriter writer = new StringWriter();
                    IOUtils.copy((InputStream)is, (Writer)writer, (String)"UTF-8");
                    String logDocString = writer.toString();
                    this.pdfgLogger.debug("Conversion Log: " + logDocString);
                }
                catch (IOException ioe) {
                    Object var14_15 = null;
                    IOUtils.closeQuietly((InputStream)is);
                    return ret;
                }
            }
            Object var14_14 = null;
            IOUtils.closeQuietly((InputStream)is);
            return ret;
        }
        catch (Throwable var13_17) {
            Object var14_16 = null;
            IOUtils.closeQuietly((InputStream)is);
            throw var13_17;
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    private Map createPDFCommon(Document inputDoc, String inputFilenameOrExtension, String pdfSettings, String securitySettings, Document settingsDoc, Document xmpDoc, Utils.ValidateOption validateOption) throws InvalidParameterException, ConversionException, FileFormatNotSupportedException {
        File prologueFile = null;
        File epilogueFile = null;
        long startTime = System.currentTimeMillis();
        boolean success = true;
        PsToPdfFilePaths psToPdfFilePaths = new PsToPdfFilePaths();
        File psFile = null;
        File xmpFile = null;
        File pdfgTmpDir = null;
        File modifiedPsFile = null;
        String fileAttr = null;
        String jobOptionNamePrefix = new Guid().toString();
        String jobIdentityId = null;
        boolean debugMsgsLogged = false;
        StringBuilder debugMsgs = null;
        try {
            Map map;
            try {
                boolean bIsPrologueOn;
                try {
                    fileAttr = Utils.validate((Document)inputDoc, (String)inputFilenameOrExtension, (Utils.ValidateOption)validateOption);
                }
                catch (InvalidParameterException e) {
                    this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                    fileAttr = "File.ps";
                }
                jobIdentityId = fileAttr + new Guid().toString();
                Utils.threadLocalValue.set(jobIdentityId);
                debugMsgs = new StringBuilder();
                this.pdfgLogger.info("\nJob ID for the submitted createPDF job =" + jobIdentityId, "");
                debugMsgs.append("\nentered DistillerImpl.createPDFCommon() for job=" + jobIdentityId);
                if (!Utils.isCallerAuthorizedUser()) {
                    throw new ConversionException(80015, "DistillerService.convertPDF()");
                }
                this.pdfgLogger.info("001-024", new Object[]{fileAttr, new Date(startTime), jobIdentityId});
                this.pdfgLogger.info("001-016", new Object[]{fileAttr, "Convert to PDF"});
                fileAttr = this.getValidName(fileAttr);
                String jobConfigurationString = this.getJobConfigurationString(settingsDoc, pdfSettings, securitySettings);
                debugMsgs.append("\nJobConfigurationString--" + jobConfigurationString + "--for job=" + jobIdentityId);
                JobConfiguration config = null;
                try {
                    config = PDFGGlobalCache.getJobConfiguration((String)jobConfigurationString);
                }
                catch (JAXBException e) {
                    throw new InvalidParameterException(1001, (Throwable)e);
                }
                String extension = this.getValidExtension(fileAttr);
                if (extension == null) {
                    File inputFile = null;
                    try {
                        inputFile = PDFGConfigUtility.getFile((Document)inputDoc, (File)this.tfm.getTempFile());
                        if (new FileTypeAnalyzer().identify(inputFile) != 4) {
                            throw new FileFormatNotSupportedException(1015, "Only Postscript and Enhanced PostScript files are supported");
                        }
                        extension = "ps";
                        Object var28_35 = null;
                        if (inputFile != null && inputFile.exists()) {
                            inputFile.delete();
                        }
                    }
                    catch (Throwable var27_37) {
                        Object var28_36 = null;
                        if (inputFile != null && inputFile.exists()) {
                            inputFile.delete();
                        }
                        throw var27_37;
                    }
                }
                int operationTimeout = config.getConversionTimeoutSetting(5, timeoutSeconds, timeoutSeconds);
                String guidString = new Guid().toString();
                pdfgTmpDir = FileUtilities.createGuidDir((String)guidString);
                psFile = new File(pdfgTmpDir, "in-ps" + extension);
                inputDoc.copyToFile(psFile);
                if (psFile.length() == 0) {
                    throw new ConversionException(11019);
                }
                this.pdfgLogger.info("001-008", "PS/EPS/PRN to PDF Conversion");
                String baseSourceFileName = psFile.getName();
                PostProcessFileInfo postProcessFilePaths = new PostProcessFileInfo();
                String newPsFilePath = null;
                String psFilePath = psFile.getAbsolutePath();
                if (extension.endsWith(".ps") || extension.endsWith(".prn")) {
                    newPsFilePath = psFilePath;
                    this.pdfgLogger.debug("003-001", "PS");
                } else {
                    this.pdfgLogger.debug("003-001", "EPS");
                    modifiedPsFile = this.createTempFile();
                    newPsFilePath = PsToPdfUtils.preProcessEPS(psFilePath, modifiedPsFile);
                }
                psToPdfFilePaths.psFilePath = newPsFilePath;
                debugMsgs.append("\nafter getting newPsFilePath for job=" + jobIdentityId);
                if (xmpDoc != null) {
                    xmpFile = new File(psFile.getParent(), fileAttr + ".xmp");
                    xmpDoc.copyToFile(xmpFile);
                    postProcessFilePaths.xmpFilePath = xmpFile.getAbsolutePath();
                    this.pdfgLogger.debug("003-002", postProcessFilePaths.xmpFilePath);
                }
                SecuritySettings.Settings security = config.getSecuritySettings();
                boolean shouldApplySecurity = Utils.shouldApplySecurity((SecuritySettings.Settings)security);
                this.pdfgLogger.debug("003-003", "" + shouldApplySecurity + "");
                if (shouldApplySecurity) {
                    this.updateSecuritySettings(security);
                    this.pdfgLogger.debug("003-004");
                }
                String jobOptionsName = config.getJobOptionName();
                this.pdfgLogger.debug("003-005", jobOptionsName);
                JobOptions.JobOption jobOptions = config.getJobOptions();
                if (jobOptions == null) {
                    throw new InvalidParameterException(12512);
                }
                InitialView initialView = jobOptions.getInitialView();
                String jobOptionsString = jobOptions.getOptionData();
                Map jobOptionsMap = PDFGGlobalCache.getJobOptionsMap((String)jobOptionsString);
                jobOptionsString = Utils.checkJobOptionsPageNumbers((String)jobOptionsString);
                Map distillerParameters = (Map)jobOptionsMap.get("setdistillerparams");
                debugMsgs.append("\nafter getting distillerParameters for job=" + jobIdentityId);
                if (shouldApplySecurity) {
                    debugMsgs.append("\nshouldApplySecurity is true for job=" + jobIdentityId);
                    SettingValidator validator = new SettingValidator(jobOptionsMap, security);
                    if (!validator.areJobOptionsCompatible()) {
                        throw new InvalidParameterException(12017);
                    }
                    if (validator.areEncryptionPasswordsIdentical()) {
                        throw new InvalidParameterException(12018);
                    }
                    if (!validator.areSecuritySettingsCompatible()) {
                        throw new InvalidParameterException(12019);
                    }
                }
                String attachmentFileName = null;
                Boolean bEmbedJobOptions = (Boolean)distillerParameters.get("EmbedJobOptions");
                if (bEmbedJobOptions != null && bEmbedJobOptions.booleanValue()) {
                    attachmentFileName = jobOptionsName + ".joboptions";
                    File attachmentFile = FileUtilities.saveStringToUtf8GuidFile((String)jobOptionsString, (File)pdfgTmpDir, (String)(jobOptionNamePrefix + ".joboptions"));
                    postProcessFilePaths.attachmentFilePath = attachmentFile.getAbsolutePath();
                    this.pdfgLogger.debug("003-006", postProcessFilePaths.attachmentFilePath);
                } else {
                    postProcessFilePaths.attachmentFilePath = "";
                    this.pdfgLogger.debug("003-007");
                }
                Boolean bUsePrologue = (Boolean)distillerParameters.get("UsePrologue");
                boolean bl = bIsPrologueOn = bUsePrologue != null && bUsePrologue != false;
                if (bIsPrologueOn) {
                    Map prologueMap = this.configService.getPrologue();
                    prologueFile = File.createTempFile("PDFG", ".ps");
                    epilogueFile = File.createTempFile("PDFG", ".ps");
                    FileUtilities.binaryDataToFile((byte[])((byte[])prologueMap.get("prologue")), (File)prologueFile);
                    FileUtilities.binaryDataToFile((byte[])((byte[])prologueMap.get("epilogue")), (File)epilogueFile);
                    psToPdfFilePaths.prologueFilePath = prologueFile.getAbsolutePath();
                    psToPdfFilePaths.epilogueFilePath = epilogueFile.getAbsolutePath();
                } else {
                    psToPdfFilePaths.prologueFilePath = "";
                    psToPdfFilePaths.epilogueFilePath = "";
                }
                String jobOptionsFileName = jobOptionNamePrefix + ".joboptions";
                this.pdfgLogger.debug("JobOptions File " + jobOptionsFileName + " created for job option " + jobOptionsName, "");
                this.pdfgLogger.debug("003-008", jobOptionsFileName);
                if (bEmbedJobOptions.booleanValue()) {
                    psToPdfFilePaths.settingsFilePath = postProcessFilePaths.attachmentFilePath;
                } else {
                    File jobOptionsFile = FileUtilities.saveStringToUtf8GuidFile((String)jobOptionsString, (File)pdfgTmpDir, (String)jobOptionsFileName);
                    psToPdfFilePaths.settingsFilePath = jobOptionsFile.getAbsolutePath();
                    this.pdfgLogger.debug("003-010", new Object[]{"joboptions", psToPdfFilePaths.settingsFilePath});
                }
                Boolean isLinearize = (Boolean)distillerParameters.get("Optimize");
                if (isLinearize != null && isLinearize.booleanValue()) {
                    this.pdfgLogger.debug("003-009", "on");
                } else {
                    this.pdfgLogger.debug("003-009", "off");
                }
                boolean doPDFAProcessing = Utils.isPDFAComplianceOn((Map)distillerParameters);
                String tempBaseSourceFileName = "~" + baseSourceFileName;
                String baseDir = psFile.getParent();
                postProcessFilePaths.pdfFilePath = this.getDestinationDir(baseSourceFileName, baseDir, "pdf");
                postProcessFilePaths.tempPdfFilePath = psToPdfFilePaths.pdfFilePath = this.getDestinationDir(tempBaseSourceFileName, baseDir, "pdf");
                psToPdfFilePaths.jdfFilePath = this.getDestinationDir(baseSourceFileName, baseDir, "jdf");
                this.pdfgLogger.debug("003-010", new Object[]{"jdf", psToPdfFilePaths.jdfFilePath});
                psToPdfFilePaths.logFilePath = this.getDestinationDir(baseSourceFileName, baseDir, "log");
                this.pdfgLogger.debug("003-010", new Object[]{"log", psToPdfFilePaths.logFilePath});
                postProcessFilePaths.logFilePath = psToPdfFilePaths.logFilePath;
                boolean applyWatermark = this.applyWaterMark();
                debugMsgs.append("\nbefore calculating postProcessingRequired for job=" + jobIdentityId);
                boolean postProcessingRequired = this.isPostProcessingRequired(postProcessFilePaths, shouldApplySecurity, initialView, isLinearize, doPDFAProcessing, null, applyWatermark);
                debugMsgs.append("\npostProcessingRequired=" + postProcessingRequired + "  for job=" + jobIdentityId);
                if (!postProcessingRequired) {
                    psToPdfFilePaths.pdfFilePath = postProcessFilePaths.pdfFilePath;
                    postProcessFilePaths.tempPdfFilePath = "";
                }
                debugMsgs.append("\nbefore this.invokeBMC() for job=" + jobIdentityId);
                this.pdfgLogger.debug(debugMsgs.toString());
                debugMsgsLogged = true;
                this.invokeBMC(psToPdfFilePaths, bIsPrologueOn, operationTimeout);
                debugMsgs = new StringBuilder();
                debugMsgsLogged = false;
                debugMsgs.append("\nafter this.invokeBMC() for job=" + jobIdentityId);
                if (postProcessingRequired) {
                    this.pdfgLogger.debug("001-008", "Beginning PDF Post-Processing");
                    debugMsgs.append("\nbefore this.pdfPostProcess() for job=" + jobIdentityId);
                    this.pdfgLogger.debug(debugMsgs.toString());
                    debugMsgsLogged = true;
                    this.pdfPostProcess(postProcessFilePaths, attachmentFileName, initialView, shouldApplySecurity ? security : null, isLinearize, doPDFAProcessing, null, applyWatermark);
                    debugMsgs = new StringBuilder();
                    debugMsgsLogged = false;
                    this.pdfgLogger.debug("001-009", "Finishing PDF Post-Processing");
                }
                debugMsgs.append("\nbefore getResponse() for job=" + jobIdentityId);
                this.pdfgLogger.debug(debugMsgs.toString());
                debugMsgsLogged = true;
                Map response = this.getResponse(postProcessFilePaths.pdfFilePath, psToPdfFilePaths.jdfFilePath, psToPdfFilePaths.logFilePath, postProcessFilePaths.postProcessedDoc, fileAttr, pdfgTmpDir);
                debugMsgs = new StringBuilder();
                debugMsgsLogged = false;
                debugMsgs.append("\nafter getResponse() for job=" + jobIdentityId);
                this.pdfgLogger.info("001-009", "PS/EPS/PRN to PDF Conversion");
                map = response;
                Object var54_63 = null;
            }
            catch (ConversionException e) {
                this.pdfgLogger.severe(e.getMessage(), "");
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                this.setConversionLog(e, psToPdfFilePaths.logFilePath);
                success = false;
                throw e;
            }
            catch (InvalidParameterException e) {
                this.pdfgLogger.severe(e.getMessage(), "");
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                success = false;
                throw e;
            }
            catch (FileFormatNotSupportedException e) {
                this.pdfgLogger.severe(e.getMessage(), "");
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                success = false;
                throw e;
            }
            catch (PDFGBaseException e) {
                this.pdfgLogger.severe(e.getMessage(), "");
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                throw new ConversionException(e.getErrorCode());
            }
            catch (Exception e) {
                this.pdfgLogger.severe(e.getMessage(), "");
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                ConversionException conversionException = new ConversionException(1000, (Throwable)e);
                this.setConversionLog(conversionException, psToPdfFilePaths.logFilePath);
                success = false;
                throw conversionException;
            }
            long endTime = System.currentTimeMillis();
            if (success) {
                this.pdfgLogger.info("001-027", fileAttr);
            } else {
                this.pdfgLogger.info("001-028", fileAttr);
            }
            this.pdfgLogger.info("001-025", new Object[]{fileAttr, new Date(endTime), jobIdentityId});
            this.pdfgLogger.info("001-030", new Object[]{fileAttr, new Long(this.waitTime), jobIdentityId});
            this.pdfgLogger.info("001-026", new Object[]{fileAttr, endTime - startTime - this.waitTime, jobIdentityId});
            if (pdfgTmpDir != null) {
                this.deleteSubFiles(pdfgTmpDir);
            }
            if (prologueFile != null) {
                prologueFile.delete();
            }
            if (epilogueFile != null) {
                epilogueFile.delete();
            }
            if (psFile != null && psFile.exists()) {
                psFile.delete();
            }
            if (xmpFile != null && xmpFile.exists()) {
                xmpFile.delete();
            }
            FileUtils.deleteQuietly((File)modifiedPsFile);
            if (!debugMsgsLogged && debugMsgs != null) {
                this.pdfgLogger.debug(debugMsgs.toString());
            }
            return map;
        }
        catch (Throwable var53_67) {
            Object var54_64 = null;
            long endTime = System.currentTimeMillis();
            if (success) {
                this.pdfgLogger.info("001-027", fileAttr);
            } else {
                this.pdfgLogger.info("001-028", fileAttr);
            }
            this.pdfgLogger.info("001-025", new Object[]{fileAttr, new Date(endTime), jobIdentityId});
            this.pdfgLogger.info("001-030", new Object[]{fileAttr, new Long(this.waitTime), jobIdentityId});
            this.pdfgLogger.info("001-026", new Object[]{fileAttr, endTime - startTime - this.waitTime, jobIdentityId});
            if (pdfgTmpDir != null) {
                this.deleteSubFiles(pdfgTmpDir);
            }
            if (prologueFile != null) {
                prologueFile.delete();
            }
            if (epilogueFile != null) {
                epilogueFile.delete();
            }
            if (psFile != null && psFile.exists()) {
                psFile.delete();
            }
            if (xmpFile != null && xmpFile.exists()) {
                xmpFile.delete();
            }
            FileUtils.deleteQuietly((File)modifiedPsFile);
            if (!debugMsgsLogged && debugMsgs != null) {
                this.pdfgLogger.debug(debugMsgs.toString());
            }
            throw var53_67;
        }
    }

    private File createTempFile() throws IOException {
        return File.createTempFile("pdfg", null, new File(this.coreConfigService.getServerTempDir()));
    }

    private void deleteSubFiles(File parentFolder) {
        File[] files = parentFolder.listFiles();
        if (files != null && files.length > 0) {
            for (int i = 0; i < files.length; ++i) {
                if (files[i].isDirectory()) {
                    this.deleteSubFiles(files[i]);
                    continue;
                }
                files[i].delete();
            }
        }
        parentFolder.delete();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    private void setConversionLog(ConversionException conversionException, String logFilePath) {
        if (logFilePath == null) {
            return;
        }
        logFile = new File(logFilePath);
        if (logFile.exists() == false) return;
        if (logFile.isFile() == false) return;
        if (logFile.length() <= 0) return;
        if (logFile.canRead() == false) return;
        fileReader = null;
        stringWriter = null;
        try {
            try {
                fileReader = new BufferedReader(new FileReader(logFile));
                stringWriter = new StringWriter();
                buffer = new char[256];
                nCharacters = fileReader.read(buffer);
                while (nCharacters != -1) {
                    stringWriter.write(buffer, 0, nCharacters);
                    nCharacters = fileReader.read(buffer);
                }
                conversionException.setConversionLog(stringWriter.toString());
            }
            catch (Exception e) {
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                var9_10 = null;
                if (fileReader == null) return;
                try {}
                catch (Exception e) {
                    this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                    return;
                }
                fileReader.close();
                return;
            }
            var9_9 = null;
            if (fileReader == null) return;
            fileReader.close();
            return;
            catch (Exception e) {
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                return;
            }
        }
        catch (Throwable throwable) {
            var9_11 = null;
            if (fileReader == null) throw throwable;
            ** try [egrp 2[TRYBLOCK] [4 : 173->181)] { 
lbl46: // 1 sources:
            fileReader.close();
            throw throwable;
lbl48: // 1 sources:
            catch (Exception e) {
                this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
            }
            throw throwable;
        }
    }

    private void pdfPostProcess(PostProcessFileInfo filePaths, String attachmentName, InitialView initialView, SecuritySettings.Settings encryptionSettings, boolean doWebOptimization, boolean doPDFAProcessing, String targetPdfVersion, boolean applyWatermark) throws ConversionException {
        PdfPostProcessorImpl pdfPostProcessor;
        int errorCode;
        if (filePaths.xmpFilePath == null) {
            filePaths.xmpFilePath = "";
        }
        if (filePaths.attachmentFilePath == null) {
            filePaths.attachmentFilePath = "";
        }
        if (filePaths.logFilePath == null) {
            filePaths.logFilePath = "";
        }
        if (attachmentName == null) {
            attachmentName = "";
        }
        if (targetPdfVersion == null) {
            targetPdfVersion = "";
        }
        if ((errorCode = (pdfPostProcessor = new PdfPostProcessorImpl()).doPostProcess(filePaths, attachmentName, initialView, encryptionSettings, doWebOptimization, doPDFAProcessing, false, targetPdfVersion, false, "PDF generator", 1, applyWatermark)) != 0) {
            throw new ConversionException(errorCode);
        }
    }

    private boolean isPostProcessingRequired(PostProcessFileInfo postProcessFilePaths, boolean shouldApplySecurity, InitialView initialView, boolean linearize, boolean doPDFAProcessing, String targetPdfVersion, boolean applyWatermark) {
        return postProcessFilePaths.xmpFilePath != null && !"".equals(postProcessFilePaths.xmpFilePath) || postProcessFilePaths.attachmentFilePath != null && !"".equals(postProcessFilePaths.attachmentFilePath) || targetPdfVersion != null && !"".equals(targetPdfVersion) || initialView != null || shouldApplySecurity || linearize || doPDFAProcessing || applyWatermark;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private Map getResponse(String pdfFilePath, String jdfFilePath, String logFilePath, Document postProcessedDoc, String fileName, File tempFile) {
        File logFile;
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        StringBuilder debugMsgs = new StringBuilder();
        try {
            debugMsgs.append("\nInside DistillerImpl.getResponse() for job=" + jobIdentityId);
            String firstName = fileName.substring(0, fileName.lastIndexOf(".") + 1);
            String outFileName = firstName + "pdf";
            HashMap<String, Document> response = new HashMap<String, Document>();
            Document convertedDoc = postProcessedDoc;
            if (convertedDoc == null && pdfFilePath != null) {
                debugMsgs.append("\nconvertedDoc == null && pdfFilePath != null is true for job=" + jobIdentityId);
                File pdfFile = new File(pdfFilePath);
                if (pdfFile.exists() && pdfFile.length() > 0) {
                    File resultFile = new File(tempFile.getParent(), new Guid().toString());
                    pdfFile.renameTo(resultFile);
                    pdfFile.delete();
                    convertedDoc = new Document(resultFile, true);
                }
            }
            Document logDoc = null;
            if (logFilePath != null && (logFile = new File(logFilePath)).exists() && logFile.length() > 0) {
                debugMsgs.append("\nlogFile.exists() && (logFile.length() > 0) is true for job=" + jobIdentityId);
                String logFileName = firstName + "log";
                File resultFile = new File(tempFile.getParent(), new Guid().toString());
                logFile.renameTo(resultFile);
                logFile.delete();
                logDoc = new Document(resultFile, true);
                logDoc.setAttribute("file", (Object)logFileName);
                logDoc.setContentType("text/plain");
            }
            if (convertedDoc != null) {
                debugMsgs.append("\nconvertedDoc != null is true for job=" + jobIdentityId);
                convertedDoc.setAttribute("file", (Object)outFileName);
                convertedDoc.setContentType("application/pdf");
            }
            response.put("ConvertedDoc", convertedDoc);
            response.put("LogDoc", logDoc);
            debugMsgs.append("\nbefore returning response for job=" + jobIdentityId);
            logFile = response;
            Object var18_17 = null;
        }
        catch (Throwable var17_19) {
            Object var18_18 = null;
            this.pdfgLogger.debug(debugMsgs.toString());
            throw var17_19;
        }
        this.pdfgLogger.debug(debugMsgs.toString());
        return logFile;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Converted monitor instructions to comments
     * Lifted jumps to return sites
     */
    private void invokeBMC(PsToPdfFilePaths psToPdfFilePaths, boolean bIsPrologueOn, int operationTimeout) throws ConversionException {
        boolean debugMsgsLogged = false;
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        StringBuilder debugMsgs = new StringBuilder();
        try {
            debugMsgs.append("\nInside DistillerImpl.invokeBMC for job=" + jobIdentityId);
            if (psToPdfConversionLock == null) {
                debugMsgs.append("\nbefore synchronized(DistillerImpl.class) for job=" + jobIdentityId);
                Class<DistillerServiceImpl> class_ = DistillerServiceImpl.class;
                // MONITORENTER : com.adobe.pdfg.impl.DistillerServiceImpl.class
                if (psToPdfConversionLock == null) {
                    debugMsgs.append("\nbefore initializePSConversionLock for job=" + jobIdentityId);
                    this.initializePsToPdfConversionLock();
                    debugMsgs.append("\nafter initializePSConversionLock for job=" + jobIdentityId);
                }
                // MONITOREXIT : class_
            }
            try {
                try {
                    debugMsgs.append("\nbefore psConversionLock.acquire() for job=" + jobIdentityId);
                    long waitStartTime = System.currentTimeMillis();
                    psToPdfConversionLock.acquire();
                    long waitEndTime = System.currentTimeMillis();
                    this.waitTime = waitEndTime - waitStartTime;
                    debugMsgs.append("\nbefore invokeInSMT() for job=" + jobIdentityId);
                    this.pdfgLogger.debug(debugMsgs.toString());
                    debugMsgsLogged = true;
                    this.invokeInSMT(psToPdfFilePaths, this.retrievePsToPdfFontPaths(), bIsPrologueOn, operationTimeout);
                    debugMsgs = new StringBuilder();
                    debugMsgsLogged = false;
                    debugMsgs.append("\nafter invokeInSMT() for job=" + jobIdentityId);
                }
                catch (NameNotFoundException e) {
                    this.pdfgLogger.severe("003-011", e.getMessage());
                    throw new ConversionException(12515);
                }
                catch (Exception e) {
                    this.pdfgLogger.severe("003-011", e.getMessage());
                    if (!(e instanceof PsToPdfFailureException)) throw new ConversionException(12514);
                    throw new ConversionException(((PsToPdfFailureException)e).errorCode);
                }
                Object var12_12 = null;
                debugMsgs.append("\nbefore psConversionLock.release() for job=" + jobIdentityId);
                psToPdfConversionLock.release();
                debugMsgs.append("\nafter psConversionLock.release() for job=" + jobIdentityId);
            }
            catch (Throwable var11_14) {
                Object var12_13 = null;
                debugMsgs.append("\nbefore psConversionLock.release() for job=" + jobIdentityId);
                psToPdfConversionLock.release();
                debugMsgs.append("\nafter psConversionLock.release() for job=" + jobIdentityId);
                throw var11_14;
            }
            Object var14_15 = null;
            if (debugMsgsLogged) return;
            this.pdfgLogger.debug(debugMsgs.toString());
            return;
        }
        catch (Throwable var13_17) {
            Object var14_16 = null;
            if (debugMsgsLogged) throw var13_17;
            this.pdfgLogger.debug(debugMsgs.toString());
            throw var13_17;
        }
    }

    String getDestinationDir(String fileName, String baseDir, String tgtExtension) {
        String changedName = FileUtilities.changeExtension((String)fileName, (String)tgtExtension);
        File changedFile = new File(baseDir, changedName);
        return changedFile.getAbsolutePath();
    }

    private String getValidExtension(String fileName) throws Exception {
        String lowerCaseName = fileName.toLowerCase();
        if (lowerCaseName.endsWith(".ps")) {
            if (lowerCaseName.length() < 4) {
                throw new InvalidParameterException(12020);
            }
            return ".ps";
        }
        if (lowerCaseName.endsWith(".prn")) {
            if (lowerCaseName.length() < 5) {
                throw new InvalidParameterException(12020);
            }
            return ".prn";
        }
        if (lowerCaseName.endsWith(".eps")) {
            if (lowerCaseName.length() < 5) {
                throw new InvalidParameterException(12020);
            }
            return ".eps";
        }
        return null;
    }

    private String getValidName(String fileName) {
        int nameStartIndex = fileName.lastIndexOf(File.separator);
        if (nameStartIndex == -1) {
            nameStartIndex = fileName.lastIndexOf(47);
        }
        return fileName.substring(nameStartIndex + 1, fileName.length());
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    public String getJobConfigurationString(Document settingsDoc, String pdfSettings, String securitySettings) throws InvalidParameterException {
        try {
            jobConfigurationString = null;
            if (settingsDoc == null) {
                if (securitySettings == null || "".equals(securitySettings)) {
                    securitySettings = this.m_securitySettings;
                }
                if (pdfSettings == null || "".equals(pdfSettings)) {
                    pdfSettings = this.m_adobePDFSettings;
                }
                fileTypeSettings = ErrorCodeConversion.getErrorString((int)3, (Locale)AESProperties.getLocale());
                this.pdfgLogger.debug("001-013", pdfSettings);
                this.pdfgLogger.debug("001-014", securitySettings);
                this.pdfgLogger.debug("001-015", fileTypeSettings);
                jobConfigurationString = this.configService.getConfigurationXML(securitySettings, pdfSettings, fileTypeSettings);
            } else {
                in = null;
                try {
                    in = new InputStreamReader(settingsDoc.getInputStream());
                    out = new StringWriter();
                    numChars = -1;
                    buffer = new char[4096];
                    while ((numChars = in.read(buffer)) != -1) {
                        out.write(buffer, 0, numChars);
                    }
                    jobConfigurationString = out.toString();
                    var10_11 = null;
                    if (in != null) {
                        try {
                            in.close();
                        }
                        catch (Exception e) {
                            this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                        }
                    }
                }
                catch (Throwable var9_15) {
                    var10_12 = null;
                    if (in == null) throw var9_15;
                    ** try [egrp 2[TRYBLOCK] [2 : 196->204)] { 
lbl38: // 1 sources:
                    in.close();
                    throw var9_15;
lbl40: // 1 sources:
                    catch (Exception e) {
                        this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
                    }
                    throw var9_15;
                }
            }
            this.pdfgLogger.trace("001-012", new Object[]{jobConfigurationString});
            return jobConfigurationString;
        }
        catch (Exception e) {
            this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
            throw new InvalidParameterException(1001);
        }
    }

    void updateSecuritySettings(SecuritySettings.Settings security) throws Exception {
        String documentOpenPassword = this.configService.getClearText(security.getDocumentOpenPasswd());
        security.setDocumentOpenPasswd(documentOpenPassword);
        String documentChangePassword = this.configService.getClearText(security.getDocumentChangePasswd());
        security.setDocumentChangePasswd(documentChangePassword);
    }

    private Map getRequestMap(String arg, String value) {
        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(arg, value);
        return requestMap;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    boolean applyWaterMark() {
        try {
            long currentTime = System.currentTimeMillis();
            if (!applyWaterMarkVal || currentTime - lastTriggerTime <= WAIT_TIME_FOR_EVAL) return applyWaterMarkVal;
            Class<DistillerServiceImpl> class_ = DistillerServiceImpl.class;
            synchronized (DistillerServiceImpl.class) {
                applyWaterMarkVal = false;
                // ** MonitorExit[var3_3] (shouldn't be in output)
                return applyWaterMarkVal;
            }
        }
        catch (Exception ex) {
            this.pdfgLogger.trace("Problem in getting product info: " + ex.getMessage(), null, (Throwable)ex);
            return true;
        }
    }

    String getLicenceString() {
        this.initializeProductInfo();
        String licenseType = null;
        if (m_productInfo != null) {
            licenseType = (String)m_productInfo.get("PDFG_LICENSE_TYPE");
        }
        return licenseType;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void initializeProductInfo() {
        if (m_productInfo != null) return;
        Class<DistillerServiceImpl> class_ = DistillerServiceImpl.class;
        synchronized (DistillerServiceImpl.class) {
            if (m_productInfo != null) return;
            {
                try {
                    m_productInfo = this.configService.getPDFGProductInfo();
                }
                catch (Exception ex) {
                    this.pdfgLogger.trace("Problem in getting product info: " + ex.getMessage(), null, (Throwable)ex);
                }
            }
            // ** MonitorExit[var1_1] (shouldn't be in output)
            return;
        }
    }

    private PsToPdfFontPaths retrievePsToPdfFontPaths() {
        PsToPdfFontPaths fontPaths = new PsToPdfFontPaths();
        fontPaths.customerFontPath = this.getNormalizerFontPath(this.fontManager.getCustomerFontDirectory());
        fontPaths.systemFontPath = this.getNormalizerFontPath(this.fontManager.getSystemFontDirectory());
        fontPaths.adobeFontPath = this.getNormalizerFontPath(this.fontManager.getAdobeServerFontDirectory());
        return fontPaths;
    }

    private String getNormalizerFontPath(String path) {
        String fileSeparator = System.getProperty("file.separator");
        String pathSeparator = ";";
        String modifiedPath = "";
        if (path == null) {
            return modifiedPath;
        }
        StringTokenizer tokens = new StringTokenizer(path, ";");
        while (tokens.hasMoreTokens()) {
            path = tokens.nextToken();
            if (path != null && !"".equals(path)) {
                modifiedPath = !path.endsWith(fileSeparator) ? modifiedPath + path + fileSeparator : modifiedPath + path;
            }
            if (!tokens.hasMoreTokens()) continue;
            modifiedPath = modifiedPath + ";";
        }
        return modifiedPath;
    }

    public TransactionTemplate getTransactionTemplate() {
        return new TransactionTemplate(this.transactionManager);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void invokeInSMT(PsToPdfFilePaths filePaths, PsToPdfFontPaths fontPaths, boolean bUsePrologue, int operationTimeout) throws NameNotFoundException {
        boolean debugMsgsLogged = false;
        String jobIdentityId = (String)Utils.threadLocalValue.get();
        StringBuilder debugMsgs = new StringBuilder();
        try {
            this.pdfgLogger.debug("\nInside DistillerImpl.invokeInSMT for job=" + jobIdentityId);
            debugMsgs.append("\nafter PsToPDFTransactionCallback.initConnectionFactory() for job=" + jobIdentityId);
            TransactionTemplate _txTemplate = this.getTransactionTemplate();
            debugMsgs.append("\nafter getTransactionTemplate() for job=" + jobIdentityId);
            _txTemplate.setPropagationBehavior(0);
            _txTemplate.setTimeout(operationTimeout + 30);
            PsToPDFTransactionCallback transactionCallback = new PsToPDFTransactionCallback(this.psToPdfFactory);
            transactionCallback.setFilePaths(filePaths);
            transactionCallback.setUsePrologue(bUsePrologue);
            transactionCallback.setFontPaths(fontPaths);
            transactionCallback.setTimeout(operationTimeout);
            debugMsgs.append("\nbefore  getTransactionTemplate() for job=" + jobIdentityId);
            _txTemplate.execute(transactionCallback);
            Object var11_10 = null;
        }
        catch (Throwable var10_12) {
            Object var11_11 = null;
            this.pdfgLogger.debug(debugMsgs.toString());
            throw var10_12;
        }
        this.pdfgLogger.debug(debugMsgs.toString());
        {
        }
    }

    public void setAdobePDFSettings(String adobePDFSettings) {
        if (!"".equals(adobePDFSettings)) {
            this.m_adobePDFSettings = adobePDFSettings;
        }
    }

    public void setSecuritySettings(String securitySettings) {
        if (!"".equals(securitySettings)) {
            this.m_securitySettings = securitySettings;
        }
    }

    public void setPsToPdfPoolSize(int poolSize) {
        if (poolSize > 0) {
            m_PsToPdfPoolSize = poolSize;
        }
    }

    public int getPsToPdfPoolSize() {
        return m_PsToPdfPoolSize;
    }

    protected void bindPsToPdfFactory(ConnectionFactory connectionFactory) {
        this.psToPdfFactory = connectionFactory;
    }

    protected void unbindPsToPdfFactory(ConnectionFactory connectionFactory) {
        if (this.psToPdfFactory == connectionFactory) {
            this.psToPdfFactory = null;
        }
    }

    protected void bindConfigService(PDFGConfigService pDFGConfigService) {
        this.configService = pDFGConfigService;
    }

    protected void unbindConfigService(PDFGConfigService pDFGConfigService) {
        if (this.configService == pDFGConfigService) {
            this.configService = null;
        }
    }

    protected void bindFontManager(FontManagerService fontManagerService) {
        this.fontManager = fontManagerService;
    }

    protected void unbindFontManager(FontManagerService fontManagerService) {
        if (this.fontManager == fontManagerService) {
            this.fontManager = null;
        }
    }

    protected void bindCoreConfigService(CoreConfigService coreConfigService) {
        this.coreConfigService = coreConfigService;
    }

    protected void unbindCoreConfigService(CoreConfigService coreConfigService) {
        if (this.coreConfigService == coreConfigService) {
            this.coreConfigService = null;
        }
    }

    protected void bindTfm(TempFileManager tempFileManager) {
        this.tfm = tempFileManager;
    }

    protected void unbindTfm(TempFileManager tempFileManager) {
        if (this.tfm == tempFileManager) {
            this.tfm = null;
        }
    }

    protected void bindTransactionManager(TransactionManager transactionManager) {
        this.transactionManager = transactionManager;
    }

    protected void unbindTransactionManager(TransactionManager transactionManager) {
        if (this.transactionManager == transactionManager) {
            this.transactionManager = null;
        }
    }
}