Commits

dloy committed 3cf6eb1

BitBucket

  • Participants
  • Parent commits 29a9f09

Comments (0)

Files changed (30)

File fixity-src/pom_hsqldb.xml

-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.cdlib.mrt</groupId>
-  <artifactId>mrt-fixitysrc</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0-SNAPSHOT</version>
-  <name>UC3-mrtFixitySrc</name>
-  <url>http://uc3.cdlib.org</url>
-
-  <!-- force UTF-8 -->
-  <properties>
-      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-  <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.2</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-        </configuration>
-      </plugin>
-  </plugins>
-  </build>
-
-  <dependencies>
-        
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-bundle</artifactId>
-        <version>1.5</version>
-    </dependency>
-
-    <dependency>
-        <groupId>com.sun.jersey.contribs</groupId>
-        <artifactId>jersey-multipart</artifactId>
-        <version>1.5</version>
-    </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-jena</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-core</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-fixityconf</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-        <dependency>
-          <groupId>javax.ws.rs</groupId>
-          <artifactId>jsr311-api</artifactId>
-          <version>1.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpcore</artifactId>
-            <version>4.0.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>4.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>hsqldb</groupId>
-            <artifactId>hsqldb</artifactId>
-            <version>2.1.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>hsqldb</groupId>
-            <artifactId>sqltool</artifactId>
-            <version>2.1.0</version>
-        </dependency>
-
-    <dependency>
-        <groupId>javax.servlet</groupId>
-        <artifactId>servlet-api</artifactId>
-        <version>2.5</version>
-    </dependency>
-
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.5</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-        <groupId>jargs</groupId>
-        <artifactId>jargs</artifactId>
-        <version>1.1.1</version>
-    </dependency>
-  </dependencies>
-    <reporting>
-        <outputDirectory>/uc3qa/nexus34211/tomcat/webapps/report/mrt/core</outputDirectory>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-project-info-reports-plugin</artifactId>
-                <version>2.0.1</version>
-            </plugin>
-        </plugins>
-   </reporting>
-
-</project>
-
-
-

File fixity-src/pom_mysql.xml

-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.cdlib.mrt</groupId>
-  <artifactId>mrt-fixitysrc</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0-SNAPSHOT</version>
-  <name>UC3-mrtFixitySrc</name>
-  <url>http://uc3.cdlib.org</url>
-
-  <!-- force UTF-8 -->
-  <properties>
-      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-  <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.2</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-        </configuration>
-      </plugin>
-  </plugins>
-  </build>
-
-  <dependencies>
-        
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-bundle</artifactId>
-        <version>1.5</version>
-    </dependency>
-
-    <dependency>
-        <groupId>com.sun.jersey.contribs</groupId>
-        <artifactId>jersey-multipart</artifactId>
-        <version>1.5</version>
-    </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-jena</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-core</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-      <dependency>
-          <groupId>org.cdlib.mrt</groupId>
-          <artifactId>mrt-fixityconf</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-
-        <dependency>
-          <groupId>javax.ws.rs</groupId>
-          <artifactId>jsr311-api</artifactId>
-          <version>1.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpcore</artifactId>
-            <version>4.0.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>4.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>5.1.13</version>
-        </dependency>
-
-    <dependency>
-        <groupId>javax.servlet</groupId>
-        <artifactId>servlet-api</artifactId>
-        <version>2.5</version>
-    </dependency>
-
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.5</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-        <groupId>jargs</groupId>
-        <artifactId>jargs</artifactId>
-        <version>1.1.1</version>
-    </dependency>
-  </dependencies>
-    <reporting>
-        <outputDirectory>/uc3qa/nexus34211/tomcat/webapps/report/mrt/core</outputDirectory>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-project-info-reports-plugin</artifactId>
-                <version>2.0.1</version>
-            </plugin>
-        </plugins>
-   </reporting>
-
-</project>
-
-
-

