[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Thu Sep 22 16:07:09 UTC 2005


senger
Thu Sep 22 12:07:09 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv17235/src/main/org/biomoby/client

Modified Files:
	BaseCmdLineClient.java CentralDigestCachedImpl.java 
	CentralDigestImpl.java CentralImpl.java GraphsServlet.java 
	ServiceConnections.java 
Log Message:


moby-live/Java/src/main/org/biomoby/client BaseCmdLineClient.java,1.2,1.3 CentralDigestCachedImpl.java,1.6,1.7 CentralDigestImpl.java,1.4,1.5 CentralImpl.java,1.26,1.27 GraphsServlet.java,1.11,1.12 ServiceConnections.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/BaseCmdLineClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/BaseCmdLineClient.java	2005/09/04 13:45:37	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/BaseCmdLineClient.java	2005/09/22 16:07:08	1.3
@@ -288,8 +288,7 @@
      *************************************************************************/
     protected MobyObject createInstance (String className)
 	throws MobyException {
-	MobyObject data = null;
-	try {
+    try {
 	    Class theClass = mapDataTypes.getClass (className);
 	    if (theClass == null)
 		throw new MobyException ("Cannot instantiate data type '" + className + "'. Does it exist?");
@@ -533,7 +532,6 @@
 	    throw new MobyException
 		("Service name was not given. Try to add parameter: -service <name>");
 
-	String xmlResponse = null;
 	String methodName = serviceName;
 	Method method = null;
 	Object service = null;

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/09/19 08:08:32	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/09/22 16:07:08	1.7
@@ -21,6 +21,7 @@
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.MobyException;
 import org.biomoby.shared.MobyService;
+import org.biomoby.shared.MobyServiceType;
 import org.biomoby.shared.NoSuccessException;
 
 /**
@@ -29,7 +30,7 @@
  * does not need to access Moby registry all the time. The other
  * methods of the Central interface do not use the results of the
  * cached cumulative results (their implementation is just passed to
- * the parent class). It does not cache service types. <p>
+ * the parent class). <p>
  *
  * The caching is done in the file system, not in memory, so the
  * results are permanent (until someone removes the caching
@@ -46,14 +47,27 @@
     extends CentralDigestImpl
     implements CentralAll {
 
+    // filename for a list of cached entities
+    protected static final String LIST_FILE = "__L__I__S__T__";
+
+    /** An ID used in {@link #removeFromCache} indicating data types part. */
+    public static final String CACHE_PART_DATATYPES    = "c1";
+
+    /** An ID used in {@link #removeFromCache} indicating services part. */
+    public static final String CACHE_PART_SERVICES     = "c2";
+
+    /** An ID used in {@link #removeFromCache} indicating service types part. */
+    public static final String CACHE_PART_SERVICETYPES = "c3";
+
+    /** An ID used in {@link #removeFromCache} indicating namespaces part. */
+    public static final String CACHE_PART_NAMESPACES   = "c4";
+
     // cache location
     private String cacheDir;        // as defined in the constructor
     protected File dataTypesCache;
     protected File servicesCache;
     protected File namespacesCache;
-
-    // cache age
-    private long cacheAge = -1;
+    protected File serviceTypesCache;
 
     // for optimalization
     private String fileSeparator;
@@ -93,31 +107,40 @@
 	    File cache = createCacheDir (cacheDir, getRegistryEndpoint());
 	    messageLn ("Using cache directory: " + cache);
 	    dataTypesCache = createSubCacheDir (cache, "dataTypes");
-	    long dataTypesCacheAge = (isCacheEmpty (dataTypesCache) ? -1 : dataTypesCache.lastModified());
 	    servicesCache  = createSubCacheDir (cache, "services");
-	    long servicesCacheAge = (isCacheEmpty (servicesCache) ? -1 : servicesCache.lastModified());
 	    namespacesCache = createSubCacheDir (cache, "namespaces");
-	    long namespacesCacheAge = (isCacheEmpty (namespacesCache) ? -1 : namespacesCache.lastModified());
-
-	    if (dataTypesCacheAge > -1 && servicesCacheAge > -1 && namespacesCacheAge > -1)
-		cacheAge = Math.min (Math.min (dataTypesCacheAge, servicesCacheAge),
-				     namespacesCacheAge);
-	    else
-		cacheAge = Math.max (Math.max (dataTypesCacheAge, servicesCacheAge),
-				     namespacesCacheAge);
+	    serviceTypesCache = createSubCacheDir (cache, "serviceTypes");
 	}
     }
 
     /**************************************************************************
-     * It removes the whole cache (for the Moby registry this instance
-     * as initiated for), regardless of the 'id' passed.
+     * Removes object groups from the cache. If 'id' is null it
+     * removes the whole cache (for the Moby registry this instance as
+     * initiated for). Otherwise 'id' indicates what part of the cache
+     * that will be removed. <p>
+     *
+     * @param id should be either null, or one of the fillowing:
+     * {@link #CACHE_PART_DATATYPES}, {@link #CACHE_PART_SERVICES},
+     * {@link #CACHE_PART_SERVICETYPES}, and {@link
+     * #CACHE_PART_NAMESPACES}.
      **************************************************************************/
     public void removeFromCache (String id) {
 	try {
 	    if (cacheDir != null) {
-		removeCacheDir (cacheDir, getRegistryEndpoint(),
-				new String[] { "dataTypes", "services" });
-		cacheAge= -1;
+		String[] parts = null;
+		if (id == null)
+		    parts = new String[] { "dataTypes", "services", "serviceTypes", "namespaces" };
+		else if (id.equals (CACHE_PART_SERVICES))
+		    parts = new String[] { "services" };
+		else if (id.equals (CACHE_PART_DATATYPES))
+		    parts = new String[] { "dataTypes" };
+		else if (id.equals (CACHE_PART_SERVICETYPES))
+		    parts = new String[] { "serviceTypes" };
+		else if (id.equals (CACHE_PART_NAMESPACES))
+		    parts = new String[] { "namespaces" };
+		if (parts != null) {
+		    removeCacheDir (cacheDir, getRegistryEndpoint(), parts);
+		}
 	    }
 	} catch (MobyException e) {
 	    // TBD: keep this here at least for some time (until we
@@ -255,8 +278,10 @@
 	}
     }
 
-    // read a cached file
-    protected String load (File file)
+    /**************************************************************************
+     * Read a cached file
+     *************************************************************************/
+    protected static String load (File file)
 	throws MobyException {
 	try {
 	    StringBuffer buf = new StringBuffer();
@@ -280,6 +305,7 @@
     //
     protected boolean isCacheEmpty (File cache)
 	throws MobyException {
+	if (cache == null) return true;
 	String[] list = cache.list();
 	return ( list == null || list.length == 0 );
     }
@@ -287,7 +313,9 @@
     protected void fillDataTypesCache()
 	throws MobyException {
 	try {
-	    Map types = getDataTypeNames();
+	    String typesAsXML = getDataTypeNamesAsXML();
+	    store (dataTypesCache, LIST_FILE, typesAsXML);
+	    Map types = createDataTypeNamesFromXML (typesAsXML);
 	    for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
 		Map.Entry entry = (Map.Entry)it.next();
 		String name = (String)entry.getKey();
@@ -295,9 +323,6 @@
 		String xml = getDataTypeAsXML (name);
 		store (dataTypesCache, name, xml);
 	    }
-	    if (cacheAge <= 0)
-		cacheAge = dataTypesCache.lastModified();
-
 	} catch (Exception e) {
 	    throw new MobyException (formatException (e));
 	}
@@ -307,17 +332,36 @@
 	throws MobyException {
 	try {
 	    messageLn ("(CDCI) Asking for all service names...");
-	    Map names = getServiceNames();
-	    for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) {
+	    String byAuthorityAsXML = getServiceNamesByAuthorityAsXML();
+	    store (servicesCache, LIST_FILE, byAuthorityAsXML);
+	    Map authorities = createServiceNamesByAuthorityFromXML (byAuthorityAsXML);
+	    for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) {
 		Map.Entry entry = (Map.Entry)it.next();
-		String name = (String)entry.getKey();
-		messageLn ("(CDCI) Processing service " + name + "...");
-		String xml = getServicesAsXML (new MobyService (name), null, true, true);
-		store (servicesCache, name, xml);
+		String authority = (String)entry.getKey();
+		messageLn ("(CDCI) Processing authority " + authority + "...");
+		String xml = getServicesAsXML (new MobyService (MobyService.DUMMY_NAME, authority), null, true, true);
+		store (servicesCache, authority, xml);
 	    }
-	    if (cacheAge <= 0)
-		cacheAge = servicesCache.lastModified();
+	} catch (Exception e) {
+	    throw new MobyException (formatException (e));
+	}
+    }
 
+    //
+    protected void fillServiceTypesCache()
+	throws MobyException {
+	try {
+	    messageLn ("(CDCI) Asking for all service type names...");
+	    String typesAsXML = getServiceTypesAsXML();
+	    store (serviceTypesCache, LIST_FILE, typesAsXML);
+	    Map types = createServiceTypesFromXML (typesAsXML);
+	    for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
+		Map.Entry entry = (Map.Entry)it.next();
+		String name = (String)entry.getKey();
+		messageLn ("(CDCI) Processing service type " + name + "...");
+		String xml = getServiceTypeRelationshipsAsXML (name, false);
+		store (serviceTypesCache, name, xml);
+	    }
 	} catch (Exception e) {
 	    throw new MobyException (formatException (e));
 	}
@@ -328,16 +372,34 @@
 	throws MobyException {
 	try {
 	    String xml = getNamespacesAsXML();
-	    store (namespacesCache, "all_namespaces_in_one_go", xml);
-	    if (cacheAge <= 0)
-		cacheAge = namespacesCache.lastModified();
-
+	    store (namespacesCache, LIST_FILE, xml);
 	} catch (Exception e) {
 	    throw new MobyException (formatException (e));
 	}
     }
 
-    // read all data types
+    /*************************************************************************
+     *
+     *************************************************************************/
+    public Map getDataTypeNames()
+	throws MobyException {
+	if (dataTypesCache == null)
+	    return super.getDataTypeNames();
+	synchronized (dataTypesCache) {
+	    if (isCacheEmpty (dataTypesCache)) {
+		initCache();
+		fillDataTypesCache();
+	    }
+
+	    // get a list file (with all data type names)
+	    String xmlList = getListFile (dataTypesCache);
+	    return createDataTypeNamesFromXML (xmlList);
+	}
+    }
+
+    /*************************************************************************
+     *
+     *************************************************************************/
     public MobyDataType[] getDataTypes()
 	throws MobyException {
 	if (dataTypesCache == null)
@@ -350,15 +412,14 @@
 	    }
 	    File[] list = dataTypesCache.listFiles();
 	    if (list == null)
-		throw new MobyException ("Surprisingly, '" + dataTypesCache.getAbsolutePath() + "' is not a directory. Strange...");
+		throw new MobyException (MSG_CACHE_NOT_DIR (dataTypesCache));
+
 	    for (int i = 0; i < list.length; i++) {
 		try {
-		    if (list[i].getPath().endsWith ("~"))
-			continue;   // ignore some files
+		    if (ignored (list[i])) continue;
 		    v.addElement (createDataTypeFromXML (load (list[i]), "-dummy-"));
 		} catch (NoSuccessException e) {
-		    System.err.println ("Ignoring '" + list[i].getPath() + "'. It should not be in the cache directory.");
-// 		    throw new MobyException (e.getMessage() + " (" + e.getCulprit() + ")");
+		    System.err.println (MSG_CACHE_BAD_FILE (list[i], e));
 		}
 	    }
 	    MobyDataType[] result = new MobyDataType [v.size()];
@@ -367,7 +428,28 @@
 	}
     }
 
-    // read all services
+    /*************************************************************************
+     *
+     *************************************************************************/
+    public Map getServiceNamesByAuthority()
+	throws MobyException {
+	if (servicesCache == null)
+	    return super.getServiceNamesByAuthority();
+	synchronized (servicesCache) {
+	    if (isCacheEmpty (servicesCache)) {
+		initCache();
+		fillServicesCache();
+	    }
+
+	    // get a list file (with all service names)
+	    String xmlList = getListFile (servicesCache);
+	    return createServiceNamesByAuthorityFromXML (xmlList);
+	}
+    }
+
+    /*************************************************************************
+     *
+     *************************************************************************/
     public MobyService[] getServices()
 	throws MobyException {
 	if (servicesCache == null)
@@ -380,13 +462,17 @@
 	    }
 	    File[] list = servicesCache.listFiles();
 	    if (list == null)
-		throw new MobyException ("Surprisingly, '" + servicesCache.getAbsolutePath() + "' is not a directory. Strange...");
+		throw new MobyException (MSG_CACHE_NOT_DIR (servicesCache));
 	    for (int i = 0; i < list.length; i++) {
-		if (list[i].getPath().endsWith ("~"))
-		    continue;   // ignore some files
-		MobyService[] servs = extractServices (load (list[i]));
-		for (int j = 0; j < servs.length; j++)
-		    v.addElement (servs[j]);
+		try {
+		    if (ignored (list[i])) continue;
+		    MobyService[] servs = extractServices (load (list[i]));
+		    for (int j = 0; j < servs.length; j++) {
+			v.addElement (servs[j]);
+		    }
+		} catch (MobyException e) {
+		    System.err.println (MSG_CACHE_BAD_FILE (list[i], e));
+		}
 	    }
 	    MobyService[] result = new MobyService [v.size()];
 	    v.copyInto (result);
@@ -394,7 +480,10 @@
 	}
     }
 
