dloy avatar dloy committed 2237a24

Add optional queue instead of add

Comments (0)

Files changed (2)

fixity-storeload/src/main/java/org/cdlib/mrt/fixity/tools/Store2Fixity.java

 {
     private static final String NAME = "Store2Fixity";
     private static final String MESSAGE = NAME + ": ";
+    public enum CmdType {add, queue};
 
     private static final String NL = System.getProperty("line.separator");
     private static final boolean DEBUG = true;
     protected String serverLink = null;
     protected String[] owners = null;
     protected String[] members = null;
+    protected CmdType cmdType = null;
 
     public Store2Fixity(
             File baseFile,
             String baseURL,
             String serverLink,
+            String cmdS,
             String line,
             LoggerInf logger)
         throws TException
         this.line = line;
         this.serverLink = serverLink;
         this.client = new FixityClient(logger);
-        validate();
+        validate(cmdS);
     }
 
-    protected void validate()
+    protected void validate(String cmdS)
         throws TException
     {
         if (StringUtil.isEmpty(serverLink)) {
         if (StringUtil.isEmpty(line)) {
             throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "Missing line");
         }
+        if (StringUtil.isEmpty(cmdS)) {
+            cmdS = "add";
+        }
+        try {
+            cmdS = cmdS.toLowerCase();
+            cmdType = CmdType.valueOf(cmdS);
+        } catch (Exception ex) {
+            cmdType = CmdType.add;
+        }
         setLine();
     }
 
                 baseFile,
                 baseURL,
                 serverLink,
+                "add",
                 line,
                 logger);
             System.out.println(test.dump("MAIN dump"));
-            if (false) return;
+            if (true) return;
             test.run();
 
         } catch(Exception e) {
 
             String note = null;
             String formatTypeS = "XML";
+            Properties prop = null;
+            if (cmdType == CmdType.add) {
+                prop = client.add(
+                    linkS,
+                    timeout,
+                    retry,
+                    urlS,
+                    source,
+                    sizeS,
+                    digestType,
+                    digestValue,
+                    context,
+                    note,
+                    formatTypeS);
 
-            Properties prop = client.add(
-                linkS,
-                timeout,
-                retry,
-                urlS,
-                source,
-                sizeS,
-                digestType,
-                digestValue,
-                context,
-                note,
-                formatTypeS);
+            } else if (cmdType == CmdType.queue) {
+                prop = client.queue(
+                    linkS,
+                    timeout,
+                    retry,
+                    urlS,
+                    source,
+                    sizeS,
+                    digestType,
+                    digestValue,
+                    context,
+                    note,
+                    formatTypeS);
+
+            } else {
+                throw new TException.REQUEST_INVALID(
+                        MESSAGE + "command type not supported:" + cmdType);
+            }
             if (isError(prop)) {
                 handleException(prop);
             }
                     + " - baseFile=" + baseFile.getCanonicalPath() + NL
                     + " - baseURL=" + baseURL + NL
                     + " - serverLink=" + serverLink + NL
+                    + " - cmdType=" + cmdType.toString() + NL
                     );
             if (members != null) {
                 for (String item: members) {

fixity-storeload/src/main/java/org/cdlib/mrt/fixity/tools/Store2FixityList.java

     protected File baseFile = null;
     protected String baseURL = null;
     protected String serverLink = null;
+    protected String cmdTypeS = null;
     protected BufferedReader reader = null;
     protected Vector <String> exArr = new Vector <String> (100);
     protected int maxExceptions = 100;
             File baseFile,
             String baseURL,
             String serverLink,
+            String cmdTypeS,
             LoggerInf logger)
         throws TException
     {
         this.logger = logger;
         this.listFile = listFile;
         this.serverLink = serverLink;
+        this.cmdTypeS = cmdTypeS;
         validate();
     }
 
         if (!listFile.exists()) {
             throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "listFile does not exist");
         }
+        if (StringUtil.isEmpty(cmdTypeS)) {
+            cmdTypeS = "add";
+        }
         setList();
     }
 
                     break;
                 }
                 System.out.println("Line:" + line);
-                Store2Fixity s2f = new Store2Fixity(baseFile, baseURL, serverLink, line, logger);
+                Store2Fixity s2f = new Store2Fixity(baseFile, baseURL, serverLink, cmdTypeS, line, logger);
                 try {
                     s2f.run();
 
 
             String serverLink = get(prop, "serverLink");
 
+            String cmdTypeS = prop.getProperty("cmdType");
+
             String maxoutS = prop.getProperty("maxout", "10");
             int maxout = Integer.parseInt(maxoutS);
 
                 baseFile,
                 baseURL,
                 serverLink,
+                cmdTypeS,
                 logger);
             System.out.println(test.dump("MAIN dump"));
             test.run();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.