[Mulgara-svn] r174 - trunk/src/jar/itql/java/org/mulgara/itql

pag at mulgara.org pag at mulgara.org
Fri Feb 23 22:19:04 UTC 2007


Author: pag
Date: 2007-02-23 16:19:04 -0600 (Fri, 23 Feb 2007)
New Revision: 174

Modified:
   trunk/src/jar/itql/java/org/mulgara/itql/Collaborator.java
   trunk/src/jar/itql/java/org/mulgara/itql/CollaboratorUnitTest.java
Log:
Standardized formatting.  Also added a stacktrace to the log on a failed SOAP test

Modified: trunk/src/jar/itql/java/org/mulgara/itql/Collaborator.java
===================================================================
--- trunk/src/jar/itql/java/org/mulgara/itql/Collaborator.java	2007-02-23 22:17:06 UTC (rev 173)
+++ trunk/src/jar/itql/java/org/mulgara/itql/Collaborator.java	2007-02-23 22:19:04 UTC (rev 174)
@@ -106,8 +106,7 @@
 
       SERVER = "rmi://" + java.net.InetAddress.getLocalHost().getCanonicalHostName() +
           "/" + SERVER_NAME + "#";
-    }
-    catch (java.net.UnknownHostException ex) {
+    } catch (java.net.UnknownHostException ex) {
 
       System.err.print("Unable to determine local host name :" + ex.toString());
     }
@@ -342,8 +341,7 @@
       try {
 
         this.initializeModel();
-      }
-      catch (Exception ex) {
+      } catch (Exception ex) {
 
         log.fatal("Unable to initialize collaboration model", ex);
       }
@@ -412,16 +410,13 @@
 
       // Send newMessage
       Transport.send(message);
-    }
-    catch (NoSuchProviderException nex) {
+    } catch (NoSuchProviderException nex) {
 
       log.error("Cannot send email", nex);
-    }
-    catch (AddressException ex) {
+    } catch (AddressException ex) {
 
       log.error("Cannot send email", ex);
-    }
-    catch (MessagingException mex) {
+    } catch (MessagingException mex) {
 
       log.error("Cannot send email", mex);
     }
@@ -513,8 +508,7 @@
                        "Welcome to Mulgara Collaborator. Your access key is " +
                        key);
       }
-    }
-    else {
+    } else {
 
       log.warn("Existing registration already exists for " + emailAddress);
 
@@ -569,8 +563,7 @@
       }
 
       accessOk = true;
-    }
-    else {
+    } else {
 
       log.warn("Invaild access key :" + key + " for email address :" +
                emailAddress);
@@ -733,8 +726,7 @@
         //Check the result
         added = (annotationId.length() > 0);
       }
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       //Rollback the transaction
       this.rollback("editAnnotation");
@@ -757,8 +749,7 @@
                             "Unable to edit annotation");
 
       throw se;
-    }
-    else {
+    } else {
 
       // Commit the changes
       this.commit("editAnnotation");
@@ -792,7 +783,7 @@
     this.checkAccessKey(key, emailAddress);
 
     //Check parameters
-    if ( (documentId == null) || (documentId.length() == 0)) {
+    if ((documentId == null) || (documentId.length() == 0)) {
 
       log.warn("Invalid paramaters supplied for retrieving annotations");
 
@@ -818,15 +809,12 @@
     try {
 
       results = this.decode(itqlBean.executeQueryToString(query));
-    }
-    catch (Exception ex) {
+    } catch (Exception ex) {
 
-      log.error("Unable to retrieve annotations for documentId :" + documentId,
-                ex);
+      log.error("Unable to retrieve annotations for documentId :" + documentId, ex);
 
-      SOAPException se =
-          new SOAPException(Constants.FAULT_CODE_SERVER,
-                            "Unable to retrieve annotations");
+      SOAPException se = new SOAPException(Constants.FAULT_CODE_SERVER,
+                            "Unable to retrieve annotations: " + ex.getMessage(), ex);
 
       throw se;
     }
@@ -888,8 +876,7 @@
     try {
 
       String ans = itqlBean.executeQueryToString(CHECK_MODEL);
-    }
-    catch (Exception ex) {
+    } catch (Exception ex) {
 
       ex.printStackTrace();
     }
@@ -933,19 +920,16 @@
               initialized = (model.substring(pos + 1).equals(MODEL));
             }
           }
-        }
-        catch (TuplesException e) {
+        } catch (TuplesException e) {
           throw new QueryException("Couldn't initialize model", e);
         }
