OODT-892 fix more null assignment issues

Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/c11a4dd6
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/c11a4dd6
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/c11a4dd6

Branch: refs/heads/master
Commit: c11a4dd6899daac363142ce65e54cf56ccfb2c39
Parents: 020d44f
Author: Tom Barber <[email protected]>
Authored: Sat Oct 24 15:06:30 2015 +0100
Committer: Tom Barber <[email protected]>
Committed: Sat Oct 24 15:06:30 2015 +0100

----------------------------------------------------------------------
 .../cas/filemgr/browser/model/QueryBuilder.java |   2 +-
 .../org/apache/oodt/commons/exec/ExecUtils.java |  44 ++-
 .../org/apache/oodt/commons/util/JDBC_DB.java   |  25 +-
 .../oodt/cas/filemgr/catalog/Catalog.java       |   2 +-
 .../repository/DataSourceRepositoryManager.java |  42 +--
 .../cas/filemgr/system/XmlRpcFileManager.java   |  29 +-
 .../validation/DataSourceValidationLayer.java   |  60 ++-
 .../extractors/DataSourceMetExtractor.java      |  38 +-
 .../oodt/cas/metadata/util/MimeTypeUtils.java   |   4 +-
 .../apache/oodt/opendapps/DatasetExtractor.java |  22 +-
 .../oodt/profile/gui/ProfileBuilderGUI.java     | 367 +++++++++----------
 .../cas/resource/scheduler/LRUScheduler.java    |   8 +-
 .../instance/WorkflowInstancesViewer.java       |  25 +-
 .../examples/ExternScriptTaskInstance.java      |  51 ++-
 .../DataSourceWorkflowInstanceRepository.java   | 114 +++---
 .../DataSourceWorkflowRepository.java           | 148 ++++----
 16 files changed, 478 insertions(+), 503 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/QueryBuilder.java
----------------------------------------------------------------------
diff --git 
a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/QueryBuilder.java
 
b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/QueryBuilder.java
index a1e62c7..47ab4e4 100644
--- 
a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/QueryBuilder.java
+++ 
b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/QueryBuilder.java
@@ -52,7 +52,7 @@ public class QueryBuilder {
       e.printStackTrace();
     }
 
