XMLFormService.java
31.1 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.service.ResourceFactoryManager
* com.adobe.service.Service
* com.adobe.service.ServiceAPI
* com.day.cq.dam.handler.gibson.fontmanager.FontManagerService
* 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
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.document;
import com.adobe.document.XMLFormServiceLogger;
import com.adobe.document.XMLFormServiceMBean;
import com.adobe.document.XMLFormServiceProcessFactoryManager;
import com.adobe.service.ResourceFactoryManager;
import com.adobe.service.ServiceAPI;
import com.day.cq.dam.handler.gibson.fontmanager.FontManagerService;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
import java.util.*;
@Component(metatype=1, immediate=1, label="%xmlform.bmc.name", description="%xmlform.bmc.description", inherit=1)
@Service
public class XMLFormService
extends com.adobe.service.Service
implements XMLFormServiceMBean {
private static final String CONFIG_BUNDLE = "com.adobe.config.XMLFormService-init";
private static final String CONFIG_XCI_BUNDLE = "com.adobe.config.XMLFormService-xci";
private static final String DEFAULT_XCI_PATH = "default.xci";
private static final String OUTPUT_XCI_PATH = "xmlform.xci";
private XMLFormServiceLogger moLogger = null;
private XMLFormServiceProcessFactoryManager moProcessFactoryManager = null;
@Reference
FontManagerService fontManagerService;
private static final boolean DEFAULT_ALLOW_SYSTEM_FONTS = true;
@Property(boolValue={1}, label="Allow system fonts ?", description="Whether look-up of system font is allowed if the specified font is not found")
public static final String PROPERTY_ALLOW_SYSTEM_FONTS = "XMLFormService.ctAllowSystemFonts";
private static final int DEFAULT_TRACE_LEVEL = 0;
@Property(intValue={0}, label="Trace Level for XMLFM traces", description="Trace Level for XMLFM traces")
public static final String PROPERTY_TRACE_LEVEL = "XMLFormService.traceLevel";
private static final int DEFAULT_JAVASCRIPT_TIMEOUT = 0;
@Property(intValue={0}, label="Timeout for server side script execution", description="Timeout for server side script execution")
public static final String PROPERTY_JAVASCRIPT_TIMEOUT = "XMLFormService.javascript.timeout";
private static final boolean DEFAULT_REPORT_TIMING_INFO = false;
@Property(boolValue={0}, label="Report XMLFM timing info", description="Report XMLFM timing info")
public static final String PROPERTY_REPORT_TIMING_INFO = "XMLFormService.report.timing.info";
private static final String DEFAULT_TMP_DIRECTORY = "";
@Property(value={""}, label="Temprorary directory for XTG activities", description="Temprorary directory for XTG activities")
public static final String PROPERTY_TMP_DIRECTORY = "XMLFormService.ctTmpDirectory.name";
private static final int DEFAULT_PDF_MEMORY_SIZE = 1024;
@Property(intValue={1024}, label="Maximum memory size for pdfl", description="Allowed Maximum memory size for pdfl")
public static final String PROPERTY_PDF_MEMORY_SIZE = "XMLFormService.PDFLMemorySize";
private static final boolean DEFAULT_USE_PROXIMITY = false;
@Property(boolValue={0}, label="Use Proximity?", description="Use Proximity?")
public static final String PROPERTY_USE_PROXIMITY = "XMLFormService.useproximity";
private static final int DEFAULT_MAX_REUSE_COUNT = 10000;
@Property(intValue={10000}, label="Maximum number of requests after which process is recycled", description="Maximum number of requests after which process is recycled")
public static final String PROPERTY_MAX_REUSE_COUNT = "XMLFormService.maxreusecount";
private static final int DEFAULT_MAX_POOL_SIZE = 4;
@Property(intValue={4}, label="Maximum number of processes to launch", description="Maximum number of processes to launch")
public static final String PROPERTY_MAX_POOL_SIZE = "XMLFormService.poolmax";
private static final String DEFAULT_ORB_PARAMS = "";
@Property(value={""}, label="ORB Parameters", description="Parameters for corba layer")
public static final String PROPERTY_ORB_PARAMS = "XMLFormService.orb.params";
private static final String XCI_PATH_ROOT = "config/present/";
private static final String XCI_PATH_TEMP_URI = "config/present/common/temp/uri";
private static final String XCI_PATH_TEMPLATE_BASE = "config/present/common/template/base";
private static final String XCI_PATH_COMP_LEVEL = "config/present/pdf/compression/level";
private static final String XCI_PATH_COMP_TYPE = "config/present/pdf/compression/type";
private static final String XCI_PATH_SUBMIT_FORMAT = "config/present/pdf/submitFormat";
private Document moXCIDom = null;
private final String msExecutableName = "bin/XMLForm.exe";
private String msDefaultTitle = "XMLFormModule";
private boolean mbReportTimingInformation = false;
private int mnTraceLevel = 0;
private int mnJavaScriptTimeout = 0;
private int mnGlobalTimeout = 2147483646;
private boolean mbFillDurationInfo = false;
private boolean mbUseProximity = false;
private int mnPDFLMemorySize = 0;
private String msAdditionalFontsCacheFile = "";
private String msCommonFontsCacheFile = "";
private String msSystemCacheFile = "";
private String msTmpDirectory = "";
private boolean mbAllowSystemFonts = true;
private String msCommonDir = "";
private String msUnicodeDir = "";
private String msAdditionalDir = "";
private String msFontDB = "";
private final String REPORT_TIMING_INFORMATION = "ReportTimingInformation";
private final String POOL_MAX = "PoolMax";
private final String MAXIMUM_REUSE_COUNT = "MaximumReUseCount";
private final String DEBUG = "Debug";
private String msInputXCI = null;
private String msOutputXCI = null;
private boolean mbUpdatePending = false;
private boolean mbIsWebAS = false;
private boolean mbGotFonts = false;
private boolean mbAutoPoolMax;
private boolean mbCachingOff = false;
private boolean mbReportMissingXCI = false;
private boolean mbUseAEMNatives = false;
private boolean exceptionOnStart = false;
public XMLFormService() {
Logger logger = LoggerFactory.getLogger(XMLFormService.class);
this.moLogger = new XMLFormServiceLogger(logger);
}
public void onStartService(Map config) {
this.moProcessFactoryManager = new XMLFormServiceProcessFactoryManager((ServiceAPI)this);
this.exceptionOnStart = false;
this.mbReportMissingXCI = true;
this.moProcessFactoryManager.setExecutableName("bin/XMLForm.exe");
this.moProcessFactoryManager.setExtraProcessArgs();
this.registerConnectionFactoryManager((ResourceFactoryManager)this.moProcessFactoryManager);
this.updateProperties(config);
if (!this.mbIsWebAS) {
// empty if block
}
this.moLogger.trace("ALC-XTG-100-101");
if (this.exceptionOnStart) {
this.moLogger.info("ALC-XTG-100-020");
} else {
this.moLogger.info("ALC-XTG-100-019");
}
}
private void updateProperties(Map config) {
if (config.get("XMLFormService.ctAllowSystemFonts") != null) {
this.setCT_AllowSystemFonts(OsgiUtil.toBoolean(config.get("XMLFormService.ctAllowSystemFonts"), (boolean)true));
} else {
this.logger.warn("Found null for XMLFormService.ctAllowSystemFonts");
}
if (config.get("XMLFormService.ctTmpDirectory.name") != null) {
this.setCT_TmpDirectory(OsgiUtil.toString(config.get("XMLFormService.ctTmpDirectory.name"), (String)""));
} else {
this.logger.warn("Found null for XMLFormService.ctTmpDirectory.name");
}
if (config.get("XMLFormService.traceLevel") != null) {
this.setTraceLevel(OsgiUtil.toInteger(config.get("XMLFormService.traceLevel"), (int)0));
} else {
this.logger.warn("Found null for XMLFormService.traceLevel");
}
if (config.get("XMLFormService.javascript.timeout") != null) {
this.setJavaScriptTimeout(OsgiUtil.toInteger(config.get("XMLFormService.javascript.timeout"), (int)0));
} else {
this.logger.warn("Found null for XMLFormService.javascript.timeout");
}
if (config.get("XMLFormService.report.timing.info") != null) {
this.setReportTimingInformation(OsgiUtil.toBoolean(config.get("XMLFormService.report.timing.info"), (boolean)false));
} else {
this.logger.warn("Found null for XMLFormService.report.timing.info");
}
if (config.get("XMLFormService.PDFLMemorySize") != null) {
this.setPDFLMemorySize(OsgiUtil.toInteger(config.get("XMLFormService.PDFLMemorySize"), (int)1024));
} else {
this.logger.warn("Found null for XMLFormService.PDFLMemorySize");
}
if (config.get("XMLFormService.useproximity") != null) {
this.setUseProximity(OsgiUtil.toBoolean(config.get("XMLFormService.useproximity"), (boolean)false));
} else {
this.logger.warn("Found null for XMLFormService.useproximity");
}
if (config.get("XMLFormService.poolmax") != null) {
this.setPoolMax(OsgiUtil.toInteger(config.get("XMLFormService.poolmax"), (int)4));
} else {
this.logger.warn("Found null for XMLFormService.poolmax");
}
if (config.get("XMLFormService.maxreusecount") != null) {
this.setMaximumReUseCount(OsgiUtil.toInteger(config.get("XMLFormService.maxreusecount"), (int)10000));
} else {
this.logger.warn("Found null for XMLFormService.maxreusecount");
}
if (config.get("XMLFormService.orb.params") != null) {
this.setORBParams(OsgiUtil.toString(config.get("XMLFormService.orb.params"), (String)""));
} else {
this.logger.warn("Found null for XMLFormService.orb.params");
}
}
public void onStopService() {
this.moLogger.trace("ALC-XTG-100-102");
this.exceptionOnStart = false;
this.moLogger.info("ALC-XTG-100-021");
}
public String about() {
return "XML Form Module";
}
public void setDefaultTitle(String title) {
this.msDefaultTitle = title;
}
public String getDefaultTitle() {
return this.msDefaultTitle;
}
public boolean getReportTimingInformation() {
return this.mbReportTimingInformation;
}
public void setReportTimingInformation(boolean bReportTimings) {
this.mbReportTimingInformation = bReportTimings;
this.moLogger.trace("ALC-XTG-100-103", Boolean.toString(bReportTimings));
}
public int getTraceLevel() {
return this.mnTraceLevel;
}
public void setTraceLevel(int TraceLevel) {
this.mnTraceLevel = TraceLevel;
}
public String getSpecificationVersion() {
return "11.0.1";
}
public String getImplementationVersion() {
return "11.0.1";
}
public boolean getAutoDetectPoolMax() {
return this.mbAutoPoolMax;
}
public void setAutoDetectPoolMax(boolean autodetectpoolmax) {
this.mbAutoPoolMax = autodetectpoolmax;
}
public boolean getDebug() {
return this.moProcessFactoryManager.getDebug();
}
public void setDebug(boolean debug) {
this.moProcessFactoryManager.setDebug(debug);
this.moLogger.trace("ALC-XTG-100-104", Boolean.toString(debug));
}
public void setPoolMax(int newMax) {
this.moProcessFactoryManager.setPoolMax(newMax);
this.moLogger.trace("ALC-XTG-100-105", Integer.toString(newMax));
}
public int getPoolMax() {
return this.moProcessFactoryManager.getPoolMax();
}
public void setMaximumReUseCount(int newMax) {
this.moProcessFactoryManager.setMaximumReUseCount(newMax);
this.moLogger.trace("ALC-XTG-100-106", Integer.toString(newMax));
}
public int getMaximumReUseCount() {
int maxReuseCount = this.moProcessFactoryManager.getMaximumReUseCount();
this.moLogger.trace("ALC-XTG-100-107", Integer.toString(maxReuseCount));
return maxReuseCount;
}
public void setCT_AdditionalFontsCacheFile(String additionalFontsCacheFile) {
this.moLogger.trace("ALC-XTG-100-111", additionalFontsCacheFile);
this.msAdditionalFontsCacheFile = additionalFontsCacheFile;
}
public String getCT_AdditionalFontsCacheFile() {
this.moLogger.trace("ALC-XTG-100-112", this.msAdditionalFontsCacheFile);
return this.msAdditionalFontsCacheFile;
}
public void setCT_CommonFontsCacheFile(String commonFontsCacheFile) {
this.moLogger.trace("ALC-XTG-100-113", commonFontsCacheFile);
this.msCommonFontsCacheFile = commonFontsCacheFile;
}
public String getCT_CommonFontsCacheFile() {
this.moLogger.trace("ALC-XTG-100-114", this.msCommonFontsCacheFile);
return this.msCommonFontsCacheFile;
}
public void setCT_SystemCacheFile(String systemCacheFile) {
this.moLogger.trace("ALC-XTG-100-115", systemCacheFile);
this.msSystemCacheFile = systemCacheFile;
}
public String getCT_SystemCacheFile() {
this.moLogger.trace("ALC-XTG-100-116", this.msSystemCacheFile);
return this.msSystemCacheFile;
}
public void setCT_TmpDirectory(String tmpDirectory) {
this.moLogger.trace("ALC-XTG-100-117", tmpDirectory);
this.msTmpDirectory = tmpDirectory;
}
public String getCT_TmpDirectory() {
if (this.msTmpDirectory.equals("")) {
this.msTmpDirectory = System.getProperty("java.io.tmpdir");
}
if (!(this.msTmpDirectory.equals("") || this.msTmpDirectory.endsWith("/") || this.msTmpDirectory.endsWith("\\"))) {
this.msTmpDirectory = this.msTmpDirectory + System.getProperty("file.separator");
}
this.moLogger.trace("ALC-XTG-100-118", this.msTmpDirectory);
return this.msTmpDirectory;
}
public void setUseProximity(boolean bUseProximity) {
this.mbUseProximity = bUseProximity;
this.moLogger.trace("ALC-XTG-100-022", Boolean.toString(bUseProximity));
}
public boolean getUseProximity() {
return this.mbUseProximity;
}
public void setCT_AllowSystemFonts(boolean bAllowSystemFonts) {
this.mbAllowSystemFonts = bAllowSystemFonts;
this.moLogger.trace("ALC-XTG-100-119", Boolean.toString(bAllowSystemFonts));
}
public boolean getCT_AllowSystemFonts() {
return this.mbAllowSystemFonts;
}
public String getCommonDir() {
if (this.msCommonDir.equals("") && !this.mbGotFonts) {
try {
this.getFontDirectories();
}
catch (Exception e) {
// empty catch block
}
}
this.moLogger.trace("ALC-XTG-100-120", this.msCommonDir);
return this.msCommonDir;
}
public String getUnicodeDir() {
if (this.msUnicodeDir.equals("") && !this.mbGotFonts) {
try {
this.getFontDirectories();
}
catch (Exception e) {
// empty catch block
}
}
this.moLogger.trace("ALC-XTG-100-121", this.msUnicodeDir);
return this.msUnicodeDir;
}
public String getAdditionalDir() {
if (this.msAdditionalDir.equals("") && !this.mbGotFonts) {
try {
this.getFontDirectories();
}
catch (Exception e) {
// empty catch block
}
}
this.moLogger.trace("ALC-XTG-100-122", this.msAdditionalDir);
return this.msAdditionalDir;
}
public String getFontDB() {
if (this.msFontDB.equals("") && !this.mbGotFonts) {
try {
this.getFontDirectories();
}
catch (Exception e) {
// empty catch block
}
}
this.moLogger.trace("ALC-XTG-100-123", this.msFontDB);
return this.msFontDB;
}
public void setORBParams(String params) {
this.moProcessFactoryManager.setORBParams(params);
}
public String getORBParams() {
return this.moProcessFactoryManager.getORBParams();
}
public boolean getXMLFormCachingOff() {
return this.mbCachingOff;
}
public void setXMLFormCachingOff(boolean bCachingOff) {
this.mbCachingOff = bCachingOff;
}
public String getConfigXML() {
if (this.mbIsWebAS) {
return "";
}
if (this.mbUpdatePending) {
this.updateXCI();
}
return this.getOutputXCIPath();
}
public String getXCIPath() {
return this.msInputXCI;
}
public void setXCIPath(String path) {
this.mbUpdatePending = true;
try {
this.msInputXCI = this.getFullPath(path);
if (this.msInputXCI != null && this.msInputXCI.length() > 0) {
this.updateXCI();
}
}
catch (Exception oException) {
this.moLogger.warn("ALC-XTG-100-011", oException.getMessage());
this.exceptionOnStart = true;
}
}
public void updateXCI() {
try {
this.loadXCI();
this.applyConfig();
this.saveXCI();
this.mbUpdatePending = false;
}
catch (Exception e) {
this.mbUpdatePending = true;
}
}
private String getFullPath(String inPath) {
if (inPath == null) {
return null;
}
File f = new File(inPath);
if (f == null) {
this.moLogger.error("ALC-XTG-100-001", inPath);
return null;
}
if (f.isAbsolute()) {
return inPath;
}
String sPersistDir = this.getPersistentDir().getAbsolutePath();
return sPersistDir + File.separator + inPath;
}
private void getFontDirectories() throws Exception {
this.moLogger.trace("ALC-XTG-100-124");
String adobeFontDir = "";
String custFontDir = "";
try {
adobeFontDir = this.fontManagerService.getAdobeServerFontDirectory();
custFontDir = this.fontManagerService.getCustomerFontDirectory();
}
catch (Exception e) {
this.moLogger.error("ALC-XTG-100-002", e.toString());
e.printStackTrace();
throw e;
}
this.moLogger.trace("ALC-XTG-100-128");
this.mbGotFonts = true;
StringBuffer commonSuffix = new StringBuffer();
StringBuffer unicodeSuffix = new StringBuffer();
commonSuffix.append(File.separator).append("reqrd").append(File.separator).append("cmaps");
unicodeSuffix.append(File.separator).append("typespt").append(File.separator).append("unicode");
StringBuffer pdfl = new StringBuffer(adobeFontDir);
pdfl.append(File.separator).append("pdfl").append(File.separator);
StringBuffer commonDir = new StringBuffer();
StringBuffer unicodeDir = new StringBuffer();
StringBuffer additionalDir = new StringBuffer();
StringBuffer fontDB = new StringBuffer();
commonDir.append(adobeFontDir).append(commonSuffix);
unicodeDir.append(adobeFontDir).append(unicodeSuffix);
fontDB.append(adobeFontDir).append(File.separator).append("typespt").append(File.separator).append("FntNames.db");
if (custFontDir != null && custFontDir.length() > 0) {
additionalDir.append(custFontDir).append(";");
}
additionalDir.append(adobeFontDir).append(";");
additionalDir.append(pdfl).append("fonts").append(";");
additionalDir.append(pdfl).append("fonts").append(File.separator).append("pfm");
this.msCommonDir = commonDir.toString();
this.moLogger.trace("ALC-XTG-100-129", this.msCommonDir);
this.msUnicodeDir = unicodeDir.toString();
this.moLogger.trace("ALC-XTG-100-130", this.msUnicodeDir);
this.msAdditionalDir = additionalDir.toString();
this.moLogger.trace("ALC-XTG-100-131", this.msAdditionalDir);
this.msFontDB = fontDB.toString();
this.moLogger.trace("ALC-XTG-100-132", this.msFontDB);
}
private void applyConfig() throws Exception {
try {
ResourceBundle props = ResourceBundle.getBundle("com.adobe.config.XMLFormService-xci");
Enumeration<String> names = props.getKeys();
while (names.hasMoreElements()) {
String name = names.nextElement().toString();
if (name.equalsIgnoreCase("TemplateBase")) {
this.setXCIProperty("config/present/common/template/base", props.getString(name));
continue;
}
if (name.equalsIgnoreCase("TempURI")) {
this.setXCIProperty("config/present/common/temp/uri", props.getString(name));
continue;
}
if (name.equalsIgnoreCase("SubmitFormat")) {
this.setXCIProperty("config/present/pdf/submitFormat", props.getString(name));
continue;
}
if (name.equalsIgnoreCase("CompressionLevel")) {
this.setXCIProperty("config/present/pdf/compression/level", props.getString(name));
continue;
}
if (!name.equalsIgnoreCase("CompressionType")) continue;
this.setXCIProperty("config/present/pdf/compression/type", props.getString(name));
}
}
catch (Exception e) {
// empty catch block
}
}
private void setXCIProperty(String propName, String propValue) {
this.moLogger.trace("ALC-XTG-100-133", propName, propValue);
if (this.moXCIDom == null) {
return;
}
Node oPropNode = this.getXCINode(this.moXCIDom.getDocumentElement(), propName);
if (oPropNode != null) {
this.removeChildNodes(oPropNode);
oPropNode.appendChild(this.moXCIDom.createTextNode(propValue));
}
}
private Node getXCINode(Element oParentElement, String nodePath) {
if (oParentElement == null) {
return null;
}
StringTokenizer toks = new StringTokenizer(nodePath, "/");
int iToks = toks.countTokens();
if (iToks > 0) {
String tok = toks.nextToken();
Vector<Node> oNodeList = new Vector<Node>();
for (Node oCh = oParentElement.getFirstChild(); oCh != null; oCh = oCh.getNextSibling()) {
if (oCh.getNodeType() != 1 || !oCh.getNodeName().equals(tok)) continue;
oNodeList.add(oCh);
}
int nodeCnt = oNodeList.size();
if (iToks == 1) {
if (nodeCnt > 0) {
return (Node)oNodeList.elementAt(0);
}
return null;
}
for (int i = 0; i < nodeCnt; ++i) {
Node oNode = this.getXCINode((Element)oNodeList.elementAt(i), nodePath.substring(nodePath.indexOf(tok) + tok.length() + 1));
if (oNode == null) continue;
return oNode;
}
return null;
}
return null;
}
private void removeChildNodes(Node oParentNode) {
if (oParentNode != null && oParentNode.hasChildNodes()) {
NodeList oList = oParentNode.getChildNodes();
for (int i = 0; i < oList.getLength(); ++i) {
oParentNode.removeChild(oList.item(i));
}
}
}
private void loadXCI() throws Exception {
boolean bSuccess = false;
this.moXCIDom = null;
File xciFile = new File(this.msInputXCI);
if (xciFile != null && xciFile.length() > 0) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(false);
dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", Boolean.valueOf("false"));
DocumentBuilder oParser = dbf.newDocumentBuilder();
this.moXCIDom = oParser.parse(xciFile);
bSuccess = true;
}
catch (IOException e) {
this.moLogger.error("ALC-XTG-100-004", e.getMessage());
throw e;
}
catch (SAXException e) {
this.moLogger.error("ALC-XTG-100-004", e.getMessage());
throw e;
}
} else if (this.mbReportMissingXCI) {
this.moLogger.error("ALC-XTG-100-005", this.msInputXCI);
}
if (!bSuccess) {
throw new Exception();
}
}
private void saveXCI() throws Exception {
try {
DOMSource oDOMSource = new DOMSource(this.moXCIDom);
byte[] raw = this.toXML(oDOMSource);
this.writeFile(this.getOutputXCIPath(), raw);
}
catch (FileNotFoundException e) {
this.moLogger.error("ALC-XTG-100-006", this.getOutputXCIPath());
throw e;
}
catch (IOException e) {
this.moLogger.error("ALC-XTG-100-007", e.toString());
e.printStackTrace();
throw e;
}
catch (Exception e) {
this.moLogger.error("ALC-XTG-100-007", e.toString());
e.printStackTrace();
throw e;
}
}
public byte[] toXML(DOMSource oSource) throws Exception {
Properties props = new Properties();
props.put("method", "xml");
props.put("encoding", "UTF-8");
props.put("omit-xml-declaration", "no");
props.put("indent", "yes");
return this.transformToBytes(oSource, props);
}
private void writeFile(String file, byte[] data) throws IOException {
FileOutputStream oXMLNewFile = new FileOutputStream(file);
oXMLNewFile.write(data);
oXMLNewFile.close();
}
private String getOutputXCIPath() {
if (this.msOutputXCI == null) {
this.msOutputXCI = this.getFullPath("xmlform.xci");
}
return this.msOutputXCI;
}
private void loadConfigProperties() {
try {
this.loadPropertyFile();
}
catch (Exception e) {
// empty catch block
}
}
private void loadPropertyFile() {
String sMaxReuseCount;
String sReportTimingInformation;
ResourceBundle props = ResourceBundle.getBundle("com.adobe.config.XMLFormService-init");
String sPoolMax = null;
if (sPoolMax == null) {
try {
sPoolMax = props.getString("PoolMax");
}
catch (MissingResourceException e) {
sPoolMax = null;
}
}
if (sPoolMax != null) {
try {
this.setPoolMax(Integer.parseInt(sPoolMax));
}
catch (NumberFormatException e) {
this.moLogger.warn("ALC-XTG-100-010", e.getMessage());
this.exceptionOnStart = true;
}
}
if ((sMaxReuseCount = null) == null) {
try {
sMaxReuseCount = props.getString("MaximumReUseCount");
}
catch (MissingResourceException e) {
sMaxReuseCount = null;
}
}
if (sMaxReuseCount != null) {
try {
this.setMaximumReUseCount(Integer.parseInt(sMaxReuseCount));
}
catch (NumberFormatException e) {
this.moLogger.warn("ALC-XTG-100-012", e.getMessage());
this.exceptionOnStart = true;
}
}
if ((sReportTimingInformation = null) == null) {
try {
sReportTimingInformation = props.getString("ReportTimingInformation");
}
catch (MissingResourceException e) {
sReportTimingInformation = null;
}
}
if (sReportTimingInformation != null) {
this.setReportTimingInformation(Boolean.valueOf(sReportTimingInformation));
}
String sDebug = null;
try {
sDebug = props.getString("Debug");
}
catch (MissingResourceException e) {
sDebug = null;
}
if (sDebug != null) {
this.setDebug(Boolean.valueOf(sDebug));
}
String sXCIPath = null;
try {
sXCIPath = props.getString("XCIPath");
}
catch (MissingResourceException e) {
sXCIPath = null;
}
if (sXCIPath != null) {
this.setXCIPath(sXCIPath);
}
}
private byte[] transformToBytes(DOMSource oSource, Properties props) throws TransformerException {
TransformerFactory trans_factory = TransformerFactory.newInstance();
Transformer xml_out = trans_factory.newTransformer();
ByteArrayOutputStream out = new ByteArrayOutputStream();
xml_out.setOutputProperties(props);
xml_out.transform(oSource, new StreamResult(out));
return out.toByteArray();
}
public int getJavaScriptTimeout() {
return this.mnJavaScriptTimeout;
}
public int getGlobalTimeout() {
return this.mnGlobalTimeout;
}
public boolean getFillDurationInfo() {
return this.mbFillDurationInfo;
}
public boolean getUseAEMNatives() {
return this.mbUseAEMNatives;
}
public int getPDFLMemorySize() {
return this.mnPDFLMemorySize;
}
public void setJavaScriptTimeout(int inTimeout) {
this.mnJavaScriptTimeout = inTimeout;
}
public void setGlobalTimeout(int inGlobalTimeout) {
this.mnGlobalTimeout = inGlobalTimeout;
}
public void setFillDurationInfo(boolean inFillDurationInfo) {
this.mbFillDurationInfo = inFillDurationInfo;
}
public void setPDFLMemorySize(int inMemorySize) {
this.mnPDFLMemorySize = inMemorySize;
}
public void setUseAEMNatives(boolean useAEMNatives) {
this.mbUseAEMNatives = useAEMNatives;
}
protected void bindFontManagerService(FontManagerService fontManagerService) {
this.fontManagerService = fontManagerService;
}
protected void unbindFontManagerService(FontManagerService fontManagerService) {
if (this.fontManagerService == fontManagerService) {
this.fontManagerService = null;
}
}
}