From 83a2aec26047d8d59f9c7d128dc37490445c3252 Mon Sep 17 00:00:00 2001 From: James McMullan Date: Fri, 21 Sep 2018 15:46:39 -0400 Subject: [PATCH] Code review changes - Moved to an older version of log4j that doesnt require newer Java versions - Deprecated Utils.print & Utils.println - Changed default log level in print & println to info / warn - Added log function to Utils for end users to potential use - Reversed logging changes in rdf2hpcc & clienttools --- .../hpccsystems/clienttools/EclCompile.java | 6 +- rdf2hpcc/log4j.properties | 6 - rdf2hpcc/pom.xml | 5 - .../hpccsystems/rdf/rdf2hpcc/RDF2HPCC.java | 81 ++++++----- .../rdf/rdf2hpcc/RDFHPCCWsClient.java | 126 +++++++++--------- wsclient/pom.xml | 6 +- .../ws/client/HPCCFileSprayClient.java | 4 +- .../hpccsystems/ws/client/HPCCWsClient.java | 4 +- .../ws/client/HPCCWsDFUClient.java | 4 +- .../ws/client/HPCCWsFileIOClient.java | 4 +- .../ws/client/HPCCWsPackageProcessClient.java | 4 +- .../ws/client/HPCCWsTopologyClient.java | 4 +- .../ws/client/HPCCWsWorkUnitsClient.java | 4 +- .../ws/client/antlr/EclRecordReader.java | 4 +- .../extended/HPCCWsAttributesClient.java | 4 +- .../ws/client/extended/HPCCWsSQLClient.java | 4 +- .../ws/client/utils/Connection.java | 4 +- .../org/hpccsystems/ws/client/utils/Sftp.java | 4 +- .../hpccsystems/ws/client/utils/Utils.java | 56 +++++--- 19 files changed, 169 insertions(+), 165 deletions(-) delete mode 100644 rdf2hpcc/log4j.properties diff --git a/clienttools/src/main/java/org/hpccsystems/clienttools/EclCompile.java b/clienttools/src/main/java/org/hpccsystems/clienttools/EclCompile.java index d197e95e8..69233f7b7 100644 --- a/clienttools/src/main/java/org/hpccsystems/clienttools/EclCompile.java +++ b/clienttools/src/main/java/org/hpccsystems/clienttools/EclCompile.java @@ -1,7 +1,5 @@ package org.hpccsystems.clienttools; -import org.apache.logging.log4j.*; - import java.io.BufferedReader; import java.io.File; import java.io.InputStream; @@ -14,8 +12,6 @@ public class EclCompile { - private static final Logger log = LogManager.getLogger(EclCompile.class.getName()); - /** * @param ecl - the ecl text to compile * @param eclccInstallDir - the installation dir of eclcc/eclcc.exe @@ -197,7 +193,7 @@ else if (!cf.canExecute()) } catch (Exception e) { - log.error(e.toString()); + System.out.println(e.toString()); e.printStackTrace(); } diff --git a/rdf2hpcc/log4j.properties b/rdf2hpcc/log4j.properties deleted file mode 100644 index 2c4206e53..000000000 --- a/rdf2hpcc/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootLogger=INFO, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -log4j.appender.stdout.layout.ConversionPattern=%d %p %t %C - %m%n \ No newline at end of file diff --git a/rdf2hpcc/pom.xml b/rdf2hpcc/pom.xml index 3f7bb2e93..d6dbcb62f 100644 --- a/rdf2hpcc/pom.xml +++ b/rdf2hpcc/pom.xml @@ -79,11 +79,6 @@ jena-core 2.7.4 - - org.apache.logging.log4j - log4j-api - 2.10.0 - junit junit diff --git a/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDF2HPCC.java b/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDF2HPCC.java index d96896c11..8283fa481 100644 --- a/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDF2HPCC.java +++ b/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDF2HPCC.java @@ -5,15 +5,12 @@ import java.util.StringTokenizer; import java.io.File; -import org.apache.logging.log4j.*; - import org.hpccsystems.ws.client.utils.Connection; import org.hpccsystems.ws.client.utils.Utils; public class RDF2HPCC { static private final String PARAMPREFIX = "-(?i)"; - static private final Logger log = LogManager.getLogger( RDF2HPCC.class.getName() ); static public final String RDFDATALOCPATTERN = PARAMPREFIX + "rdflocation"; static public final String HPCCFILEPATTERN = PARAMPREFIX + "hpccfile"; @@ -90,20 +87,20 @@ private boolean processRDF2HPCCArgs(String[] args, RDFHPCCWsClient connector) } else { - log.error( "ERROR: " + currentParam + "=??"); + Utils.println(System.out, "ERROR: " + currentParam + "=??", false, false); return false; } if (currentParam.matches(RDFDATALOCPATTERN)) { connector.setTargetRDFDataPath(currentParamVal); - log.trace("TARGET RDF location: " + currentParamVal); + Utils.println(System.out, "TARGET RDF location: " + currentParamVal, false, false); rdffile = true; } else if (currentParam.matches(HPCCFILEPATTERN)) { connector.setTargetHPCCFilePath(currentParamVal); - log.trace("TARGET HPCC FILE: " + currentParamVal); + Utils.println(System.out, "TARGET HPCC FILE: " + currentParamVal, false, false); hpccfile = true; } else if (currentParam.matches(RDFLANGPATTERN)) @@ -113,106 +110,106 @@ else if (currentParam.matches(RDFLANGPATTERN)) else if (currentParam.matches(ECLWATCHPROTPATTERN)) { protocol = currentParamVal; - log.trace("TARGET HPCC ECL Watch protocol: " + currentParamVal); + Utils.println(System.out, "TARGET HPCC ECL Watch protocol: " + currentParamVal, false, false); } else if (currentParam.matches(ECLWATCHIPPATTERN)) { host = currentParamVal; - log.trace("TARGET HPCC ECL Watch IP: " + currentParamVal); + Utils.println(System.out, "TARGET HPCC ECL Watch IP: " + currentParamVal, false, false); } else if (currentParam.matches(ECLWATCHPORTPATTERN)) { port = currentParamVal; - log.trace("TARGET HPCC ECL Watch Port: " + currentParamVal); + Utils.println(System.out, "TARGET HPCC ECL Watch Port: " + currentParamVal, false, false); } else if (currentParam.matches(DROPZONEPATTERN)) { connector.setTargetHPCCDropzonePath(currentParamVal); - log.trace("TARGET HPCC dropzone path: " + currentParamVal); + Utils.println(System.out, "TARGET HPCC dropzone path: " + currentParamVal, false, false); } else if (currentParam.matches(DESTGROUPPATTERN)) { connector.setTargetDestinationGroup(currentParamVal); - log.trace("Dest group: " + currentParamVal); + Utils.println(System.out, "Dest group: " + currentParamVal, false, false); } else if (currentParam.matches(SPRAYPATTERN)) { boolean performSpray = Boolean.parseBoolean(currentParamVal); setPerformspray(performSpray); - log.trace("Perform Spray: " + performSpray); + Utils.println(System.out, "Perform Spray: " + performSpray, false, false); } else if (currentParam.matches(VERBOSEPATTERN)) { boolean verbosemode = Boolean.parseBoolean(currentParamVal); connector.setVerbosemode(verbosemode); - log.trace("Verbose mode: " + verbosemode); + Utils.println(System.out, "Verbose mode: " + verbosemode, false, false); } else if (currentParam.matches(OVERWRITEPATTERN)) { boolean overwrite = Boolean.parseBoolean(currentParamVal); connector.setOverwrite(overwrite); - log.trace("Overwrite HPCC files: " + overwrite); + Utils.println(System.out, "Overwrite HPCC files: " + overwrite, false, false); } else if (currentParam.matches(UPLOADCHUNPATTERN)) { int uploadchunksize = Integer.parseInt(currentParamVal); connector.setUploadchunksize(uploadchunksize); - log.trace("ESP file upload limit: " + uploadchunksize); + Utils.println(System.out, "ESP file upload limit: " + uploadchunksize, false, false); } else if (currentParam.matches(USERPATTERN)) { user = currentParamVal; - log.trace("ESP username: " + currentParamVal); + Utils.println(System.out, "ESP username: " + currentParamVal, false, false); } else if (currentParam.matches(PASSPATTERN)) { pass = currentParamVal; - log.trace("ESP password: *****"); + Utils.println(System.out, "ESP password: *****", false, false); } else if (currentParam.matches(ABBREVPATTERN)) { boolean abbreviate = Boolean.parseBoolean(currentParamVal); connector.setAbbreviate(abbreviate); - log.trace("Abbreviate Namespaces: " + abbreviate); + Utils.println(System.out, "Abbreviate Namespaces: " + abbreviate, false, false); } else if (currentParam.matches(FIXNSPATTERN)) { boolean fixNSIssues = Boolean.parseBoolean(currentParamVal); connector.setFixNSIssues(fixNSIssues); - log.trace("Attempt to fix namespace issues: " + fixNSIssues); + Utils.println(System.out, "Attempt to fix namespace issues: " + fixNSIssues, false, false); } else if (currentParam.matches(BASEURLPATTERN)) { connector.setTargetRDFBaseURI(currentParamVal); - log.trace("Base URI: " + currentParamVal); + Utils.println(System.out, "Base URI: " + currentParamVal, false, false); } else if (currentParam.matches(TARGETCLUSTERPATTERN)) { connector.setTargetECLCluster(currentParamVal); - log.trace("Target cluster for ECL execution: " + currentParamVal); + Utils.println(System.out, "Target cluster for ECL execution: " + currentParamVal, false, false); } else if (currentParam.matches(ECLMAXWAITMSPATTERN)) { int maxwaitms = Integer.parseInt(currentParamVal); connector.setEclmaxwaitMS(maxwaitms); - log.trace("Max wait for ECL execution in MS: " + maxwaitms); + Utils.println(System.out, "Max wait for ECL execution in MS: " + maxwaitms, false, false); } else if (currentParam.matches(RUNSTATSPATTERN)) { boolean getstats = Boolean.parseBoolean(currentParamVal); setRunstats(getstats); - log.trace("Produce stats: " + getstats); + Utils.println(System.out, "Produce stats: " + getstats, false, false); } else if (currentParam.matches(ECLSTATSFILE)) { if(new File(currentParamVal).isFile()) { connector.setECLStatsFile(currentParamVal); - log.trace("Ecl Stats File: " + currentParamVal); + Utils.println(System.out, "Ecl Stats File: " + currentParamVal, false, false); } else { - log.error("ERROR provided eclstatsfile does not exist."); + Utils.println(System.out, "ERROR provided eclstatsfile does not exist.", false, false); return false; } } @@ -229,21 +226,21 @@ else if (currentParam.matches(ADDNSPATTERN)) String nextToken = nstokens.nextToken(); additionalNSs.add(nextToken); - log.trace("Additional namespace: " + nextToken); + Utils.println(System.out, "Additional namespace: " + nextToken, false, false); } connector.setAdditionalNSs(additionalNSs); } else { - log.error("ERROR additional namespaces list."); + Utils.println(System.out, "ERROR additional namespaces list.", false, false); return false; } } else { - log.error("ERROR Invalid param: " + currentParam); + Utils.println(System.out, "ERROR Invalid param: " + currentParam, false, false); return false; } } @@ -259,18 +256,18 @@ else if (currentParam.matches(ADDNSPATTERN)) { if (!rdffile) { - log.error("ERROR required parameter -rdflocation not provided."); + Utils.println(System.out, "ERROR required parameter -rdflocation not provided.", false, false); } if (!hpccfile) { - log.error("ERROR required parameter -hpccfile not provided."); + Utils.println(System.out, "ERROR required parameter -hpccfile not provided.", false, false); } return false; } } else { - log.error("ERROR no params detected: "); + Utils.println(System.out, "ERROR no params detected: ", true, false); return false; } @@ -330,7 +327,7 @@ else if (currentParam.matches(ADDNSPATTERN)) private static void printRDF2HPCCUsage() { - log.error(rdf2hpccusageMessage); + System.err.println(rdf2hpccusageMessage); } public static void main(String[] args) @@ -358,43 +355,43 @@ public static void main(String[] args) String stats = connector.getRDFStats(); if (stats != null) { - log.trace("RDF2HPCC: Raw stats: \n" + stats); + Utils.println(System.out, "RDF2HPCC: Raw stats: \n" + stats, false, false); - log.trace("RDF2HPCC: Parsing raw stats: \n"); + Utils.println(System.out, "RDF2HPCC: Parsing raw stats: \n", false, false); List> parsedECLResults = org.hpccsystems.ws.client.utils.Utils .parseECLResults(stats); if (parsedECLResults != null) { - log.trace("RDF2HPCC: parsed stats: \n"); - log.trace(Utils.eclResultsToString(parsedECLResults, " , ", "\n")); + Utils.println(System.out, "RDF2HPCC: parsed stats: \n", false, false); + System.out.println(Utils.eclResultsToString(parsedECLResults, " , ", "\n")); } else { - log.error("RDF2HPCC: Failed to parse stats."); + Utils.println(System.out, "RDF2HPCC: Failed to parse stats.", false, false); } } else { - log.error("RDF2HPCC: Failed to produce stats."); + Utils.println(System.out, "RDF2HPCC: Failed to produce stats.", false, false); } } } else { - log.error("RDF2HPCC: Spraying file failed."); + Utils.println(System.out, "RDF2HPCC: Spraying file failed.", false, false); } } else if (rdf2hpcc.getRunstats()) { - log.error("RDF2HPCC: Will not run stats while file not sprayed."); + Utils.println(System.out, "RDF2HPCC: Will not run stats while file not sprayed.", false, false); } } else { - log.error("RDF2HPCC: Could not import file."); + Utils.println(System.out, "RDF2HPCC: Could not import file.", false, false); } - log.trace("RDF2HPCC: Finished."); + Utils.println(System.out, "RDF2HPCC: Finished.", false, false); } catch (Exception e) { diff --git a/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDFHPCCWsClient.java b/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDFHPCCWsClient.java index aa3baf348..85fd8d101 100644 --- a/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDFHPCCWsClient.java +++ b/rdf2hpcc/src/main/java/org/hpccsystems/rdf/rdf2hpcc/RDFHPCCWsClient.java @@ -12,8 +12,6 @@ import java.util.List; import java.util.Map; -import org.apache.logging.log4j.*; - import org.hpccsystems.ws.client.gen.ecldirect.v1_0.ArrayOfEspException; import org.hpccsystems.ws.client.gen.ecldirect.v1_0.EspException; import org.hpccsystems.ws.client.gen.filespray.v1_13.DropZone; @@ -44,8 +42,6 @@ public class RDFHPCCWsClient extends HPCCWsClient { public static DataSingletonCollection All = new DataSingletonCollection(); - private static final Logger log = LogManager.getLogger(RDFHPCCWsClient.class.getName()); - public static RDFHPCCWsClient get() { return (RDFHPCCWsClient) All.get(new RDFHPCCWsClient()); @@ -337,7 +333,7 @@ public void setTargetRDFLanguage(String targetRDFLanguage) } else { - log.error("Only valid entries are: 'RDF/XML', 'N-TRIPLE', 'TURTLE' (or 'TTL') and 'N3'."); + Utils.println(System.out, "Only valid entries are: 'RDF/XML', 'N-TRIPLE', 'TURTLE' (or 'TTL') and 'N3'.", false, verbosemode); } } @@ -424,7 +420,7 @@ public boolean sprayHPCCFile() } else { - log.error("Could not spray file, no destgroup specified."); + Utils.println(System.out, "Could not spray file, no destgroup specified.", false, verbosemode); try { printValidTargetGroups(System.out); @@ -440,7 +436,7 @@ public String getRDFStats() String eclreturn = null; String eclstats = null; - log.error("Attempting to run ECL stats on " + targetHPCCFilePath); + Utils.println(System.out, "Attempting to run ECL stats on " + targetHPCCFilePath, false, false); try { @@ -463,20 +459,20 @@ public String getRDFStats() } catch (ArrayOfEspException e) { - log.error("Error while submiting ecl: "); + Utils.println(System.out, "Error while submiting ecl: ", false, verbosemode); EspException[] espExceptions = e.getException(); for (EspException espException : espExceptions) { - log.error(espException.getMessage()); + Utils.println(System.out, espException.getMessage(), false, verbosemode); } } catch (IOException e) { - log.error("Error reading from user defined ecl stats file: " + e.getLocalizedMessage()); + Utils.println(System.out, "Error reading from user defined ecl stats file: " + e.getLocalizedMessage(), false, verbosemode); } catch (Exception e) { - log.error("Error while submiting ecl: " + e.getLocalizedMessage()); + Utils.println(System.out, "Error while submiting ecl: " + e.getLocalizedMessage(), false, verbosemode); } return eclreturn; @@ -513,7 +509,7 @@ public boolean importToHPCC() throws Exception } else { - log.error("Could not create target HPCC namespaces file."); + Utils.println(System.out, "Could not create target HPCC namespaces file.", false, verbosemode); } } @@ -527,23 +523,23 @@ public boolean importToHPCC() throws Exception { if (!fioclient.writeHPCCFileData(nsMappingsCSVFormat.toString().getBytes(), targetHPCCFilePath+"::namespaces", targetDropzoneNetAddress, false, 0, uploadchunksize)) { - log.error("Could not write to HPCC namespaces file."); + Utils.println(System.out, "Could not write to HPCC namespaces file.", false, verbosemode); } } } } else { - log.error("Could not create target HPCC file."); + Utils.println(System.out, "Could not create target HPCC file.", false, verbosemode); } } else { - log.error("Could not find target HPCC dropzone info."); + Utils.println(System.out, "Could not find target HPCC dropzone info.", false, verbosemode); } } - log.error("Success: " + String.valueOf(success)); + Utils.println(System.out, "Success: " + String.valueOf(success), false,verbosemode); return success; } @@ -568,14 +564,14 @@ static public Model createModelFromFile(String targetrdflanguage, String targetr //Open inputstream from specified RDF file InputStream in = FileManager.get().open( targetrdflocation ); - log.error("Attempting to create a Jena model:"); - log.error(" Original RDF location: " + targetrdflocation); - log.error(" RDF Syntax: " + targetrdflanguage); - log.error(" Base URI: " + targetrdfbaseuri); + Utils.println(System.out, "Attempting to create a Jena model:", false, verbosemode); + Utils.println(System.out, " Original RDF location: " + targetrdflocation, false, verbosemode); + Utils.println(System.out, " RDF Syntax: " + targetrdflanguage, false, verbosemode); + Utils.println(System.out, " Base URI: " + targetrdfbaseuri, false, verbosemode); if (in == null) { - log.error("Error: RDF data: " + targetrdflocation + " not found"); + Utils.println(System.out, "Error: RDF data: " + targetrdflocation + " not found", false, verbosemode); return null; } else @@ -586,15 +582,15 @@ static public Model createModelFromFile(String targetrdflanguage, String targetr } catch (SyntaxError e) { - log.error("Error while loading model: Language Syntax error: " + e.getLocalizedMessage()); + Utils.println(System.out, "Error while loading model: Language Syntax error: " + e.getLocalizedMessage(), false, verbosemode); } catch (TurtleParseException e) { - log.error("Error while loading model: " + e.getLocalizedMessage()); + Utils.println(System.out, "Error while loading model: " + e.getLocalizedMessage(), false, verbosemode); } catch (Exception e) { - log.error("Error while loading model: " + e.getLocalizedMessage()); + Utils.println(System.out, "Error while loading model: " + e.getLocalizedMessage(), false, verbosemode); e.printStackTrace(); } finally @@ -607,7 +603,7 @@ static public Model createModelFromFile(String targetrdflanguage, String targetr } catch (IOException e) { - log.error("Error while closing input file stream:\n"); + Utils.println(System.out, "Error while closing input file stream:\n", false, verbosemode); e.printStackTrace(); } } @@ -615,7 +611,7 @@ static public Model createModelFromFile(String targetrdflanguage, String targetr } if (model != null) - log.error("Model created."); + Utils.println(System.out, "Model created.", false, verbosemode); return model; } @@ -630,7 +626,7 @@ static public Map getNameSpaceMapping(Model themodel, List getNameSpaceMapping(Model themodel, List " + substring + subjectName); + Utils.println(System.err, "Is this an invalid qname: " + namespacekey + " -> " + substring + subjectName, true, verbosemode); } break; @@ -702,24 +698,24 @@ public String serializeModelToCSV(Model themodel, String outputdelim, String out if (subjectShorthandNS == null || subjectsNS == null) { serializedmodel.append(outputdelim).append(subject.toString()); - System.out.print(outputdelim+subject.toString()); + Utils.print(System.out, outputdelim+subject.toString(), true, verbosemode); } else { serializedmodel.append(subjectShorthandNS+outputdelim+subjectName); - System.out.print(subjectShorthandNS+outputdelim+subjectName); + Utils.print(System.out, subjectShorthandNS+outputdelim+subjectName, true, verbosemode); } } else { serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); serializedmodel.append(subject.toString()); - System.out.print(subject.toString()); + Utils.print(System.out, subject.toString(), true, verbosemode); } serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); } predicateSerializationBlock: @@ -733,24 +729,24 @@ public String serializeModelToCSV(Model themodel, String outputdelim, String out { predicateShorthandNS = HPCCNAMESPACE + (hpccnsprefixmap.size()+1); hpccnsprefixmap.put(predicateNS, predicateShorthandNS); - log.debug("Added NS found in predicate: " + predicateNS +":::::::"+predicateName); + System.err.println("Added NS found in predicate: " + predicateNS +":::::::"+predicateName); } if (predicateShorthandNS == null || predicateName == null) { serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); serializedmodel.append(predicate); - System.out.print(predicate.toString()); + Utils.print(System.out, predicate.toString(), true, verbosemode); } else { serializedmodel.append(predicateShorthandNS+outputdelim+predicateName); - System.out.print(predicateShorthandNS+outputdelim+predicateName); + Utils.print(System.out, predicateShorthandNS+outputdelim+predicateName, true, verbosemode); } serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); } objectSerializationBlock: @@ -764,52 +760,52 @@ public String serializeModelToCSV(Model themodel, String outputdelim, String out if (objectShorthandNS == null || objectName == null) { serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); serializedmodel.append(object); - System.out.print(object.toString()); + Utils.print(System.out, object.toString(), true, verbosemode); serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); if ( object.isAnon()) { serializedmodel.append("false"); - System.out.print("false"); + Utils.print(System.out, "false", true, verbosemode); } else { - log.debug("Encountered object URI without known namespace, treating as literal: " + object); + System.err.println("Encountered object URI without known namespace, treating as literal: " + object); serializedmodel.append("true"); - System.out.print("true"); + Utils.print(System.out, "true", true, verbosemode); } } else { serializedmodel.append(objectShorthandNS+outputdelim+objectName); - System.out.print(objectShorthandNS+outputdelim+objectName); + Utils.print(System.out, objectShorthandNS+outputdelim+objectName, true, verbosemode); serializedmodel.append(outputdelim).append("false"); - System.out.print(outputdelim+"false"); + Utils.print(System.out, outputdelim+"false", true, verbosemode); } } else { serializedmodel.append(outputdelim); - System.out.print(outputdelim); + Utils.print(System.out, outputdelim, true, verbosemode); //object is a literal - single quote it Node asNode = object.asNode(); String literalLexicalForm = asNode.getLiteralLexicalForm(); serializedmodel.append(outputquote).append(literalLexicalForm).append(outputquote); - System.out.print(outputquote+literalLexicalForm+outputquote); + Utils.print(System.out, outputquote+literalLexicalForm+outputquote, true, verbosemode); serializedmodel.append(outputdelim).append("true"); - System.out.print(outputdelim+"true"); + Utils.print(System.out, outputdelim+"true", true, verbosemode); } serializedmodel.append(outputterminator); - System.out.print(outputterminator); + Utils.print(System.out, outputterminator, true, verbosemode); } } } @@ -830,43 +826,43 @@ private boolean setDropZoneInfo() throws Exception { targetDropzoneNetAddress = dropZones[0].getNetAddress(); targetHPCCDropzonePath = dropZones[0].getPath(); - log.error("Found dropzone net address: " + targetDropzoneNetAddress); - log.error("Found dropzone path: " + targetHPCCDropzonePath); + Utils.println(System.out, "Found dropzone net address: " + targetDropzoneNetAddress, false, verbosemode); + Utils.println(System.out, "Found dropzone path: " + targetHPCCDropzonePath, false, verbosemode); try { PhysicalFileStruct[] files = fsclient.listFiles(targetDropzoneNetAddress, targetHPCCDropzonePath, null); - log.trace("Existing Dropzone files:"); + Utils.println(System.out, "Existing Dropzone files:", true, verbosemode); for (PhysicalFileStruct file : files) { - log.trace("\t" + file.getName() +"-"+ file.getFilesize()); + Utils.println(System.out, "\t" + file.getName() +"-"+ file.getFilesize(), true, verbosemode); } } catch (Exception e) { - log.warn("Warning: could not fetch existing landingzone file list."); + Utils.println(System.out, "Warning: could not fetch existing landingzone file list.", true, verbosemode); } success = true; } } catch (org.hpccsystems.ws.client.gen.filespray.v1_06.ArrayOfEspException e1) { - log.error("ERROR: Attempting to fetch HPCC dropzone Info:"); + Utils.println(System.out, "ERROR: Attempting to fetch HPCC dropzone Info:", false, verbosemode); for (org.hpccsystems.ws.client.gen.filespray.v1_06.EspException exception : e1.getException()) { - log.error("\t"+exception.getMessage()); + Utils.println(System.out, "\t"+exception.getMessage(), false, verbosemode); } } catch (RemoteException e1) { - log.error("ERROR:\tAttempting to fetch HPCC dropzone Info:"); - log.error("\t"+e1.getLocalizedMessage()); + Utils.println(System.out, "ERROR:\tAttempting to fetch HPCC dropzone Info:", false, verbosemode); + Utils.println(System.out, "\t"+e1.getLocalizedMessage(), false, verbosemode); if (e1.getCause() != null) - log.error("\t"+e1.getCause().getLocalizedMessage()); + Utils.println(System.out, "\t"+e1.getCause().getLocalizedMessage(), false, verbosemode); } catch (Exception e) { - log.error(e.getLocalizedMessage()); + Utils.println(System.out, e.getLocalizedMessage(), false, verbosemode); } return success; @@ -877,7 +873,7 @@ public void printValidTargetGroups(PrintStream stream) throws Exception String[] clusterGroups = getAvailableClusterGroups(); for (int i = 0; i < clusterGroups.length; i++) { - log.debug(clusterGroups[i]); + System.out.println(clusterGroups[i]); try { String[] actualclusternames = getAvailableClusterNames(clusterGroups[i]); diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 7bb986f66..8e43f271f 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -137,9 +137,9 @@ 1.4 - org.apache.logging.log4j - log4j-api - 2.10.0 + log4j + log4j + 1.2.17 diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java index cf288835c..7c47bc9f5 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.Properties; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.hpccsystems.ws.client.gen.filespray.v1_15.DropZone; @@ -113,7 +113,7 @@ public static SprayVariableFormat convertVarSprayFormatName2Code(String varSpray } private static URL originalURL; - private static Logger log = LogManager.getLogger(HPCCFileSprayClient.class.getName()); + private static Logger log = Logger.getLogger(HPCCFileSprayClient.class.getName()); public static URL getOriginalURL() throws MalformedURLException { diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsClient.java index 55684e190..dd6309b45 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsClient.java @@ -5,7 +5,7 @@ import java.rmi.RemoteException; import java.util.List; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.hpccsystems.ws.client.HPCCFileSprayClient.SprayVariableFormat; import org.hpccsystems.ws.client.extended.HPCCWsAttributesClient; @@ -36,7 +36,7 @@ */ public class HPCCWsClient extends DataSingleton { - private static final Logger log = LogManager.getLogger(HPCCWsClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsClient.class.getName()); public static DataSingletonCollection All = new DataSingletonCollection(); public static DataSingletonCollection SubClients = new DataSingletonCollection(); diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsDFUClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsDFUClient.java index 0ffa3b5e6..f078e49b7 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsDFUClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsDFUClient.java @@ -13,7 +13,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.apache.commons.lang3.StringUtils; @@ -68,7 +68,7 @@ public class HPCCWsDFUClient extends DataSingleton { private static URL originalURL; - private static final Logger log = LogManager.getLogger(HPCCWsDFUClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsDFUClient.class.getName()); public static URL getOriginalURL() throws MalformedURLException { diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsFileIOClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsFileIOClient.java index 95ddae95f..4441945a2 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsFileIOClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsFileIOClient.java @@ -4,7 +4,7 @@ import java.net.URL; import java.rmi.RemoteException; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.hpccsystems.ws.client.gen.wsfileio.v1_0.ArrayOfEspException; @@ -27,7 +27,7 @@ */ public class HPCCWsFileIOClient extends DataSingleton { - private static final Logger log = LogManager.getLogger(HPCCWsFileIOClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsFileIOClient.class.getName()); private static URL originalURL; public static URL getOriginalURL() throws MalformedURLException diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsPackageProcessClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsPackageProcessClient.java index e89a91c02..55f6f565f 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsPackageProcessClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsPackageProcessClient.java @@ -4,7 +4,7 @@ import java.net.URL; import java.rmi.RemoteException; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.hpccsystems.ws.client.gen.wsfileio.v1_0.ArrayOfEspException; @@ -31,7 +31,7 @@ */ public class HPCCWsPackageProcessClient extends DataSingleton { - private static final Logger log = LogManager.getLogger(HPCCWsPackageProcessClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsPackageProcessClient.class.getName()); private static URL originalURL; public static URL getOriginalURL() throws MalformedURLException diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsTopologyClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsTopologyClient.java index bd3212b1e..4e522f45b 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsTopologyClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsTopologyClient.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.hpccsystems.ws.client.gen.wstopology.v1_27.ArrayOfEspException; @@ -40,7 +40,7 @@ */ public class HPCCWsTopologyClient extends DataSingleton { - private static final Logger log = LogManager.getLogger(HPCCWsTopologyClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsTopologyClient.class.getName()); private static URL originalURL; public static URL getOriginalURL() throws MalformedURLException diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsWorkUnitsClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsWorkUnitsClient.java index 80446f007..4c080cf33 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsWorkUnitsClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsWorkUnitsClient.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.Set; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.apache.axis.utils.StringUtils; import org.apache.axis.types.NonNegativeInteger; @@ -48,7 +48,7 @@ public static HPCCWsWorkUnitsClient get(Connection connection) return new HPCCWsWorkUnitsClient(connection); } - private static final Logger log = LogManager.getLogger(HPCCWsWorkUnitsClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsWorkUnitsClient.class.getName()); public static final String WSWORKUNITSWSDLURI = "/WsWorkunits"; private WsWorkunitsServiceSoapProxy wsWorkunitsServiceSoapProxy = null; private org.hpccsystems.ws.client.gen.wsworkunits.v1_56.WsWorkunitsServiceSoapProxy fallBackWorkunitsServiceSoapProxy = null; diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecordReader.java b/wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecordReader.java index 28fc9d21d..fdc3769be 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecordReader.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecordReader.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.antlr.v4.runtime.tree.ParseTreeProperty; import org.hpccsystems.ws.client.platform.*; @@ -12,7 +12,7 @@ */ public class EclRecordReader extends EclRecordBaseListener { - private static final Logger log = LogManager.getLogger(EclRecordReader.class.getName()); + private static final Logger log = Logger.getLogger(EclRecordReader.class.getName()); private ErrorListener errorHandler = new ErrorListener(); private EclRecordInfo eclInfo = new EclRecordInfo(); private DFURecordDefInfo currentrec = null; diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsAttributesClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsAttributesClient.java index b34e0a9ea..972fb9859 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsAttributesClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsAttributesClient.java @@ -11,7 +11,7 @@ import java.util.Set; import org.apache.axis.client.Stub; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.hpccsystems.ws.client.gen.extended.wsattributes.v1_21.ArrayOfEspException; import org.hpccsystems.ws.client.gen.extended.wsattributes.v1_21.CheckinAttributeRequest; @@ -47,7 +47,7 @@ public class HPCCWsAttributesClient extends DataSingleton { private static URL originalURL; - private static final Logger log = LogManager.getLogger(HPCCWsAttributesClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsAttributesClient.class.getName()); public static URL getOriginalURL() throws MalformedURLException { diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsSQLClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsSQLClient.java index d77e05212..8a2550807 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsSQLClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/extended/HPCCWsSQLClient.java @@ -6,7 +6,7 @@ import java.util.List; import org.apache.axis.client.Stub; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.hpccsystems.ws.client.gen.extended.wssql.v3_05.ArrayOfEspException; import org.hpccsystems.ws.client.gen.extended.wssql.v3_05.ECLException; @@ -49,7 +49,7 @@ */ public class HPCCWsSQLClient extends DataSingleton { - private static final Logger log = LogManager.getLogger(HPCCWsSQLClient.class.getName()); + private static final Logger log = Logger.getLogger(HPCCWsSQLClient.class.getName()); public static final String WSSQLURI = "/WsSQL"; private WssqlServiceSoapProxy wsSqlServiceSoapProxy = null; private boolean verbose = false; diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java index dc514a1a1..3745273f6 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java @@ -6,7 +6,7 @@ import java.net.URLConnection; import java.net.URLEncoder; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.apache.axis.client.Stub; import org.apache.axis.encoding.Base64; import org.apache.axis.utils.StringUtils; @@ -106,7 +106,7 @@ public int hashCode() } } - private final static Logger log = LogManager.getLogger(Connection.class.getName()); + private final static Logger log = Logger.getLogger(Connection.class.getName()); public final static String protDelimiter = "://"; public final static char portDelimiter = ':'; diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Sftp.java b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Sftp.java index 981dc35cc..9bd473960 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Sftp.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Sftp.java @@ -5,7 +5,7 @@ import java.util.Properties; import java.util.Vector; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; @@ -14,7 +14,7 @@ public class Sftp { - private static final Logger log = LogManager.getLogger(Sftp.class.getName()); + private static final Logger log = Logger.getLogger(Sftp.class.getName()); static public void lzPut(String localFileName, String hostname, String landingZonePath, String targetFileName, String machineLoginUsername, String password, boolean isLZLinux, Properties connconfig) throws Exception { diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Utils.java b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Utils.java index 6fe2fc338..90c4ac4f2 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Utils.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Utils.java @@ -30,7 +30,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.apache.logging.log4j.*; +import org.apache.log4j.Logger; import org.w3c.dom.CharacterData; import org.w3c.dom.Document; @@ -41,11 +41,13 @@ public class Utils { - private final static Logger log = LogManager.getLogger(Utils.class.getName()); + private final static Logger log = Logger.getLogger(Utils.class.getName()); final static char LINUX_SEP = '/'; final static char WIN_SEP = '\\'; final static String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.sss'Z'"; + + public enum LogLevel {DEBUG,ERROR,FATAL,INFO,TRACE,WARN}; /** * @param wsdlurl - url to web service definition @@ -66,25 +68,49 @@ public static String parseVersionFromWSDLURL(String wsdlurl) return ""; } + @Deprecated static public void println(PrintStream stream, String message, boolean onlyifverbose, boolean verbosemode ) { - // if (verbosemode || !onlyifverbose) - // stream.println(message); - if (onlyifverbose) { - log.debug(message); - } else { - log.error(message); - } + if (onlyifverbose && verbosemode) + log.warn(message); + else + log.info(message); } + @Deprecated static public void print(PrintStream stream, String message, boolean onlyifverbose, boolean verbosemode) { - // if (verbosemode || !onlyifverbose) - // stream.print(message); - if (onlyifverbose) { - log.debug(message); - } else { - log.error(message); + if (onlyifverbose && verbosemode) + log.warn(message); + else + log.info(message); + } + + static public void log(String message, LogLevel logLevel) + { + switch (logLevel) + { + case DEBUG: + log.debug(message); + break; + case ERROR: + log.error(message); + break; + case FATAL: + log.fatal(message); + break; + case INFO: + log.info(message); + break; + case TRACE: + log.trace(message); + break; + case WARN: + log.warn(message); + break; + default: + log.trace(message); + break; } }