-      }
-      else {
+      } else {
 
         if (obj instanceof String) {
 
           log.error("Unable to check collaboration model for existance :" +
                     ( (String) obj).toString() + " Using query :" + CHECK_MODEL);
-        }
-        else {
+        } else {
 
           log.error("Unable to check collaboration model for existance " +
                     " Using query :" + CHECK_MODEL);
@@ -957,8 +941,7 @@
 
       //Model has not been initialized
       initialized = this.createModel();
-    }
-    else {
+    } else {
 
       log.debug("Collaborator model already initialized at " + SERVER + MODEL);
     }
@@ -1075,8 +1058,7 @@
                 "'" +
                 this.encode(((LiteralImpl) annotation.getObject(objectIndex)).getLexicalForm()) +
                 "'";
-          }
-          else if (annotation.getObject(objectIndex) instanceof URIReference) {
+          } else if (annotation.getObject(objectIndex) instanceof URIReference) {
 
             object =
                 "<" +
@@ -1103,8 +1085,7 @@
                 new SOAPException(Constants.FAULT_CODE_SERVER,
                                   "Unable to remove annotation");
             throw se;
-          }
-          else {
+          } else {
 
             // the flag the update document
             this.documentHasUpdated(documentId);
@@ -1116,8 +1097,7 @@
 
           this.commit("removeAnnotation");
         }
-      }
-      catch (TuplesException ex) {
+      } catch (TuplesException ex) {
 
         //Rollback the transaction
         if (trans) {
@@ -1133,8 +1113,7 @@
                               "Unable to locate annotation for removal");
         throw se;
       }
-    }
-    else {
+    } else {
 
       log.warn("Unable to locate annotation for removal documentId :" +
                documentId + " annotationId :" + annotationId);
@@ -1270,8 +1249,7 @@
 
         this.rollback("addAnnotation");
       }
-    }
-    else {
+    } else {
 
       // Commit the inserts
       if (trans) {
@@ -1391,8 +1369,7 @@
 
             break;
           }
-        }
-        catch (TuplesException ex) {
+        } catch (TuplesException ex) {
 
           log.error("Error executing command :" + command, ex);
 
@@ -1484,8 +1461,7 @@
 
             answer = (Answer) obj;
           }
-        }
-        catch (TuplesException ex) {
+        } catch (TuplesException ex) {
 
           log.error("Error executing query :" + query, ex);
         }
@@ -1553,8 +1529,7 @@
 
       // has been updated
       lastUpdatedTime = ( (Long) documentUpdates.get(documentId)).longValue();