-    System.out.println(luceneQ.toString());
+    System.out.println(luceneQ != null ? luceneQ.toString() : null);
     GenerateCASQuery(casQ, luceneQ);
 
     return casQ;

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/commons/src/main/java/org/apache/oodt/commons/exec/ExecUtils.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/exec/ExecUtils.java 
b/commons/src/main/java/org/apache/oodt/commons/exec/ExecUtils.java
index bb4b9e5..39272ec 100644
--- a/commons/src/main/java/org/apache/oodt/commons/exec/ExecUtils.java
+++ b/commons/src/main/java/org/apache/oodt/commons/exec/ExecUtils.java
@@ -39,11 +39,11 @@ public final class ExecUtils {
    }
 
    public static String printCommandLine(String[] args) {
-      StringBuffer cmdLine = new StringBuffer();
+      StringBuilder cmdLine = new StringBuilder();
 
       if (args != null && args.length > 0) {
-         for (int i = 0; i < args.length; i++) {
-            cmdLine.append(args[i]);
+         for (String arg : args) {
+            cmdLine.append(arg);
             cmdLine.append(" ");
          }
       }
@@ -60,7 +60,7 @@ public final class ExecUtils {
          OutputStream stdErrStream) throws IOException {
       return callProgram(commandLine, stdOutStream, stdErrStream, null);
    }
-
+b
    public static int callProgram(String commandLine, Logger logger, File 
workDir)
          throws IOException {
       LoggerOutputStream loggerInfoStream = null;
@@ -74,8 +74,16 @@ public final class ExecUtils {
       } catch (Exception e) {
          throw new IOException(e);
       } finally {
-         try { loggerInfoStream.close(); } catch (Exception e) {}
-         try { loggerSevereStream.close(); } catch (Exception e) {}
+         try {
+            if (loggerInfoStream != null) {
+               loggerInfoStream.close();
+            }
+         } catch (Exception ignored) {}
+         try {
+            if (loggerSevereStream != null) {
+               loggerSevereStream.close();
+            }
+         } catch (Exception ignored) {}
       }
    }
 
@@ -107,9 +115,21 @@ public final class ExecUtils {
          if (outputGobbler != null) {
             outputGobbler.stopGobblingAndDie();
          }
-         try { progProcess.getErrorStream().close(); } catch (Exception e) {}
-         try { progProcess.getInputStream().close(); } catch (Exception e) {}
-         try { progProcess.getOutputStream().close(); } catch (Exception e) {}
+         try {
+            if (progProcess != null) {
+               progProcess.getErrorStream().close();
+            }
+         } catch (Exception ignored) {}
+         try {
+            if (progProcess != null) {
+               progProcess.getInputStream().close();
+            }
+         } catch (Exception ignored) {}
+         try {
+            if (progProcess != null) {
+               progProcess.getOutputStream().close();
+            }
+         } catch (Exception ignored) {}
       }
    }
 
@@ -142,14 +162,12 @@ public final class ExecUtils {
       } catch (InterruptedException ignore) {
       } finally {
          // first stop the threads
-         if (outputGobbler != null && outputGobbler.isAlive()) {
+         if (outputGobbler.isAlive()) {
             outputGobbler.stopGobblingAndDie();
-            outputGobbler = null;
          }
 
-         if (errorGobbler != null && errorGobbler.isAlive()) {
+         if (errorGobbler.isAlive()) {
             errorGobbler.stopGobblingAndDie();
-            errorGobbler = null;
          }
 
          try { p.getErrorStream().close(); } catch (Exception ignore) {}

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java 
b/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
index 5d41776..86b21ff 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
@@ -39,12 +39,10 @@ public class JDBC_DB
        ResultSet rs;
        ResultSetMetaData rs_meta;
        int affected;
-       boolean more_rows;
-       boolean keep_connect_open;
+       boolean keep_connect_open;
        private boolean autoCommitMode = false;
-       public final String TO_DATE_FORMAT = "DD-MM-YYYY HH24:MI:SS";
 
-       /******************************************************************
+  /******************************************************************
        **
        ** JDBC_DB
        **
@@ -56,9 +54,8 @@ public class JDBC_DB
        public  JDBC_DB(
                        java.util.Properties sys_props) throws SQLException
        {
-                       String  classname;
 
-                       serverProps = sys_props;
+                       serverProps = sys_props;
                        keep_connect_open = true;
 
        }
@@ -67,16 +64,11 @@ public class JDBC_DB
                        java.util.Properties sys_props,
                        Connection srv_connect) throws SQLException
        {
-                       String  classname;
 
-                       serverProps = sys_props;
+                       serverProps = sys_props;
                        connect = srv_connect;
 
-                       if (srv_connect == null) {
-                               keep_connect_open  = false;
-                       } else {
-                               keep_connect_open = true;
-                       }
+                       keep_connect_open = srv_connect != null;
        }
 
        public void setAutoCommitMode(boolean autoCommitMode) {
@@ -364,7 +356,7 @@ public class JDBC_DB
                                connect.rollback();
                }
 
-               catch (SQLException e)
+               catch (SQLException ignored)
                {
 
                }
@@ -391,7 +383,7 @@ public class JDBC_DB
                        }
 
                }
-               catch (SQLException e)
+               catch (SQLException ignored)
                {
                }
        }
@@ -420,9 +412,8 @@ public class JDBC_DB
 */
 
                SimpleDateFormat fmt = new SimpleDateFormat("dd-MM-yyyy 
HH:mm:ss");
-               String dateStr = fmt.format(inDate);
 
-               return dateStr;
+         return fmt.format(inDate);
 
 
        }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
----------------------------------------------------------------------
diff --git 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
index 1ebca26..841633e 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
@@ -185,7 +185,7 @@ public interface Catalog extends Pagination {
      *         specified Product.
      * @throws CatalogException
      */
-    public List<Reference> getProductReferences(Product product) throws 
CatalogException;
+    public List getProductReferences(Product product) throws CatalogException;
 
     /**
      * <p>

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/DataSourceRepositoryManager.java
----------------------------------------------------------------------
diff --git 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/DataSourceRepositoryManager.java
 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/DataSourceRepositoryManager.java
index 6769469..6612acd 100644
--- 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/DataSourceRepositoryManager.java
+++ 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/DataSourceRepositoryManager.java
@@ -97,7 +97,7 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                     + addProductTypeSql);
             statement.execute(addProductTypeSql);
 
-            String productTypeId = new String();
+            String productTypeId = "";
             String getProductTypeIdSql = "SELECT MAX(product_type_id) AS 
max_id FROM product_types";
 
             rs = statement.executeQuery(getProductTypeIdSql);
@@ -128,7 +128,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
             LOG.log(Level.WARNING, "Exception adding product type. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback addProductType transaction. 
Message: "
@@ -143,7 +145,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -152,7 +153,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -162,7 +162,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -207,7 +206,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                     "Exception modifying product type. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback modifyProductType transaction. 
Message: "
@@ -222,7 +223,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -232,7 +232,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -273,7 +272,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
             LOG.log(Level.WARNING, "Exception removing product type. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeProductType transaction. 
Message: "
@@ -287,7 +288,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -297,7 +297,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -336,7 +335,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
             LOG.log(Level.WARNING, "Exception getting product type. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getProductTypeById transaction. 
Message: "
@@ -351,7 +352,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -360,7 +360,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -370,7 +369,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -410,7 +408,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
             LOG.log(Level.WARNING, "Exception getting product type. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getProductTypeByName transaction. 
Message: "
@@ -425,7 +425,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -434,7 +433,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -444,7 +442,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -488,7 +485,9 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
             LOG.log(Level.WARNING, "Exception getting product types. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getProductTypes transaction. 
Message: "
@@ -503,7 +502,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -512,7 +510,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -522,7 +519,6 @@ public class DataSourceRepositoryManager implements 
RepositoryManager {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
----------------------------------------------------------------------
diff --git 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
index 0af87b0..a003828 100644
--- 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
+++ 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
@@ -66,7 +66,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Vector;
@@ -338,7 +337,7 @@ public class XmlRpcFileManager {
 
     public int getNumProducts(Hashtable<String, Object> productTypeHash)
             throws CatalogException {
-        int numProducts = -1;
+        int numProducts;
 
         ProductType type = XmlRpcStructFactory
                 .getProductTypeFromXmlRpc(productTypeHash);
@@ -529,7 +528,7 @@ public class XmlRpcFileManager {
             throws ValidationLayerException {
         ProductType type = XmlRpcStructFactory
                 .getProductTypeFromXmlRpc(productTypeHash);
-        List<Element> elementList = null;
+        List<Element> elementList;
 
         try {
             elementList = catalog.getValidationLayer().getElements(type);
@@ -721,7 +720,9 @@ public class XmlRpcFileManager {
         try {
           versioner = GenericFileManagerObjectFactory
               .getVersionerFromClassName(p.getProductType().getVersioner());
-          versioner.createDataStoreReferences(p, expandedMetdata);
+          if (versioner != null) {
+            versioner.createDataStoreReferences(p, expandedMetdata);
+          }
         } catch (Exception e) {
           LOG.log(Level.SEVERE,
               "ingestProduct: VersioningException when versioning Product: "
@@ -794,7 +795,11 @@ public class XmlRpcFileManager {
                + "' bytes from file '" + filePath + "' at index '" + offset
                + "' : " + e.getMessage(), e);
       } finally {
-         try { is.close(); } catch (Exception ignored) {}
+         try {
+           if (is != null) {
+             is.close();
+           }
+         } catch (Exception ignored) {}
       }
    }
     
@@ -1101,11 +1106,11 @@ public class XmlRpcFileManager {
                 extractor.configure(spec.getConfiguration());
               }
               LOG.log(Level.INFO, "Running Met Extractor: ["
-                        + extractor.getClass().getName()
+                        + (extractor != null ? extractor.getClass().getName() 
: null)
                         + "] for product type: ["
                         + product.getProductType().getName() + "]");
                 try {
-                    met = extractor.extractMetadata(product, met);
+                    met = extractor != null ? 
extractor.extractMetadata(product, met) : null;
                 } catch (MetExtractionException e) {
                     LOG.log(Level.SEVERE,
                             "Exception extractor metadata from product: ["
@@ -1140,8 +1145,8 @@ public class XmlRpcFileManager {
     }
     
     private List<Product> query(Query query, ProductType productType) throws 
CatalogException {
-        List<String> productIdList = null;
-        List<Product> productList = null;
+        List<String> productIdList;
+        List<Product> productList;
 
         try {            
             productIdList = catalog.query(this.getCatalogQuery(query, 
productType), productType);
@@ -1212,9 +1217,9 @@ public class XmlRpcFileManager {
         List<TypeHandler> handlers = this.repositoryManager.getProductTypeById(
                 productType.getProductTypeId()).getHandlers();
         if (handlers != null) {
-            for (Iterator<TypeHandler> iter = handlers.iterator(); iter
-                    .hasNext();)
-                iter.next().postGetMetadataHandle(metadata);
+          for (TypeHandler handler : handlers) {
+            handler.postGetMetadataHandle(metadata);
+          }
         }
         return metadata;
     }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/DataSourceValidationLayer.java
----------------------------------------------------------------------
diff --git 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/DataSourceValidationLayer.java
 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/DataSourceValidationLayer.java
index 38a5664..8b136db 100644
--- 
a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/DataSourceValidationLayer.java
+++ 
b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/DataSourceValidationLayer.java
@@ -23,17 +23,19 @@ import org.apache.oodt.cas.filemgr.structs.ProductType;
 import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException;
 import org.apache.oodt.cas.filemgr.util.DbStructFactory;
 
-//JDK imports
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import javax.sql.DataSource;
 import java.util.List;
 import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.sql.DataSource;
+
+//JDK imports
+
 /**
  * @author mattmann
  * @author bfoster
@@ -92,7 +94,7 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                     + addMetaElemSql);
             statement.execute(addMetaElemSql);
 
-            String elementId = new String();
+            String elementId = "";
 
             String getMetaIdSql = "SELECT MAX(element_id) AS max_id FROM 
elements";
             LOG.log(Level.FINE, "addElement: Executing: " + getMetaIdSql);
@@ -112,7 +114,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                             + element.getElementName() + ". Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback addElement transaction. Message: "
@@ -127,7 +131,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -136,7 +139,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -146,7 +148,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -181,7 +182,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
             LOG.log(Level.WARNING, "Exception modifying element. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback modifyElement transaction. 
Message: "
@@ -196,7 +199,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -206,7 +208,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -240,7 +241,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
             LOG.log(Level.WARNING, "Exception removing element. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeElement transaction. 
Message: "
@@ -254,7 +257,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -264,7 +266,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -306,7 +307,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                     + element.getElementName() + " to product type "
                     + type.getName() + " . Message: " + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback addElementToProductType 
transaction. Message: "
@@ -320,7 +323,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -330,7 +332,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -373,7 +374,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                     + element.getElementName() + " from product type "
                     + type.getName() + ". Message: " + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeElementFromProductType 
transaction. Message: "
@@ -387,7 +390,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -397,7 +399,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -432,7 +433,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                     "Exception adding parent info to product type "
                             + type.getName() + " . Message: " + 
e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback addParentToProductType 
transaction. Message: "
@@ -446,7 +449,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -455,7 +457,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
     }
@@ -491,7 +492,9 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                     "Exception removing parent from product type "
                             + type.getName() + ". Message: " + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeParentFromProductType 
transaction. Message: "
@@ -505,7 +508,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -514,7 +516,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
     }
@@ -691,7 +692,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -700,7 +700,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -710,7 +709,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -758,7 +756,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -767,7 +764,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -777,7 +773,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -825,7 +820,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -834,7 +828,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -844,7 +837,6 @@ public class DataSourceValidationLayer implements 
ValidationLayer {
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/DataSourceMetExtractor.java
----------------------------------------------------------------------
diff --git 
a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/DataSourceMetExtractor.java
 
b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/DataSourceMetExtractor.java
index 821b9c6..8ece382 100644
--- 
a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/DataSourceMetExtractor.java
+++ 
b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/DataSourceMetExtractor.java
@@ -17,27 +17,25 @@
 package org.apache.oodt.cas.metadata.extractors;
 
 // JDK imports
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
+
+import org.apache.oodt.cas.metadata.AbstractMetExtractor;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.exceptions.MetExtractionException;
+import org.apache.oodt.commons.database.DatabaseConnectionBuilder;
+
 import java.io.File;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-
-// JAVAX imports
 import javax.sql.DataSource;
 
-
+// JAVAX imports
 // OODT imports
-import org.apache.oodt.cas.metadata.AbstractMetExtractor;
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.metadata.exceptions.MetExtractionException;
-import org.apache.oodt.commons.database.DatabaseConnectionBuilder;
-
-
 // Google imports
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Splitter;
 
 /**
  * MetExtractor which uses input file's name as key for lookup into a sql 
database to get metadata.
@@ -84,9 +82,21 @@ public class DataSourceMetExtractor extends 
AbstractMetExtractor {
       throw new MetExtractionException(
           String.format("Failed to get metadaata for key '%s'", key), e);
     } finally {
-      try { conn.close(); } catch (Exception e) { /* ignore */ }
-      try { statement.close(); } catch (Exception e) { /* ignore */ }
-      try { rs.close(); } catch (Exception e) { /* ignore */ }
+      try {
+        if (conn != null) {
+          conn.close();
+        }
+      } catch (Exception e) { /* ignore */ }
+      try {
+        if (statement != null) {
+          statement.close();
+        }
+      } catch (Exception e) { /* ignore */ }
+      try {
+        if (rs != null) {
+          rs.close();
+        }
+      } catch (Exception e) { /* ignore */ }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java
----------------------------------------------------------------------
diff --git 
a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java 
b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java
index 49a6946..51bba2a 100644
--- 
a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java
+++ 
b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java
@@ -155,7 +155,7 @@ public final class MimeTypeUtils {
      */
     public String autoResolveContentType(String typeName, String url,
             byte[] data) {
-        MimeType type = null;
+        MimeType type;
         String cleanedMimeType = null;
 
         try {
@@ -220,7 +220,7 @@ public final class MimeTypeUtils {
             }
         }
 
-        return type.getName();
+        return type != null ? type.getName() : null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
----------------------------------------------------------------------
diff --git 
a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java 
b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
index 6e666bb..ff22071 100644
--- a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
+++ b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
@@ -18,6 +18,10 @@
 package org.apache.oodt.opendapps;
 
 //JDK imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.opendapps.config.OpendapConfig;
+import org.apache.oodt.xmlquery.XMLQuery;
+
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.List;
@@ -29,16 +33,13 @@ import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-//OODT imports
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.opendapps.config.OpendapConfig;
-import org.apache.oodt.xmlquery.XMLQuery;
-
-//NetCDF-Java imports
-import thredds.catalog.crawl.CatalogCrawler;
-import ucar.nc2.util.CancelTask;
 import opendap.dap.DConnect;
 import opendap.dap.DataDDS;
+import thredds.catalog.crawl.CatalogCrawler;
+import ucar.nc2.util.CancelTask;
+
+//OODT imports
+//NetCDF-Java imports
 
 /**
  * 
@@ -137,7 +138,10 @@ public class DatasetExtractor {
             + " is neither a valid URL nor a filename.");
       }
       try {
-        DataDDS dds = dConn.getData(queryExpression, null);
+        DataDDS dds = null;
+        if (dConn != null) {
+          dds = dConn.getData(queryExpression, null);
+        }
 
         if (dds != null) {
           datasetUrls.add(datasetUrl);

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/profile/src/main/java/org/apache/oodt/profile/gui/ProfileBuilderGUI.java
----------------------------------------------------------------------
diff --git 
a/profile/src/main/java/org/apache/oodt/profile/gui/ProfileBuilderGUI.java 
b/profile/src/main/java/org/apache/oodt/profile/gui/ProfileBuilderGUI.java
index 25fd02f..ce5b202 100755
--- a/profile/src/main/java/org/apache/oodt/profile/gui/ProfileBuilderGUI.java
+++ b/profile/src/main/java/org/apache/oodt/profile/gui/ProfileBuilderGUI.java
@@ -17,43 +17,36 @@
 
 package org.apache.oodt.profile.gui;
 
-import javax.swing.JSeparator;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JPanel;
-import javax.swing.JEditorPane;
-import javax.swing.JScrollPane;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.BorderLayout;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreeModel;
-import javax.swing.JFileChooser;
-
 import org.apache.oodt.profile.Profile;
 import org.apache.oodt.profile.ProfileElement;
 import org.apache.oodt.profile.RangedProfileElement;
-import org.apache.oodt.profile.gui.profileTree;
-
 import org.apache.oodt.profile.gui.pstructs.ProfilePrinter;
+import org.xml.sax.SAXException;
 
-
-import java.util.Iterator;
-import java.util.Enumeration;
-import java.util.List;
-
-
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileReader;
-import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.Enumeration;
+import java.util.List;
 
 import javax.swing.JButton;
-import org.xml.sax.SAXException;
+import javax.swing.JEditorPane;
+import javax.swing.JFileChooser;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreeNode;
 
 /**
 * This code was generated using CloudGarden's Jigloo
@@ -509,7 +502,7 @@ return jEditorPane1;        }
                
                for(Enumeration e = theProfElemRoot.children(); 
e.hasMoreElements(); ){
                        DefaultMutableTreeNode profElemN_Root = 
(DefaultMutableTreeNode)e.nextElement();
-                       System.out.println("Got Profile Element 
"+(String)profElemN_Root.getUserObject());
+                       System.out.println("Got Profile Element "+ 
profElemN_Root.getUserObject());
                        ProfileElement profElem = 
makeProfileElementFromTreeNode(p,profElemN_Root);
                        
                        if(profElem != null){
@@ -580,13 +573,13 @@ return jEditorPane1;      }
                //version String
                
                DefaultMutableTreeNode profAttr_children = new 
DefaultMutableTreeNode("Children");
-               
-               for(Iterator i = 
p.getProfileAttributes().getChildren().iterator(); i.hasNext(); ){
-                       String theChild = (String)i.next();
-                       
-                       DefaultMutableTreeNode profAttr_childN = new 
DefaultMutableTreeNode(theChild);
-                       profAttr_children.add(profAttr_childN);
-               }
+
+         for (Object o : p.getProfileAttributes().getChildren()) {
+               String theChild = (String) o;
+
+               DefaultMutableTreeNode profAttr_childN = new 
DefaultMutableTreeNode(theChild);
+               profAttr_children.add(profAttr_childN);
+         }
                
                
                DefaultMutableTreeNode profAttr_id = new 
DefaultMutableTreeNode("Id");
@@ -599,13 +592,13 @@ return jEditorPane1;      }
                profAttr_regAuth.add(new 
DefaultMutableTreeNode(p.getProfileAttributes().getRegAuthority()));           
                
                DefaultMutableTreeNode profAttr_revNotes = new 
DefaultMutableTreeNode("Revision Notes");
-               
-               for(Iterator i = 
p.getProfileAttributes().getRevisionNotes().iterator(); i.hasNext(); ){
-                       String revNoteString = (String)i.next();
-                       
-                       DefaultMutableTreeNode revNote_Child = new 
DefaultMutableTreeNode(revNoteString);
-                       profAttr_revNotes.add(revNote_Child);
-               }
+
+         for (Object o : p.getProfileAttributes().getRevisionNotes()) {
+               String revNoteString = (String) o;
+
+               DefaultMutableTreeNode revNote_Child = new 
DefaultMutableTreeNode(revNoteString);
+               profAttr_revNotes.add(revNote_Child);
+         }
 
                DefaultMutableTreeNode profAttr_securityType = new 
DefaultMutableTreeNode("Security Type");
                profAttr_securityType.add(new 
DefaultMutableTreeNode(p.getProfileAttributes().getSecurityType()));            
  
@@ -658,140 +651,112 @@ return jEditorPane1;    }
                
                
                DefaultMutableTreeNode resAttr_contexts = new 
DefaultMutableTreeNode("Contexts");
-               
-               for(Iterator i = 
p.getResourceAttributes().getResContexts().iterator(); i.hasNext(); ){
-                       String theContext = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_contextN = new 
DefaultMutableTreeNode(theContext);
-                       resAttr_contexts.add(resAttr_contextN);
-               }
+
+         for (String theContext : p.getResourceAttributes().getResContexts()) {
+               DefaultMutableTreeNode resAttr_contextN = new 
DefaultMutableTreeNode(theContext);
+               resAttr_contexts.add(resAttr_contextN);
+         }
 
                DefaultMutableTreeNode resAttr_contributors = new 
DefaultMutableTreeNode("Contributors");
-               
-               for(Iterator i = 
p.getResourceAttributes().getContributors().iterator(); i.hasNext(); ){
-                       String theContributor = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_contribN = new 
DefaultMutableTreeNode(theContributor);
-                       resAttr_contributors.add(resAttr_contribN);
-               }
+
+         for (String theContributor : 
p.getResourceAttributes().getContributors()) {
+               DefaultMutableTreeNode resAttr_contribN = new 
DefaultMutableTreeNode(theContributor);
+               resAttr_contributors.add(resAttr_contribN);
+         }
                
                DefaultMutableTreeNode resAttr_coverages = new 
DefaultMutableTreeNode("Coverages");
-               
-               for(Iterator i = 
p.getResourceAttributes().getCoverages().iterator(); i.hasNext(); ){
-                       String theCoverage = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_coverageN= new 
DefaultMutableTreeNode(theCoverage);
-                       resAttr_coverages.add(resAttr_coverageN);
-               }
+
+         for (String theCoverage : p.getResourceAttributes().getCoverages()) {
+               DefaultMutableTreeNode resAttr_coverageN = new 
DefaultMutableTreeNode(theCoverage);
+               resAttr_coverages.add(resAttr_coverageN);
+         }
                
                DefaultMutableTreeNode resAttr_creators = new 
DefaultMutableTreeNode("Creators");
-               
-               for(Iterator i = 
p.getResourceAttributes().getCreators().iterator(); i.hasNext(); ){
-                       String theCreator = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_creatorN = new 
DefaultMutableTreeNode(theCreator);
-                       resAttr_creators.add(resAttr_creatorN);
-               }
+
+         for (String theCreator : p.getResourceAttributes().getCreators()) {
+               DefaultMutableTreeNode resAttr_creatorN = new 
DefaultMutableTreeNode(theCreator);
+               resAttr_creators.add(resAttr_creatorN);
+         }
 
                DefaultMutableTreeNode resAttr_dates = new 
DefaultMutableTreeNode("Dates");
-               
-               for(Iterator i = 
p.getResourceAttributes().getDates().iterator(); i.hasNext(); ){
-                       String theDate = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_dateN = new 
DefaultMutableTreeNode(theDate);
-                       resAttr_dates.add(resAttr_dateN);
-               }
+
+         for (String theDate : p.getResourceAttributes().getDates()) {
+               DefaultMutableTreeNode resAttr_dateN = new 
DefaultMutableTreeNode(theDate);
+               resAttr_dates.add(resAttr_dateN);
+         }
        
                DefaultMutableTreeNode resAttr_description = new 
DefaultMutableTreeNode("Description");
                resAttr_description.add(new 
DefaultMutableTreeNode(p.getResourceAttributes().getDescription()));            
    
 
                DefaultMutableTreeNode resAttr_formats = new 
DefaultMutableTreeNode("Formats");
-               
-               for(Iterator i = 
p.getResourceAttributes().getFormats().iterator(); i.hasNext(); ){
-                       String theFormat = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_formatN = new 
DefaultMutableTreeNode(theFormat);
-                       resAttr_formats.add(resAttr_formatN);
-               }
+
+         for (String theFormat : p.getResourceAttributes().getFormats()) {
+               DefaultMutableTreeNode resAttr_formatN = new 
DefaultMutableTreeNode(theFormat);
+               resAttr_formats.add(resAttr_formatN);
+         }
                
                DefaultMutableTreeNode resAttr_identifier = new 
DefaultMutableTreeNode("Identifier");
                resAttr_identifier.add(new 
DefaultMutableTreeNode(p.getResourceAttributes().getIdentifier()));          
 
                DefaultMutableTreeNode resAttr_languages = new 
DefaultMutableTreeNode("Languages");
-               
-               for(Iterator i = 
p.getResourceAttributes().getLanguages().iterator(); i.hasNext(); ){
-                       String theLanguage = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_langN = new 
DefaultMutableTreeNode(theLanguage);
-                       resAttr_languages.add(resAttr_langN);
-               }
+
+         for (String theLanguage : p.getResourceAttributes().getLanguages()) {
+               DefaultMutableTreeNode resAttr_langN = new 
DefaultMutableTreeNode(theLanguage);
+               resAttr_languages.add(resAttr_langN);
+         }
                
                DefaultMutableTreeNode resAttr_locations = new 
DefaultMutableTreeNode("Resource Locations");
-               
-               for(Iterator i = 
p.getResourceAttributes().getResLocations().iterator(); i.hasNext(); ){
-                       String theLoc = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_locN = new 
DefaultMutableTreeNode(theLoc);
-                       resAttr_locations.add(resAttr_locN);
-               }
+
+         for (String theLoc : p.getResourceAttributes().getResLocations()) {
+               DefaultMutableTreeNode resAttr_locN = new 
DefaultMutableTreeNode(theLoc);
+               resAttr_locations.add(resAttr_locN);
+         }
 
                DefaultMutableTreeNode resAttr_publishers = new 
DefaultMutableTreeNode("Publishers");
-               
-               for(Iterator i = 
p.getResourceAttributes().getPublishers().iterator(); i.hasNext(); ){
-                       String thePublisher = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_pubN = new 
DefaultMutableTreeNode(thePublisher);
-                       resAttr_publishers.add(resAttr_pubN);
-               }
+
+         for (String thePublisher : p.getResourceAttributes().getPublishers()) 
{
+               DefaultMutableTreeNode resAttr_pubN = new 
DefaultMutableTreeNode(thePublisher);
+               resAttr_publishers.add(resAttr_pubN);
+         }
                
                DefaultMutableTreeNode resAttr_relations = new 
DefaultMutableTreeNode("Relations");
-               
-               for(Iterator i = 
p.getResourceAttributes().getRelations().iterator(); i.hasNext(); ){
-                       String theRelation = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_relationN = new 
DefaultMutableTreeNode(theRelation);
-                       resAttr_relations.add(resAttr_relationN);
-               }
+
+         for (String theRelation : p.getResourceAttributes().getRelations()) {
+               DefaultMutableTreeNode resAttr_relationN = new 
DefaultMutableTreeNode(theRelation);
+               resAttr_relations.add(resAttr_relationN);
+         }
 
                
                DefaultMutableTreeNode resAttr_rights = new 
DefaultMutableTreeNode("Rights");
-               
-               for(Iterator i = 
p.getResourceAttributes().getRights().iterator(); i.hasNext(); ){
-                       String theRight = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_rightN = new 
DefaultMutableTreeNode(theRight);
-                       resAttr_rights.add(resAttr_rightN);
-               }
+
+         for (String theRight : p.getResourceAttributes().getRights()) {
+               DefaultMutableTreeNode resAttr_rightN = new 
DefaultMutableTreeNode(theRight);
+               resAttr_rights.add(resAttr_rightN);
+         }
 
                DefaultMutableTreeNode resAttr_sources = new 
DefaultMutableTreeNode("Sources");
-               
-               for(Iterator i = 
p.getResourceAttributes().getSources().iterator(); i.hasNext(); ){
-                       String theSource = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_sourceN = new 
DefaultMutableTreeNode(theSource);
-                       resAttr_sources.add(resAttr_sourceN);
-               }
+
+         for (String theSource : p.getResourceAttributes().getSources()) {
+               DefaultMutableTreeNode resAttr_sourceN = new 
DefaultMutableTreeNode(theSource);
+               resAttr_sources.add(resAttr_sourceN);
+         }
 
                DefaultMutableTreeNode resAttr_subjects = new 
DefaultMutableTreeNode("Subjects");
-               
-               for(Iterator i = 
p.getResourceAttributes().getSubjects().iterator(); i.hasNext(); ){
-                       String theSubject = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_subjectN = new 
DefaultMutableTreeNode(theSubject);
-                       resAttr_subjects.add(resAttr_subjectN);
-               }
+
+         for (String theSubject : p.getResourceAttributes().getSubjects()) {
+               DefaultMutableTreeNode resAttr_subjectN = new 
DefaultMutableTreeNode(theSubject);
+               resAttr_subjects.add(resAttr_subjectN);
+         }
 
                DefaultMutableTreeNode resAttr_title = new 
DefaultMutableTreeNode("Title");
                resAttr_title.add(new 
DefaultMutableTreeNode(p.getResourceAttributes().getTitle()));            
        
                DefaultMutableTreeNode resAttr_types = new 
DefaultMutableTreeNode("Types");
-               
-               for(Iterator i = 
p.getResourceAttributes().getTypes().iterator(); i.hasNext(); ){
-                       String theType = (String)i.next();
-                       
-                       DefaultMutableTreeNode resAttr_typeN = new 
DefaultMutableTreeNode(theType);
-                       resAttr_types.add(resAttr_typeN);
-               }
+
+         for (String theType : p.getResourceAttributes().getTypes()) {
+               DefaultMutableTreeNode resAttr_typeN = new 
DefaultMutableTreeNode(theType);
+               resAttr_types.add(resAttr_typeN);
+         }
        
 
                resAttrRoot.add(resAttr_aggregation);
@@ -814,59 +779,57 @@ return jEditorPane1;      }
                resAttrRoot.add(resAttr_title);
                resAttrRoot.add(resAttr_types);
 
-        for(Iterator i = p.getProfileElements().keySet().iterator(); 
i.hasNext(); ){
-               String peKey = (String)i.next();
-               
-               ProfileElement theProfileElement = 
(ProfileElement)p.getProfileElements().get(peKey);
-               DefaultMutableTreeNode thePENode = new 
DefaultMutableTreeNode(theProfileElement.getName());
-               DefaultMutableTreeNode theCommentsRoot = new 
DefaultMutableTreeNode("Comments");
-               DefaultMutableTreeNode theComments = new 
DefaultMutableTreeNode(theProfileElement.getComments());
-               
-               theCommentsRoot.add(theComments);
-               
-               DefaultMutableTreeNode theDesc = new 
DefaultMutableTreeNode(theProfileElement.getDescription());
-               DefaultMutableTreeNode theDescRoot = new 
DefaultMutableTreeNode("Description");
-               
-               theDescRoot.add(theDesc);
-               
-               
-               
-               DefaultMutableTreeNode theID = new 
DefaultMutableTreeNode(theProfileElement.getID());
-               DefaultMutableTreeNode theIDRoot = new 
DefaultMutableTreeNode("ID");
-               
-               theIDRoot.add(theID);
-               
-               DefaultMutableTreeNode theMO = new DefaultMutableTreeNode(new 
Integer(theProfileElement.getMaxOccurrence()).toString());
-               DefaultMutableTreeNode theMORoot = new 
DefaultMutableTreeNode("Max Occurence");
-               theMORoot.add(theMO);
-               
-               DefaultMutableTreeNode theSynonyms = new 
DefaultMutableTreeNode("Synonyms");
-               
-               for(Iterator i2 = theProfileElement.getSynonyms().iterator(); 
i2.hasNext(); ){
-                       String theSynonym = (String)i2.next();
-                       DefaultMutableTreeNode sNode = new 
DefaultMutableTreeNode(theSynonym);
-                       theSynonyms.add(sNode);
-               }
+         for (String peKey : p.getProfileElements().keySet()) {
+               ProfileElement theProfileElement = 
p.getProfileElements().get(peKey);
+               DefaultMutableTreeNode thePENode = new 
DefaultMutableTreeNode(theProfileElement.getName());
+               DefaultMutableTreeNode theCommentsRoot = new 
DefaultMutableTreeNode("Comments");
+               DefaultMutableTreeNode theComments = new 
DefaultMutableTreeNode(theProfileElement.getComments());
 
-               DefaultMutableTreeNode theType = new 
DefaultMutableTreeNode(theProfileElement.getType());
-               DefaultMutableTreeNode theTypeRoot = new 
DefaultMutableTreeNode("Type");
-               theTypeRoot.add(theType);
-               
-               
-               DefaultMutableTreeNode theUnit = new 
DefaultMutableTreeNode(theProfileElement.getUnit());
-               DefaultMutableTreeNode theUnitRoot = new 
DefaultMutableTreeNode("Unit");
-               theUnitRoot.add(theUnit);
-               
-               thePENode.add(theCommentsRoot);
-               thePENode.add(theDescRoot);
-               thePENode.add(theIDRoot);
-               thePENode.add(theMORoot);
-               thePENode.add(theSynonyms);
-               thePENode.add(theTypeRoot);
-               thePENode.add(theUnitRoot);
-               
-               profElemRoot.add(thePENode);
-        }
+               theCommentsRoot.add(theComments);
+
+               DefaultMutableTreeNode theDesc = new 
DefaultMutableTreeNode(theProfileElement.getDescription());
+               DefaultMutableTreeNode theDescRoot = new 
DefaultMutableTreeNode("Description");
+
+               theDescRoot.add(theDesc);
+
+
+               DefaultMutableTreeNode theID = new 
DefaultMutableTreeNode(theProfileElement.getID());
+               DefaultMutableTreeNode theIDRoot = new 
DefaultMutableTreeNode("ID");
+
+               theIDRoot.add(theID);
+
+               DefaultMutableTreeNode theMO =
+                       new 
DefaultMutableTreeNode(Integer.toString(theProfileElement.getMaxOccurrence()));
+               DefaultMutableTreeNode theMORoot = new 
DefaultMutableTreeNode("Max Occurence");
+               theMORoot.add(theMO);
+
+               DefaultMutableTreeNode theSynonyms = new 
DefaultMutableTreeNode("Synonyms");
+
+               for (Object o : theProfileElement.getSynonyms()) {
+                 String theSynonym = (String) o;
+                 DefaultMutableTreeNode sNode = new 
DefaultMutableTreeNode(theSynonym);
+                 theSynonyms.add(sNode);
+               }
+
+               DefaultMutableTreeNode theType = new 
DefaultMutableTreeNode(theProfileElement.getType());
+               DefaultMutableTreeNode theTypeRoot = new 
DefaultMutableTreeNode("Type");
+               theTypeRoot.add(theType);
+
+
+               DefaultMutableTreeNode theUnit = new 
DefaultMutableTreeNode(theProfileElement.getUnit());
+               DefaultMutableTreeNode theUnitRoot = new 
DefaultMutableTreeNode("Unit");
+               theUnitRoot.add(theUnit);
+
+               thePENode.add(theCommentsRoot);
+               thePENode.add(theDescRoot);
+               thePENode.add(theIDRoot);
+               thePENode.add(theMORoot);
+               thePENode.add(theSynonyms);
+               thePENode.add(theTypeRoot);
+               thePENode.add(theUnitRoot);
+
+               profElemRoot.add(thePENode);
+         }
                
                root.add(profAttrRoot);
                root.add(resAttrRoot);
@@ -905,16 +868,18 @@ return jEditorPane1;      }
            }
            
            char [] buf = new char[256];
-           StringBuffer sb = new StringBuffer();
+           StringBuilder sb = new StringBuilder();
            
-           int numRead = -1;
+           int numRead;
            
            try{
-                   while((numRead = fr.read(buf,0,256)) != -1){
-                     sb.append(buf,0,numRead);
-                     buf = new char[256];
-                   }
-           }
+                 if (fr != null) {
+                       while((numRead = fr.read(buf,0,256)) != -1){
+              sb.append(buf,0,numRead);
+              buf = new char[256];
+            }
+                 }
+               }
            catch(IOException ioe){
                ioe.printStackTrace();
                System.out.println(ioe.getMessage());           
@@ -981,8 +946,10 @@ return jEditorPane1;       }
         }
         finally{
                try{
-                       fos.close();
-               }catch(Exception ignore){
+                         if (fos != null) {
+                               fos.close();
+                         }
+                       }catch(Exception ignore){
                        //ignore
                }
         }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
----------------------------------------------------------------------
diff --git 
a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
 
b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
index f237da5..d756292 100644
--- 
a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
+++ 
b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
@@ -130,7 +130,7 @@ public class LRUScheduler implements Scheduler {
     public synchronized boolean schedule(JobSpec spec)
             throws SchedulerException {
         String queueName = spec.getJob().getQueueName();
-        int load = spec.getJob().getLoadValue().intValue();
+        int load = spec.getJob().getLoadValue();
 
         ResourceNode node = nodeAvailable(spec);
 
@@ -222,10 +222,10 @@ public class LRUScheduler implements Scheduler {
             throws SchedulerException {
         try {
                String queueName = spec.getJob().getQueueName();
-               int load = spec.getJob().getLoadValue().intValue();
+               int load = spec.getJob().getLoadValue();
        
                for (String nodeId : queueManager.getNodes(queueName)) {
-                   int nodeLoad = -1;
+                   int nodeLoad;
                    ResourceNode resNode = null;
        
                    try {
@@ -234,7 +234,7 @@ public class LRUScheduler implements Scheduler {
                    } catch (MonitorException e) {
                        LOG
                                .log(Level.WARNING, "Exception getting load on "
-                                       + "node: [" + resNode.getNodeId()
+                                       + "node: [" + (resNode != null ? 
resNode.getNodeId() : null)
                                        + "]: Message: " + e.getMessage());
                        throw new SchedulerException(e.getMessage());
                    }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java
----------------------------------------------------------------------
diff --git 
a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java
 
b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java
index a1afedb..e2bb66a 100644
--- 
a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java
+++ 
b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java
@@ -67,7 +67,16 @@ public class WorkflowInstancesViewer extends Panel {
   private static final int PAGE_SIZE = 20;
 
   /**
-   * @param id
+   * @param id the id
+   * @param workflowUrlStr the workflow url
+   * @param status the status
+   * @param pageNum the page number
+   * @param wStatuses the workflow statuses
+   * @param lifecycleFilePath the lifecycle path
+   * @param metInstanceFilePath the met instance file path
+   * @param workflowViewer the workflow viewer
+   * @param workflowTaskViewer the workflow task viewer
+   * @param workflowInstViewer the workflow instviewer
    */
   public WorkflowInstancesViewer(String id, String workflowUrlStr,
       final String status, int pageNum, List<String> wStatuses,
@@ -78,7 +87,7 @@ public class WorkflowInstancesViewer extends Panel {
     super(id);
     this.wm = new WorkflowMgrConn(workflowUrlStr);
     this.pageNum = pageNum;
-    WorkflowInstancePage page = null;
+    WorkflowInstancePage page;
     System.out.println("STATUS IS "+status);
     if (status.equals("ALL")) {
       page = this.wm.safeGetWorkflowInstPageByStatus(pageNum);
@@ -210,7 +219,7 @@ public class WorkflowInstancesViewer extends Panel {
       this.pageNum = page.getPageNum();
 
       // get the last page
-      WorkflowInstancePage lastPage = null;
+      WorkflowInstancePage lastPage;
       lastPage = wm.safeGetWorkflowInstPageByStatus(page.getTotalPages());
       this.totalWorkflowInsts += lastPage.getPageWorkflows().size();
 
@@ -222,7 +231,7 @@ public class WorkflowInstancesViewer extends Panel {
   }
 
   private String getWorkflowInstMet(WorkflowInstance inst, String 
metMapFilePath) {
-    WorkflowInstanceMetMap wInstMetMap = null;
+    WorkflowInstanceMetMap wInstMetMap;
     String metString = null;
 
     try {
@@ -234,7 +243,7 @@ public class WorkflowInstancesViewer extends Panel {
           .getWorkflow().getId()) != null ? wInstMetMap
           .getFieldsForWorkflow(inst.getWorkflow().getId()) : wInstMetMap
           .getDefaultFields();
-      StringBuffer metStrBuf = new StringBuffer();
+      StringBuilder metStrBuf = new StringBuilder();
 
       for (String wInstField : wInstFields) {
         metStrBuf.append(wInstField);
@@ -268,14 +277,14 @@ public class WorkflowInstancesViewer extends Panel {
     } catch (Exception e) {
       e.printStackTrace();
     }
-    return lifecycleMgr
-        .formatPct(lifecycleMgr.getPercentageComplete(inst) * 100.0);
+    return lifecycleMgr != null ? WorkflowLifecycleManager
+        .formatPct((lifecycleMgr.getPercentageComplete(inst)) * 100.0) : null;
   }
   
   private String getTaskNameFromTaskId(WorkflowInstance w, String taskId) {
     if (w.getWorkflow() != null && w.getWorkflow().getTasks() != null
             && w.getWorkflow().getTasks().size() > 0) {
-        for(WorkflowTask task: 
(List<WorkflowTask>)(List<?>)w.getWorkflow().getTasks()){
+        for(WorkflowTask task: w.getWorkflow().getTasks()){
             if (task.getTaskId().equals(taskId)) {
                 return task.getTaskName();
             }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/ExternScriptTaskInstance.java
----------------------------------------------------------------------
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/ExternScriptTaskInstance.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/ExternScriptTaskInstance.java
index 8f82409..85a55a0 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/ExternScriptTaskInstance.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/ExternScriptTaskInstance.java
@@ -19,6 +19,10 @@
 package org.apache.oodt.cas.workflow.examples;
 
 //Java imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,9 +31,6 @@ import java.util.Iterator;
 import java.util.List;
 
 //OODT imports
-import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance;
-import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
-import org.apache.oodt.cas.metadata.Metadata;
 
 /**
  * @author davoodi
@@ -68,7 +69,7 @@ public class ExternScriptTaskInstance implements 
WorkflowTaskInstance {
         String shellType = config.getProperty("ShellType"); // e.g. /bin/sh/
 
         // joining the argument list's elements to a string
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         Iterator iter = args.iterator();
         while (iter.hasNext()) {
             buffer.append(iter.next());
@@ -88,37 +89,49 @@ public class ExternScriptTaskInstance implements 
WorkflowTaskInstance {
             // TODO Auto-generated catch block
             e1.printStackTrace();
         }
-        InputStream inputstream = proc.getInputStream();
-        InputStreamReader inputstreamreader = new 
InputStreamReader(inputstream);
-        BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
+        InputStream inputstream = null;
+        if (proc != null) {
+            inputstream = proc.getInputStream();
+        }
+        InputStreamReader inputstreamreader = null;
+        if (inputstream != null) {
+            inputstreamreader = new InputStreamReader(inputstream);
+        }
+        BufferedReader bufferedreader = null;
+        if (inputstreamreader != null) {
+            bufferedreader = new BufferedReader(inputstreamreader);
+        }
 
         // sending the script's output result to System.out to be printed
         String cmdlnOutput;
         try {
-            while ((cmdlnOutput = bufferedreader.readLine()) != null) {
-                System.out.println(cmdlnOutput);
+            if (bufferedreader != null) {
+                while ((cmdlnOutput = bufferedreader.readLine()) != null) {
+                    System.out.println(cmdlnOutput);
+                }
             }
         } catch (IOException e1) {
             // TODO Auto-generated catch block
             e1.printStackTrace();
         }
         try {
-            if (proc.waitFor() != 0) {
-                System.err
-                        .println("the process did not terminate normally exit 
code: ["
-                                + proc.exitValue() + "]");
+            if (proc != null) {
+                if (proc.waitFor() != 0) {
+                    System.err
+                            .println("the process did not terminate normally 
exit code: ["
+                                     + proc.exitValue() + "]");
+                }
             }
         } catch (InterruptedException e) {
-            System.err.println(e);
+            System.err.println(e.getLocalizedMessage());
         } finally {
-            if (bufferedreader != null) {
-                try {
+            try {
+                if (bufferedreader != null) {
                     bufferedreader.close();
-                } catch (Exception ignore) {
                 }
-
-                bufferedreader = null;
+            } catch (Exception ignore) {
             }
+
         }
 
     }

http://git-wip-us.apache.org/repos/asf/oodt/blob/c11a4dd6/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
----------------------------------------------------------------------
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
index 0cbffd0..368875a 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
@@ -21,24 +21,24 @@ package org.apache.oodt.cas.workflow.instrepo;
 //OODT imports
 import org.apache.oodt.cas.metadata.Metadata;
 import org.apache.oodt.cas.workflow.structs.WorkflowInstance;
-import org.apache.oodt.cas.workflow.structs.WorkflowTask;
 import 
org.apache.oodt.cas.workflow.structs.exceptions.InstanceRepositoryException;
 import org.apache.oodt.cas.workflow.util.DbStructFactory;
 
-//JDK imports
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.sql.DataSource;
 
+//JDK imports
+
 /**
  * @author mattmann
  * @version $Revision$
@@ -75,7 +75,7 @@ public class DataSourceWorkflowInstanceRepository extends
      */
     public synchronized void addWorkflowInstance(WorkflowInstance wInst)
             throws InstanceRepositoryException {
-        Connection conn = null;
+        Connoection conn = null;
         Statement statement = null;
         ResultSet rs = null;
 
@@ -84,18 +84,18 @@ public class DataSourceWorkflowInstanceRepository extends
             conn.setAutoCommit(false);
             statement = conn.createStatement();
 
-            String startWorkflowSql = null;
-            String taskIdField = null;
-            String workflowIdField = null;
+            String startWorkflowSql;
+            String taskIdField;
+            String workflowIdField;
 
             if (quoteFields) {
                 taskIdField = "'"
-                        + ((WorkflowTask) 
wInst.getWorkflow().getTasks().get(0))
+                        + wInst.getWorkflow().getTasks().get(0)
                                 .getTaskId() + "'";
                 workflowIdField = "'" + wInst.getWorkflow().getId() + "'";
             } else {
-                taskIdField = ((WorkflowTask) wInst.getWorkflow().getTasks()
-                        .get(0)).getTaskId();
+                taskIdField = wInst.getWorkflow().getTasks()
+                        .get(0).getTaskId();
                 workflowIdField = wInst.getWorkflow().getId();
             }
 
@@ -113,7 +113,7 @@ public class DataSourceWorkflowInstanceRepository extends
             LOG.log(Level.FINE, "sql: Executing: " + startWorkflowSql);
             statement.execute(startWorkflowSql);
 
-            String workflowInstId = new String();
+            String workflowInstId = "";
 
             synchronized (workflowInstId) {
                 String getWorkflowInstIdSql = "SELECT 
MAX(workflow_instance_id) "
@@ -136,7 +136,9 @@ public class DataSourceWorkflowInstanceRepository extends
             LOG.log(Level.WARNING, "Exception starting workflow. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback startWorkflow transaction. 
Message: "
@@ -151,7 +153,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -160,7 +161,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -170,7 +170,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -185,7 +184,7 @@ public class DataSourceWorkflowInstanceRepository extends
             throws InstanceRepositoryException {
         Connection conn = null;
         Statement statement = null;
-        String taskIdField = null, workflowIdField = null;
+        String taskIdField, workflowIdField;
 
         try {
             conn = dataSource.getConnection();
@@ -231,7 +230,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception updating workflow instance. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback updateWorkflowInstanceStatus "
@@ -245,7 +246,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -255,7 +255,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -292,7 +291,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception removing workflow instance. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeWorkflowInstance "
@@ -306,7 +307,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -316,7 +316,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -360,7 +359,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting workflow instance. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getWorkflowInstanceById "
@@ -375,7 +376,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -384,7 +384,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -394,7 +393,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -440,7 +438,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting workflow instance. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getWorkflowInstances "
@@ -455,7 +455,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -464,7 +463,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -474,7 +472,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -523,7 +520,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting workflow instance. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getWorkflowInstancesByStatus "
@@ -538,7 +537,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -547,7 +545,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -557,7 +554,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -595,7 +591,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting num workflow instances. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getNumWorkflowInstances "
@@ -610,7 +608,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -619,7 +616,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -629,7 +625,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -669,7 +664,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting num workflow instances by status. 
Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getNumWorkflowInstancesByStatus "
@@ -684,7 +681,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -693,7 +689,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -703,7 +698,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -717,7 +711,7 @@ public class DataSourceWorkflowInstanceRepository extends
         ResultSet rs = null;
 
         List wInstIds = null;
-        int numResults = -1;
+        int numResults;
 
         if (status == null || (status.equals(""))) {
             numResults = getNumWorkflowInstances();
@@ -785,7 +779,9 @@ public class DataSourceWorkflowInstanceRepository extends
             LOG.log(Level.WARNING, "Exception performing query. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback query transaction. Message: "
@@ -800,7 +796,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -809,7 +804,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -819,7 +813,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -855,7 +848,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception getting workflow instance metadata. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback getWorkflowInstancesMetadata "
@@ -870,7 +865,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                rs = null;
             }
 
             if (statement != null) {
@@ -879,7 +873,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -889,7 +882,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -901,13 +893,11 @@ public class DataSourceWorkflowInstanceRepository extends
 
         if (inst.getSharedContext() != null
                 && inst.getSharedContext().getHashtable().keySet().size() > 0) 
{
-            for (Iterator i = inst.getSharedContext().getHashtable().keySet()
-                    .iterator(); i.hasNext();) {
-                String key = (String) i.next();
+            for (String key : inst.getSharedContext().getHashtable().keySet()) 
{
                 List vals = inst.getSharedContext().getAllMetadata(key);
                 if (vals != null && vals.size() > 0) {
-                    for (Iterator j = vals.iterator(); j.hasNext();) {
-                        String val = (String) j.next();
+                    for (Object val1 : vals) {
+                        String val = (String) val1;
                         if (val != null && !val.equals("")) {
                             addMetadataValue(inst.getId(), key, val);
                         }
@@ -942,7 +932,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     + val + "] to workflow inst: [" + wInstId + "]. Message: "
                     + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback addMetadataValue transaction. 
Message: "
@@ -957,7 +949,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -967,7 +958,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
 
@@ -996,7 +986,9 @@ public class DataSourceWorkflowInstanceRepository extends
                     "Exception removing workflow instance metadata. Message: "
                             + e.getMessage());
             try {
-                conn.rollback();
+                if (conn != null) {
+                    conn.rollback();
+                }
             } catch (SQLException e2) {
                 LOG.log(Level.SEVERE,
                         "Unable to rollback removeWorkflowInstanceMetadata "
@@ -1010,7 +1002,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                statement = null;
             }
 
             if (conn != null) {
@@ -1020,7 +1011,6 @@ public class DataSourceWorkflowInstanceRepository extends
                 } catch (SQLException ignore) {
                 }
 
-                conn = null;
             }
         }
     }

Reply via email to