diff --git a/src/main/java/org/dpdirect/dpmgmt/DPCustomOp.java b/src/main/java/org/dpdirect/dpmgmt/DPCustomOp.java index 793b98e..7cf8ebe 100644 --- a/src/main/java/org/dpdirect/dpmgmt/DPCustomOp.java +++ b/src/main/java/org/dpdirect/dpmgmt/DPCustomOp.java @@ -25,10 +25,11 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import org.dpdirect.dpmgmt.DPDirectBase.Operation; -import org.dpdirect.dpmgmt.DPDirectBase.Operation.Option; import org.dpdirect.utils.FileUtils; +import static org.dpdirect.dpmgmt.Defaults.DEFAULT_POLL_INT_MILLIS; +import static org.dpdirect.dpmgmt.Defaults.DEFAULT_WAIT_TIME_SECONDS; + /** * Class for the management of IBM DataPower device via the XML management * interface. @@ -94,7 +95,7 @@ public static int getDefaultTailLines() { /** * The log poll interval as a value in milliseconds. */ - protected int pollIntMillis = DPDirectBase.getDefaultPollIntMillis(); + protected int pollIntMillis = DEFAULT_POLL_INT_MILLIS; /** * The tail-log poll interval as a value in milliseconds. @@ -104,7 +105,7 @@ public static int getDefaultTailLines() { /** * The tail-count (message-counts) poll interval as a value in milliseconds. */ - public static int COUNT_POLL_INT_MILLIS = DPDirectBase.getDefaultPollIntMillis(); + public static int COUNT_POLL_INT_MILLIS = DEFAULT_WAIT_TIME_SECONDS; /** * HashMap of all custom operations configured for this class, diff --git a/src/main/java/org/dpdirect/dpmgmt/DPDirectBase.java b/src/main/java/org/dpdirect/dpmgmt/DPDirectBase.java index 2ac38e1..f0e31fb 100644 --- a/src/main/java/org/dpdirect/dpmgmt/DPDirectBase.java +++ b/src/main/java/org/dpdirect/dpmgmt/DPDirectBase.java @@ -18,16 +18,13 @@ import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -48,7 +45,7 @@ import org.apache.log4j.Logger; -import org.dpdirect.dpmgmt.DPDirectBase.Operation.Option; +import org.dpdirect.dpmgmt.Operation.Option; import org.dpdirect.schema.DocumentHelper; import org.dpdirect.schema.SchemaLoader; import org.dpdirect.utils.Credentials; @@ -56,6 +53,8 @@ import org.dpdirect.utils.FileUtils; import org.dpdirect.utils.PostXML; +import static org.dpdirect.dpmgmt.Defaults.DEFAULT_FIRMWARE_LEVEL; + /** * Base Class for the management of IBM DataPower device via the XML management * interface. @@ -110,21 +109,6 @@ * @author Tim Goodwill */ public class DPDirectBase implements DPDirectInterface { - - /** - * Default firmware level - determines SOMA and AMP version. - */ - public static int DEFAULT_FIRMWARE_LEVEL = 5; - - /** - * Default waitTime - determines wait time when polling for a result. - */ - public static int DEFAULT_WAIT_TIME_SECONDS = 30; - - /** - * A default value for the log poll interval as a value in milliseconds. - */ - public static int DEFAULT_POLL_INT_MILLIS = 2000; /** * Class logger. @@ -209,21 +193,6 @@ public static void antHelp() { System.out.println(); } } - - /** - * @param pollIntMillis - * the pollIntMillis to set - */ - public static void setDefaultPollIntMillis(int pollIntMillis) { - DEFAULT_POLL_INT_MILLIS = pollIntMillis; - } - - /** - * @returns default pollIntMillis - */ - public static int getDefaultPollIntMillis() { - return DEFAULT_POLL_INT_MILLIS; - } /** * Constructs a new DPDirect class. @@ -730,8 +699,7 @@ public void setRollbackOnError(boolean enableRollback) { synchronized (DATE_FORMATTER) { checkPointName = "CP" + DATE_FORMATTER.format(new Date()); } - Operation operation = new Operation( - Constants.SAVE_CHECKPOINT_OP_NAME); + Operation operation = new Operation(this, Constants.SAVE_CHECKPOINT_OP_NAME); operation.addOption(Constants.CHK_NAME_OP_NAME, checkPointName); addToOperationChain(0, operation); failOnError = true; @@ -745,8 +713,7 @@ public void setRollbackOnError(boolean enableRollback) { */ @Override public void removeCheckpoint() { - Operation removeCheckpoint = new Operation( - Constants.REMOVE_CHECKPOINT_OP_NAME); + Operation removeCheckpoint = new Operation(this, Constants.REMOVE_CHECKPOINT_OP_NAME); removeCheckpoint.addOption(Constants.CHK_NAME_OP_NAME, checkPointName); String xmlResponse = generateAndPost(removeCheckpoint); @@ -759,7 +726,7 @@ public void removeCheckpoint() { */ @Override public Operation createOperation() { - Operation operation = new Operation(); + Operation operation = new Operation(this); addToOperationChain(operation); return operation; } @@ -769,17 +736,13 @@ public Operation createOperation() { */ @Override public Operation createOperation(String operationName) { - Operation operation = new Operation(operationName); + Operation operation = new Operation(this, operationName); addToOperationChain(operation); return operation; } - - public Operation newOperation() { - return new Operation(); - } - + public Operation newOperation(String operationName) { - return new Operation(operationName); + return new Operation(this, operationName); } /* (non-Javadoc) @@ -787,7 +750,7 @@ public Operation newOperation(String operationName) { */ @Override public void addOperation(String operationName) { - Operation operation = new Operation(operationName); + Operation operation = new Operation(this, operationName); addToOperationChain(operation); } @@ -1104,7 +1067,7 @@ public String parseResponseMsg(Operation operation, boolean handleError) { if ((logLevel.toInt() > org.apache.log4j.Level.INFO_INT) && log.isDebugEnabled() && handleError) { logWarn(operation, parsedText); - } else if ((logLevel.toInt() <= org.apache.log4j.Level.INFO_INT) + } else if ((logLevel.toInt() <= org.apache.log4j.Level.INFO_INT) && (operation.getSuppressResponse() != true || logLevel.toInt() > org.apache.log4j.Level.ERROR_INT)){ logInfo(operation, parsedText); @@ -1354,8 +1317,7 @@ protected boolean restoreCheckpoint() throws Exception { boolean success = false; if (checkPointName != null) { // create and post new operation to request rollback. - Operation rollback = new Operation( - Constants.ROLLBACK_CHECKPOINT_OP_NAME); + Operation rollback = new Operation(this, Constants.ROLLBACK_CHECKPOINT_OP_NAME); rollback.addOption(Constants.CHK_NAME_OP_NAME, checkPointName); // schemaLoaderList.add(new SchemaLoader( // this.getClass().getResource(Constants.SOMA_MGMT_50_SCHEMA_PATH).toExternalForm())); @@ -1473,1038 +1435,6 @@ public void setNetrcFilePath(String netrcFilePath) { this.netrcFilePath = netrcFilePath; } - /** - * Inner class representing nested or stacked individual DP SOMA or AMP - * operations. Several operations may belong to a single DPDirect session. - */ - public class Operation { - - protected String name = null; - - protected DPCustomOp customOperation = null; - - protected DPCustomOp parentOperation = null; - - protected String domain = null; - - protected String srcFile = null; - - protected String destFile = null; - - protected String srcDir = null; - - protected String destDir = null; - - protected String endPoint = null; - - protected boolean isAMP = false; - - protected String payload = null; - - protected String response = null; - protected boolean failFlag = true; - - protected String failState = null; - - protected String waitFor = null; - - protected String waitForXPath = null; - - protected int waitTimeSeconds = DEFAULT_WAIT_TIME_SECONDS; - - protected int pollIntMillis = DEFAULT_POLL_INT_MILLIS; - - protected String filter = null; - - protected String filterOut = null; - - protected boolean overwrite = true; - - protected boolean replace = true; - - protected boolean suppressResponse = false; - - protected boolean memSafe = false; - - protected List