-//     public MobyNamespace[] getNamespaces()
+    /*************************************************************************
+     *
+     *************************************************************************/
+//     public MobyNamespace[] getNamespaces()   //TBD: later, when API allows it
     public Map getNamespaces()
 	throws MobyException {
 	if (namespacesCache == null)
@@ -404,23 +493,89 @@
 		initCache();
 		fillNamespacesCache();
 	    }
-	    File[] list = namespacesCache.listFiles();
-	    if (list == null)
-		throw new MobyException
-		    ("Surprisingly, '" + namespacesCache.getAbsolutePath() + "' is not a directory. Strange...");
-	    for (int i = 0; i < list.length; i++) {
+
+	    // get a list file (with all namespaces)
+	    String xmlList = getListFile (namespacesCache);
+	    return createNamespacesFromXML (xmlList);
+	}
+    }
+
+    /*************************************************************************
+     *
+     *************************************************************************/
+    protected MobyServiceType[] readServiceTypes()
+	throws MobyException {
+	if (serviceTypesCache == null)
+	    return super.readServiceTypes();
+	synchronized (serviceTypesCache) {
+	    if (isCacheEmpty (serviceTypesCache)) {
+		initCache();
+		fillServiceTypesCache();
+	    }
+
+	    // get a list file (with all service type names)
+	    String xmlList = getListFile (serviceTypesCache);
+	    Map types = createServiceTypesFromXML (xmlList);
+
+	    // get individual (almost) full service types
+	    Vector v = new Vector();
+	    for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
+		Map.Entry entry = (Map.Entry)it.next();
+		String name = (String)entry.getKey();
+		File file = new File (serviceTypesCache, name);
 		try {
-		    if (list[i].getPath().endsWith ("~"))
-			continue;   // ignore some files
-		    return createNamespacesFromXML (load (list[i]));
+		    MobyServiceType serviceType = new MobyServiceType (name);
+		    serviceType.setParentNames (createServiceTypeRelationshipsFromXML (load (file)));
+		    serviceType.setDescription ((String)entry.getValue());
+		    v.addElement (serviceType);
 		} catch (MobyException e) {
-		    System.err.println ("Ignoring '" + list[i].getPath() +
-					"'. It should not be in the cache directory:" +
-					e.getMessage());
+		    System.err.println (MSG_CACHE_BAD_FILE (file, e));
 		}
 	    }
+	    MobyServiceType[] result = new MobyServiceType [v.size()];
+	    v.copyInto (result);
+	    return result;
 	}
