[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Sat Jun 9 18:21:43 UTC 2007
gordonp
Sat Jun 9 14:21:43 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta
In directory dev.open-bio.org:/tmp/cvs-serv5011/src/main/org/biomoby/registry/meta
Modified Files:
RegistryCache.java
Log Message:
Fixed javadoc, added cache deletion mechanisms, removed debug message
moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/08 20:31:15 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 18:21:43 1.2
@@ -22,7 +22,7 @@
/**
* Returns where a resource should be cached locally, whether it current exists or not.
*
- * @param one of the resources listed in org.biomoby.shared.Central
+ * @param resourceName one of the resources listed in org.biomoby.shared.Central
*/
public static File getOntologyFile(Registry reg, String resourceName){
File fileLocation = null;
@@ -87,7 +87,6 @@
cacheFileWriter.write(line+"\n");
}
cacheFileWriter.close();
- System.err.println("Wrote " + cacheFile);
}
public synchronized static Registry getDefaultRegistry(){
@@ -112,7 +111,7 @@
String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym();
String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name");
return new File(tempDir,
- REG_CACHE_FILE_PREFIX+"DataType"+userName+"."+regName);
+ REG_CACHE_FILE_PREFIX+userName+"."+regName+".DataTypes.rdf");
}
public static File getServiceTypeOntologyFile(Registry reg){
@@ -129,7 +128,7 @@
String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym();
String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name");
return new File(tempDir,
- REG_CACHE_FILE_PREFIX+"ServiceType"+userName+"."+regName);
+ REG_CACHE_FILE_PREFIX+userName+"."+regName+".ServiceTypes.rdf");
}
public static File getNamespaceOntologyFile(Registry reg){
@@ -146,7 +145,7 @@
String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym();
String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name");
return new File(tempDir,
- REG_CACHE_FILE_PREFIX+"Namespace"+userName+"."+regName);
+ REG_CACHE_FILE_PREFIX+userName+"."+regName+".Namespaces.rdf");
}
public static File getServiceOntologyFile(Registry reg){
@@ -163,7 +162,7 @@
String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym();
String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name");
return new File(tempDir,
- REG_CACHE_FILE_PREFIX+"Service"+userName+"."+regName);
+ REG_CACHE_FILE_PREFIX+userName+"."+regName+".Services.rdf");
}
/**
@@ -204,4 +203,34 @@
public static void setTempDir(File dir){
tempDir = dir;
}
+
+ /**
+ * @param allowedAgeMillis files older than this are deleted, or if negative, all are deleted, or if zero, deleted at the end of the session
+ */
+ public static void deleteExpiredCacheFiles(long allowedAgeMillis){
+ String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name");
+ String relativeRegFilePrefix = REG_CACHE_FILE_PREFIX+userName;
+ String relativeCallFilePrefix = CALL_CACHE_FILE_PREFIX+userName;
+
+ long currentTime = System.currentTimeMillis();
+
+ for(File tempFile: tempDir.listFiles()){
+ // See if it belongs to us, based on the name
+ if(tempFile.getName().startsWith(relativeRegFilePrefix) ||
+ tempFile.getName().startsWith(relativeCallFilePrefix)){
+ // 0 means "for this session only"
+ if(allowedAgeMillis == 0){
+ tempFile.deleteOnExit();
+ }
+ else if(allowedAgeMillis < 0 ||
+ currentTime-tempFile.lastModified() > allowedAgeMillis){
+ tempFile.delete();
+ }
+ }
+ }
+ }
+
+ public static void deleteAllCacheFiles(){
+ deleteExpiredCacheFiles(-1); // negative time == delete all
+ }
}
More information about the MOBY-guts
mailing list