diff options
author | Instrumental <jgonap@stl.gathman.org> | 2020-03-19 08:10:12 -0500 |
---|---|---|
committer | Instrumental <jgonap@stl.gathman.org> | 2020-03-19 13:02:59 -0500 |
commit | 6a1ddb5e38cf8fa29f84c4b6ac4172bc1063691a (patch) | |
tree | 2928b6182f0d4c517ae13e544e6677ea49d3d74c /auth/auth-batch/src/main/java/org | |
parent | 6129846e19a51f266d61df7b71fac408e5611b76 (diff) |
Fix standalone Batch Jars
Issue-ID: AAF-1114
Signed-off-by: Instrumental <jgonap@stl.gathman.org>
Change-Id: I6ceb7ef714b3c7c2b33371abfca9202746151231
Diffstat (limited to 'auth/auth-batch/src/main/java/org')
-rw-r--r-- | auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java | 25 | ||||
-rw-r--r-- | auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Upload.java | 5 |
2 files changed, 19 insertions, 11 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java index d2695a35..3058ddc5 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java @@ -55,7 +55,6 @@ import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.Env; -import org.onap.aaf.misc.env.StaticSlot; import org.onap.aaf.misc.env.TimeTaken; import org.onap.aaf.misc.env.util.Chrono; import org.onap.aaf.misc.env.util.Split; @@ -68,9 +67,6 @@ import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; public abstract class Batch { - - private static StaticSlot ssargs; - protected static final String STARS = "*****"; protected static Cluster cluster; @@ -83,6 +79,8 @@ public abstract class Batch { private static File logdir; + private static String[] batchArgs; + public static final String CASS_ENV = "CASS_ENV"; public static final String LOG_DIR = "LOG_DIR"; protected static final String MAX_EMAILS="MAX_EMAILS"; @@ -157,7 +155,7 @@ public abstract class Batch { protected void _close(AuthzTrans trans) {} public String[] args() { - return env.get(ssargs); + return batchArgs; } public boolean isDryRun() @@ -380,11 +378,12 @@ public abstract class Batch { // Use a StringBuilder to save off logs until a File can be setup StringBuilderOutputStream sbos = new StringBuilderOutputStream(); PropAccess access = new PropAccess(new PrintStream(sbos),args); - access.log(Level.INIT, "------- Starting Batch ------\n Args: "); + access.log(Level.INFO, "------- Starting Batch ------\n Args: "); for(String s: args) { sbos.getBuffer().append(s); sbos.getBuffer().append(' '); } + sbos.getBuffer().append('\n'); InputStream is = null; String filename; @@ -454,13 +453,10 @@ public abstract class Batch { len -= 1; if (len < 0) len = 0; - String nargs[] = new String[len]; + batchArgs = new String[len]; if (len > 0) { - System.arraycopy(args, 1, nargs, 0, len); + System.arraycopy(args, 1, batchArgs, 0, len); } - - env.put(ssargs = env.staticSlot("ARGS"), nargs); - /* * Add New Batch Programs (inherit from Batch) here */ @@ -505,6 +501,7 @@ public abstract class Batch { if (cls != null) { Constructor<?> cnst = cls.getConstructor(AuthzTrans.class); batch = (Batch) cnst.newInstance(trans); + System.out.println(batch.getClass().getCanonicalName()); env.info().log("Begin", classifier, toolName); } @@ -519,8 +516,12 @@ public abstract class Batch { } if (batch != null) { try { + for(String s : batchArgs) { + System.out.println(s); + } batch.run(trans); } catch (Exception e) { + trans.error().log(e); if(cluster!=null && !cluster.isClosed()) { cluster.close(); } @@ -536,6 +537,8 @@ public abstract class Batch { trans.auditTrail(4, sb, AuthzTrans.SUB, AuthzTrans.REMOTE); trans.info().log(sb); } + } catch (Exception e) { + env.warn().log(e); } finally { batchLog.close(); } diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Upload.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Upload.java index b0db0a79..83de05af 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Upload.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Upload.java @@ -85,6 +85,10 @@ public class Upload extends Batch { @Override protected void run(AuthzTrans trans) { List<File> files = new ArrayList<>(); + for(String s : args()) { + trans.init().log(s); + } + if(args().length>0) { File dir = new File(args()[0]); if(dir.isDirectory()) { @@ -105,6 +109,7 @@ public class Upload extends Batch { } } } + for(File file : files) { String f = file.getName(); final Feed feed = feeds.get(f.substring(0,f.length()-4)); |