-	return null;
+    }
+
+    /**************************************************************************
+     *
+     *************************************************************************/
+    protected static String getListFile (File cache)
+	throws MobyException {
+	File listFile = new File (cache, LIST_FILE);
+	if (! listFile.exists())
+	    throw new MobyException ("Corrupted cache '" + cache + "': Missing a LIST file.");
+	return load (listFile);
+    }
+
+    /**************************************************************************
+     * Some file (when being read from a cache directory) are ignored.
+     *************************************************************************/
+    protected static boolean ignored (File file) {
+	String path = file.getPath();
+	return
+	    path.endsWith ("~") ||
+	    path.endsWith (LIST_FILE);
+    }
+
+    /**************************************************************************
+     *
+     *************************************************************************/
+    protected static String MSG_CACHE_NOT_DIR (File cache) {
+	return
+	    "Surprisingly, '" + cache.getAbsolutePath() +
+	    "' is not a directory. Strange...";
+    }
+
+    /**************************************************************************
+     *
+     *************************************************************************/
+    protected static String MSG_CACHE_BAD_FILE (File file, Exception e) {
+	return
+	    "Ignoring '" + file.getPath() +
+	    "'. It should not be in the cache directory:" +
+	    e.getMessage();
     }
 
     /**************************************************************************
@@ -434,7 +589,7 @@
 
     /**************************************************************************
      * It always (again, if it functions as a cache which is when
-     * 'cacheDir' was given) reports that caching is disabled (even
+     * 'cacheDir' is given) reports that caching is disabled (even
      * though for the cumulative results is actually always enabled -
      * but that is obvious from the name of this class, isn't it?).
      **************************************************************************/
