[Mulgara-svn] r2044 - in trunk/src/jar: resolver-store/java/org/mulgara/store/statement/xa resolver-url/java/org/mulgara/resolver/url store-stringpool-xa/java/org/mulgara/store/stringpool/xa store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11 tag/java/org/mulgara/extractor/tag tag/java/org/mulgara/tag tag/java/org/mulgara/util web/java/org/mulgara/webquery

alexhall at mulgara.org alexhall at mulgara.org
Mon Sep 26 22:50:54 UTC 2011


Author: alexhall
Date: 2011-09-26 22:50:53 +0000 (Mon, 26 Sep 2011)
New Revision: 2044

Modified:
   trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
   trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java
   trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolverFactory.java
   trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
   trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java
   trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolLoadTest.java
   trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeMapper.java
   trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
   trunk/src/jar/tag/java/org/mulgara/extractor/tag/AlldocsTEI.java
   trunk/src/jar/tag/java/org/mulgara/extractor/tag/InitTEI.java
   trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTEI.java
   trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTag.java
   trunk/src/jar/tag/java/org/mulgara/extractor/tag/RenderTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/AnswerTEI.java
   trunk/src/jar/tag/java/org/mulgara/tag/AnswerTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/ExecuteTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/InitTEI.java
   trunk/src/jar/tag/java/org/mulgara/tag/InitTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/QueryTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/RenderTag.java
   trunk/src/jar/tag/java/org/mulgara/tag/StatementTEI.java
   trunk/src/jar/tag/java/org/mulgara/tag/StatementTag.java
   trunk/src/jar/tag/java/org/mulgara/util/CachedTransformerFactory.java
   trunk/src/jar/tag/java/org/mulgara/util/TagSoapClient.java
   trunk/src/jar/web/java/org/mulgara/webquery/ResourceBinaryFile.java
Log:
More updates for Fortify compliance, and to quiet Java warnings.

Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -295,13 +295,20 @@
    * @throws IOException EXCEPTION TO DO
    */
   public synchronized void close() throws IOException {
+    boolean success = false;
     try {
       if (avlFile != null) {
         avlFile.close();
       }
+      success = true;
     } finally {
       if (blockFile != null) {
-        blockFile.close();
+        try {
+          blockFile.close();
+        } catch (IOException e) {
+          if (success) throw e; // This is a new exception, need to re-throw it.
+          else logger.info("Suppressing I/O exception cleaning up from failed write", e); // Log suppressed exception.
+        }
       }
     }
   }
@@ -678,10 +685,17 @@
 
       if (tripleWriteThread != null) tripleWriteThread.drain();
 
+      boolean success = false;
       try {
         syncAddTriple(triple);
+        success = true;
       } finally {
-        releaseCache();
+        try {
+          releaseCache();
+        } catch (IOException e) {
+          if (success) throw e; // This is a new exception, need to re-throw it.
+          else logger.info("Suppressing I/O exception cleaning up from failed write", e); // Log suppressed exception.
+        }
       }
     }
 
@@ -696,6 +710,7 @@
       if (this != currentPhase) throw new IllegalStateException("Attempt to modify a read-only phase.");
 
       Arrays.sort(triples, tripleComparator);
+      boolean success = false;
       try {
         for (int i = 0; i < triples.length; ++i) {
           long[] triple = triples[i];
@@ -705,8 +720,14 @@
           // wasn't already there.
           syncAddTriple(triple);
         }
+        success = true;
       } finally {
-        releaseCache();
+        try {
+          releaseCache();
+        } catch (IOException e) {
+          if (success) throw e; // This is a new exception, need to re-throw it.
+          else logger.info("Suppressing I/O exception cleaning up from failed write", e); // Log suppressed exception.
+        }
       }
     }
 
@@ -826,6 +847,7 @@
       }
       node.incRefCount();
 
+      boolean success = false;
       Block tripleBlock = null;
       boolean tripleBlockDirty = false;
       try {
@@ -1022,10 +1044,16 @@
         }
         node.write();
         incNrTriples();
