Commits

dloy  committed 44b1b37

Add FixityTest.properties - fix periodic report

  • Participants
  • Parent commits 4c190f7

Comments (0)

Files changed (19)

File fixity-src/src/main/java/org/cdlib/mrt/fixity/action/FixityEmailWrapper.java

                 + " - disp=" + disp
                 );
             FixityEmail emailer = new FixityEmail(setupProperties);
-            String[] to = {email};
+            String[] to = getTo(email);
             emailer.sendEmail(
                 "report",
                 formatTypeS,
                 disp);
     }
 
+    public String[] getTo(String to)
+        throws TException
+    {
+        if (StringUtil.isEmpty(to)) {
+            throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "TO not supplied");
+        }
+        String [] addrs = to.split("\\s*\\;\\s*");
+        if (addrs.length == 0) {
+            throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "TO invalid");
+        }
+        String [] retAddrs = new String [addrs.length];
+        for (int i=0; i < addrs.length; i++) {
+            String addr = addrs[i];
+            retAddrs[i] = stripMailto(addr);
+            if (DEBUG) System.out.println("MAILTO:" + retAddrs[i]);
+        }
+        return retAddrs;
+    }
+
+    protected String stripMailto(String value)
+    {
+        value = value.trim();
+        if (!value.startsWith("mailto:")) return value;
+        return value.substring(7);
+    }
 
     public String formatIt(
             StateInf responseState)

File fixity-src/src/main/java/org/cdlib/mrt/fixity/action/FixityReportItem.java

 
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             TFrame tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/service/FixityPeriodicReport.java

     private static final String MESSAGE = NAME + ": ";
     private static final String NL = System.getProperty("line.separator");
 
-    private static final boolean DEBUG = true;
+    private static final boolean DEBUG = false;
     protected LoggerInf logger = null;
     protected FixityItemDB db = null;
     protected Properties prop = null;
     {
         String value = serviceProperties.getProperty(key);
         if (StringUtil.isEmpty(value)) return null;
-        if (!value.startsWith("mailto:")) return null;
+        if (!value.startsWith("mailto:")) return value;
         return value.substring(7);
     }
 
         FixityServiceProperties fixityServiceProperties = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
             fixityServiceProperties =
                     FixityServiceProperties.getFixityServiceProperties(tFrame.getProperties());
                     fixityServiceProperties,
                     logger
                     );
+            System.out.println("AFTER constructor:"
+                    + " - isRunning:" + report.isRunning()
+                    );
             FixityEmailWrapper wrapper = report.setWrapper();
             wrapper.run();
             //report.run();
             DateState dateSubmitted = new DateState();
             String msg = "Fixity Periodic Report" + NL + NL
                     + "Reports started: " + dateSubmitted.getIsoDate() + NL;
-            log(PropertiesUtil.dumpProperties("!!!!setWrapper", serviceProperties));
+            log(PropertiesUtil.dumpProperties("setWrapper", serviceProperties));
             PeriodicServiceReport report = PeriodicServiceReport.getPeriodicServiceReport(fixityServiceProperties, logger);
 
             FixityEmailWrapper wrapper = new FixityEmailWrapper(
     protected synchronized boolean isRunning()
         throws TException
     {
-        if (scheduler != null) return false;
+        if (scheduler == null) return false;
         return true;
     }
     
         }
     }
 
-    public boolean isScheduled()
-    {
-        if (scheduler != null) return true;
-        return false;
-    }
-
     public synchronized void shutdown()
     {
         try {

File fixity-src/src/main/java/org/cdlib/mrt/fixity/service/FixityServiceProperties.java

 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
 import java.sql.Connection;
 
 
 import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.utility.FixityDBUtil;
 import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
 
 /**
  * Base properties for Fixity
 {
     private static final String NAME = "FixityServiceProperties";
     private static final String MESSAGE = NAME + ": ";
-    private static final boolean DEBUG = false;
+    private static final boolean DEBUG = true;
 
     protected Properties serviceProperties = null;
     protected Properties setupProperties = null;
             periodicReport =  new FixityPeriodicReport(
                     this,
                     logger);
+            if (DEBUG) {
+                System.out.println("PERIODIC REPORT INITIAL:" + periodicReport.isRunning());
+            }
 
         } catch (Exception ex) {
             throw new TException(ex);
     public void startPeriodicReport()
         throws TException
     {
+        if (DEBUG) {
+            System.out.println("startPeriodicReport:" + periodicReport.isRunning());
+        }
         if (periodicReport.isRunning()) return;
         periodicReport.run();
+        if (DEBUG) {
+            System.out.println("PeriodicReport STARTED");
+        }
     }
 
     public void shutdownPeriodicReport()
         throws TException
     {
+        if (DEBUG) {
+            System.out.println("shutdownPeriodicReport:" + periodicReport.isRunning());
+        }
         if (!periodicReport.isRunning()) return;
         periodicReport.shutdown();
+        if (DEBUG) {
+            System.out.println("PeriodicReport STOPPED");
+        }
     }
 }

File fixity-src/src/main/java/org/cdlib/mrt/fixity/service/FixityServiceStateManager.java

         FixityItemDB db = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
             Properties prop = tFrame.getProperties();
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/service/RunFixity.java

         FixityItemDB db = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/RunQueue.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestAddFixity.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestClientProcessFixity.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestFixity.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestFixityClient.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestFixityItemReport.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestFixityItemsReport.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestFixityReport.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestHSQLDB.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/test/TestProcessFixity.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/tools/SaveDirectory.java

         TFrame tFrame = null;
         try {
             String propertyList[] = {
-                "resources/Fixity.properties"};
+                "resources/FixityTest.properties"};
             tFrame = new TFrame(propertyList, "TestFixity");
 
             // Create an instance of this object

File fixity-src/src/main/java/org/cdlib/mrt/fixity/utility/FixityDBUtil.java

             if ((contexts != null) && (contexts.length > 0)) {
                 entry.setContextEntries(contexts);
             }
+            /* stubbed for now !!!!
             FixityHistoryEntry[] histories = getHistoryEntries(connection, key, logger);
             if ((histories != null) && (histories.length > 0)) {
                 entry.setHistoryEntries(histories);
             }
+             */
         }
         return itemEntries;
     }

File fixity-src/src/main/java/org/cdlib/mrt/fixity/utility/FixityUtil.java

 
     private static void addHistorySystemException(FixityEntry entry, Exception ex)
     {
+        if (ex == null) return;
+        entry.setNote(ex.toString());
+        entry.setStatus(FixityEntry.StatusType.systemunavailable);
+        entry.setVerified();
+        if (true) return;
+        // The section below set up a history entry and is, for now, stubbed
         FixityHistoryEntry historyEntry = new FixityHistoryEntry();
-        entry.setStatus(FixityEntry.StatusType.systemunavailable);
         historyEntry.setNote(ex.toString());
         historyEntry.setSubject(SYSTEM_EXCEPTION);
         entry.addHistoryEntry(historyEntry);
     private static void addHistoryFixityException(FixityEntry entry, String out)
     {
         if (StringUtil.isEmpty(out)) return;
+        entry.setNote(out);
+        if (true) return;
+        // The section below set up a history entry and is, for now, stubbed
         FixityHistoryEntry historyEntry = new FixityHistoryEntry();
         historyEntry.setNote(out);
         historyEntry.setSubject(FIXITY_EXCEPTION);