@@ -445,12 +600,28 @@
     /**************************************************************************
      * Return age of the current (whole) cache in millis from the
      * beginning of the Epoch; or -1 if cache is empty, or the age is
-     * unknown.
+     * unknown. <p>
      *
-     * The cache age is taken as the oldest (but filled) cache part.
+     * @return the cache age which is taken as the oldest (but filled)
+     * cache part (part is considered e.g. 'services', or 'data
+     * types', not their individual entities)
      **************************************************************************/
     public long getCacheAge() {
-	return cacheAge;
+	try {
+	    long dataTypesCacheAge =
+		(isCacheEmpty (dataTypesCache)    ? Long.MAX_VALUE : dataTypesCache.lastModified());
+	    long servicesCacheAge =
+		(isCacheEmpty (servicesCache)     ? Long.MAX_VALUE : servicesCache.lastModified());
+	    long namespacesCacheAge =
+		(isCacheEmpty (namespacesCache)   ? Long.MAX_VALUE : namespacesCache.lastModified());
+	    long serviceTypesCacheAge =
+		(isCacheEmpty (serviceTypesCache) ? Long.MAX_VALUE : serviceTypesCache.lastModified());
+	    long age = Math.min (Math.min (dataTypesCacheAge, servicesCacheAge),
+				 Math.min (namespacesCacheAge, serviceTypesCacheAge));
+	    return (age == Long.MAX_VALUE ? -1 : age);
+	} catch (MobyException e) {
+	    return -1;
+	}
     }
 
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java	2005/09/04 13:45:37	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestImpl.java	2005/09/22 16:07:09	1.5
@@ -11,6 +11,7 @@
 import org.biomoby.shared.MobyException;
 import org.biomoby.shared.MobyService;
 import org.biomoby.shared.MobyServiceType;
