6
6
import java .net .*;
7
7
import java .io .*;
8
8
import java .util .*;
9
- import sun . misc . BASE64Encoder ;
9
+ import org . apache . commons . codec . binary . Base64 ;
10
10
import java .io .BufferedReader ;
11
11
import java .io .BufferedWriter ;
12
12
import java .io .ByteArrayInputStream ;
@@ -64,7 +64,7 @@ public class ECLSoap {
64
64
private String maxReturn = "" ;
65
65
private String cluster = "" ;
66
66
private boolean includeML = false ;
67
-
67
+ private int maxRunTime = 300 ; //in seconds, 300 is server default;
68
68
private String outputName = "" ;
69
69
70
70
private String wuid = "" ;
@@ -73,6 +73,7 @@ public class ECLSoap {
73
73
74
74
private int errorCount = 0 ;
75
75
private int warningCount = 0 ;
76
+ private String errorText = "" ;
76
77
77
78
private String user = "" ;
78
79
private String pass = "" ;
@@ -239,6 +240,8 @@ public void setIncludeSALT(boolean includeSALT) {
239
240
//end getters and setters
240
241
241
242
243
+
244
+
242
245
public ECLSoap () {
243
246
if (System .getProperty ("os.name" ).startsWith ("Windows" )) {
244
247
this .tempDir = System .getProperty ("java.io.tmpdir" );
@@ -249,7 +252,15 @@ public ECLSoap() {
249
252
250
253
//System.out.println("OS Temp Dir is: " + tempDir);
251
254
}
252
- public String syntaxCheck (String ecl ){
255
+ public String getErrorText () {
256
+ return errorText ;
257
+ }
258
+
259
+ public void setErrorText (String errorText ) {
260
+ this .errorText = errorText ;
261
+ }
262
+
263
+ public String syntaxCheck (String ecl ){
253
264
String res = "" ;
254
265
int test = 0 ;
255
266
String inFile = this .outputName + "CheckSpoonEclCode.ecl" ;
@@ -324,6 +335,12 @@ public String syntaxCheck(String ecl){
324
335
325
336
pb .redirectErrorStream (true ); // merge stdout, stderr of process
326
337
System .out .println (pb .command ().toString ());
338
+ boolean pathExists = (new File (eclccInstallDir )).exists ();
339
+ if (!pathExists ){
340
+ errorCount ++;
341
+ res += "Unable to locate the ecl compiler, Check Global Variables\r \n " ;
342
+ errorText += "Unable to locate the ecl compiler, Check Global Variables\r \n " ;
343
+ }
327
344
File path = new File (eclccInstallDir );
328
345
pb .directory (path );
329
346
Process p = pb .start ();
@@ -333,6 +350,7 @@ public String syntaxCheck(String ecl){
333
350
String line ;
334
351
while ((line = br .readLine ()) != null ){
335
352
res += cleanError (line )+"\r \n " ;
353
+ errorText += cleanError (line )+"\r \n " ;
336
354
}
337
355
338
356
InputStream iError = p .getErrorStream ();
@@ -342,6 +360,7 @@ public String syntaxCheck(String ecl){
342
360
while ((lineErr = brErr .readLine ()) != null ){
343
361
344
362
res += cleanError (lineErr )+"\r \n " ;
363
+ errorText += cleanError (lineErr )+"\r \n " ;
345
364
}
346
365
347
366
//deleteFile(this.tempDir+inFile);
@@ -388,7 +407,7 @@ public String cleanError(String in){
388
407
String ec = matcher .group ();
389
408
390
409
try {
391
- this .errorCount = Integer .parseInt (ec );
410
+ this .errorCount = Integer .parseInt (ec ) + this . errorCount ;
392
411
}catch (Exception ee ){
393
412
394
413
}
@@ -415,7 +434,7 @@ public String cleanError(String in){
415
434
String wc = matcher .group ();
416
435
417
436
try {
418
- this .warningCount = Integer .parseInt (wc );
437
+ this .warningCount = Integer .parseInt (wc ) + this . warningCount ;
419
438
}catch (Exception we ){
420
439
421
440
}
@@ -730,13 +749,16 @@ public void submitSoapCall(String wuid){
730
749
"<soapenv:Body>" +
731
750
"<WUSubmit xmlns=\" urn:hpccsystems:ws:wsworkunits\" >" +
732
751
"<Wuid>" + wuid + "</Wuid>" +
752
+ "<MaxRunTime>" + maxRunTime + "<MaxRunTime>" +
733
753
"<Cluster>" + this .cluster + "</Cluster>" +
734
754
"</WUSubmit>" +
735
755
"</soapenv:Body>" +
736
756
"</soapenv:Envelope>" ;
737
757
738
758
String path = "/WsWorkunits/WUSubmit" ;
739
759
InputStream is2 = this .doSoap (xml , path );
760
+
761
+ //need to check for errors here
740
762
}
741
763
742
764
/*
@@ -1139,7 +1161,7 @@ public InputStream doSoap(String xmldata, String path){
1139
1161
URLConnection conn = null ;
1140
1162
boolean isError = false ;
1141
1163
boolean isSuccess = false ;
1142
-
1164
+
1143
1165
int errorCnt = 0 ;
1144
1166
InputStream is = null ;
1145
1167
while (errorCnt < 5 && !isSuccess && !isLogonFail ){
@@ -1167,8 +1189,7 @@ public InputStream doSoap(String xmldata, String path){
1167
1189
if (!user .equals ("" )){
1168
1190
String authStr = user + ":" + pass ;
1169
1191
//System.out.println("USER INFO: " + authStr);
1170
- BASE64Encoder encoder = new BASE64Encoder ();
1171
- String encoded = encoder .encode (authStr .getBytes ());
1192
+ String encoded = new String (Base64 .encodeBase64 (authStr .getBytes ()));
1172
1193
1173
1194
1174
1195
conn .setRequestProperty ("Authorization" ,"Basic " +encoded );
@@ -1266,7 +1287,12 @@ private String compileECL(String ecl){
1266
1287
1267
1288
// System.out.println("_________________________ECLCC_______________________________");
1268
1289
1269
-
1290
+ boolean pathExists = (new File (eclccInstallDir )).exists ();
1291
+ if (!pathExists ){
1292
+ errorCount ++;
1293
+ errorText += "Unable to locate the ecl compiler, Check Global Variables\r \n " ;
1294
+ }
1295
+
1270
1296
ArrayList <String > paramsAL = new ArrayList <String >();
1271
1297
paramsAL .add (c );
1272
1298
paramsAL .add ("-E" );
@@ -1322,9 +1348,9 @@ private String compileECL(String ecl){
1322
1348
// System.out.println("+++++++++++++++++++++");
1323
1349
// System.out.println("+++++++++++++++++++++");
1324
1350
// System.out.println("+++++++++++++++++++++");
1325
- System .out .println ("++++++++++Compile ECLSOAP+++++++++++" );
1326
- System .out .println ("+++++++++++++++++++++" );
1327
- System .out .println (pb .command ().toString ());
1351
+ // System.out.println("++++++++++Compile ECLSOAP+++++++++++");
1352
+ // System.out.println("+++++++++++++++++++++");
1353
+ // System.out.println(pb.command().toString());
1328
1354
pb .redirectErrorStream (true ); // merge stdout, stderr of process
1329
1355
1330
1356
File path = new File (eclccInstallDir );
@@ -1337,7 +1363,7 @@ private String compileECL(String ecl){
1337
1363
String lineErr ;
1338
1364
while ((lineErr = brErr .readLine ()) != null ){
1339
1365
//System.out.println("#####"+lineErr);
1340
-
1366
+ errorText += lineErr + " \r \n " ;
1341
1367
}
1342
1368
1343
1369
InputStream is = p .getInputStream ();
@@ -1347,6 +1373,7 @@ private String compileECL(String ecl){
1347
1373
1348
1374
while ((line = br .readLine ()) != null ){
1349
1375
//System.out.println(line);
1376
+
1350
1377
}
1351
1378
1352
1379
@@ -1453,10 +1480,20 @@ public static void main(String[] args){
1453
1480
System .out .println (line );
1454
1481
}
1455
1482
1483
+
1484
+
1456
1485
}catch (Exception e ){
1457
1486
System .out .println (e .toString ());
1458
1487
e .printStackTrace ();
1459
1488
}
1489
+
1490
+ ECLSoap es = new ECLSoap ();
1491
+ es .setCluster ("mythor" );
1492
+ es .setHostname ("10.239.227.6" );
1493
+ es .setEclccInstallDir (eclccInstallDir );
1494
+ es .setJobName ("test" );
1495
+ es .executeECL ("output('hi');" );
1496
+
1460
1497
}
1461
1498
1462
1499
/*
@@ -1499,7 +1536,15 @@ private static String openFile(String filePath){
1499
1536
return fileData .toString ();
1500
1537
}
1501
1538
1502
- /*
1539
+ public int getMaxRunTime () {
1540
+ return maxRunTime ;
1541
+ }
1542
+
1543
+ public void setMaxRunTime (int maxRunTime ) {
1544
+ this .maxRunTime = maxRunTime ;
1545
+ }
1546
+
1547
+ /*
1503
1548
* ECLAuthenticator
1504
1549
*
1505
1550
* Hnadles the http authentication for the soap request
0 commit comments