+        success = true;
         return;
       } finally {
         if (tripleBlock != null) {
-          if (tripleBlockDirty) releaseBlockToCache(tripleBlock);
+          try {
+            if (tripleBlockDirty) releaseBlockToCache(tripleBlock);
+          } catch (IOException e) {
+            if (success) throw e; // Otherwise succeeded, need to throw this new exception.
+            else logger.info("Suppressing I/O exception for failed AVL file", e);
+          }
         }
         AVLFile.release(findResult);
         releaseNodeToCache(node);
@@ -2178,8 +2206,11 @@
           throw new RuntimeException(ex.toString(), ex);
         } finally {
           try {
-            if (t1 != null) t1.close();
-            if (t2 != null) t2.close();
+            try {
+              if (t1 != null) t1.close();
+            } finally {
+              if (t2 != null) t2.close();
+            }
           } catch (TuplesException ex) {
             throw new RuntimeException(ex.toString(), ex);
           }

Modified: trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java
===================================================================
--- trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -72,7 +72,7 @@
   /**
    * Logger.
    */
-  private static Logger logger = Logger.getLogger(URLResolver.class.getName());
+  private static final Logger logger = Logger.getLogger(URLResolver.class.getName());
 
   /**
    * The session that this resolver is associated with.

Modified: trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolverFactory.java
===================================================================
--- trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolverFactory.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolverFactory.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -50,7 +50,7 @@
    * Logger.
    */
   @SuppressWarnings("unused")
-  private static Logger logger = Logger.getLogger(URLResolverFactory.class.getName());
+  private static final Logger logger = Logger.getLogger(URLResolverFactory.class.getName());
 
   //
   // Constructors

Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -845,6 +845,7 @@
     // TODO: This synchronization is probably redundant due to the global lock in StringPoolSession
     synchronized (this) {
       checkInitialized();
+      boolean success = false;
       try {
         if (prepared) {
           // Restore phaseIndex and phaseNumber to their previous values.
@@ -859,6 +860,7 @@
           block.write();
           metarootFile.force();
         }
+        success = true;
       } catch (IOException ex) {
         throw new SimpleXAResourceException(
             "I/O error while performing rollback (invalidating metaroot)", ex
@@ -867,9 +869,13 @@
         try {
           new Phase(committedPhaseToken.getPhase());
         } catch (IOException ex) {
-          throw new SimpleXAResourceException(
-              "I/O error while performing rollback (new committed phase)", ex
-          );
+          if (success) { // this is a new exception...
+            throw new SimpleXAResourceException(
+                "I/O error while performing rollback (new committed phase)", ex
+            );
+          } else { // something else already went wrong, log it and throw it away.
+            logger.info("I/O error while performing rollback (new committed phase)", ex);
+          }
         }
       }
     }

Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImplTest.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -27,26 +27,24 @@
 
 package org.mulgara.store.stringpool.xa;
 
-import java.io.*;
-import java.net.*;
-import java.nio.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
 
-// Java 2 standard packages
-import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
-// third party packages
-import junit.framework.*;
 import org.apache.log4j.Logger;
-
-
-// locally written packages
 import org.mulgara.query.Cursor;
 import org.mulgara.query.TuplesException;
-import org.mulgara.query.rdf.*;
-import org.mulgara.store.*;
+import org.mulgara.query.rdf.XSD;
 import org.mulgara.store.nodepool.NodePool;
-import org.mulgara.store.stringpool.*;
-import org.mulgara.store.stringpool.xa.SPObjectFactoryImpl;
+import org.mulgara.store.stringpool.SPObject;
+import org.mulgara.store.stringpool.StringPoolAbstractTest;
+import org.mulgara.store.stringpool.StringPoolException;
 import org.mulgara.store.tuples.Tuples;
 import org.mulgara.store.xa.SimpleXAResource;
 import org.mulgara.store.xa.SimpleXAResourceException;
@@ -76,6 +74,7 @@
  */
 public class XAStringPoolImplTest extends StringPoolAbstractTest {
 
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(XAStringPoolImplTest.class);
 
 
@@ -538,7 +537,7 @@
         "1969-12-31T23:59:59", XSD.DATE_TIME_URI
     ));
 
-    List allStrings = new ArrayList();
+    List<Long> allStrings = new ArrayList<Long>();
     allStrings.add(new Long(11)); // alpha
     allStrings.add(new Long(12)); // bravo
     allStrings.add(new Long(22)); // charlie
@@ -617,7 +616,7 @@
     assertEquals(allStrings.subList(4, 7), asList(t));
     t.close();
 
-    List allDoubles = new ArrayList();
+    List<Long> allDoubles = new ArrayList<Long>();
     allDoubles.add(new Long(30)); // -10
     allDoubles.add(new Long(29)); // 3.14159265358979323846
     allDoubles.add(new Long(15)); // 42
@@ -688,7 +687,7 @@
     assertEquals(allDoubles.subList(4, 10), asList(t));
     t.close();
 
-    List allDates = new ArrayList();
+    List<Long> allDates = new ArrayList<Long>();
     allDates.add(new Long(17)); // 18/09/1966 15:00
     allDates.add(new Long(42)); // 05/05/1968
     allDates.add(new Long(50)); // 31/12/1969 23:59:59
@@ -824,8 +823,8 @@
   /**
    * Converts a single column Tuples to a List of Longs.
    */
-  static List asList(Tuples t) throws TuplesException {
-    List l = new ArrayList();
+  static List<Long> asList(Tuples t) throws TuplesException {
+    List<Long> l = new ArrayList<Long>();
     long rowCount = t.getRowCount();
 
     t.beforeFirst();

Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolLoadTest.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolLoadTest.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolLoadTest.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -29,9 +29,6 @@
 
 import java.io.*;
 
-// Java 2 standard packages
-import java.util.*;
-
 // third party packages
 import junit.framework.*;
 import org.apache.log4j.Logger;
@@ -66,11 +63,13 @@
   /**
    * Logger.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(XAStringPoolLoadTest.class);
 
   /**
    * Description of the Field
    */
+  @SuppressWarnings("unused")
   private static File dbDirName = new File(
       System.getProperty("java.io.tmpdir"), System.getProperty("user.name")
       );

Modified: trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeMapper.java
===================================================================
--- trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeMapper.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeMapper.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 
+import org.apache.log4j.Logger;
 import org.mulgara.util.IntFile;
 import org.mulgara.util.LongMapper;
 
@@ -30,6 +31,8 @@
  */
 public class BlankNodeMapper implements LongMapper {
 
+  private static final Logger logger = Logger.getLogger(BlankNodeMapper.class);
+  
   /** Maps normal node values to other node values. */
   private IntFile nodeMap;
 
@@ -45,10 +48,20 @@
    * @see org.mulgara.util.LongMapper#delete()
    */
   public void delete() throws IOException {
+    boolean success = false;
     try {
       nodeMap.delete();
+      success = true;
     } finally {
-      blankNodeMap.delete();
+      try {
+        blankNodeMap.delete();
+      } catch (IOException e) {
+        if (success) { // nodeMap was successfully deleted, this is a new exception so re-throw it.
+          throw e;
+        } else { // nodeMap failed also, so suppress this exception and allow the original one to be thrown.
+          logger.info("I/O exception on failed delete", e);
+        }
+      }
     }
   }
 

Modified: trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -516,6 +516,7 @@
    */
   public void rollback() throws SimpleXAResourceException {
     // TODO: This synchronization is probably redundant due to the global lock in StringPoolSession
+    SimpleXAResourceException xaEx = null; // variable to hold the first thrown exception.
     synchronized (this) {
       checkInitialized();
       try {
@@ -533,7 +534,7 @@
           metarootFile.force();
         }
       } catch (IOException ex) {
-        throw new SimpleXAResourceException("I/O error while performing rollback (invalidating metaroot)", ex);
+        xaEx = new SimpleXAResourceException("I/O error while performing rollback (invalidating metaroot)", ex);
       } finally {
         try {
           try {
@@ -545,13 +546,20 @@
             gNodeToDataFile.truncate(offset);
             MappingUtil.truncate(gNodeToDataAppender, offset);
           } catch (IOException ioe) {
-            throw new SimpleXAResourceException("I/O error while performing rollback (new committed phase)", ioe);
+            String msg = "I/O error while performing rollback (new committed phase)";
+            if (xaEx == null) xaEx = new SimpleXAResourceException(msg, ioe); // this is the first exception.
+            else logger.info(msg, ioe); // another exception already occurred, log the suppressed exception.
           }
         } finally {
           try {
             currentPhase = new TreePhase(committedPhaseToken.getPhase());
           } catch (IOException ex) {
-            throw new SimpleXAResourceException("I/O error while performing rollback (new committed phase)", ex);
+            String msg = "I/O error while performing rollback (new committed phase)";
+            if (xaEx == null) xaEx = new SimpleXAResourceException(msg, ex); // this is the first exception.
+            else logger.info(msg, ex); // another exception already occurred, log the suppressed exception.
+          } finally {
+            // This is the last thing to execute; re-throw any previously caught exception now.
+            if (xaEx != null) throw xaEx;
           }
         }
       }
@@ -1080,6 +1088,7 @@
      * @return <code>true</code> for a file with an appropriate header, <code>false</code> otherwise.
      */
     public static boolean check(String filename) throws IOException {
+      boolean failed = false;
       RandomAccessFile file = new RandomAccessFile(filename, "r");
       try {
         if (file.length() < 2 * Constants.SIZEOF_INT) return false;
@@ -1090,8 +1099,16 @@
           fileVersion = XAUtils.bswap(fileVersion);
         }
         if (FILE_MAGIC != fileMagic || FILE_VERSION != fileVersion) return false;
+      } catch (IOException e) {
+        failed = true;
+        throw e;
       } finally {
-        file.close();
+        try {
+          file.close();
+        } catch (IOException e) {
+          if (!failed) throw e;
+          else logger.info("I/O exception closing a failed file", e);
+        }
       }
       return true;
     }

Modified: trunk/src/jar/tag/java/org/mulgara/extractor/tag/AlldocsTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/extractor/tag/AlldocsTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/extractor/tag/AlldocsTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,10 +28,14 @@
 package org.mulgara.extractor.tag;
 
 // standard java packages
-import java.net.*;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
 
 /**
  * Validates attributes and creates scripting variables for the {@link
@@ -108,9 +112,9 @@
       try {
 
         // try to convert it to a URL
-        URI modelURL = new URI((String) model);
+        new URI((String) model);
       }
-       catch (Exception e) {
+       catch (URISyntaxException e) {
 
         valid = false;
       }
@@ -130,9 +134,9 @@
         try {
 
           // try to convert it to a URL
-          URL serverURL = new URL((String) server);
+          new URL((String) server);
         }
-         catch (Exception e) {
+         catch (MalformedURLException e) {
 
           valid = false;
         }

Modified: trunk/src/jar/tag/java/org/mulgara/extractor/tag/InitTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/extractor/tag/InitTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/extractor/tag/InitTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,10 +28,13 @@
 package org.mulgara.extractor.tag;
 
 // standard java packages
-import java.net.*;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
 
 /**
  * Validates attributes for the {@link InitTag} tag.
@@ -72,9 +75,9 @@
       try {
 
         // try to convert it to a URL
-        URL serverURL = new URL((String) server);
+        new URL((String) server);
       }
-       catch (Exception e) {
+       catch (MalformedURLException e) {
 
         valid = false;
       }
@@ -94,9 +97,9 @@
         try {
 
           // try to convert it to a URI
-          URI modelURL = new URI((String) model);
+          new URI((String) model);
         }
-         catch (Exception e) {
+         catch (URISyntaxException e) {
 
           valid = false;
         }

Modified: trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,10 +28,14 @@
 package org.mulgara.extractor.tag;
 
 // standard java packages
-import java.net.*;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
 
 /**
  * Validates attributes and creates scripting variables for the {@link
@@ -108,9 +112,9 @@
       try {
 
         // try to convert it to a URL
-        URL serverURL = new URL((String) server);
+        new URL((String) server);
       }
-       catch (Exception e) {
+       catch (MalformedURLException e) {
 
         valid = false;
       }
@@ -130,9 +134,9 @@
         try {
 
           // try to convert it to a URI
-          URI modelURI = new URI((String) model);
+          new URI((String) model);
         }
-         catch (Exception e) {
+         catch (URISyntaxException e) {
 
           valid = false;
         }
@@ -155,9 +159,9 @@
         try {
 
           // try to convert it to a URI
-          URL documentURL = new URL((String) document);
+          new URL((String) document);
         }
-         catch (Exception e) {
+         catch (MalformedURLException e) {
 
           valid = false;
         }

Modified: trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/extractor/tag/MetadataTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -63,6 +63,8 @@
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 public class MetadataTag extends TagSupport {
+  
+  private static final boolean DEBUG = false;
 
   /** Serialization ID */
   private static final long serialVersionUID = -2907904987343759108L;
@@ -693,37 +695,42 @@
       BufferedReader in =
         new BufferedReader(new FileReader(queriesFileLocation));
 
-      // read in the contents of the file into the queries buffer
-      String line = in.readLine();
+      try {
+        
+        // read in the contents of the file into the queries buffer
+        String line = in.readLine();
 
-      while (line != null) {
+        while (line != null) {
 
-        // log that we've read the line
-        if (log.isDebugEnabled()) {
+          // log that we've read the line
+          if (log.isDebugEnabled()) {
 
-          log.debug("Read line: " + line);
-        }
+            log.debug("Read line: " + line);
+          }
 
-        // trim the line
-        line = line.trim();
+          // trim the line
+          line = line.trim();
 
-        // ignore comments and blank lines
-        if (!line.startsWith("#") && !line.equals("")) {
+          // ignore comments and blank lines
+          if (!line.startsWith("#") && !line.equals("")) {
 
-          // replace any markers in the text with the real values
-          line = line.replaceAll(MODEL_MARKER, model.toString());
-          line = line.replaceAll(DOCUMENT_MARKER, document.toString());
+            // replace any markers in the text with the real values
+            line = line.replaceAll(MODEL_MARKER, model.toString());
+            line = line.replaceAll(DOCUMENT_MARKER, document.toString());
 
-          // log that we've replaced the markers in the line
-          log.debug("Replaced markers in line: " + line);
+            // log that we've replaced the markers in the line
+            log.debug("Replaced markers in line: " + line);
 
-          // save the line
-          queries.append(line);
+            // save the line
+            queries.append(line);
+          }
+
+          // end if
+          // read the next one...
+          line = in.readLine();
         }
-
-        // end if
-        // read the next one...
-        line = in.readLine();
+      } finally {
+        in.close();
       }
 
       // end while
@@ -761,7 +768,7 @@
     // construct the query
     StringBuffer metadataQuery = new StringBuffer();
 
-    if (false) {
+    if (DEBUG) {
 
       metadataQuery.append(
         "select $docNode $predicate $predicateLabel $classLabel $value $score $generator " +

Modified: trunk/src/jar/tag/java/org/mulgara/extractor/tag/RenderTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/extractor/tag/RenderTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/extractor/tag/RenderTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -65,6 +65,10 @@
  */
 public class RenderTag extends BodyTagSupport {
 
+  private static final long serialVersionUID = 5508736603982578506L;
+
+  private static final boolean DEBUG = false;
+  
   //
   // TMex classes
   //
@@ -139,7 +143,7 @@
   /**
    * the map of TMex class XSL stylesheet handlers
    */
-  private HashMap handlerMap = null;
+  private HashMap<String,URL> handlerMap = null;
 
   // release()
   //
@@ -180,7 +184,7 @@
   public void doInitBody() throws JspTagException {
 
     // create a new handler map
-    this.setHandlerMap(new HashMap());
+    this.handlerMap = new HashMap<String,URL>();
 
     try {
 
@@ -247,7 +251,11 @@
       log.debug("Rendering tag body contents");
 
       // render the content
-      this.render(masterStylesheet, contentReader, this.getPreviousOut());
+      try {
+        this.render(masterStylesheet, contentReader, this.getPreviousOut());
+      } finally {
+        contentReader.close();
+      }
     }
      catch (MalformedURLException mue) {
 
@@ -300,7 +308,7 @@
    */
   public void addHandler(String tmexClass, URL stylesheet) {
 
-    this.getHandlerMap().put(tmexClass, stylesheet);
+    this.handlerMap.put(tmexClass, stylesheet);
   }
 
   // addHandler()
@@ -309,30 +317,6 @@
   //
 
   /**
-   * Sets the map of TMex class XSL stylesheet handlers.
-   *
-   * @param handlerMap the map of TMex class XSL stylesheet handlers
-   */
-  private void setHandlerMap(HashMap handlerMap) {
-
-    this.handlerMap = handlerMap;
-  }
-
-  // setHandlerMap()
-
-  /**
-   * Returns the map of TMex class XSL stylesheet handlers.
-   *
-   * @return the map of TMex class XSL stylesheet handlers
-   */
-  private HashMap getHandlerMap() {
-
-    return this.handlerMap;
-  }
-
-  // getHandlerMap()
-
-  /**
    * Renders the <code>input</code> using the given XSL stylesheet.
    *
    * @param masterStylesheet PARAMETER TO DO
@@ -351,7 +335,7 @@
 
     // DEBUG *************
     //if (masterStylesheet.toString().endsWith("metadata.xsl")) {
-    if (false) {
+    if (DEBUG) {
 
       PrintWriter out = new PrintWriter(new BufferedWriter(output));
       out.println("<p>SOAP content is:</p>\n<pre>");

Modified: trunk/src/jar/tag/java/org/mulgara/tag/AnswerTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/AnswerTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/AnswerTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,11 +28,10 @@
 package org.mulgara.tag;
 
 // standard java packages
-import java.net.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
-
 /**
  * Validates attributes and creates scripting variables for the {@link
  * AnswerTag} tag.

Modified: trunk/src/jar/tag/java/org/mulgara/tag/AnswerTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/AnswerTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/AnswerTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,23 +28,23 @@
 package org.mulgara.tag;
 
 // Java 2 enterprise packages
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
 
-import javax.servlet.*;
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.*;
-import javax.xml.transform.stream.*;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
 
-// third party packages
-import org.apache.log4j.*;
-import org.w3c.dom.*;
-import org.xml.sax.*;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
 
 /**
  * Retrieves an answer to a query from a statement.
@@ -66,6 +66,8 @@
  */
 public class AnswerTag extends BodyTagSupport {
 
+  private static final long serialVersionUID = 3726055494484378655L;
+
   /**
    * variables to have page scope
    */
@@ -141,13 +143,13 @@
    * the answers to the specified statement
    *
    */
-  private ArrayList answers = null;
+  private ArrayList<Document> answers = null;
 
   /**
    * the mapping of query ids to answer list indices
    *
    */
-  private HashMap answerPositionMap = null;
+  private HashMap<String,Integer> answerPositionMap = null;
 
   // release()
   //
@@ -234,6 +236,7 @@
    * @throws JspException
    * @throws JspTagException EXCEPTION TO DO
    */
+  @SuppressWarnings("unchecked")
   public int doStartTag() throws JspTagException {
 
     // log that we're starting execution of the start tag
@@ -260,8 +263,8 @@
     log.debug("Verified that query attribute was set");
 
     // get the list of answers
-    ArrayList answers =
-        (ArrayList)this.pageContext.getAttribute(this.getStatement());
+    ArrayList<Document> answers =
+        (ArrayList<Document>)this.pageContext.getAttribute(this.getStatement());
 
     if (answers == null) {
 
@@ -271,15 +274,15 @@
 
     // end if
     // set the answers
-    this.setAnswers(answers);
+    this.answers = answers;
 
     // log that we've found the answers
     log.debug("Found " + answers.size() +
               " answers in the specified statement");
 
     // get mapping of answer positions
-    HashMap answerPositions =
-        (HashMap)this.pageContext.getAttribute(StatementTag.
+    HashMap<String, Integer> answerPositions =
+        (HashMap<String, Integer>)this.pageContext.getAttribute(StatementTag.
                                                KEY_STATEMENT_PREFIX +
                                                "." + this.getStatement());
 
@@ -291,14 +294,14 @@
 
     // end if
     // add the answer position map
-    this.setAnswerPositionMap(answerPositions);
+    this.answerPositionMap = answerPositions;
 
     // log that we've found the position map
     log.debug("Found query answers position map from specified statement " +
               "tag containing " + answerPositions.size() + " query id mappings");
 
     // continue to evaluate the body
-    return EVAL_BODY_TAG;
+    return EVAL_BODY_BUFFERED;
   }
 
   // doStartTag()
@@ -318,14 +321,14 @@
 
       // find out the position of the answer to the query
       Integer position =
-          (Integer)this.getAnswerPositionMap().get(this.getQuery());
+          this.answerPositionMap.get(this.getQuery());
 
       // only continue of we found its position (ie. there is an answer to
       // this query)
       if (position != null) {
 
         // get the answer to the query
-        Document answer = (Document)this.getAnswers().get(position.intValue());
+        Document answer = this.answers.get(position.intValue());
 
         // log that we've found an answer
         log.debug("Found answer to specified query");
@@ -390,7 +393,6 @@
     catch (Exception e) {
 
       log.error("Unhandled exception in answers tag", e);
-      e.printStackTrace();
     }
 
     // try-catch
@@ -417,33 +419,6 @@
   // getVariableScope()
 
   /**
-   * Sets the answers to the specified statement.
-   *
-   * @param answers The new Answers value
-   */
-  private void setAnswers(ArrayList answers) {
-
-    this.answers = answers;
-  }
-
-  // getAnswers()
-
-  /**
-   * Sets the mapping of query ids to answer list indices.
-   *
-   * @param answerPositionMap the mapping of query ids to answer list indices
-   */
-  private void setAnswerPositionMap(HashMap answerPositionMap) {
-
-    this.answerPositionMap = answerPositionMap;
-  }
-
-  // getScope()
-  //
-  // Internal methods
-  //
-
-  /**
    * Returns the scope to create the variables in (as a PageContext constant).
    *
    * @return the scope to create the variables in
@@ -482,29 +457,5 @@
     return scope;
   }
 
-  // setAnswers()
-
-  /**
-   * Returns the answers to the specified statement.
-   *
-   * @return the answers to the specified statement
-   */
-  private ArrayList getAnswers() {
-
-    return this.answers;
-  }
-
-  // setAnswerPositionMap()
-
-  /**
-   * Returns the mapping of query ids to answer list indices.
-   *
-   * @return the mapping of query ids to answer list indices
-   */
-  private HashMap getAnswerPositionMap() {
-
-    return this.answerPositionMap;
-  }
-
   // getAnswerPositionMap()
 }

Modified: trunk/src/jar/tag/java/org/mulgara/tag/ExecuteTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/ExecuteTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/ExecuteTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,15 +28,12 @@
 package org.mulgara.tag;
 
 // Java 2 enterprise packages
-import java.net.*;
-import java.util.*;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import org.apache.log4j.Logger;
 
-// Third party packages
-import org.apache.log4j.*;
-
 /**
  * Executes a statement.
  *
@@ -57,6 +54,8 @@
  */
 public class ExecuteTag extends TagSupport {
 
+  private static final long serialVersionUID = 3567013795216088561L;
+
   /**
    * the name of the query attribute
    */
@@ -174,7 +173,6 @@
     catch (Exception e) {
 
       log.error("Unhandled exception in query tag", e);
-      e.printStackTrace();
     }
 
     // try-catch

Modified: trunk/src/jar/tag/java/org/mulgara/tag/InitTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/InitTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/InitTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,10 +28,11 @@
 package org.mulgara.tag;
 
 // standard java packages
-import java.net.*;
+import java.net.MalformedURLException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
 
 /**
  * Validates attributes for the {@link InitTag} tag.
@@ -72,9 +73,9 @@
       try {
 
         // try to convert it to a URL
-        URL serverURL = new URL( (String) server);
+        new URL( (String) server);
       }
-      catch (Exception e) {
+      catch (MalformedURLException e) {
 
         valid = false;
       }

Modified: trunk/src/jar/tag/java/org/mulgara/tag/InitTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/InitTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/InitTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,14 +28,14 @@
 package org.mulgara.tag;
 
 // Java 2 enterprise packages
-import java.net.*;
-import java.util.*;
+import java.net.MalformedURLException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.TagSupport;
 
-// Third party packages
-import org.apache.log4j.*;
+import org.apache.log4j.Logger;
 
 /**
  * Initialises the Mulgara JSP environment.
@@ -59,6 +59,8 @@
  */
 public class InitTag extends TagSupport {
 
+  private static final long serialVersionUID = -5709763450328898111L;
+
   /**
    * variables to have page scope
    */

Modified: trunk/src/jar/tag/java/org/mulgara/tag/QueryTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/QueryTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/QueryTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -29,18 +29,12 @@
 
 
 // Java 2 enterprise packages
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
 
-import javax.servlet.*;
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import org.apache.log4j.Logger;
 
-// third party packages
-import org.apache.log4j.*;
-
 /**
  * Adds an iTQL query to a statement.
  *
@@ -61,6 +55,8 @@
  */
 public class QueryTag extends BodyTagSupport {
 
+  private static final long serialVersionUID = -2095876373529429038L;
+
   /**
    * the name of the id attribute
    *
@@ -127,7 +123,6 @@
     catch (Exception e) {
 
       log.error("Unhandled exception in query tag", e);
-      e.printStackTrace();
     }
 
     // try-catch

Modified: trunk/src/jar/tag/java/org/mulgara/tag/RenderTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/RenderTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/RenderTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,17 +28,25 @@
 package org.mulgara.tag;
 
 // Java 2 enterprise packages
-import java.io.*;
-import java.net.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
-import javax.xml.transform.*;
-import javax.xml.transform.stream.*;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
 
-// third party packages
-import org.apache.log4j.*;
+import org.apache.log4j.Logger;
 import org.mulgara.util.CachedTransformerFactory;
 
 /**
@@ -65,6 +73,10 @@
   // Constants
   //
 
+  private static final long serialVersionUID = 6848444503467806038L;
+
+  private static final boolean DEBUG = false;
+  
   /**
    * the category to log to
    */
@@ -149,7 +161,11 @@
       log.debug("Rendering tag body contents");
 
       // render the content
-      this.render(masterStylesheet, contentReader, this.getPreviousOut());
+      try {
+        this.render(masterStylesheet, contentReader, this.getPreviousOut());
+      } finally {
+        contentReader.close();
+      }
     }
     catch (MalformedURLException mue) {
 
@@ -216,7 +232,7 @@
 
     // DEBUG *************
     //if (masterStylesheet.toString().endsWith("metadata.xsl")) {
-    if (false) {
+    if (DEBUG) {
 
       PrintWriter out = new PrintWriter(new BufferedWriter(output));
       out.println("<p>SOAP content is:</p>\n<pre>");
@@ -254,8 +270,7 @@
       // DEBUG *************
       long timeMillis = System.currentTimeMillis() - transformerTime;
       double timeSeconds = ( (double) timeMillis) / ( (double) 1000L);
-      System.out.println("\n\nTransformer creation time = " + timeSeconds +
-                         "\n\n");
+      log.debug("\nTransformer creation time = " + timeSeconds + "\n");
 
       long transformationTime = System.currentTimeMillis();
 
@@ -266,7 +281,7 @@
       // DEBUG *************
       timeMillis = System.currentTimeMillis() - transformationTime;
       timeSeconds = ( (double) timeMillis) / ( (double) 1000L);
-      System.out.println("\n\nTransformation time = " + timeSeconds + "\n\n");
+      log.debug("\nTransformation time = " + timeSeconds + "\n");
 
       // DEBUG *************
       // DEBUG *************

Modified: trunk/src/jar/tag/java/org/mulgara/tag/StatementTEI.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/StatementTEI.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/StatementTEI.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -28,10 +28,12 @@
 package org.mulgara.tag;
 
 // standard java packages
-import java.net.*;
+import java.net.MalformedURLException;
+import java.net.URL;
 
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
 
 /**
  * Validates attributes and creates scripting variables for the {@link
@@ -110,9 +112,9 @@
       try {
 
         // try to convert it to a URL
-        URL serverURL = new URL( (String) server);
+        new URL( (String) server);
       }
-      catch (Exception e) {
+      catch (MalformedURLException e) {
 
         valid = false;
       }

Modified: trunk/src/jar/tag/java/org/mulgara/tag/StatementTag.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/tag/StatementTag.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/tag/StatementTag.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -30,29 +30,31 @@
 //Mulgara utilities
 
 // Java 2 enterprise packages
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
 
-import javax.servlet.*;
-import javax.servlet.jsp.*;
-import javax.servlet.jsp.tagext.*;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
-//Standard packages
-import javax.xml.parsers.*;
+import org.apache.log4j.Logger;
+import org.apache.soap.SOAPException;
+import org.apache.soap.rpc.Parameter;
+import org.apache.soap.rpc.Response;
+import org.mulgara.util.TagSoapClient;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
-// third party packages
-import org.apache.log4j.*;
-
-// Apache Soap packages
-import org.apache.soap.*;
-import org.apache.soap.rpc.*;
-import org.apache.soap.util.xml.*;
-import org.mulgara.util.*;
-import org.w3c.dom.*;
-import org.xml.sax.*;
-
 /**
  * Sends queries to a Mulgara server.
  *
@@ -74,6 +76,8 @@
  */
 public class StatementTag extends BodyTagSupport {
 
+  private static final long serialVersionUID = -7419226348089456963L;
+
   /**
    * the name of the id attribute
    */
@@ -114,7 +118,7 @@
   /**
    * the (ordered) map of queries to send to a Mulgara server
    */
-  private LinkedHashMap queries = null;
+  private LinkedHashMap<String,String> queries = null;
 
   /**
    * the URL of the SOAP endpoint of the Mulgara server
@@ -126,12 +130,12 @@
    * in this tag, in the order of execution specified by the {@link ExecuteTag}s
    * in the body
    */
-  private ArrayList answers = null;
+  private ArrayList<Response> answers = null;
 
   /**
    * mapping of query ids to answer list indices
    */
-  private HashMap answerPositionMap = null;
+  private HashMap<String,Integer> answerPositionMap = null;
 
   // findSoapEndpoint()
 
@@ -249,9 +253,9 @@
     log.debug("Starting statement tag execution");
 
     // intialise the members
-    this.setQueries(new LinkedHashMap());
-    this.setAnswers(new ArrayList());
-    this.setAnswerPositionMap(new HashMap());
+    this.queries = new LinkedHashMap<String,String>();
+    this.answers = new ArrayList<Response>();
+    this.answerPositionMap = new HashMap<String,Integer>();
 
     try {
 
@@ -269,7 +273,7 @@
       log.debug("Found Mulgara server SOAP enpoint - " + soapEndpoint);
 
       // set the SOAP endpoint
-      this.setSoapEndpoint(soapEndpoint);
+      this.soapEndpoint = soapEndpoint;
     }
     catch (MalformedURLException mue) {
 
@@ -283,7 +287,7 @@
 
     // try-catch
     // continue to evaluate the body
-    return EVAL_BODY_TAG;
+    return EVAL_BODY_BUFFERED;
   }
 
   // doStartTag()
@@ -302,7 +306,7 @@
     try {
 
       // parse the Reponse answers into a list of Answers
-      if ( (this.getAnswers() != null) && (this.getAnswers().size() > 0)) {
+      if ( (this.answers != null) && (this.answers.size() > 0)) {
 
         // find out whether to return the answers in the raw (as SOAP messages)
         // or parsed into a nice list of Documents
@@ -312,15 +316,15 @@
           log.debug("Returning results as list of Documents");
 
           // create a list for the answers
-          ArrayList formattedAnswers = new ArrayList();
+          ArrayList<Document> formattedAnswers = new ArrayList<Document>();
 
           // parse the Response answers into a list of Answers
-          for (Iterator ansIterator = this.getAnswers().iterator();
+          for (Iterator<Response> ansIterator = this.answers.iterator();
                ansIterator.hasNext(); ) {
 
             // get the answer as a document
             Document document =
-                StatementTag.formatSoapResponse( (Response) ansIterator.next());
+                StatementTag.formatSoapResponse( ansIterator.next());
 
             // add it to the
             formattedAnswers.add(document);
@@ -337,11 +341,11 @@
           // set a page context variable containing the answer position mappings
           this.pageContext.setAttribute(StatementTag.KEY_STATEMENT_PREFIX +
                                         "." + this.getId(),
-                                        this.getAnswerPositionMap());
+                                        this.answerPositionMap);
 
           // log that we've added the answer position map
           log.debug("Added position mappings to " +
-                    this.getAnswerPositionMap().size() + " queries");
+                    this.answerPositionMap.size() + " queries");
         }
         else {
 
@@ -352,16 +356,15 @@
           StringBuffer output = new StringBuffer();
 
           // print each answer to this buffer
-          for (Iterator ansIterator = this.getAnswers().iterator();
+          for (Iterator<Response> ansIterator = this.answers.iterator();
                ansIterator.hasNext(); ) {
 
-            pageContext.getOut().println(TagSoapClient.getContent(
-                (Response) ansIterator.next()));
+            pageContext.getOut().println(TagSoapClient.getContent(ansIterator.next()));
           }
 
           // end for
           // log that we're about to print the query answers
-          log.debug("Printing " + this.getAnswers().size() + " answers");
+          log.debug("Printing " + this.answers.size() + " answers");
 
           // write the answers to the output stream
           this.getPreviousOut().println(output.toString());
@@ -415,7 +418,6 @@
     catch (Exception e) {
 
       log.error("Unhandled exception in statement tag", e);
-      e.printStackTrace();
     }
 
     // try-catch
@@ -451,13 +453,13 @@
   public void addQuery(String query) {
 
     // no id was specified, make one up
-    String id = "Query-" + Integer.toString(this.getQueries().size());
+    String id = "Query-" + Integer.toString(this.queries.size());
 
-    while (this.getQueries().containsKey(id)) {
+    while (this.queries.containsKey(id)) {
 
       // we should never get duplicate keys as we cannot remove queries, but
       // just in case
-      id += ("-" + Integer.toString(this.getQueries().size()));
+      id += ("-" + Integer.toString(this.queries.size()));
     }
 
     // end if
@@ -479,7 +481,7 @@
   public void addQuery(String queryId, String query) {
 
     log.debug("Adding new query (" + queryId + ") - " + query);
-    this.getQueries().put(queryId, query);
+    this.queries.put(queryId, query);
   }
 
   // addQuery()
@@ -501,10 +503,10 @@
       StringBuffer queryBatch = new StringBuffer();
 
       // build up the batch query
-      for (Iterator ids = this.getQueries().keySet().iterator(); ids.hasNext(); ) {
+      for (Iterator<String> ids = this.queries.keySet().iterator(); ids.hasNext(); ) {
 
         // add the query to the batch buffer
-        String query = (String)this.getQueries().get(ids.next());
+        String query = this.queries.get(ids.next());
         queryBatch.append(query + "\n");
       }
 
@@ -519,7 +521,7 @@
       log.debug("Adding answers to batch query to answer list");
 
       // add the answer to the list of answers
-      this.getAnswers().add(batchAnswer);
+      this.answers.add(batchAnswer);
 
       // log that we've added the answers
       log.debug("Added answers to batch query to answer list");
@@ -550,7 +552,7 @@
     try {
 
       // make sure the query id is valid
-      if (!this.getQueries().containsKey(queryId)) {
+      if (!this.queries.containsKey(queryId)) {
 
         throw new JspTagException("statement: No query exists with id " +
                                   queryId);
@@ -561,7 +563,7 @@
       log.debug("Executing query id - " + queryId);
 
       // get the query to execute
-      String query = (String)this.getQueries().get(queryId);
+      String query = this.queries.get(queryId);
 
       // send the query
       Response answer = this.sendQuery(query);
@@ -570,11 +572,11 @@
       log.debug("Adding answer to query " + queryId + " to answer list");
 
       // add the SOAP answer to the answers list
-      this.getAnswers().add(answer);
+      this.answers.add(answer);
 
       // save the position of the answer to this query
-      this.getAnswerPositionMap().put(queryId,
-                                      new Integer(this.getAnswers().size() - 1));
+      this.answerPositionMap.put(queryId,
+                                      new Integer(this.answers.size() - 1));
     }
     catch (SOAPException se) {
 
@@ -592,105 +594,6 @@
   // formatSoapResponse()
 
   /**
-   * Sets the (ordered) map of queries to send to a Mulgara server.
-   *
-   * @param queries the (ordered) map of queries to send to a Mulgara server
-   */
-  private void setQueries(LinkedHashMap queries) {
-
-    this.queries = queries;
-  }
-
-  // getQueries()
-
-  /**
-   * Sets the URL of the SOAP endpoint of the Mulgara server.
-   *
-   * @param soapEndpoint the URL of the SOAP endpoint of the Mulgara server
-   */
-  private void setSoapEndpoint(URL soapEndpoint) {
-
-    this.soapEndpoint = soapEndpoint;
-  }
-
-  // getSoapEndpoint()
-
-  /**
-   * Sets the list of answers to the queries in this tag.
-   *
-   * @param answers the list of answers to the queries in this tag
-   */
-  private void setAnswers(ArrayList answers) {
-
-    this.answers = answers;
-  }
-
-  // getAnswers()
-
-  /**
-   * Sets the mapping of query ids to answer list indices.
-   *
-   * @param answerPositionMap mapping of query ids to answer list indices
-   */
-  private void setAnswerPositionMap(HashMap answerPositionMap) {
-
-    this.answerPositionMap = answerPositionMap;
-  }
-
-  // setQueries()
-
-  /**
-   * Returns the (ordered) map of queries to send to a Mulgara server.
-   *
-   * @return the (ordered) map of queries to send to a Mulgara server
-   */
-  private LinkedHashMap getQueries() {
-
-    return this.queries;
-  }
-
-  // setSoapEndpoint()
-
-  /**
-   * Returns the URL of the SOAP endpoint of the Mulgara server.
-   *
-   * @return the URL of the SOAP endpoint of the Mulgara server
-   */
-  private URL getSoapEndpoint() {
-
-    return this.soapEndpoint;
-  }
-
-  // setAnswers()
-
-  /**
-   * Returns the list of answers to the queries in this tag
-   *
-   * @return the list of answers to the queries in this tag
-   */
-  private ArrayList getAnswers() {
-
-    return this.answers;
-  }
-
-  // setAnswerPositionMap()
-
-  /**
-   * Returns the mapping of query ids to answer list indices.
-   *
-   * @return mapping of query ids to answer list indices
-   */
-  private HashMap getAnswerPositionMap() {
-
-    return this.answerPositionMap;
-  }
-
-  // getServer()
-  //
-  // Internal methods
-  //
-
-  /**
    * Sends a query to a Mulgara server.
    *
    * @param query the query to send
@@ -708,7 +611,7 @@
     try {
 
       //Create a URL to the SOAP end - point
-      url = new URL(this.getSoapEndpoint().toString());
+      url = new URL(this.soapEndpoint.toString());
     }
     catch (MalformedURLException mue) {
 

Modified: trunk/src/jar/tag/java/org/mulgara/util/CachedTransformerFactory.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/util/CachedTransformerFactory.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/util/CachedTransformerFactory.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -80,7 +80,7 @@
   /**
    * the map of XSLT transformers
    */
-  private static HashMap transformers = new HashMap();
+  private static HashMap<URL,Transformer> transformers = new HashMap<URL,Transformer>();
 
   //
   // Public API
@@ -111,8 +111,7 @@
       log.debug("Found transformer for stylesheet in cache");
 
       // return the transformer for this stylesheet
-      transformer =
-        (Transformer) CachedTransformerFactory.transformers.get(stylesheet);
+      transformer = CachedTransformerFactory.transformers.get(stylesheet);
     }
     else {
 

Modified: trunk/src/jar/tag/java/org/mulgara/util/TagSoapClient.java
===================================================================
--- trunk/src/jar/tag/java/org/mulgara/util/TagSoapClient.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/tag/java/org/mulgara/util/TagSoapClient.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -152,7 +152,7 @@
     call.setMethodName("execute");
     call.setEncodingStyleURI(org.apache.soap.Constants.NS_URI_LITERAL_XML);
 
-    Vector params = new Vector();
+    Vector<Parameter> params = new Vector<Parameter>();
     params.addElement(new Parameter("queryString", String.class, query,
 			org.apache.soap.Constants.NS_URI_SOAP_ENC));
     call.setParams(params);

Modified: trunk/src/jar/web/java/org/mulgara/webquery/ResourceBinaryFile.java
===================================================================
--- trunk/src/jar/web/java/org/mulgara/webquery/ResourceBinaryFile.java	2011-09-24 02:24:17 UTC (rev 2043)
+++ trunk/src/jar/web/java/org/mulgara/webquery/ResourceBinaryFile.java	2011-09-26 22:50:53 UTC (rev 2044)
@@ -79,7 +79,7 @@
       int r;
       while ((r = in.read(buffer)) != -1) out.write(buffer, 0, r);
     } finally {
-      in.close();
+      if (in != null) in.close();
       out.close();
     }
     return out;



More information about the Mulgara-svn mailing list