+import org.biomoby.shared.MobyNamespace;
 
 import org.tulsoft.tools.debug.DGUtils;
 
@@ -35,6 +36,7 @@
     protected MobyDataType[] dataTypes = new MobyDataType[] {};
     protected MobyServiceType[] serviceTypes = new MobyServiceType[] {};
     protected MobyService[] services = new MobyService[] {};
+    protected MobyNamespace[] namespaces = new MobyNamespace[] {};
 
 
     /*************************************************************************
@@ -101,7 +103,7 @@
 		String typeName = (String)entry.getKey();
 		messageLn ("(CDI) Processing service type " + typeName + "...");
 		MobyServiceType serviceType = new MobyServiceType (typeName);
-		serviceType.setDescription ((String)entry.getKey());
+		serviceType.setDescription ((String)entry.getValue());
 		serviceType.setParentNames (getServiceTypeRelationships (typeName, false));
 		v.addElement (serviceType);
 	    }
@@ -115,6 +117,36 @@
     }
 
     /*************************************************************************
+     * Physically gather together all namespaces. It is not that hard
+     * (comparing to other Biomoby entities) because all namespaces
+     * are delivered by a single call to Biomoby. This method differs
+     * form the Central.getNamespaces() in the type of returned
+     * result, and - hopefully in the future - also in the amount of
+     * information stored in the returned value (but at the monent,
+     * because of a limitation of the Biomoby API, both result types
+     * contain the same information).
+     *************************************************************************/
+    protected MobyNamespace[] readNamespaces()
+	throws MobyException {
+	try {
+	    Map names = getNamespaces();
+	    MobyNamespace[] result = new MobyNamespace [ names.size() ];
+	    int i = 0;
+	    for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) {
+		Map.Entry entry = (Map.Entry)it.next();
+		String name = (String)entry.getKey();
+		MobyNamespace ns = new MobyNamespace (name);
+		ns.setDescription ((String)entry.getValue());
+		result[i++] = ns;
+	    }
+	    return result;
+
+	} catch (Exception e) {
+	    throw new MobyException (formatException (e));
+	}
+    }
+
+    /*************************************************************************
      * Physically gather together all service instances.
      *************************************************************************/
     protected MobyService[] readServices()
