From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- .../c2kernel/persistency/XMLClusterStorage.java | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'source/com/c2kernel/persistency/XMLClusterStorage.java') diff --git a/source/com/c2kernel/persistency/XMLClusterStorage.java b/source/com/c2kernel/persistency/XMLClusterStorage.java index 24697af..277551d 100644 --- a/source/com/c2kernel/persistency/XMLClusterStorage.java +++ b/source/com/c2kernel/persistency/XMLClusterStorage.java @@ -17,7 +17,8 @@ public class XMLClusterStorage extends ClusterStorage { public XMLClusterStorage() { } - public void open() throws ClusterStorageException { + @Override + public void open() throws ClusterStorageException { String rootProp = Gateway.getProperty("XMLStorage.root"); if (rootProp == null) throw new ClusterStorageException("XMLClusterStorage.open() - Root path not given in config file."); @@ -31,33 +32,38 @@ public class XMLClusterStorage extends ClusterStorage { } } - public void close() { + @Override + public void close() { rootDir = null; } // introspection - public short queryClusterSupport(String clusterType) { + @Override + public short queryClusterSupport(String clusterType) { return ClusterStorage.READWRITE; } - public String getName() { + @Override + public String getName() { return "XML File Cluster Storage"; } - - public String getId() { + + @Override + public String getId() { return "XML"; } /* object manipulation */ // retrieve object by path - public C2KLocalObject get(Integer sysKey, String path) throws ClusterStorageException { + @Override + public C2KLocalObject get(Integer sysKey, String path) throws ClusterStorageException { try { String type = ClusterStorage.getClusterType(path); String filePath = getFilePath(sysKey, path)+".xml"; String objString = FileStringUtility.file2String(filePath); if (objString.length() == 0) return null; - + if (type.equals("Outcome")) return new Outcome(path, objString); else @@ -70,7 +76,8 @@ public class XMLClusterStorage extends ClusterStorage { } // store object by path - public void put(Integer sysKey, C2KLocalObject obj) throws ClusterStorageException { + @Override + public void put(Integer sysKey, C2KLocalObject obj) throws ClusterStorageException { try { String filePath = getFilePath(sysKey, getPath(obj)+".xml"); Logger.msg(7, "Writing "+filePath); @@ -89,7 +96,8 @@ public class XMLClusterStorage extends ClusterStorage { } // delete cluster - public void delete(Integer sysKey, String path) throws ClusterStorageException { + @Override + public void delete(Integer sysKey, String path) throws ClusterStorageException { try { String filePath = getFilePath(sysKey, path+".xml"); boolean success = FileStringUtility.deleteDir(filePath, true, true); @@ -104,11 +112,12 @@ public class XMLClusterStorage extends ClusterStorage { /* navigation */ // directory listing - public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException { + @Override + public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException { String[] result = new String[0]; try { String filePath = getFilePath(sysKey, path); - ArrayList paths = FileStringUtility.listDir( filePath, true, false ); + ArrayList paths = FileStringUtility.listDir( filePath, true, false ); if (paths == null) return result; // dir doesn't exist yet ArrayList contents = new ArrayList(); String previous = null; @@ -126,8 +135,8 @@ public class XMLClusterStorage extends ClusterStorage { if (next.indexOf('/') > -1) next = next.substring(next.lastIndexOf('/')+1); contents.add(next); } - - result = (String[])contents.toArray(result); + + result = contents.toArray(result); return result; } catch (Exception e) { Logger.error(e); -- cgit v1.2.3