Index: src/edu/ucsb/nceas/metacat/DocumentIdentifier.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentIdentifier.java	(revision 735)
+++ src/edu/ucsb/nceas/metacat/DocumentIdentifier.java	(revision 736)
@@ -70,58 +70,75 @@
   /**
    * parses the docid into its parts
    */
-  private void parseDocid()
+  private void parseDocid() throws AccessionNumberException
   {
-    int firstIndex = docid.indexOf(separator);
-    int lastIndex = docid.lastIndexOf(separator);
-    if(firstIndex != lastIndex)
-    { //this docid contains a revision number
-      rev = docid.substring(lastIndex + 1);
-      uniqueId = docid.substring(firstIndex + 1, lastIndex);
-      siteCode = docid.substring(0, firstIndex);
+    try {
+      int firstIndex = docid.indexOf(separator);
+      int lastIndex = docid.lastIndexOf(separator);
+      if(firstIndex != lastIndex)
+      { //this docid contains a revision number
+        rev = docid.substring(lastIndex + 1);
+        uniqueId = docid.substring(firstIndex + 1, lastIndex);
+        siteCode = docid.substring(0, firstIndex);
+      }
+      else
+      {
+        uniqueId = docid.substring(firstIndex + 1);
+        siteCode = docid.substring(0, firstIndex);
+        rev = getNewestRev();
+      }
+    } catch (StringIndexOutOfBoundsException e) {
+      throw new 
+      AccessionNumberException("Error in DocumentIdentifier.parseDocid(). " +
+                               "Use accession number format as: " +
+                               "sitecode" + separator + "uniqueid" + 
+                               separator + "revisionid");
+    } catch (SQLException e) {
+      throw new 
+      AccessionNumberException("Error in DocumentIdentifier.parseDocid(). " +
+                               "DB Error when reading revisionid");
+    } catch (ClassNotFoundException e) {
+      throw new 
+      AccessionNumberException("Error in DocumentIdentifier.parseDocid(). " +
+                                e.getMessage());
     }
-    else
-    {
-      uniqueId = docid.substring(firstIndex + 1);
-      siteCode = docid.substring(0, firstIndex);
-      rev = getNewestRev();
-    }
     
-    if(rev.equals("newest"))
-    {
-      rev = getNewestRev();
+    try {
+      if(rev.equals("newest")) {
+        rev = getNewestRev();
+      }
+    } catch (SQLException e) {
+      throw new 
+      AccessionNumberException("Error in DocumentIdentifier.parseDocid(). " +
+                               "DB Error when reading revisionid");
+    } catch (ClassNotFoundException e) {
+      throw new 
+      AccessionNumberException("Error in DocumentIdentifier.parseDocid(). " +
+                                e.getMessage());
     }
+      
   }
   
   /**
    * returns the newest revision number for a document
    */
-  private String getNewestRev()
+  private String getNewestRev() throws SQLException, ClassNotFoundException
   {
     PreparedStatement pstmt;
     Connection conn = null;
     
-    try
-    {
-      try
-      { //this connection is prone to error for some reason so we 
+    try {
+      try {
+        //this connection is prone to error for some reason so we 
         //try to connect it three times before quiting.
         conn = util.openDBConnection();
-      }
-      catch(SQLException sqle)
-      {
-        try
-        {
+      } catch(SQLException sqle) {
+        try {
           conn = util.openDBConnection();
-        }
-        catch(SQLException sqlee)
-        {
-          try
-          {
+        } catch(SQLException sqlee) {
+          try {
             conn = util.openDBConnection();
-          }
-          catch(SQLException sqleee)
-          {
+          } catch(SQLException sqleee) {
             System.out.println("error getting db connection in " + 
                                "MetacatReplication.handleGetDocumentRequest: " +
                                sqleee.getMessage());
@@ -128,13 +145,13 @@
           }
         }
       }
+      
       pstmt = conn.prepareStatement("select rev from xml_documents where " +
                                     "docid like '" + docid + "'");
       pstmt.execute();
       ResultSet rs = pstmt.getResultSet();
       boolean tablehasrows = rs.next();
-      if(tablehasrows)
-      {
+      if (tablehasrows) {
         String retStr = rs.getString(1);
         pstmt.close();
         conn.close();
@@ -141,18 +158,15 @@
         return retStr;
       }
       conn.close();
-    }
-    catch(Exception e)
-    {
+    } catch(SQLException e) {
       System.out.println("error in DocumentIdentifier.getNewestRev(): " +
                           e.getMessage());
-      try
-      {
+      try {
         conn.close();
-      }
-      catch(Exception e2)
-      {}
+      } catch(SQLException e2) { throw e2; }
+      throw e;
     }
+    
     return "1";
   }
   