@@ -122,14 +154,17 @@
 	try {
 	    Vector v = new Vector();
 	    messageLn ("(CDI) Asking for all service names...");
-	    Map names = getServiceNames();
-	    for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) {
+	    Map authorities = getServiceNamesByAuthority();
+	    for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) {
 		Map.Entry entry = (Map.Entry)it.next();
-		String name = (String)entry.getKey();
-		messageLn ("(CDI) Processing service " + name + "...");
-		MobyService[] servs = findService (new MobyService (name));
-		for (int i = 0; i < servs.length; i++)
-		    v.addElement (servs[i]);
+		String authority = (String)entry.getKey();
+		String[] names = (String[])entry.getValue();
+		for (int i = 0; i < names.length; i++) {
+		    messageLn ("(CDI) Processing service " + names[i] + "...");
+		    MobyService[] servs = findService (new MobyService (names[i], authority));
+		    for (int j = 0; j < servs.length; j++)
+			v.addElement (servs[j]);
+		}
 	    }
 	    MobyService[] result = new MobyService [v.size()];
 	    v.copyInto (result);
@@ -227,6 +262,22 @@
     /*************************************************************************
      *
      *************************************************************************/
+    public MobyNamespace[] getFullNamespaces()
+	throws MobyException {
+	synchronized (namespaces) {
+	    if (getCacheMode()) {
+		if (namespaces.length == 0)
+		    namespaces = readNamespaces();
+		return namespaces;
+	    } else {
+		return readNamespaces();
+	    }
+	}
+    }
+
+    /*************************************************************************
+     *
+     *************************************************************************/
     public MobyService[] getServices()
 	throws MobyException {
 	synchronized (services) {
@@ -240,7 +291,6 @@
 	}
     }
 
-
     // Work in progress - implement the methods above by getting RDF
     // graphs in-one-go and parsing them. Actually ability to get such
     // graphs was the main motivation for this implementation, and for

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/09/19 08:08:32	1.26
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/09/22 16:07:09	1.27
@@ -23,6 +23,7 @@
 import org.biomoby.shared.Utils;
 import org.biomoby.shared.MobyResourceRef;
 
+import org.tulsoft.shared.UUtils;
 import org.tulsoft.tools.soap.axis.AxisUtils;
 
 import org.w3c.dom.Document;
@@ -401,7 +402,7 @@
 	buf.append ("<serviceType>" + service.getType() + "</serviceType>\n");
 
 	String name = service.getName();
-	if (!name.equals ("") && !name.equals ("dummy"))
+	if (!name.equals ("") && !name.equals ("dummy") && !name.equals (MobyService.DUMMY_NAME))
 	    buf.append ("<serviceName>" + service.getName() + "</serviceName>\n");
 
 	buf.append ("<Category>" + service.getCategory() + "</Category>\n");