File fixity-src/src/main/java/org/cdlib/mrt/fixity/app/jersey/JerseyBase.java

         }
         try {
             typeFile = getStateFile(exception, format, logger);
+            jerseyCleanup.addTempFile(typeFile.file);
 
         } catch (TException dtex) {
             throw new JerseyException.INTERNAL_SERVER_ERROR("Could not process this format:" + formatType + "Exception:" + dtex);

File fixity-src/src/main/java/org/cdlib/mrt/fixity/db/FixityItemDB.java

             + "but he that stands by it now, deserves the love and thanks of man and woman.";
     protected LoggerInf logger = null;
     protected FixityConnectionPool pool = null;
-
+    protected String dburl = null;
+    protected String dbuser = null;
+    protected String dbpass = null;
+    private static final boolean DEBUG = false;
+    
     public FixityItemDB(LoggerInf logger, Properties frame)
         throws TException
     {
         this.logger = logger;
+        
+  
         String password = frame.getProperty("db.password");
         String pw = frame.getProperty("db.pw");
         if (StringUtil.isNotEmpty(pw)) {
                 + " - db.pw=" + frame.getProperty("db.pw")
                 + " - db.password=" + frame.getProperty("db.password")
                 );
-
-        pool = FixityConnectionPool.getFixityConnectionPool(
-                frame.getProperty("db.url"),
-                frame.getProperty("db.user"),
-                password);
+        dburl = frame.getProperty("db.url");
+        dbpass = password;
+        dbuser = frame.getProperty("db.user");
+        setPool();
     }
 
     public FixityItemDB(LoggerInf logger,
         throws TException
     {
         this.logger = logger;
-        pool = FixityConnectionPool.getFixityConnectionPool(dburl, dbuser, dbpass);
+        setPool();
     }
 
      public Connection getConnection(
             boolean autoCommit)
         throws TException
      {
+         
+         if(pool == null) return null;
+         return getConnectionWithReconnect(autoCommit);
+     }
+
+     public Connection getSingleConnection(
+            boolean autoCommit)
+        throws TException
+     {
+         if(pool == null) return null;
+         try {
+            return pool.getConnection(autoCommit);
+
+        } catch(Exception e) {
+            String msg = "Exception"
+                + " - exception:" + e;
+
+            logger.logError(MESSAGE + "getOperation - " + msg, 0);
+            e.printStackTrace();
+            throw new TException.GENERAL_EXCEPTION(msg, e);
+        }
+
+     }
+
+    public Connection getConnectionWithReconnect(
+            boolean autoCommit)
+        throws TException
+    {
+        if(pool == null) return null;
+        Connection connect = null;
+        try {
+            connect = getSingleConnection(autoCommit);
+            if (connect == null) {
+                for (int i=0; i<5; i++) {
+                    try {
+                        if (i > 1) Thread.sleep(1000 * 60 * 30);
+                        attemptReconnection();
+                        connect = getSingleConnection(autoCommit);
+                        if (connect == null) continue;
+                        return connect;
+
+                     } catch (Exception arex) {
+                         throw new TException.SQL_EXCEPTION("Reconnect attempted and fails:" + arex);
+                     }
+                }
+            }
+            return connect;
+
+         } catch (Exception ex) {
+                 throw new TException.SQL_EXCEPTION("Reconnect attempted and fails:" + ex);
+         }
+     }
+     
+     protected void setPool()
+         throws TException
+     {
+        pool = FixityConnectionPool.getFixityConnectionPool(dburl, dbuser, dbpass);
+     }
+     
+     public void attemptReconnection()
+         throws TException
+     {
+         if (DEBUG) System.out.println("attemptReconnection entered");
+         shutDown();
+         try {
+            setPool();
+         } catch (Exception ex) {
+             System.err.println("WARNING setPool fails:" + ex);
+         }
+         
+     }
+
+     public Connection getConnectionOriginal(
+            boolean autoCommit)
+        throws TException
+     {
          if(pool == null) return null;
          try {
             return pool.getConnection(autoCommit);

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.db.FixityContextEntry;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.db.FixityHistoryEntry;
-import org.cdlib.mrt.fixity.utility.FixityDBUtil;
-import org.cdlib.mrt.fixity.action.AddFixityEntry;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-
-
-/**
- * Test
- * @author dloy
- */
-
-public class TestAddFixity
-{
-    private static final String NAME = "TestAddFixity";
-    private static final String MESSAGE = NAME + ": ";
-    private static final boolean SENDINGEST=true;
-    private static final boolean DELETECREATE=false;
-    protected LoggerInf logger = null;
-    protected FixityItemDB db = null;
-    protected Properties prop = null;
-
-    public TestAddFixity(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        db = new FixityItemDB(logger, prop);
-        this.prop = prop;
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestAddFixity test = new TestAddFixity(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            Connection connection = db.getConnection(true);
-            Properties prop = new Properties();
-            prop.setProperty("source", "web");
-            prop.setProperty("url", "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls");
-            prop.setProperty("type", "MD5");
-            prop.setProperty("value", "10fd0f569807aa5de4d6df592b6b4579");
-            prop.setProperty("size", "15872");
-            prop.setProperty("context", "attachments/20250670/testG18.xls");
-
-            System.out.println(PropertiesUtil.dumpProperties("match input ", prop));
-            FixityEntry entry = new FixityEntry(prop);
-            entry.printEntry("BEFORE");
-            AddFixityEntry add = AddFixityEntry.getAddFixityEntry(entry, connection, logger);
-
-            add.run();
-            entry.printEntry("AFTER");
-            Exception ex = add.getException();
-            if (ex != null) {
-                System.out.println("EXCEPTION:" + ex);
-            }
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } finally {
-            try {
-                db.shutDown();
-            } catch (Exception ex) {}
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import org.cdlib.mrt.core.FixityClient;
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.db.FixityContextEntry;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.db.FixityHistoryEntry;
-import org.cdlib.mrt.fixity.utility.FixityDBUtil;
-import org.cdlib.mrt.fixity.action.ProcessFixityEntry;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-
-
-/**
- * Test
- * @author dloy
- */
-
-public class TestClientProcessFixity
-{
-    private static final String NAME = "TestClientProcessFixity";
-    private static final String MESSAGE = NAME + ": ";
-    protected LoggerInf logger = null;
-    protected String serverURL = null;
-
-    public TestClientProcessFixity(String serverURL, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        this.serverURL = serverURL;
-        validate();
-    }
-
-    protected void validate()
-        throws TException
-    {
-        if (logger == null) {
-            throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "logger missing");
-        }
-        if (StringUtil.isEmpty(serverURL)) {
-            throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "serverURL missing");
-        }
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-
-            String propName = NAME + ".url";
-            String url = tFrame.getProperty(propName);
-            if (StringUtil.isEmpty(url)) {
-                throw new TException.INVALID_OR_MISSING_PARM("Missing parm:" + propName);
-            }
-            TestClientProcessFixity test = new TestClientProcessFixity(url, logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            Properties prop = new Properties();
-            prop.setProperty("source", "web");
-            prop.setProperty("url", "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls");
-            prop.setProperty("type", "MD5");
-            prop.setProperty("value", "10fd0f569807aa5de4d6df592b6b4579");
-            prop.setProperty("size", "15872");
-            prop.setProperty("context", "attachments/20250670/testG18.xls");
-            runProcess("OK test", "test", prop);
-
-            prop.setProperty("value", "fffd0f569807aa5de4d6df592b6b4579");
-            prop.setProperty("size", "15872");
-            runProcess("FAIL test digest", "test", prop);
-
-            prop.setProperty("value", "10fd0f569807aa5de4d6df592b6b4579");
-            prop.setProperty("size", "15870");
-            runProcess("FAIL test size", "test", prop);
-
-            
-            prop.setProperty("source", "web");
-            prop.setProperty("url", "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls");
-            prop.setProperty("type", "MD5");
-            prop.setProperty("value", "10fd0f569807aa5de4d6df592b6b4579");
-            prop.setProperty("size", "15872");
-            prop.setProperty("context", "attachments/20250670/testG18.xls");
-
-
-            delete(prop);
-            runProcess("OK add", "add", prop);
-
-            runProcess("FAIL duplicate add", "add", prop);
-
-            runProcess("FAIL duplicate queue", "queue", prop);
-
-            delete(prop);
-            runProcess("OK queue", "queue", prop);
-
-            runProcess("FAIL duplicate queue 2", "queue", prop);
-
-            Properties updateProp = new Properties();
-            updateProp.setProperty("url", "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls");
-            updateProp.setProperty("context", "New attachment");
-            runUpdate("OK add attachment 2", "update", updateProp);
-
-            updateProp = new Properties();
-            updateProp.setProperty("url", "https://xxxxx.ucop.edu/download/attachments/20250670/testG18.xls");
-            updateProp.setProperty("context", "New attachment");
-            runUpdate("FAIL - update url not found", "update", updateProp);
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-
-        } 
-    }
-
-    protected Properties delete(
-            Properties prop)
-    {
-        try {
-            FixityClient client = new FixityClient(logger);
-
-            FixityEntry entry = new FixityEntry(prop);
-            System.out.println("------------------------------------------------------------");
-            System.out.println(">>>>DELETE " + entry.getUrl() + "    <<<<");
-            System.out.println("------------------------------------------------------------");
-            Properties retProp = client.delete(serverURL, 30000, 3, entry.getUrl(), "XML");
-            System.out.println(PropertiesUtil.dumpProperties("D IN", prop));
-            System.out.println(PropertiesUtil.dumpProperties("DELETE", prop));
-            return retProp;
-
-        } catch (Exception ex) {
-            System.out.println("delete exception:" + ex);
-            ex.printStackTrace();
-            return null;
-        }
-    }
-
-    protected Properties runProcess(
-            String header,
-            String cmd,
-            Properties prop)
-        throws TException
-    {
-        try {
-            System.out.println("------------------------------------------------------------");
-            System.out.println(">>>>   " + header + "    <<<<");
-            System.out.println("------------------------------------------------------------");
-
-            FixityClient client = new FixityClient(logger);
-            FixityEntry entry = new FixityEntry(prop);
-            entry.printEntry("runProcess");
-            FixityEntry.SourceType sourceType = entry.getSource();
-            String sourceTypeS = null;
-            if (sourceType != null) sourceTypeS = sourceType.toString();
-            Properties retProp = client.process(
-                cmd,
-                serverURL,
-                30000,
-                3,
-                entry.getUrl(),
-                sourceTypeS,
-                "" + entry.getSize(),
-                entry.getDigestType(),
-                entry.getDigestValue(),
-                "Context:" + entry.getUrl(),
-                entry.getNote(),
-                "xml");
-
-            System.out.println(PropertiesUtil.dumpProperties("CLIENT IN", prop));
-            System.out.println(PropertiesUtil.dumpProperties("CLIENT OUT", retProp));
-            return retProp;
-
-        } catch (Exception ex) {
-            System.out.println("runProcess exception:" + ex);
-            ex.printStackTrace();
-            return null;
-        }
-    }
-
-    protected Properties runUpdate(
-            String header,
-            String cmd,
-            Properties prop)
-        throws TException
-    {
-        try {
-            System.out.println("------------------------------------------------------------");
-            System.out.println(">>>>   " + header + "    <<<<");
-            System.out.println("------------------------------------------------------------");
-
-            FixityClient client = new FixityClient(logger);
-            FixityEntry entry = new FixityEntry(prop);
-            entry.printEntry("runUpdate");
-            String contextEntry = null;
-            if (entry.getContextEntry(0) != null) {
-                contextEntry = entry.getContextEntry(0).getContext();
-            }
-            FixityEntry.SourceType sourceType = entry.getSource();
-            String sourceTypeS = null;
-            if (sourceType != null) sourceTypeS = sourceType.toString();
-            Properties retProp = client.update(
-                serverURL,
-                30000,
-                3,
-                null,
-                entry.getUrl(),
-                sourceTypeS,
-                "" + entry.getSize(),
-                entry.getDigestType(),
-                entry.getDigestValue(),
-                contextEntry,
-                entry.getNote(),
-                "xml");
-
-            System.out.println(PropertiesUtil.dumpProperties("CLIENT IN", prop));
-            System.out.println(PropertiesUtil.dumpProperties("CLIENT OUT", retProp));
-            return retProp;
-
-        } catch (Exception ex) {
-            System.out.println("runProcess exception:" + ex);
-            ex.printStackTrace();
-            return null;
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-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.fixity.action.FixityValidation;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-
-
-/**
- * Test
- * @author dloy
- */
-
-public class TestFixity
-{
-    private static final String NAME = "TestFixity";
-    private static final String MESSAGE = NAME + ": ";
-    private static final boolean SENDINGEST=true;
-    private static final boolean DELETECREATE=false;
-    protected LoggerInf logger = null;
-    protected FixityItemDB db = null;
-    protected Properties prop = null;
-
-    public TestFixity(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        db = new FixityItemDB(logger, prop);
-        this.prop = prop;
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestFixity test = new TestFixity(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            for (int id=1; id < 10; id++) {
-                Connection connection = db.getConnection(true);
-                FixityEntry entry = FixityDBUtil.getItemEntry(connection, id, logger);
-                if (entry == null) {
-                    System.out.print("EXIT: " + id);
-                    break;
-                }
-                System.out.println(entry.dump("BEFORE(" + id + ")"));
-                
-                FixityValidation valid = FixityValidation.getFixityValidation(entry, connection, logger);
-                valid.run();
-                System.out.println(entry.dump("AFTER (" + id + ")"));
-                 
-            }
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } finally {
-            try {
-                db.shutDown();
-            } catch (Exception ex) {}
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.db.FixityContextEntry;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.db.FixityHistoryEntry;
-import org.cdlib.mrt.core.FixityClient;
-import org.cdlib.mrt.fixity.utility.FixityDBUtil;
-import org.cdlib.mrt.fixity.action.AddFixityEntry;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-
-/**
- * Test
- * @author dloy
- */
-
-public class TestFixityClient
-{
-    private static final String NAME = "TestFixityClient";
-    private static final String MESSAGE = NAME + ": ";
-
-    protected LoggerInf logger = null;
-    protected Properties prop = null;
-    protected FixityClient client = null;
-
-    public TestFixityClient(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        this.prop = prop;
-        client = new FixityClient(logger);
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestFixityClient test = new TestFixityClient(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            delete();
-            add();
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-
-
-    private void delete()
-        throws TException
-    {
-        try {
-            Properties response = client.delete(
-                "http://localhost:28080/mrtfixity",
-                30000,
-                3,
-                "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls",
-                "JSON");
-            System.out.println(PropertiesUtil.dumpProperties("DELETE", response));
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } 
-    }
-
-    private void add()
-        throws TException
-    {
-        try {
-            Properties response = client.add(
-                "http://localhost:28080/mrtfixity",
-                30000,
-                3,
-                "https://confluence.ucop.edu/download/attachments/20250670/testG18.xls",
-                "web",
-                "15872",
-                "MD5",
-                "10fd0f569807aa5de4d6df592b6b4579",
-                "attachments/20250670/testG18.xls",
-                null,
-                "JSON");
-            System.out.println(PropertiesUtil.dumpProperties("ADD", response));
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.action.FixityReportEntries;
-import org.cdlib.mrt.fixity.service.FixityEntriesState;
-
-
-import org.cdlib.mrt.formatter.FormatterAbs;
-import org.cdlib.mrt.formatter.FormatterInf;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.action.FixityReportItem;
-import org.cdlib.mrt.fixity.action.FixityEmailWrapper;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.StateInf;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-/**
- * Test
- * @author dloy
- */
-
-public class TestFixityItemReport
-{
-    private static final String NAME = "TestFixityItemReport";
-    private static final String MESSAGE = NAME + ": ";
-    private static final String NL = System.getProperty("line.separator");
-    protected LoggerInf logger = null;
-    protected FixityItemDB db = null;
-    protected Properties prop = null;
-
-    public TestFixityItemReport(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        db = new FixityItemDB(logger, prop);
-        this.prop = prop;
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestFixityItemReport test = new TestFixityItemReport(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            String match = "%5.pdf";
-            prop.setProperty("url", match);
-            FixityEntry entry = new FixityEntry(prop);
-            entry.setStatus((FixityEntry.StatusType)null);
-            runReport("all", match);
-            runWrapper("all", match);
-
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } finally {
-            try {
-                db.shutDown();
-            } catch (Exception ex) {}
-        }
-    }
-
-    private void runReport(String typeS, String context)
-        throws TException
-    {
-        try {
-            Connection connection = db.getConnection(true);
-            FixityReportItem report = FixityReportItem.getFixityReportItem(typeS, context, logger);
-            report.setConnection(connection);
-            FixityEntriesState state = report.call();
-            FormatterInf anvl = FormatterAbs.getJSONFormatter(logger);
-            String format = formatIt(anvl, state);
-            System.out.println("OUTPUT:" + NL + format);
-            
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-
-    private void runWrapper(String typeS, String context)
-        throws TException
-    {
-
-        try {
-            String propName = NAME + ".mailTo";
-            String mailTo = prop.getProperty(propName);
-            if (StringUtil.isEmpty(mailTo)) {
-                throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "property missing:" + propName);
-            }
-
-            FixityReportItem report = FixityReportItem.getFixityReportItem(typeS, context, logger);
-            FixityEmailWrapper wrapper = new FixityEmailWrapper(
-                report,
-                true,
-                mailTo,
-                "uc3-support@ucop.edu",
-                "TestFixityItemReport subject",
-                "This is a TestFixityItemReport message",
-                "XML",
-                db,
-                prop,
-                logger);
-            wrapper.run();
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-
-    public static String formatIt(
-            FormatterInf formatter,
-            StateInf responseState)
-    {
-        try {
-           if (responseState == null) {
-               return "NULL RESPONSE";
-           }
-           ByteArrayOutputStream outStream = new ByteArrayOutputStream(5000);
-           PrintStream  stream = new PrintStream(outStream, true, "utf-8");
-           formatter.format(responseState, stream);
-           stream.close();
-           byte [] bytes = outStream.toByteArray();
-           String retString = new String(bytes, "UTF-8");
-           return retString;
-
-        } catch (Exception ex) {
-            System.out.println("Exception:" + ex);
-            System.out.println("Trace:" + StringUtil.stackTrace(ex));
-            return null;
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.action.FixityReportEntries;
-import org.cdlib.mrt.fixity.service.FixityEntriesState;
-
-
-import org.cdlib.mrt.formatter.FormatterAbs;
-import org.cdlib.mrt.formatter.FormatterInf;
-import org.cdlib.mrt.fixity.db.FixityEntry;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.action.FixityReportEntries;
-import org.cdlib.mrt.fixity.action.FixityEmailWrapper;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.StateInf;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-/**
- * Test
- * @author dloy
- */
-
-public class TestFixityItemsReport
-{
-    private static final String NAME = "TestFixityItemsReport";
-    private static final String MESSAGE = NAME + ": ";
-    private static final String NL = System.getProperty("line.separator");
-    protected LoggerInf logger = null;
-    protected FixityItemDB db = null;
-    protected Properties prop = null;
-
-    public TestFixityItemsReport(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        db = new FixityItemDB(logger, prop);
-        this.prop = prop;
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestFixityItemsReport test = new TestFixityItemsReport(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            String match = "http://localhost:28080/fixity/b%";
-            prop.setProperty("url", match);
-            FixityEntry entry = new FixityEntry(prop);
-            entry.setStatus((FixityEntry.StatusType)null);
-            runReport(entry);
-            runWrapper(entry);
-
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } finally {
-            try {
-                db.shutDown();
-            } catch (Exception ex) {}
-        }
-    }
-
-    private void runReport(FixityEntry entry)
-        throws TException
-    {
-        try {
-            Connection connection = db.getConnection(true);
-            FixityReportEntries report = FixityReportEntries.getFixityReportEntries(entry, logger);
-            report.setConnection(connection);
-            FixityEntriesState state = report.call();
-            FormatterInf anvl = FormatterAbs.getJSONFormatter(logger);
-            String format = formatIt(anvl, state);
-            System.out.println("OUTPUT:" + NL + format);
-            
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-
-    private void runWrapper(FixityEntry entry)
-        throws TException
-    {
-
-        try {
-            String propName = NAME + ".mailTo";
-            String mailTo = prop.getProperty(propName);
-            if (StringUtil.isEmpty(mailTo)) {
-                throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "property missing:" + propName);
-            }
-
-            FixityReportEntries report = FixityReportEntries.getFixityReportEntries(entry, logger);
-
-            FixityEmailWrapper wrapper = new FixityEmailWrapper(
-                report,
-                true,
-                mailTo,
-                "uc3-support@ucop.edu",
-                "TestFixityItemsReport subject",
-                "This is a TestFixityItemsReport message",
-                "XML",
-                db,
-                prop,
-                logger);
-            wrapper.run();
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        }
-    }
-
-    public static String formatIt(
-            FormatterInf formatter,
-            StateInf responseState)
-    {
-        try {
-           if (responseState == null) {
-               return "NULL RESPONSE";
-           }
-           ByteArrayOutputStream outStream = new ByteArrayOutputStream(5000);
-           PrintStream  stream = new PrintStream(outStream, true, "utf-8");
-           formatter.format(responseState, stream);
-           stream.close();
-           byte [] bytes = outStream.toByteArray();
-           String retString = new String(bytes, "UTF-8");
-           return retString;
-
-        } catch (Exception ex) {
-            System.out.println("Exception:" + ex);
-            System.out.println("Trace:" + StringUtil.stackTrace(ex));
-            return null;
-        }
-    }
-}

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

-/******************************************************************************
-Copyright (c) 2005-2012, Regents of the University of California
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- *
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-- Neither the name of the University of California nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-*******************************************************************************/
-
-package org.cdlib.mrt.fixity.test;
-
-import java.util.Properties;
-
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-import org.cdlib.mrt.utility.TException;
-import org.cdlib.mrt.utility.LoggerInf;
-import org.cdlib.mrt.utility.StringUtil;
-
-import java.sql.Connection;
-import org.cdlib.mrt.fixity.action.FixityReportSQL;
-import org.cdlib.mrt.fixity.service.FixitySelectState;
-
-
-import org.cdlib.mrt.formatter.FormatterAbs;
-import org.cdlib.mrt.formatter.FormatterInf;
-import org.cdlib.mrt.fixity.db.FixityItemDB;
-import org.cdlib.mrt.fixity.action.FixityEmailWrapper;
-import org.cdlib.mrt.utility.PropertiesUtil;
-import org.cdlib.mrt.utility.StateInf;
-import org.cdlib.mrt.utility.TFileLogger;
-import org.cdlib.mrt.utility.TFrame;
-/**
- * Test
- * @author dloy
- */
-
-public class TestFixityReport
-{
-    private static final String NAME = "TestFixityReport";
-    private static final String MESSAGE = NAME + ": ";
-    private static final String NL = System.getProperty("line.separator");
-    protected LoggerInf logger = null;
-    protected FixityItemDB db = null;
-    protected Properties prop = null;
-
-    public TestFixityReport(Properties prop, LoggerInf logger)
-        throws TException
-    {
-        this.logger = logger;
-        db = new FixityItemDB(logger, prop);
-        this.prop = prop;
-    }
-
-    /**
-     * Main method
-     */
-    public static void main(String args[])
-    {
-
-        TFrame tFrame = null;
-        try {
-            String propertyList[] = {
-                "resources/FixityTest.properties"};
-            tFrame = new TFrame(propertyList, "TestFixity");
-
-            // Create an instance of this object
-            LoggerInf logger = new TFileLogger(NAME, 50, 50);
-            TestFixityReport test = new TestFixityReport(tFrame.getProperties(), logger);
-            test.run();
-
-        } catch(Exception e) {
-                System.out.println(
-                    "Main: Encountered exception:" + e);
-                System.out.println(
-                        StringUtil.stackTrace(e));
-        }
-    }
-
-    private void run()
-        throws TException
-    {
-        try {
-            runReport();
-            runWrapper();
-
-
-        } catch (TException fe) {
-            throw fe;
-
-        }  catch(Exception e)  {
-            if (logger != null)
-            {
-                logger.logError(
-                    "Main: Encountered exception:" + e, 0);
-                logger.logError(
-                        StringUtil.stackTrace(e), 10);
-            }
-            throw new TException(e);
-        } finally {
-            try {
-                db.shutDown();
-            } catch (Exception ex) {}
-        }
-    }
-
-    private void runReport()
-        throws TException
-    {
-        try {
-            String propName = NAME + ".select";
-            String select = prop.getProperty(propName);
-            if (StringUtil.isEmpty(select)) {
-                throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "property missing:" + propName);
-            }
-
-            Connection connection = db.getConnection(true);
-            FixityReportSQL report = FixityReportSQL.getFixityReportSQL(select, logger);
-            report.setConnection(connection);
-            FixitySelectState state = report.call();
-            Properties retProp = state.getRow(0);