From d39af7f77c7205d2c300ebca265bd3411692af37 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 9 Sep 2014 14:11:54 +0200 Subject: Support new ItemPath based Item id. --- .../persistency/xmldb/XMLDBClusterStorage.java | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java b/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java index 941350b..7cb5f69 100644 --- a/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java @@ -13,6 +13,7 @@ import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Outcome; @@ -139,12 +140,12 @@ public class XMLDBClusterStorage extends ClusterStorage { * @see com.c2kernel.persistency.ClusterStorage#get(java.lang.Integer, java.lang.String) */ @Override - public C2KLocalObject get(Integer sysKey, String path) + public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException { String type = ClusterStorage.getClusterType(path); // Get item collection - String strSysKey = String.valueOf(sysKey); - Collection itemColl = verifyCollection(root, strSysKey, false); + String subPath = itemPath.getUUID().toString(); + Collection itemColl = verifyCollection(root, subPath, false); if (itemColl == null) return null; // doesn't exist try { @@ -172,12 +173,12 @@ public class XMLDBClusterStorage extends ClusterStorage { * @see com.c2kernel.persistency.ClusterStorage#put(java.lang.Integer, com.c2kernel.entity.C2KLocalObject) */ @Override - public void put(Integer sysKey, C2KLocalObject obj) + public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException { String resName = getPath(obj); - String strSysKey = String.valueOf(sysKey); - Collection itemColl = verifyCollection(root, strSysKey, true); + String subPath = itemPath.getUUID().toString(); + Collection itemColl = verifyCollection(root, subPath, true); try { resName = resName.replace('/', '.'); @@ -198,10 +199,10 @@ public class XMLDBClusterStorage extends ClusterStorage { * @see com.c2kernel.persistency.ClusterStorage#delete(java.lang.Integer, java.lang.String) */ @Override - public void delete(Integer sysKey, String path) + public void delete(ItemPath itemPath, String path) throws ClusterStorageException { - String strSysKey = String.valueOf(sysKey); - Collection itemColl = verifyCollection(root, strSysKey, false); + String subPath = itemPath.getUUID().toString(); + Collection itemColl = verifyCollection(root, subPath, false); if (itemColl == null) return; @@ -212,7 +213,7 @@ public class XMLDBClusterStorage extends ClusterStorage { itemColl.close(); itemColl.close(); } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException("XMLClusterStorage.delete() - Could not delete "+path+" to "+sysKey); + throw new ClusterStorageException("XMLClusterStorage.delete() - Could not delete "+path+" to "+itemPath); } } @@ -220,10 +221,10 @@ public class XMLDBClusterStorage extends ClusterStorage { * @see com.c2kernel.persistency.ClusterStorage#getClusterContents(java.lang.Integer, java.lang.String) */ @Override - public String[] getClusterContents(Integer sysKey, String path) + public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException { - String strSysKey = String.valueOf(sysKey); - Collection coll = verifyCollection(root, strSysKey, false); + String subPath = itemPath.getUUID().toString(); + Collection coll = verifyCollection(root, subPath, false); if (coll == null) return new String[0]; ArrayList contents = new ArrayList(); @@ -246,10 +247,10 @@ public class XMLDBClusterStorage extends ClusterStorage { } } catch (XMLDBException e) { Logger.error(e); - throw new ClusterStorageException("Error listing collection resources for item "+strSysKey); + throw new ClusterStorageException("Error listing collection resources for item "+itemPath); } catch (UnsupportedEncodingException e) { Logger.error(e); - throw new ClusterStorageException("Error listing decoding resource name for item "+strSysKey); + throw new ClusterStorageException("Error listing decoding resource name for item "+itemPath); } return contents.toArray(new String[contents.size()]); } -- cgit v1.2.3