@@ -622,7 +623,7 @@
      * further calls unless it is set to true again. <p>
      *
      * @param shouldCache whether retrieveXXX call results should be
-     * cached in case they are called again (i.e. don't requery
+     * cached in case they are called again (i.e. don't request
      * MobyCentral every time)
      **************************************************************************/
     public void setCacheMode (boolean shouldCache) {
@@ -659,11 +660,6 @@
     public Map getServiceNames()
 	throws MobyException {
 
-	String cacheId = "retrieveServiceNames";
-	Map cachedResults = (Map)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
-
 	String result = (String)doCall ("retrieveServiceNames",
 					new Object[] {});
 
@@ -683,9 +679,6 @@
 			 elem.getAttribute ("authURI"));
 	}
 
-	// Add this data to the cache in case we get called again
-	setContents (cacheId, results);
-
 	return results;
     }
 
@@ -701,14 +694,20 @@
      *************************************************************************/
     public Map getServiceNamesByAuthority()
 	throws MobyException {
+	String result = getServiceNamesByAuthorityAsXML();
+	return createServiceNamesByAuthorityFromXML (result);
+    }
 
-	String cacheId = "retrieveServiceNamesByAuthority";
-	Map cachedResults = (Map)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
+    //
+    protected String getServiceNamesByAuthorityAsXML()
+	throws MobyException {
+	return (String)doCall ("retrieveServiceNames",
+			       new Object[] {});
+    }
 
-	String result = (String)doCall ("retrieveServiceNames",
-					new Object[] {});
+    //
+    protected Map createServiceNamesByAuthorityFromXML (String result)
+	throws MobyException {
 
 	// parse returned XML
 	Map results = new HashMap();
@@ -738,9 +737,6 @@
 	    entry.setValue (servNames);
 	}
 
-	// Add this data to the cache in case we get called again
-	setContents (cacheId, results);
-
 	return results;
     }
 
@@ -798,14 +794,20 @@
      *************************************************************************/
     public Map getServiceTypes()
 	throws MobyException {
+	String result = getServiceTypesAsXML();
+	return createServiceTypesFromXML (result);
+    }
 
-	String cacheId = "retrieveServiceTypes";
-	Map cachedResults = (Map)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
+    //
+    protected String getServiceTypesAsXML()
+	throws MobyException {
+	return (String)doCall ("retrieveServiceTypes",
+			       new Object[] {});
+    }
 
-	String result = (String)doCall ("retrieveServiceTypes",
-					new Object[] {});
+    //
+    protected Map createServiceTypesFromXML (String result)
+	throws MobyException {
 
 	// parse returned XML
 	Map results = new HashMap();
@@ -826,10 +828,6 @@
 		}
 	    }
 	}
-
-	// Add this data to the cache in case we get called again
-	setContents (cacheId, results);
-
 	return results;
     }
 
@@ -863,11 +861,6 @@
     protected Map createNamespacesFromXML (String result)
 	throws MobyException {
 
-	String cacheId = "retrieveNamespaces";
-	Map cachedResults = (Map)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
-
 	// parse returned XML
 	Map results = new HashMap();
 	Document document = null;
@@ -898,9 +891,6 @@
 	    }
 	}
 
-	// Add this data to the cache in case we get called again
-	setContents (cacheId, results);
-
 	return results;
     }
 
@@ -918,14 +908,20 @@
      *************************************************************************/
     public Map getDataTypeNames()
 	throws MobyException {
+	String result = getDataTypeNamesAsXML();
+	return createDataTypeNamesFromXML (result);
+    }
 
-	String cacheId = "retrieveObjectNames";
-	Map cachedResults = (Map)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
+    //
+    protected String getDataTypeNamesAsXML()
+	throws MobyException {
+	return (String)doCall ("retrieveObjectNames",
+			       new Object[] {});
+    }
 