-    }
-    else {
+    } else {
 
       // No modification has occur for this document.
       // ie. server has been started without any updates
@@ -1591,8 +1566,7 @@
     try {
 
       itqlBean.beginTransaction(name);
-    }
-    catch (QueryException ex) {
+    } catch (QueryException ex) {
 
       log.error("Unable to obtain a transaction for the Mulgara Collaborator <" +
                 name + ">", ex);
@@ -1621,8 +1595,7 @@
     try {
 
       itqlBean.commit(name);
-    }
-    catch (QueryException ex) {
+    } catch (QueryException ex) {
 
       log.error("Unable to obtain a transaction for the Mulgara Collaborator <" +
                 name + ">", ex);
@@ -1652,8 +1625,7 @@
     try {
 
       itqlBean.rollback(name);
-    }
-    catch (QueryException ex) {
+    } catch (QueryException ex) {
 
       log.error(
           "Unable to rollback a transaction for the Mulgara Collaborator <" +

Modified: trunk/src/jar/itql/java/org/mulgara/itql/CollaboratorUnitTest.java
===================================================================
--- trunk/src/jar/itql/java/org/mulgara/itql/CollaboratorUnitTest.java	2007-02-23 22:17:06 UTC (rev 173)
+++ trunk/src/jar/itql/java/org/mulgara/itql/CollaboratorUnitTest.java	2007-02-23 22:19:04 UTC (rev 174)
@@ -167,9 +167,9 @@
 
       this.assertTrue("Failed to create collaborator model",
           collaborator.createModel());
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Model tests failed " + ex.getMessage(), false);
     }
   }
@@ -183,9 +183,9 @@
 
       this.assertTrue("Register user",
           collaborator.register("xyz at company.com", "Joe Brown"));
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Registration test failed " + ex.getMessage(), false);
     }
 
@@ -193,8 +193,7 @@
 
       collaborator.register("xyz at company.com", "Alex Mole");
       this.assertTrue("Failed to detect duplicate registered user", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue("Failed to get the expected message (Your Email address has already been registered)",
           ex.getMessage().equals(
@@ -205,8 +204,7 @@
 
       collaborator.register("", "Alex Mole");
       this.assertTrue("Failed to detect empty email address", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue("Failed to get the expected message (Email address and nick name must be supplied)",
           ex.getMessage().equals("Email address and nick name must be supplied"));
@@ -228,9 +226,9 @@
           " email address : guest at pisoftware.com",
           collaborator.checkAccessKey(collaborator.lastAccessKeyCreated,
           "guest at pisoftware.com"));
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Not expecting exception on checking access key " +
           ex.getMessage(), false);
     }
@@ -239,8 +237,7 @@
 
       collaborator.checkAccessKey("12345", "guest at pisoftware.com");
       this.assertTrue("Failed to detect invalid access key", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue("Failed to get the expected message (Invaild access key)",
           ex.getMessage().indexOf("Invaild access key") >= 0);
@@ -266,9 +263,9 @@
 
       this.assertTrue("Unable to add annotation",
           (annotationId != null) && (annotationId.length() > 0));
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Failed to add annotation", false);
     }
 
@@ -281,8 +278,7 @@
           "11", "100", "101", "50", "50");
 
       this.assertTrue("Expected bad access key error", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue("Failed to get the expected message (Invaild access key)",
           ex.getMessage().indexOf("Invaild access key") >= 0);
@@ -298,8 +294,7 @@
           "50", "50");
 
       this.assertTrue("Expected bad parameters supplied", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue("Failed to get the expected message (Invalid paramaters supplied for annotation)",
           ex.getMessage().indexOf("Invalid paramaters supplied for annotation") >=
@@ -332,9 +327,9 @@
       this.assertTrue("Unable to remove annotation",
           collaborator.removeAnnotation("guest3 at pisoftware.com",
           collaborator.lastAccessKeyCreated, "1234567890", annotationId));
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Failed to add/remove annotation", false);
     }
 
@@ -346,8 +341,7 @@
           collaborator.lastAccessKeyCreated, "1234567890", annotationId));
 
       this.assertTrue("Expected not to be a successful removal", false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
       this.assertTrue(
           "Failed to get the expected message (Unable to locate annotation for removal)",
@@ -385,9 +379,9 @@
           "10", "100", "110", "1000", "1010", "500", "500");
 
       this.assertTrue("Unable to edit annotation", annotationId != null);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Failed to add/edit annotation", false);
     }
   }
@@ -437,9 +431,9 @@
       this.assertTrue("Expect document not to be updated for retrieval",
           collaborator.checkAnnotationUpdates("guest5 at pisoftware.com",
           collaborator.lastAccessKeyCreated, "newdocumentId") == false);
-    }
-    catch (SOAPException ex) {
+    } catch (SOAPException ex) {
 
+      ex.printStackTrace();
       this.assertTrue("Failed to add/retrieve annotation", false);
     } finally {
 




More information about the Mulgara-svn mailing list