ProcessResource.java
64.6 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
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.io.FileUtils
* org.apache.commons.io.FilenameUtils
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.service;
import com.adobe.CORBA.ServantBase;
import com.adobe.aemds.bedrock.internal.Utilities;
import com.adobe.service.*;
import com.adobe.service.ControlAgentPackage.CategoryTable;
import com.adobe.service.ManagerPackage.JdkLogEntry;
import com.adobe.service.ManagerPackage.LogEntry;
import com.adobe.service.impl.Platform;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import org.omg.CORBA.SystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.naming.NameNotFoundException;
import java.io.*;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.MessageFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProcessResource
extends ConnectionResource {
private static final String reservedToken = "@ADOBE";
private static final String ADOBE_TEMP_DIR_PROP_NAME = "com.adobe.tempDirectory";
private static final String DEFAULT_RUNTIME = "omniORB_4.1.1_x86_win32_vc10";
private static final String lineSeparator = System.getProperty("line.separator");
private static final boolean isWindowsPlatform = System.getProperty("os.name").startsWith("Win");
private final Logger loggerBMC;
private static final Logger logger = LoggerFactory.getLogger(ProcessResource.class);
private static final int SHUTDOWN_TIMEOUT = 10000;
private static final int MAJOR_VERSION_ADD_EXT = 2;
private static final int MINOR_VERSION_ADD_EXT = 4;
private static final int TEENY_VERSION_ADD_EXT = 20;
private int reuseCount = 0;
private int myMaximumReUseCount = 0;
private int pid = 0;
private boolean CtrlLogOptimization = false;
private boolean jdkLog = false;
private int bmcLogLevel = -1;
private static SecureRandom random;
private final ServiceAPI service;
private final ProcessFactoryManager processFactoryManager;
private final ManagerImpl manager;
private ControlAgent controlAgent;
private ORB orb;
private Process process = null;
private static final int STDIN = 0;
private ReaderThread stdoutReader;
private ReaderThread stderrReader;
private File exePath;
private File processTempDir;
private String nativeDirPath;
private String persistentDirPath;
private boolean plannedShutdown = false;
private boolean isJavaProc = false;
private Hashtable jdkLogLevelTable = new Hashtable();
private Hashtable jdkLoggerTable = new Hashtable();
public ProcessResource(ServiceAPI theService, ProcessFactoryManager theProcessFactoryManager) throws IOException {
if (random == null) {
throw new IOException("Initializing the random number generator failed");
}
this.service = theService;
this.loggerBMC = LoggerFactory.getLogger(this.service.getClass());
if (logger != null) {
logger.debug("Creating ProcessResource");
logger.debug("ProcessResource: Service = {}", (java.lang.Object)this.service.getName());
} else {
System.err.println("ProcessResource: No logger created!!!");
}
this.processFactoryManager = theProcessFactoryManager;
this.orb = Platform.UTIL.getOrb();
this.manager = new ManagerImpl();
byte[] seed = random.generateSeed(4);
random.setSeed(seed);
int variation = (int)((double)this.processFactoryManager.getMaximumReUseCount() * this.processFactoryManager.getMaximumReUseVariation() * random.nextDouble());
this.myMaximumReUseCount = this.processFactoryManager.getMaximumReUseCount() - variation;
if (this.myMaximumReUseCount <= 0) {
this.myMaximumReUseCount = 1;
}
logger.debug("*****" + Thread.currentThread().getName() + " ProcessResource " + this + " created");
this.startProcess();
logger.debug("*****" + Thread.currentThread().getName() + " ProcessResource " + this + " started");
}
public String toString() {
String name = "?";
if (this.exePath != null) {
name = this.exePath.getName();
}
return "ProcessResource@" + Integer.toHexString(this.hashCode()) + "(name=" + name + ",pid=" + this.pid + ")";
}
private void startProcess() {
boolean ipv6;
String bsljClassPath = "${COMMON_JARS_DIR}" + File.separator + "adobe-bslj.jar" + File.pathSeparator + "${COMMON_JARS_DIR}" + File.separator + "jacorb" + File.separator + "jacorb.jar" + File.pathSeparator + "${COMMON_JARS_DIR}" + File.separator + "jacorb" + File.separator + "avalon-framework-4.1.5.jar" + File.pathSeparator + "${COMMON_JARS_DIR}" + File.separator + "jacorb" + File.separator + "concurrent-1.3.2.jar" + File.pathSeparator + "${COMMON_JARS_DIR}" + File.separator + "jacorb" + File.separator + "logkit-1.2.jar" + File.pathSeparator + "${COMMON_JARS_DIR}" + File.separator + "jacorb" + File.separator + "antlr-2.7.2.jar";
try {
logger.trace("Service {}: Creating the temporary directory for managed process.", (java.lang.Object)this.service.getName());
this.createTempDir(this.service.getName());
this.nativeDirPath = this.service.getNativeDir().getCanonicalPath();
this.persistentDirPath = this.service.getPersistentDir().getCanonicalPath();
}
catch (Exception e) {
logger.error("Service " + this.service + ": Cannot create temporary directory.", (Throwable)e);
throw new UndeclaredThrowableException(e, "Error creating temporary directory for " + this.service.getName());
}
this.setReady(false);
String managerIOR = this.orb.object_to_string(this.manager._this());
String exeStr = this.processFactoryManager.getExecutableName();
String javaClassPath = this.processFactoryManager.getClassPath();
String jvmArgs = null;
String mainClass = null;
if (javaClassPath != null && !"".equals(javaClassPath)) {
this.isJavaProc = true;
javaClassPath = this.substituteVars(javaClassPath + File.pathSeparator + bsljClassPath);
jvmArgs = this.processFactoryManager.getJVMArgs();
mainClass = exeStr;
exeStr = "${JAVA}";
} else {
exeStr = "${NATIVE_DIR}/" + exeStr;
}
exeStr = this.substituteVars(exeStr);
File f = new File(exeStr);
try {
this.exePath = f.getCanonicalFile();
}
catch (IOException e) {
logger.error("Service " + this.service + ": Cannot convert executable path to canonical. Path is " + exeStr, (Throwable)e);
throw new UndeclaredThrowableException(e, "Error converting to canonical path");
}
String argStr = this.substituteVars(this.processFactoryManager.getExecutableArguments());
boolean bl = ipv6 = System.getProperty("java.net.preferIPv6Stack") != null && System.getProperty("java.net.preferIPv6Stack").equalsIgnoreCase("true");
if (ipv6) {
String string = argStr = argStr == null || argStr.equals("") ? "-ipv6" : argStr + " -ipv6";
}
if (this.isJavaProc) {
String jacorbArg = "";
String jacorbCodesetProp = System.getProperty("adobeidp.UseDefaultJacorbCodeset");
if (Platform.UTIL.getAppServer().equals("weblogic") && jacorbCodesetProp == null) {
jacorbArg = " -Dadobeidp.JacorbCodeset=utf16";
}
argStr = jvmArgs == null || jvmArgs.equals("") ? jacorbArg + " -cp " + this.quotify(javaClassPath) + " " + mainClass + " " + this.quotify(argStr) : jvmArgs + jacorbArg + " -cp " + this.quotify(javaClassPath) + " " + mainClass + " " + this.quotify(argStr);
}
String sslArg = "";
String keyPass = Platform.UTIL.getSSLPassword();
if (keyPass != null) {
sslArg = " -KeyPass " + this.quotify(keyPass) + " -CertPath " + this.quotify(Platform.UTIL.getSSLCertDir().toString()) + " -SSLNativeDir " + this.quotify(Platform.UTIL.getSSLNativeDir().toString());
}
if (this.processFactoryManager.getDebug()) {
logger.info("Service {}: Starting In Debug Mode. Run managed process in the debugger.", (java.lang.Object)this.service);
String serverTempDir = this.service.getTempDir().toString();
String iorFile = serverTempDir + File.separatorChar + "_iorFile";
try {
FileWriter buffer = new FileWriter(iorFile);
buffer.write(managerIOR);
buffer.flush();
buffer.close();
}
catch (IOException e) {
throw new UndeclaredThrowableException(e, "Error writing IOR to a file");
}
String commandLine = this.exePath.toString() + " " + argStr + " -IORFile " + iorFile + " " + sslArg + " " + this.service.getORBParams() + " -AppServer " + Platform.UTIL.getAppServer();
logger.info("Service{}: IOR has been written to file: {}", (java.lang.Object)this.service, (java.lang.Object)iorFile);
logger.info("Service{}: Use debug command: {}", (java.lang.Object)this.service, (java.lang.Object)commandLine);
} else {
if (!this.exePath.exists()) {
try {
throw new IOException("Executable does not exist: " + this.exePath.getAbsolutePath());
}
catch (Exception e) {
logger.error("Service " + this.service + ": Cannot access the path for the native process. Path is " + this.exePath, (Throwable)e);
throw new UndeclaredThrowableException(e);
}
}
String commandLine = this.quotify(this.exePath.toString()) + " " + argStr + " -IOR " + managerIOR + " " + sslArg + " " + this.service.getORBParams() + " -AppServer " + Platform.UTIL.getAppServer();
String[] commandLineArray = Utilities.tokenizeString(commandLine);
Properties envProps = Platform.UTIL.getEnvironmentVariables();
File workDir = this.exePath.getParentFile();
if (System.getProperty("os.name").startsWith("Win")) {
String newPath = workDir.toString() + ";" + Platform.UTIL.getCommonNativeDir().toString() + ";";
newPath = newPath + this.getNativeDependenciesPaths();
if (Platform.UTIL.getSSLNativeDir() != null && !Platform.UTIL.getSSLNativeDir().toString().equals(Platform.UTIL.getCommonNativeDir().toString())) {
newPath = newPath + Platform.UTIL.getSSLNativeDir().toString() + ";";
}
String[] sharedLibraryPaths = this.processFactoryManager.getSharedLibraryPaths();
for (int i = 0; i < sharedLibraryPaths.length; ++i) {
newPath = sharedLibraryPaths[i] + ";" + newPath;
}
String oldPath = envProps.getProperty("Path");
if (oldPath != null) {
envProps.setProperty("Path", newPath + oldPath);
} else {
oldPath = envProps.getProperty("path");
if (oldPath != null) {
envProps.setProperty("path", newPath + oldPath);
} else {
oldPath = envProps.getProperty("PATH");
if (oldPath != null) {
envProps.setProperty("PATH", newPath + oldPath);
}
}
}
logger.debug("Service {}: setting the path property to {}", (java.lang.Object)this.service.getName(), (java.lang.Object)(newPath + oldPath));
envProps.setProperty("TMP", this.processTempDir.getAbsolutePath());
envProps.setProperty("TEMP", this.processTempDir.getAbsolutePath());
String[] toSend = new String[envProps.size()];
Enumeration en = envProps.propertyNames();
for (int i2 = 0; i2 < envProps.size(); ++i2) {
String key = (String)en.nextElement();
toSend[i2] = key + "=" + envProps.getProperty(key);
}
try {
String useCustomLauncher = null;
try {
useCustomLauncher = this.service.getAttribute(ServiceAPI.USE_CUSTOM_LAUNCHER);
}
catch (Exception e) {
logger.debug("Error retrieving property " + ServiceAPI.USE_CUSTOM_LAUNCHER + " from service " + this.service.getName(), (Throwable)e);
}
if (ImpersonatedConnectionManager.isImpersonatedConnection(this.service) || useCustomLauncher != null && useCustomLauncher.trim().equalsIgnoreCase("true") && isWindowsPlatform) {
String impersonatedUser = "@ADOBE";
String impersonatedUserPassword = "@ADOBE";
if (ImpersonatedConnectionManager.isImpersonatedConnection(this.service)) {
ImpersonatedConnectionManager.Credential cred = this.getImpersonationCredential();
impersonatedUser = cred.user;
impersonatedUserPassword = cred.password;
}
String[] processLauncherCmdArray = new String[commandLineArray.length + 3];
String[] userAndDomain = this.getUserAndDomain(impersonatedUser);
processLauncherCmdArray[0] = this.substituteVars("${RUNAS}");
processLauncherCmdArray[1] = userAndDomain[0];
processLauncherCmdArray[2] = userAndDomain[1];
System.arraycopy(commandLineArray, 0, processLauncherCmdArray, 3, commandLineArray.length);
commandLine = processLauncherCmdArray[0] + " " + processLauncherCmdArray[1] + " " + processLauncherCmdArray[2] + " " + commandLine;
logger.info("Service {}: Starting native process with command line {}", (java.lang.Object)this.service.getName(), (java.lang.Object)commandLine);
this.process = Runtime.getRuntime().exec(processLauncherCmdArray, toSend, workDir);
this.process.getOutputStream().write((impersonatedUserPassword + lineSeparator).getBytes());
this.process.getOutputStream().flush();
}
logger.info("Service {}: Starting native process with command line {}", (java.lang.Object)this.service.getName(), (java.lang.Object)commandLine);
this.process = Runtime.getRuntime().exec(commandLineArray, toSend, workDir);
}
catch (IOException e) {
logger.error("Service " + this.service.getName() + ": Error starting native process " + commandLine, (Throwable)e);
this.doProcessExitCleanup();
throw new UndeclaredThrowableException(e, "Error executing process");
}
catch (IllegalStateException e2) {
logger.error("Service " + this.service.getName() + ": Error starting impersonated process " + commandLine, (Throwable)e2);
this.doProcessExitCleanup();
throw new UndeclaredThrowableException(e2, "Error executing process");
}
} else {
String oldPath;
if (!this.isJavaProc) {
try {
String chmodcommand = "chmod a+x " + this.exePath.toString();
Process p = Runtime.getRuntime().exec(chmodcommand);
try {
p.waitFor();
}
catch (InterruptedException ie) {
logger.warn("Interrupted waiting for process to terminate", (Throwable)ie);
}
}
catch (IOException e) {
logger.error("Service " + this.service + ": Cannot add execute permission on file " + this.exePath, (Throwable)e);
throw new UndeclaredThrowableException(e, "Error executing process");
}
}
String libPath = workDir.toString() + ":" + Platform.UTIL.getCommonNativeDir().toString();
String nativeDependencyPaths = this.getNativeDependenciesPaths();
if (nativeDependencyPaths != null && nativeDependencyPaths.length() > 0) {
libPath = libPath + ":" + nativeDependencyPaths;
}
String[] sharedLibraryPaths = this.processFactoryManager.getSharedLibraryPaths();
for (int i = 0; i < sharedLibraryPaths.length; ++i) {
libPath = sharedLibraryPaths[i] + ":" + libPath;
}
if (Platform.UTIL.getSSLNativeDir() != null && !Platform.UTIL.getSSLNativeDir().toString().equals(Platform.UTIL.getCommonNativeDir().toString())) {
libPath = libPath.concat(":" + Platform.UTIL.getSSLNativeDir().toString());
}
if (this.needToAddExt()) {
libPath = libPath.concat(":" + Platform.UTIL.getCommonNativeDir().toString() + File.separatorChar + "ext");
}
if ((oldPath = envProps.getProperty("LD_LIBRARY_PATH")) != null) {
libPath = libPath.concat(":" + oldPath);
}
envProps.setProperty("LD_LIBRARY_PATH", libPath);
logger.debug("Service {}: Setting property LD_LIBRARY_PATH to: {}", (java.lang.Object)this.service.getName(), (java.lang.Object)libPath);
oldPath = envProps.getProperty("LIBPATH");
if (oldPath != null) {
libPath = libPath.concat(":" + oldPath);
}
envProps.setProperty("LIBPATH", libPath);
logger.debug("Service {}: Setting property LIBPATH to: {}", (java.lang.Object)this.service.getName(), (java.lang.Object)libPath);
oldPath = envProps.getProperty("SHLIB_PATH");
if (oldPath != null) {
libPath = libPath.concat(":" + oldPath);
}
envProps.setProperty("SHLIB_PATH", libPath);
logger.debug("Service {}: Setting property SHLIB_PATH to: {}", (java.lang.Object)this.service.getName(), (java.lang.Object)libPath);
oldPath = envProps.getProperty("DYLD_LIBRARY_PATH");
if (oldPath != null) {
libPath = libPath.concat(":" + oldPath);
}
envProps.setProperty("DYLD_LIBRARY_PATH", libPath);
logger.debug("Service {}: Setting property DYLD_LIBRARY_PATH to: {}", (java.lang.Object)this.service.getName(), (java.lang.Object)libPath);
envProps.setProperty("TEMP", this.processTempDir.getAbsolutePath());
envProps.setProperty("TMPDIR", this.processTempDir.getAbsolutePath());
String[] toSend = new String[envProps.size()];
Enumeration en = envProps.propertyNames();
for (int i3 = 0; i3 < envProps.size(); ++i3) {
String key = (String)en.nextElement();
toSend[i3] = key + "=" + envProps.getProperty(key);
}
try {
if (ImpersonatedConnectionManager.isImpersonatedConnection(this.service)) {
ImpersonatedConnectionManager.Credential cred = this.getImpersonationCredential();
String shellScriptPath = this.createShellScript(cred.user, commandLine);
logger.info("Service {}: Command line {} has been written to file: {}", new java.lang.Object[]{this.service.getName(), commandLine, shellScriptPath});
String[] processLauncherCmdArray = new String[]{this.substituteVars("${RUNAS}"), "-u", cred.user, "-i", "--", shellScriptPath};
commandLineArray = processLauncherCmdArray;
commandLine = processLauncherCmdArray[0] + " " + processLauncherCmdArray[1] + " " + processLauncherCmdArray[2] + " " + processLauncherCmdArray[3] + " " + processLauncherCmdArray[4] + " " + processLauncherCmdArray[5];
}
logger.info("Service {}: Starting native process with command line {}", (java.lang.Object)this.service.getName(), (java.lang.Object)commandLine);
this.process = Runtime.getRuntime().exec(commandLineArray, toSend, workDir);
}
catch (IOException e) {
logger.error("Service " + this.service.getName() + ": Error starting native process " + commandLine, (Throwable)e);
this.doProcessExitCleanup();
throw new UndeclaredThrowableException(e, "Error executing process");
}
catch (IllegalStateException e2) {
logger.error("Service " + this.service.getName() + ": Error starting impersonated process " + commandLine, (Throwable)e2);
this.doProcessExitCleanup();
throw new UndeclaredThrowableException(e2, "Error executing process");
}
}
this.stdoutReader = new OutputReaderThread();
this.stderrReader = new ErrorReaderThread();
this.stdoutReader.start();
this.stderrReader.start();
}
}
public void releaseAgent() {
if (this.controlAgent != null) {
this.controlAgent._release();
logger.debug("***** [" + Thread.currentThread().getName() + "] " + this + " called _release() on " + this.controlAgent);
} else {
logger.debug("***** [" + Thread.currentThread().getName() + "] " + this + " cannot call _release() on null agent");
}
}
private String[] getUserAndDomain(String user) {
String domainName = "-";
int indexOfForwardSlash = (user = user.replaceAll("\\\\", "/")).indexOf("/");
if (indexOfForwardSlash != -1) {
String usrName = user.substring(indexOfForwardSlash + 1);
domainName = user.substring(0, indexOfForwardSlash);
if ("".equals(domainName)) {
domainName = "-";
}
user = usrName;
}
return new String[]{user, domainName};
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled force condition propagation
* Lifted jumps to return sites
*/
private String createShellScript(String userName, String commandLine) throws IOException {
PrintStream ps = null;
String fileName = null;
File shellScriptFile = null;
try {
fileName = this.service.getName() + "_" + userName + "_" + System.currentTimeMillis() + ".sh";
shellScriptFile = new File(this.processTempDir, fileName);
ps = new PrintStream(shellScriptFile);
ps.println("#!/bin/sh");
ps.println(commandLine);
fileName = shellScriptFile.getCanonicalPath();
java.lang.Object var7_6 = null;
}
catch (Throwable var6_18) {
java.lang.Object var7_7 = null;
try {
if (ps != null) {
ps.close();
}
if (System.getProperty("os.name").toLowerCase().indexOf("win") != -1) throw var6_18;
try {
String[] chmodcommand = new String[]{"chmod", "a+x", fileName.toString()};
Process p = Runtime.getRuntime().exec(chmodcommand);
try {
p.waitFor();
throw var6_18;
}
catch (InterruptedException ie) {
logger.warn("Interrupted waiting for process to terminate", (Throwable)ie);
}
throw var6_18;
}
catch (IOException e) {
logger.error("Service " + this.service + ": Cannot add execute permission on file " + fileName, (Throwable)e);
throw new UndeclaredThrowableException(e, "Error executing process");
}
}
catch (Exception e) {
logger.warn("Error in finalization logic of shell-script creation", (Throwable)e);
}
throw var6_18;
}
try {
if (ps != null) {
ps.close();
}
if (System.getProperty("os.name").toLowerCase().indexOf("win") != -1) return fileName;
try {
String[] chmodcommand = new String[]{"chmod", "a+x", fileName.toString()};
Process p = Runtime.getRuntime().exec(chmodcommand);
try {
p.waitFor();
return fileName;
}
catch (InterruptedException ie) {
logger.warn("Interrupted waiting for process to terminate", (Throwable)ie);
}
return fileName;
}
catch (IOException e) {
logger.error("Service " + this.service + ": Cannot add execute permission on file " + fileName, (Throwable)e);
throw new UndeclaredThrowableException(e, "Error executing process");
}
}
catch (Exception e) {
logger.warn("Error in finalization logic of shell-script creation", (Throwable)e);
return fileName;
}
}
private String[] getNativeDependencies() {
String nativeDepsFileName = "com.adobe.service." + this.service.getName() + ".nativedeps";
File serviceConfigFile = new File(this.service.getPersistentDir(), nativeDepsFileName);
String nativeDependencies = null;
try {
nativeDependencies = FileUtils.readFileToString((File)serviceConfigFile);
}
catch (IOException ioe) {
logger.debug("Unable to retrieve configuration for " + this.service.getName() + ": " + nativeDepsFileName, (Throwable)ioe);
}
if (nativeDependencies == null || nativeDependencies.trim().length() == 0) {
return new String[0];
}
return nativeDependencies.split(",");
}
private String getNativeDependenciesPaths() {
String[] nativeDependencies = this.getNativeDependencies();
StringBuilder sb = new StringBuilder();
for (String nativeDependency : nativeDependencies) {
sb.append(FilenameUtils.concat((String)Platform.UTIL.getCommonNativeDir().toString(), (String)nativeDependency.trim())).append(File.pathSeparator);
}
return sb.toString();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private void doProcessExitCleanup() {
if (!this.plannedShutdown) {
java.lang.Object[] arrobject = new java.lang.Object[3];
arrobject[0] = this.service;
arrobject[1] = this;
arrobject[2] = new Integer(this.process != null ? this.process.exitValue() : -1);
logger.warn("Service {}: Process {} terminated abnormally with error code {}", arrobject);
}
try {
try {
this.manager.deactivate();
ServantBase.deactivateForOwner(this);
}
catch (Exception e) {
logger.error("Unexpected exception while shutting down error thread for " + this.service.getName(), (Throwable)e);
java.lang.Object var3_2 = null;
this.process = null;
this.setReusable(false);
ImpersonatedConnectionManager.releaseCredential(this.service, this);
ResourcePooler.onDeallocate(this);
return;
}
java.lang.Object var3_1 = null;
this.process = null;
this.setReusable(false);
ImpersonatedConnectionManager.releaseCredential(this.service, this);
ResourcePooler.onDeallocate(this);
return;
}
catch (Throwable var2_5) {
java.lang.Object var3_3 = null;
this.process = null;
this.setReusable(false);
ImpersonatedConnectionManager.releaseCredential(this.service, this);
ResourcePooler.onDeallocate(this);
throw var2_5;
}
}
private ImpersonatedConnectionManager.Credential getImpersonationCredential() {
ImpersonatedConnectionManager.Credential cred = ImpersonatedConnectionManager.acquireCredential(this.service, this);
if (cred == null) {
IllegalStateException ise = new IllegalStateException("Could not acquire credential for starting impersonated process.");
logger.error("Service " + this.service.getName() + ": Error obtaining credential for starting impersonated process. " + "Verify your ALC-BMC-001- pool size is not greater than the number of credentials supplied.", (Throwable)ise);
throw ise;
}
return cred;
}
private String quotify(String str) {
return "\"" + str.replaceAll("\\\\", "\\\\\\\\") + "\"";
}
private String substituteVars(String inStr) {
String java_home_32;
String java_home = java_home_32 = System.getenv("JAVA_HOME_32");
if (java_home_32 == null || "".equals(java_home_32)) {
java_home = System.getProperty("java.home");
}
String java_exe_dir = null;
String java_exe = null;
String javaw_exe = null;
String runas_exe = null;
String native_dir = null;
String persistent_dir = null;
String commonNative_dir = null;
String commonJars_dir = null;
String retStr = inStr;
try {
native_dir = this.service.getNativeDir().getCanonicalPath();
persistent_dir = this.service.getPersistentDir().getCanonicalPath();
commonNative_dir = Platform.UTIL.getCommonNativeDir().getCanonicalPath();
commonJars_dir = new File(commonNative_dir + File.separator + ".." + File.separator + "jars").getCanonicalPath();
java_exe_dir = java_home + File.separator + "bin";
if (isWindowsPlatform) {
java_exe = new File(java_exe_dir, "java.exe").getCanonicalPath();
javaw_exe = new File(java_exe_dir, "javaw.exe").getCanonicalPath();
String[] nativeDependencies = this.getNativeDependencies();
File processLauncher = null;
for (String nativeDependency : nativeDependencies) {
nativeDependency = nativeDependency.trim();
String probablePath = commonNative_dir + File.separator + nativeDependency + File.separator + "ProcessLauncher.exe";
File probableFile = new File(probablePath);
if (!probableFile.exists()) continue;
processLauncher = probableFile;
break;
}
if (processLauncher == null) {
processLauncher = new File(commonNative_dir + File.separator + "omniORB_4.1.1_x86_win32_vc10" + File.separator + "ProcessLauncher.exe");
}
runas_exe = processLauncher.getCanonicalPath();
} else {
File sudo;
java_exe = new File(java_exe_dir, "java").getCanonicalPath();
runas_exe = "/usr/bin/sudo";
if (System.getProperty("os.name").indexOf("SunOS") != -1 && !(sudo = new File("/usr/bin/sudo")).exists()) {
sudo = new File("/usr/local/bin/sudo");
runas_exe = "/usr/local/bin/sudo";
if (!sudo.exists()) {
sudo = new File("/opt/sfw/bin/sudo");
runas_exe = "/opt/sfw/bin/sudo";
if (!sudo.exists()) {
runas_exe = "sudo";
}
}
}
}
}
catch (IOException e) {
logger.warn("Error during variable substitution in string " + inStr, (Throwable)e);
}
if (this.isJavaProc && java_exe == null) {
throw new RuntimeException("java_exe is not have a valid Path");
}
retStr = Utilities.replaceAll(retStr, "${JAVA}", java_exe);
retStr = Utilities.replaceAll(retStr, "${JAVAW}", javaw_exe);
retStr = Utilities.replaceAll(retStr, "${RUNAS}", runas_exe);
retStr = Utilities.replaceAll(retStr, "${JAVA_HOME}", java_home);
retStr = Utilities.replaceAll(retStr, "${NATIVE_DIR}", native_dir);
retStr = Utilities.replaceAll(retStr, "${COMMON_NATIVE_DIR}", commonNative_dir);
retStr = Utilities.replaceAll(retStr, "${COMMON_JARS_DIR}", commonJars_dir);
retStr = Utilities.replaceAll(retStr, "${PERSISTENT_DIR}", persistent_dir);
return retStr;
}
private void createTempDir(String serviceName) throws IOException {
String filenameSeperator = "_";
String procTempDirPrefix = "p";
String serviceTempDir = this.service.getTempDir().getCanonicalPath();
long dateInMili = System.currentTimeMillis();
String processTempDirName = serviceTempDir + File.separatorChar + "p" + dateInMili;
File ptd = new File(processTempDirName);
if (ptd.exists()) {
byte[] seed = random.generateSeed(4);
random.setSeed(seed);
ptd = new File(processTempDirName + "_" + random.nextInt());
}
if (!ptd.exists()) {
try {
boolean retCondition = ptd.mkdirs();
if (!retCondition) {
throw new IOException("Could not create temporary directory " + ptd);
}
}
catch (SecurityException se) {
logger.warn("Security error creating temp folders", (Throwable)se);
throw se;
}
}
this.processTempDir = ptd;
}
public String getProcessTempDirPath() {
return this.processTempDir.getPath();
}
public String getNativeDirPath() {
return this.nativeDirPath;
}
public String getPersistentDirPath() {
return this.persistentDirPath;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public final java.lang.Object allocateConnection() {
try {
int logLevel;
if (this.CtrlLogOptimization && (logLevel = this.checkLogLevelChange()) != -1) {
this.controlAgent.setLogLevel(logLevel);
}
if (this.jdkLog) {
ArrayList<CategoryTable> catTabSeq = new ArrayList<CategoryTable>();
for (String key : this.jdkLogLevelTable.keySet()) {
int jdkLogLevel = this.checkJdkLogLevelChange(key);
if (jdkLogLevel == -1) continue;
CategoryTable catTab = new CategoryTable();
catTab.category = key;
catTab.level = jdkLogLevel;
catTabSeq.add(catTab);
this.jdkLogLevelTable.put(key, new Integer(jdkLogLevel));
}
CategoryTable[] catTabArray = catTabSeq.toArray(new CategoryTable[0]);
if (catTabArray.length > 0) {
this.controlAgent.setJdkLogLevel(catTabArray);
}
}
Object rtn = null;
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Object.class.getClassLoader());
rtn = this.controlAgent.newRequestHandler();
java.lang.Object var7_9 = null;
Thread.currentThread().setContextClassLoader(old);
}
catch (Throwable var6_11) {
java.lang.Object var7_10 = null;
Thread.currentThread().setContextClassLoader(old);
throw var6_11;
}
return rtn;
}
catch (SystemException ex) {
logger.error("Unexpected CORBA exception while allocating a connection by service " + this.service.getName(), (Throwable)ex);
throw ex;
}
}
protected final void onPrepare() throws Resource.Rollback {
try {
if (!this.controlAgent.prepare()) {
throw new Resource.Rollback(this);
}
}
catch (SystemException ex) {
logger.error("Unexpected CORBA exception while preparing to commit by service " + this.service.getName(), (Throwable)ex);
throw ex;
}
}
protected final void onCommit() {
try {
this.controlAgent.done(true);
}
catch (SystemException ex) {
logger.error("Unexpected exception while committing", (Throwable)ex);
throw ex;
}
}
protected final void onRollback() {
try {
this.controlAgent.done(false);
}
catch (SystemException ex) {
logger.error("Unexpected exception while rolling back transaction", (Throwable)ex);
}
}
public final void onShutdown() {
this.stopProcess();
}
protected void onProcessEnd() {
}
private void stopProcess() {
try {
if (this.process != null) {
logger.info("Service {}: Native process {} stopping", (java.lang.Object)this.service, (java.lang.Object)this);
this.plannedShutdown = true;
this.process.getOutputStream().close();
do {
try {
this.stdoutReader.join(10000);
break;
}
catch (InterruptedException e) {
logger.debug("Interrupted waiting for thread to terminate. Trying again...", (Throwable)e);
continue;
}
break;
} while (true);
do {
try {
this.stderrReader.join(10000);
break;
}
catch (InterruptedException e) {
logger.debug("Interrupted waiting for thread to terminate. Trying again...", (Throwable)e);
continue;
}
break;
} while (true);
if (this.process != null) {
logger.info("Service {}: Native process {} destroying", (java.lang.Object)this.service, (java.lang.Object)this);
this.process.destroy();
}
}
}
catch (Exception e) {
logger.warn("Error stopping process", (Throwable)e);
}
}
protected final void onComplete() {
++this.reuseCount;
boolean reuse = this.reuseCount < this.myMaximumReUseCount;
this.setReusable(reuse);
if (!reuse) {
logger.info("Service {}: Process {} retired after {} uses", new java.lang.Object[]{this.service, this, new Integer(this.reuseCount)});
this.stopProcess();
this.doProcessExitCleanup();
}
this.clearConnection();
}
private int checkLogLevelChange() {
return -1;
}
private int checkJdkLogLevelChange(String cat) {
return -1;
}
private boolean needToAddExt() {
try {
String os = System.getProperty("os.name");
if (!Platform.UTIL.getAppServer().equalsIgnoreCase("webas") || os.indexOf("Linux") == -1) {
return false;
}
String version = System.getProperty("os.version");
Pattern p = Pattern.compile("[\\d\\.]+");
Matcher m = p.matcher(version);
if (m.find()) {
int nStart = m.start();
int nEnd = m.end();
String kver = version.substring(nStart, nEnd);
logger.debug("Service {}: Kernel version is {}", (java.lang.Object)this.service.getName(), (java.lang.Object)kver);
int major = 0;
int minor = 0;
int teeny = 0;
StringTokenizer st = new StringTokenizer(kver, ".", false);
if (st.hasMoreElements()) {
String majorString = (String)st.nextElement();
major = Integer.parseInt(majorString);
}
if (major < 2) {
return true;
}
if (major > 2) {
return false;
}
if (!st.hasMoreElements()) {
return true;
}
String minorString = (String)st.nextElement();
minor = Integer.parseInt(minorString);
if (minor < 4) {
return true;
}
if (minor > 4) {
return false;
}
if (!st.hasMoreElements()) {
return true;
}
String teenyString = (String)st.nextElement();
teeny = Integer.parseInt(teenyString);
if (teeny < 20) {
return true;
}
}
}
catch (Exception e) {
logger.error("Unexpected exception while checking kernel version.", (Throwable)e);
}
return false;
}
private boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; ++i) {
boolean success = this.deleteDir(new File(dir, children[i]));
if (success) continue;
return false;
}
}
return dir.delete();
}
static /* synthetic */ void access$1000(ProcessResource x0) {
x0.doProcessExitCleanup();
}
static /* synthetic */ File access$1100(ProcessResource x0) {
return x0.processTempDir;
}
static /* synthetic */ boolean access$1200(ProcessResource x0, File x1) {
return x0.deleteDir(x1);
}
static {
try {
random = SecureRandom.getInstance("SHA1PRNG");
}
catch (NoSuchAlgorithmException e) {
logger.debug("Algorithm Cannot Be Found", (Throwable)e);
}
}
private class OutputReaderThread
extends ReaderThread {
public OutputReaderThread() {
super(ProcessResource.this + " Output Reader", ProcessResource.this.process.getInputStream(), System.out);
}
}
private class ErrorReaderThread
extends ReaderThread {
public ErrorReaderThread() {
super(ProcessResource.this + " Error Reader", ProcessResource.this.process.getErrorStream(), System.err);
}
/*
* 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 void run() {
super.run();
try {
block11 : {
try {
if (ProcessResource.access$900(ProcessResource.this) == null) break block11;
ProcessResource.access$900(ProcessResource.this).getOutputStream().close();
}
catch (IOException e) {
ProcessResource.access$200().warn("Error closing process output-stream", (Throwable)e);
var3_2 = null;
do {
try {
if (ProcessResource.access$900(ProcessResource.this) == null) break;
ProcessResource.access$900(ProcessResource.this).waitFor();
break;
}
catch (InterruptedException e) {
ProcessResource.access$200().warn("Interrupted waiting for process to terminate. Trying again...", (Throwable)e);
continue;
}
break;
} while (true);
ProcessResource.this.onProcessEnd();
ProcessResource.access$1000(ProcessResource.this);
if (ProcessResource.access$1200(ProcessResource.this, ProcessResource.access$1100(ProcessResource.this)) != false) return;
ProcessResource.access$200().error("Datamanager cannot remove directory {}", (java.lang.Object)ProcessResource.access$1100(ProcessResource.this));
return;
}
}
var3_1 = null;
** GOTO lbl29
}
catch (Throwable var2_8) {
** GOTO lbl42
lbl29: // 1 sources:
do {
try {}
catch (InterruptedException e) {
ProcessResource.access$200().warn("Interrupted waiting for process to terminate. Trying again...", (Throwable)e);
continue;
}
if (ProcessResource.access$900(ProcessResource.this) == null) break;
ProcessResource.access$900(ProcessResource.this).waitFor();
break;
break;
} while (true);
ProcessResource.this.onProcessEnd();
ProcessResource.access$1000(ProcessResource.this);
if (ProcessResource.access$1200(ProcessResource.this, ProcessResource.access$1100(ProcessResource.this)) != false) return;
ProcessResource.access$200().error("Datamanager cannot remove directory {}", (java.lang.Object)ProcessResource.access$1100(ProcessResource.this));
return;
lbl42: // 1 sources:
var3_3 = null;
do {
try {}
catch (InterruptedException e) {
ProcessResource.access$200().warn("Interrupted waiting for process to terminate. Trying again...", (Throwable)e);
continue;
}
if (ProcessResource.access$900(ProcessResource.this) == null) break;
ProcessResource.access$900(ProcessResource.this).waitFor();
break;
break;
} while (true);
ProcessResource.this.onProcessEnd();
ProcessResource.access$1000(ProcessResource.this);
if (ProcessResource.access$1200(ProcessResource.this, ProcessResource.access$1100(ProcessResource.this)) != false) throw var2_8;
ProcessResource.access$200().error("Datamanager cannot remove directory {}", (java.lang.Object)ProcessResource.access$1100(ProcessResource.this));
throw var2_8;
}
}
}
private class ReaderThread
extends Thread {
private InputStream in;
private PrintStream out;
private final int BUFLEN = 512;
private byte[] buffer;
ReaderThread(String name, InputStream in, PrintStream out) {
super(name);
this.in = null;
this.out = null;
this.BUFLEN = 512;
this.buffer = new byte[512];
this.in = in;
this.out = out;
}
/*
* 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 void run() {
try {
try {}
catch (IOException e) {
ProcessResource.access$200().warn("Error reading process error/input stream", (Throwable)e);
var3_4 = null;
try {
if (this.in == null) return;
this.in.close();
return;
}
catch (IOException e1) {
ProcessResource.access$200().warn("Error closing process error/input stream", (Throwable)e1);
return;
}
}
}
catch (Throwable throwable) {
var3_5 = null;
** try [egrp 2[TRYBLOCK] [4 : 67->84)] {
lbl19: // 1 sources:
if (this.in == null) throw throwable;
this.in.close();
throw throwable;
lbl22: // 1 sources:
catch (IOException e1) {
ProcessResource.access$200().warn("Error closing process error/input stream", (Throwable)e1);
}
throw throwable;
}
do {
if ((bytesRead = this.in.read(this.buffer)) == -1) break;
this.out.write(this.buffer, 0, bytesRead);
} while (true);
var3_3 = null;
try {}
catch (IOException e1) {
ProcessResource.access$200().warn("Error closing process error/input stream", (Throwable)e1);
return;
}
if (this.in == null) return;
this.in.close();
}
}
class ManagerImpl
extends ServantBase
implements ManagerOperations {
private final String lineSeperator;
ManagerImpl() {
this.lineSeperator = System.getProperty("line.separator");
this.activateWithOwner(ProcessResource.this);
}
public final void registerController(ControlAgent cb) {
ProcessResource.this.controlAgent = cb;
logger.debug("Service {}: Controller registered", (java.lang.Object)ProcessResource.this.service.getName());
}
public void signalEvent(String event) {
logger.debug("Service {}: Signal {} received", (java.lang.Object)ProcessResource.this.service.getName(), (java.lang.Object)event);
if (event.equals("READY")) {
ProcessResource.this.setReady(true);
}
if (event.equals("DISABLE")) {
ProcessResource.this.service.disableService();
}
}
public void signalStringValue(String name, String value) {
logger.debug("Service {}: Signal name {} : value {} received", new java.lang.Object[]{ProcessResource.this.service.getName(), name, value});
if (name.equals("CTRL_CAPABILITY")) {
if (value.indexOf("CAP_LOG_OPT") != -1) {
ProcessResource.this.CtrlLogOptimization = true;
}
if (value.indexOf("CAP_JDK_LOG") != -1) {
ProcessResource.this.jdkLog = true;
}
}
}
public void signalIntValue(String name, int value) {
if (name.equals("PID")) {
ProcessResource.this.pid = value;
logger.info("Service {}: Native process PID = {}", (java.lang.Object)ProcessResource.this.service, (java.lang.Object)Integer.toString(value));
}
}
public String getProcessTempDirPath() {
return ProcessResource.this.getProcessTempDirPath();
}
public String getPersistentDirPath() {
return ProcessResource.this.getPersistentDirPath();
}
public String getNativeDirPath() {
return ProcessResource.this.getNativeDirPath();
}
public float getConfigPropertyFloat(String name) throws NoSuchPropertyException {
try {
Method m = ProcessResource.this.service.getClass().getMethod("get" + name, null);
if (m != null) {
Float frtn = (Float)m.invoke(ProcessResource.this.service, null);
return frtn.floatValue();
}
throw new Exception();
}
catch (SecurityException se) {
logger.warn("Security error retrieving property " + name + " from service", (Throwable)se);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + se);
}
catch (Exception e) {
logger.debug("Error retrieving property " + name + " from service. Trying system property...", (Throwable)e);
try {
String prop = System.getProperty(name);
if (prop == null) {
logger.debug("Service " + ProcessResource.this.service.getName() + ": No such property " + name, (Throwable)e);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e);
}
float rtn2 = Float.parseFloat(prop);
return rtn2;
}
catch (Exception e2) {
logger.warn("Error retrieving float-type system property " + name, (Throwable)e2);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e2);
}
}
}
public boolean getConfigPropertyBoolean(String name) throws NoSuchPropertyException {
try {
Method m = ProcessResource.this.service.getClass().getMethod("get" + name, null);
Boolean brtn = (Boolean)m.invoke(ProcessResource.this.service, null);
return brtn;
}
catch (SecurityException se) {
logger.warn("Security error retrieving property " + name + " from service", (Throwable)se);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + se);
}
catch (Exception e) {
logger.debug("Error retrieving property " + name + " from service. Trying system property...", (Throwable)e);
try {
String prop = System.getProperty(name);
if (prop == null) {
logger.debug("Service {}: No such property {}", (java.lang.Object)ProcessResource.this.service.getName(), (java.lang.Object)name);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e);
}
boolean rtn2 = new Boolean(prop);
return rtn2;
}
catch (Exception e2) {
logger.error("Unexpected exception while retrieving property " + name, (Throwable)e2);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e2);
}
}
}
public String getConfigPropertyString(String name) throws NoSuchPropertyException {
try {
logger.debug("Entering getConfigPropertyString");
logger.debug("getConfigPropertyString: Service Obj = " + ProcessResource.this.service);
logger.debug("getConfigPropertyString: Property Name = " + name);
Method m = ProcessResource.this.service.getClass().getMethod("get" + name, null);
logger.debug("getConfigPropertyString: Preparing to invoke get" + name);
String rtn = (String)m.invoke(ProcessResource.this.service, null);
if (rtn == null) {
logger.debug("Service {}: Property {} returned null", (java.lang.Object)ProcessResource.this.service.getName(), (java.lang.Object)name);
throw new NoSuchPropertyException(name);
}
return rtn;
}
catch (SecurityException se) {
logger.warn("Security error retrieving property " + name + " from service", (Throwable)se);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + se);
}
catch (Exception e) {
logger.debug("Error retrieving property " + name + " from service. Trying system property...", (Throwable)e);
try {
String rtn2 = null;
rtn2 = name != null && name.trim().equalsIgnoreCase("com.adobe.tempDirectory") ? ProcessResource.this.service.getTempDir().getParent() : System.getProperty(name);
if (rtn2 == null) {
logger.debug("Service {}: No such property {}", (java.lang.Object)ProcessResource.this.service.getName(), (java.lang.Object)name);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By: " + e);
}
return rtn2;
}
catch (Exception e2) {
logger.debug("Error retrieving system property: " + name, (Throwable)e2);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By: " + e2);
}
}
}
public int getConfigPropertyInt(String name) throws NoSuchPropertyException {
try {
Method m = ProcessResource.this.service.getClass().getMethod("get" + name, null);
Integer irtn = (Integer)m.invoke(ProcessResource.this.service, null);
return irtn;
}
catch (SecurityException se) {
logger.warn("Security exception while retrieving property '" + name + "' from service", (Throwable)se);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + se);
}
catch (Exception e) {
logger.debug("Error retrieving property '" + name + "' from service. Trying system property...", (Throwable)e);
try {
String prop = System.getProperty(name);
if (prop == null) {
logger.debug("Service {}: No such property {}", (java.lang.Object)ProcessResource.this.service.getName(), (java.lang.Object)name);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e);
}
int rtn2 = Integer.parseInt(prop);
return rtn2;
}
catch (Exception e2) {
logger.warn("Error retrieving int-type system property " + name, (Throwable)e2);
throw new NoSuchPropertyException(name + this.lineSeperator + "Caused By:" + e2);
}
}
}
public void setConfigPropertyBoolean(String name, boolean val) throws NoSuchPropertyException {
}
public void setConfigPropertyString(String name, String val) throws NoSuchPropertyException {
}
public void setConfigPropertyInt(String name, int val) throws NoSuchPropertyException {
}
public void setConfigPropertyFloat(String name, float val) throws NoSuchPropertyException {
}
public String getDeployPropertyString(String bundle, String name) throws NoSuchPropertyException {
try {
ResourceBundle bundleObj = ResourceBundle.getBundle(bundle, Locale.getDefault(), ProcessResource.this.service.getClass().getClassLoader());
return bundleObj.getString(name);
}
catch (Exception e) {
logger.error("Unexpected exception while retrieving config deploy property " + name, (Throwable)e);
throw new NoSuchPropertyException(name);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public final Object getResource(String resourceType) {
try {
try {
ProcessResource.this.peer.resumeTx();
Object object = Platform.UTIL.lookup(resourceType);
java.lang.Object var8_5 = null;
ProcessResource.this.peer.suspendTx();
return object;
}
catch (NameNotFoundException e) {
logger.error("Service " + ProcessResource.this.service.getName() + ": Cannot find service " + resourceType, (Throwable)e);
Object object = null;
java.lang.Object var8_6 = null;
ProcessResource.this.peer.suspendTx();
return object;
}
catch (Throwable e) {
logger.debug("Tracing original error thrown on resource-lookup before unwrapping.", e);
Throwable exp = e;
if (e instanceof UndeclaredThrowableException) {
exp = ((UndeclaredThrowableException)e).getCause();
}
logger.error("Unexpected exception while resolving a connection to an Adobe Service upon another Adobe Service request.", exp);
Object object = null;
java.lang.Object var8_7 = null;
ProcessResource.this.peer.suspendTx();
return object;
}
}
catch (Throwable throwable) {
java.lang.Object var8_8 = null;
ProcessResource.this.peer.suspendTx();
throw throwable;
}
}
private void log(Logger logger, String formattedMessage, String[] params, int level) {
switch (level) {
case 0:
case 2:
case 3: {
logger.error(formattedMessage, (java.lang.Object[])params);
break;
}
case 1:
case 4: {
logger.warn(formattedMessage, (java.lang.Object[])params);
break;
}
case 7: {
logger.debug(formattedMessage, (java.lang.Object[])params);
break;
}
default: {
logger.info(formattedMessage, (java.lang.Object[])params);
}
}
}
private String getMessage(LogEntry le) {
if (le.templateId == null) {
return null;
}
if (le.params == null || le.params.length == 0) {
return le.templateId;
}
return MessageFormat.format(le.templateId, le.params);
}
public final void log(LogEntry[] logEntries) {
for (int i = 0; i < logEntries.length; ++i) {
LogEntry logEntry = logEntries[i];
this.log(ProcessResource.this.loggerBMC, this.getMessage(logEntry), logEntry.params, logEntry.level);
}
}
private String getJdkMessage(JdkLogEntry le) {
if (le.templateId == null) {
return null;
}
if (le.params == null || le.params.length == 0) {
return le.templateId;
}
return MessageFormat.format(le.templateId, le.params);
}
public final void logJdk(JdkLogEntry[] jdkLogEntries) {
try {
for (int i = 0; i < jdkLogEntries.length; ++i) {
JdkLogEntry jdkLogEntry = jdkLogEntries[i];
Logger loggerBslj = (Logger)ProcessResource.this.jdkLoggerTable.get(jdkLogEntry.category);
if (loggerBslj == null) {
loggerBslj = LoggerFactory.getLogger((String)jdkLogEntry.category);
}
this.log(loggerBslj, this.getJdkMessage(jdkLogEntry), jdkLogEntry.params, jdkLogEntry.level);
}
}
catch (Exception ex) {
logger.error("Unexpected exception while logging BSLJ service", (Throwable)ex);
}
}
public final int getJdkLogLevel(String category) {
Logger testLogger = LoggerFactory.getLogger((String)category);
int testLevel = -1;
ProcessResource.this.jdkLogLevelTable.put(category, new Integer(testLevel));
ProcessResource.this.jdkLoggerTable.put(category, testLogger);
return testLevel;
}
}
}