From da731d2bb81666b9c697d9099da632e7dfcdc0f7 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 9 Sep 2014 12:13:21 +0200 Subject: Replaced int sysKey Item identifier with UUID, which is now portable. ItemPath objects are now used to identify Items throughout the kernel, replacing ints and Integers. --- .../java/com/c2kernel/persistency/ProxyLoader.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/ProxyLoader.java') diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index 57b91af..9a7f7bd 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -19,7 +19,7 @@ import com.c2kernel.utils.Logger; */ public class ProxyLoader extends ClusterStorage { - HashMap entities = new HashMap(); + HashMap entities = new HashMap(); Lookup lookup; @Override @@ -48,14 +48,14 @@ public class ProxyLoader extends ClusterStorage { // retrieve object by path @Override - public C2KLocalObject get(Integer sysKey, String path) throws ClusterStorageException { + public C2KLocalObject get(ItemPath thisItem, String path) throws ClusterStorageException { try { - Item thisEntity = getIOR(sysKey); + Item thisEntity = getIOR(thisItem); String type = getClusterType(path); // fetch the xml from the item String queryData = thisEntity.queryData(path); - if (Logger.doLog(6)) Logger.msg(6, "ProxyLoader - "+sysKey+":"+path+" = "+queryData); + if (Logger.doLog(6)) Logger.msg(6, "ProxyLoader - "+thisItem+":"+path+" = "+queryData); if (queryData != null) { if (type.equals(OUTCOME)) @@ -74,13 +74,13 @@ public class ProxyLoader extends ClusterStorage { // store object by path @Override - public void put(Integer sysKey, C2KLocalObject obj) throws ClusterStorageException { + public void put(ItemPath thisItem, C2KLocalObject obj) throws ClusterStorageException { // not supported throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); } // delete cluster @Override - public void delete(Integer sysKey, String path) throws ClusterStorageException { + public void delete(ItemPath thisItem, String path) throws ClusterStorageException { // not supported throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); } @@ -89,9 +89,9 @@ public class ProxyLoader extends ClusterStorage { // directory listing @Override - public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath thisItem, String path) throws ClusterStorageException { try { - Item thisEntity = getIOR(sysKey); + Item thisEntity = getIOR(thisItem); String contents = thisEntity.queryData(path+"/all"); StringTokenizer tok = new StringTokenizer(contents, ","); String[] result = new String[tok.countTokens()]; @@ -105,16 +105,16 @@ public class ProxyLoader extends ClusterStorage { } } - private Item getIOR(Integer sysKey) throws ClusterStorageException { - if (entities.containsKey(sysKey)) { + private Item getIOR(ItemPath thisPath) throws ClusterStorageException { + if (entities.containsKey(thisPath)) { // check the cache - Logger.msg(7, "ProxyLoader.getIOR() - "+sysKey+" cached."); - return entities.get(sysKey); + Logger.msg(7, "ProxyLoader.getIOR() - "+thisPath+" cached."); + return entities.get(thisPath); } try { - Logger.msg(7, "ProxyLoader.getIOR() - Resolving "+sysKey+"."); - org.omg.CORBA.Object ior = lookup.resolve(new ItemPath(sysKey.intValue())); + Logger.msg(7, "ProxyLoader.getIOR() - Resolving "+thisPath+"."); + org.omg.CORBA.Object ior = lookup.resolve(thisPath); Item thisItem = null; try { @@ -123,15 +123,15 @@ public class ProxyLoader extends ClusterStorage { try { thisItem = AgentHelper.narrow(ior); } catch (org.omg.CORBA.BAD_PARAM ex2) { - throw new ClusterStorageException ("Could not narrow "+sysKey+" as a known Entity type"); + throw new ClusterStorageException ("Could not narrow "+thisItem+" as a known Entity type"); } } - Logger.msg(7, "ProxyLoader.getIOR() - Found "+sysKey+"."); - entities.put(sysKey, thisItem); + Logger.msg(7, "ProxyLoader.getIOR() - Found "+thisItem+"."); + entities.put(thisPath, thisItem); return thisItem; } catch (Exception e) { - throw new ClusterStorageException("Error narrowing "+sysKey+": "+e.getMessage()); + throw new ClusterStorageException("Error narrowing "+thisPath+": "+e.getMessage()); } } } -- cgit v1.2.3