- access.setStreamLogIt(batchLog);
- sbos.flush();
- batchLog.print(sbos.getBuffer());
- sbos = null;
- Logger.getRootLogger().addAppender(new Log4JAccessAppender(access));
-
- Batch batch = null;
- AuthzTrans trans = env.newTrans();
-
- TimeTaken tt = trans.start("Total Run", Env.SUB);
- try {
- int len = args.length;
- if (len > 0) {
- String toolName = args[0];
- len -= 1;
- if (len < 0)
- len = 0;
- String nargs[] = new String[len];
- if (len > 0) {
- System.arraycopy(args, 1, nargs, 0, len);
- }
-
- env.put(ssargs = env.staticSlot("ARGS"), nargs);
-
- /*
- * Add New Batch Programs (inherit from Batch) here
- */
-
- // Might be a Report, Update or Temp Batch
- Class<?> cls = null;
- String classifier = "";
-
- String[] pkgs = new String[] {
- "org.onap.aaf.auth.batch.update",
- "org.onap.aaf.auth.batch.reports",
- "org.onap.aaf.auth.batch.temp"
- };
-
- String ebp = env.getProperty("EXTRA_BATCH_PKGS");
- if(ebp!=null) {
- String[] ebps = Split.splitTrim(':', ebp);
- String[] temp = new String[ebps.length + pkgs.length];
- System.arraycopy(pkgs,0, temp, 0, pkgs.length);
- System.arraycopy(ebps,0,temp,pkgs.length,ebps.length);
- pkgs = temp;
- }
-
- for(String p : pkgs) {
- try {
- cls = ClassLoader.getSystemClassLoader().loadClass(p + '.' + toolName);
- int lastDot = p.lastIndexOf('.');
- if(p.length()>0 || p.length()!=lastDot) {
- StringBuilder sb = new StringBuilder();
- sb.append(Character.toUpperCase(p.charAt(++lastDot)));
- while(++lastDot<p.length()) {
- sb.append(p.charAt(lastDot));
- }
- sb.append(':');
- classifier = sb.toString();
- break;
- }
- } catch (ClassNotFoundException e) {
- cls = null;
- }
- }
- if (cls != null) {
- Constructor<?> cnst = cls.getConstructor(AuthzTrans.class);
- batch = (Batch) cnst.newInstance(trans);
- env.info().log("Begin", classifier, toolName);
- }
-
-
- if (batch == null) {
- trans.error().log("No Batch named", toolName, "found");
- }
- /*
- * End New Batch Programs (inherit from Batch) here
- */
-
- }
- if (batch != null) {
- try {
- batch.run(trans);
- } catch (Exception e) {
- if(cluster!=null && !cluster.isClosed()) {
- cluster.close();
- }
- trans.error().log(e);
- }
- }
- } finally {
- tt.done();
- if (batch != null) {
- batch.close(trans);
- }
- StringBuilder sb = new StringBuilder("Task Times\n");
- trans.auditTrail(4, sb, AuthzTrans.SUB, AuthzTrans.REMOTE);
- trans.info().log(sb);
- }
+ access.setStreamLogIt(batchLog);
+ sbos.flush();
+ batchLog.print(sbos.getBuffer());
+ sbos = null;
+ Logger.getRootLogger().addAppender(new Log4JAccessAppender(access));
+
+ Batch batch = null;
+ AuthzTrans trans = env.newTrans();
+
+ TimeTaken tt = trans.start("Total Run", Env.SUB);
+ try {
+ int len = args.length;
+ if (len > 0) {
+ String toolName = args[0];
+ len -= 1;
+ if (len < 0)
+ len = 0;
+ String nargs[] = new String[len];
+ if (len > 0) {
+ System.arraycopy(args, 1, nargs, 0, len);
+ }
+
+ env.put(ssargs = env.staticSlot("ARGS"), nargs);
+
+ /*
+ * Add New Batch Programs (inherit from Batch) here
+ */
+
+ // Might be a Report, Update or Temp Batch
+ Class<?> cls = null;
+ String classifier = "";
+
+ String[] pkgs = new String[] {
+ "org.onap.aaf.auth.batch.update",
+ "org.onap.aaf.auth.batch.reports",
+ "org.onap.aaf.auth.batch.temp"
+ };
+
+ String ebp = env.getProperty("EXTRA_BATCH_PKGS");
+ if(ebp!=null) {
+ String[] ebps = Split.splitTrim(':', ebp);
+ String[] temp = new String[ebps.length + pkgs.length];
+ System.arraycopy(pkgs,0, temp, 0, pkgs.length);
+ System.arraycopy(ebps,0,temp,pkgs.length,ebps.length);
+ pkgs = temp;
+ }
+
+ for(String p : pkgs) {
+ try {
+ cls = ClassLoader.getSystemClassLoader().loadClass(p + '.' + toolName);
+ int lastDot = p.lastIndexOf('.');
+ if(p.length()>0 || p.length()!=lastDot) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Character.toUpperCase(p.charAt(++lastDot)));
+ while(++lastDot<p.length()) {
+ sb.append(p.charAt(lastDot));
+ }
+ sb.append(':');
+ classifier = sb.toString();
+ break;
+ }
+ } catch (ClassNotFoundException e) {
+ cls = null;
+ }
+ }
+ if (cls != null) {
+ Constructor<?> cnst = cls.getConstructor(AuthzTrans.class);
+ batch = (Batch) cnst.newInstance(trans);
+ env.info().log("Begin", classifier, toolName);
+ }
+
+
+ if (batch == null) {
+ trans.error().log("No Batch named", toolName, "found");
+ }
+ /*
+ * End New Batch Programs (inherit from Batch) here
+ */
+
+ }
+ if (batch != null) {
+ try {
+ batch.run(trans);
+ } catch (Exception e) {
+ if(cluster!=null && !cluster.isClosed()) {
+ cluster.close();
+ }
+ trans.error().log(e);
+ }
+ }
+ } finally {
+ tt.done();
+ if (batch != null) {
+ batch.close(trans);
+ }
+ StringBuilder sb = new StringBuilder("Task Times\n");
+ trans.auditTrail(4, sb, AuthzTrans.SUB, AuthzTrans.REMOTE);
+ trans.info().log(sb);
+ }