-	String result = (String)doCall ("retrieveObjectNames",
-					new Object[] {});
+    //
+    protected Map createDataTypeNamesFromXML (String result)
+	throws MobyException {
 
 	// parse returned XML
 	Map results = new HashMap();
@@ -949,7 +945,6 @@
 	    }
 	}
 
-	setContents (cacheId, results);
 	return results;
     }
 
@@ -986,20 +981,12 @@
     protected String getDataTypeAsXML (String dataTypeName)
 	throws MobyException, NoSuccessException {
 
-	String cacheId = "retrieveObjectDefinition_" + dataTypeName;
-	String cachedResults = (String)getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
-
-	String results =
-	    (String)doCall ("retrieveObjectDefinition",
-			    new Object[] {
-				"<retrieveObjectDefinition>" +
-				  "<objectType>" + dataTypeName + "</objectType>" +
-				"</retrieveObjectDefinition>"
-			    });
-	setContents (cacheId, results);
-	return results;
+	return (String)doCall ("retrieveObjectDefinition",
+			       new Object[] {
+				   "<retrieveObjectDefinition>" +
+				   "<objectType>" + dataTypeName + "</objectType>" +
+				   "</retrieveObjectDefinition>"
+			       });
     }
 
     protected MobyDataType createDataTypeFromXML (String xmlSource, String dataTypeName)
@@ -1475,13 +1462,15 @@
     public String[] getServiceTypeRelationships (String serviceTypeName,
 						 boolean expand)
 	throws MobyException {
+	String result = getServiceTypeRelationshipsAsXML (serviceTypeName, expand);
+	return createServiceTypeRelationshipsFromXML (result);
+    }
 
-	String cacheId = "Relationships_" + serviceTypeName + ":" + expand;
-	String[] cachedResults = (String[])getContents (cacheId);
-	if (cachedResults != null)
-	    return cachedResults;
-
-	String result =
+    //
+    protected String getServiceTypeRelationshipsAsXML (String serviceTypeName,
+						       boolean expand)
+	throws MobyException {
+	return
 	    (String)doCall ("Relationships",
 			    new Object[] {
 				"<Relationship>" +
@@ -1490,6 +1479,11 @@
 				"<expandRelationship>" + (expand ? "1" : "0") + "</expandRelationship>" +
 				"</Relationship>"
 			    });
+    }
+
+    //
+    protected String[] createServiceTypeRelationshipsFromXML (String result)
+	throws MobyException {
 
 	// parse returned XML
 	Vector v = new Vector();
@@ -1509,8 +1503,6 @@
 	}
 	String[] results = new String [v.size()];
 	v.copyInto (results);
-
-	setContents (cacheId, results);
 	return results;
     }
 

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/GraphsServlet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/GraphsServlet.java	2005/09/04 13:45:37	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/GraphsServlet.java	2005/09/22 16:07:09	1.12
@@ -275,10 +275,10 @@
 
 	// read some suggested defaults from the init parameters
 	defaultEndpoint = (String)initParams.get (DEFAULT_ENDPOINT);
-	if (UUtils.isEmpty (defaultEndpoint))
+	if ( UUtils.isEmpty (defaultEndpoint) || defaultEndpoint.equals ("\"\"") )
 	    defaultEndpoint = CentralImpl.DEFAULT_ENDPOINT;
 	defaultNamespace = (String)initParams.get (DEFAULT_NAMESPACE);
-	if (UUtils.isEmpty (defaultNamespace))
+	if ( UUtils.isEmpty (defaultNamespace) || defaultNamespace.equals ("\"\"") )
 	    defaultNamespace = CentralImpl.DEFAULT_NAMESPACE;
 
 	registryCacheDir = (String)initParams.get (REGISTRY_CACHE_DIR);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ServiceConnections.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ServiceConnections.java	2005/08/26 06:27:04	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ServiceConnections.java	2005/09/22 16:07:09	1.7
@@ -244,7 +244,6 @@
 		// we need to remember all connections (edges) created for this output
 		// because only after we finish with it we will find if the connections
 		// are 'weak' or not (as described in ServicesEdge.isWeakConnection)
-		int startingFrom = v.size();
 
 		boolean headCollection = false;
 		MobyPrimaryDataSimple output;




More information about the MOBY-guts mailing list