[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sat Nov 12 16:43:47 UTC 2005


senger
Sat Nov 12 11:43:47 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv12988/src/main/org/biomoby/client

Modified Files:
	CentralDigestCachedImpl.java CentralDigestImpl.java 
	CentralImpl.java 
Log Message:


moby-live/Java/src/main/org/biomoby/client CentralDigestCachedImpl.java,1.13,1.14 CentralDigestImpl.java,1.9,1.10 CentralImpl.java,1.34,1.35
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/11/10 08:54:31	1.13
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/11/12 16:43:47	1.14
@@ -446,7 +446,7 @@
 	    return true;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopDT ? DATA_TYPES_CANCELLED : DATA_TYPES_END);
 	    stopDT = false;
@@ -459,7 +459,10 @@
      *       if failed do nothing (except reporting it)
      *   - remove LIST_FILE
      *   - compare contents of new LIST_FILE with file names in the cache
-     *     and remove them, or fetched missing ones
+     *     and remove them, or fetched missing ones;
+     *     in order to compare properly you need to read individual files
+     *     and look if they really contain all services mentioned in the
+     *     LIST_FILE
      *       if success add there new LIST_FILE
      *************************************************************************/
     protected boolean fillServicesCache()
@@ -485,7 +488,31 @@
 	    for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) {
 		Map.Entry entry = (Map.Entry)it.next();
 		String authority = (String)entry.getKey();
-		if ( ! currentFiles.contains (authority)) {
+		if (currentFiles.contains (authority)) {
+		    MobyService[] servs =
+			extractServices (load (new File (servicesCache, authority)));
+		    // compare names in 'services' (those are services we have in cache)
+		    // with names in 'entry' (those are the ones we should have)
+		    boolean theyAreEqual = true;
+		    HashSet currentServices = new HashSet (servs.length);
+		    for (int i = 0; i < servs.length; i++)
+			currentServices.add (servs[i].getName());
+		    String[] newServices = (String[])entry.getValue();
+		    for (int i = 0; i < newServices.length; i++) {
+			if (currentServices.contains (newServices[i])) {
+			    currentServices.remove (newServices[i]);
+			} else {
+			    theyAreEqual = false;
+			    break;
+			}
+		    }
+		    if (currentServices.size() > 0)
+			theyAreEqual = false;
+		    if (! theyAreEqual)
+			currentFiles.remove (authority);
+		}
+
+		if (! currentFiles.contains (authority)) {
 		    // missing file: fetch it from a registry
 		    fireEvent (AUTHORITY_LOADING, authority);
 		    String xml = getServicesAsXML (new MobyService (MobyService.DUMMY_NAME, authority), null, true, true);
@@ -494,8 +521,9 @@
 		    if (stopS) {
 			return false;
 		    }
+		} else {
+		    currentFiles.remove (authority);
 		}
-		currentFiles.remove (authority);
 	    }
 
 	    // remove files that are not any more needed
@@ -507,7 +535,7 @@
 	    return true;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopS ? AUTHORITIES_CANCELLED : AUTHORITIES_END);
 	    stopS = false;
@@ -568,7 +596,7 @@
 	    return true;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopST ? SERVICE_TYPES_CANCELLED :SERVICE_TYPES_END);
 	    stopST = false;
@@ -587,7 +615,7 @@
 	    store (namespacesCache, LIST_FILE, xml);
 	    return true;
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (NAMESPACES_END);
 	}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java	2005/10/28 07:58:08	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java	2005/11/12 16:43:47	1.10
@@ -99,7 +99,7 @@
 	    return result;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopDT ? DATA_TYPES_CANCELLED : DATA_TYPES_END);
 	    stopDT = false;
@@ -135,7 +135,7 @@
 	    return result;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopST ? SERVICE_TYPES_CANCELLED : SERVICE_TYPES_END);
 	    stopST = false;
@@ -188,7 +188,7 @@
 	    return result;
 
 	} catch (Exception e) {
-	    throw new MobyException (formatException (e));
+	    throw new MobyException (formatException (e), e);
 	} finally {
 	    fireEvent (stopS ? AUTHORITIES_CANCELLED : AUTHORITIES_END);
 	    stopS = false;
@@ -199,7 +199,8 @@
      * Do more for NullPointerException...
      *************************************************************************/
     protected String formatException (Exception e) {
-	if (e instanceof java.lang.NullPointerException) {
+	if ( (e instanceof java.lang.NullPointerException) ||
+	     (e instanceof java.lang.ClassCastException) ) {
 	    StringBuffer buf = new StringBuffer();
 	    buf.append (e.toString());
 	    buf.append (DGUtils.stackTraceToString (e));

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/11/09 05:29:38	1.34
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/11/12 16:43:47	1.35
@@ -191,18 +191,18 @@
 		    System.err.println (result + "\n");
 		System.err.println ("------------\n");
 
-		return result;
+		return resultToString (result);
 
 	    } else {
-		return call.invoke (uri, method, parameters);
+		return resultToString (call.invoke (uri, method, parameters));
 	    }
 
 	} catch (AxisFault e) {
 	    throw new MobyException
 		(AxisUtils.formatFault (e, endpoint.toString(),
-					(call == null ? null : call.getOperationName())));
+					(call == null ? null : call.getOperationName())), e);
 	} catch (Exception e) {
-	    throw new MobyException (e.toString());
+	    throw new MobyException (e.toString(), e);
 // 	    e.printStackTrace();
  	}
     }
@@ -1467,7 +1467,7 @@
 						  false) + 
 				"</findService>"
 	};
-	return (String) doCall ("findService", query);
+	return (String)doCall ("findService", query);
     }
 
     /**************************************************************************
@@ -1480,6 +1480,14 @@
 	    result = doCall (methodName, new Object[] { });
 	else 
 	    result = doCall (methodName, new Object[] { inputXML });
+	return (String)result;
+    }
+
+    /**************************************************************************
+     *
+     *************************************************************************/
+    protected static String resultToString (Object result)
+	throws MobyException {
  	if (result == null)
  	    throw new MobyException ("Returned result is null.");
 	if (result instanceof String)




More information about the MOBY-guts mailing list