From 2781ee55ff030fb758f645b224f3a94e3c79a27a Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 3 Oct 2014 17:31:33 +0200 Subject: Adapt to new Exceptions --- .../persistency/xmldb/XMLDBClusterStorage.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java b/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java index 5af4eca..8e77f22 100644 --- a/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/xmldb/XMLDBClusterStorage.java @@ -12,10 +12,10 @@ import org.xmldb.api.base.Resource; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; +import com.c2kernel.common.PersistencyException; 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; import com.c2kernel.process.Gateway; import com.c2kernel.process.auth.Authenticator; @@ -34,7 +34,7 @@ public class XMLDBClusterStorage extends ClusterStorage { } - protected static Collection verifyCollection(Collection parent, String name, boolean create) throws ClusterStorageException { + protected static Collection verifyCollection(Collection parent, String name, boolean create) throws PersistencyException { Collection coll; try { coll = parent.getChildCollection(name); @@ -47,7 +47,7 @@ public class XMLDBClusterStorage extends ClusterStorage { CollectionManagementService collManager = (CollectionManagementService)parent.getService("CollectionManagementService", "1.0"); coll = collManager.createCollection(name); } catch (Exception ex2) { - throw new ClusterStorageException("Could not create XMLDB collection for item "+name); + throw new PersistencyException("Could not create XMLDB collection for item "+name); } } else // not found @@ -55,7 +55,7 @@ public class XMLDBClusterStorage extends ClusterStorage { } else { Logger.error(ex); - throw new ClusterStorageException("Error loading XMLDB collection for item "+name); + throw new PersistencyException("Error loading XMLDB collection for item "+name); } } return coll; @@ -65,7 +65,7 @@ public class XMLDBClusterStorage extends ClusterStorage { * @see com.c2kernel.persistency.ClusterStorage#open() */ @Override - public void open(Authenticator auth) throws ClusterStorageException { + public void open(Authenticator auth) throws PersistencyException { final String driver = "org.exist.xmldb.DatabaseImpl"; // Uncomment the following for integrated existdb @@ -88,25 +88,25 @@ public class XMLDBClusterStorage extends ClusterStorage { } catch (Exception ex) { Logger.error(ex); - throw new ClusterStorageException("Error initializing XMLDB"); + throw new PersistencyException("Error initializing XMLDB"); } if (root == null) - throw new ClusterStorageException("Root collection is null. Problem connecting to XMLDB."); + throw new PersistencyException("Root collection is null. Problem connecting to XMLDB."); } /* (non-Javadoc) * @see com.c2kernel.persistency.ClusterStorage#close() */ @Override - public void close() throws ClusterStorageException { + public void close() throws PersistencyException { try { root.close(); //DatabaseInstanceManager manager = (DatabaseInstanceManager)db.getService("DatabaseInstanceManager", "1.0"); //manager.shutdown(); } catch (XMLDBException e) { Logger.error(e); - throw new ClusterStorageException("Error shutting down eXist XMLDB"); + throw new PersistencyException("Error shutting down eXist XMLDB"); } @@ -141,7 +141,7 @@ public class XMLDBClusterStorage extends ClusterStorage { */ @Override public C2KLocalObject get(ItemPath itemPath, String path) - throws ClusterStorageException { + throws PersistencyException { String type = ClusterStorage.getClusterType(path); // Get item collection String subPath = itemPath.getUUID().toString(); @@ -165,7 +165,7 @@ public class XMLDBClusterStorage extends ClusterStorage { return null; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException("XMLDB error"); + throw new PersistencyException("XMLDB error"); } } @@ -174,7 +174,7 @@ public class XMLDBClusterStorage extends ClusterStorage { */ @Override public void put(ItemPath itemPath, C2KLocalObject obj) - throws ClusterStorageException { + throws PersistencyException { String resName = getPath(obj); String subPath = itemPath.getUUID().toString(); @@ -191,7 +191,7 @@ public class XMLDBClusterStorage extends ClusterStorage { itemColl.close(); } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException("XMLDB error"); + throw new PersistencyException("XMLDB error"); } } @@ -200,7 +200,7 @@ public class XMLDBClusterStorage extends ClusterStorage { */ @Override public void delete(ItemPath itemPath, String path) - throws ClusterStorageException { + throws PersistencyException { String subPath = itemPath.getUUID().toString(); Collection itemColl = verifyCollection(root, subPath, false); if (itemColl == null) return; @@ -213,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 "+itemPath); + throw new PersistencyException("XMLClusterStorage.delete() - Could not delete "+path+" to "+itemPath); } } @@ -222,7 +222,7 @@ public class XMLDBClusterStorage extends ClusterStorage { */ @Override public String[] getClusterContents(ItemPath itemPath, String path) - throws ClusterStorageException { + throws PersistencyException { String subPath = itemPath.getUUID().toString(); Collection coll = verifyCollection(root, subPath, false); if (coll == null) return new String[0]; @@ -247,10 +247,10 @@ public class XMLDBClusterStorage extends ClusterStorage { } } catch (XMLDBException e) { Logger.error(e); - throw new ClusterStorageException("Error listing collection resources for item "+itemPath); + throw new PersistencyException("Error listing collection resources for item "+itemPath); } catch (UnsupportedEncodingException e) { Logger.error(e); - throw new ClusterStorageException("Error listing decoding resource name for item "+itemPath); + throw new PersistencyException("Error listing decoding resource name for item "+itemPath); } return contents.toArray(new String[contents.size()]); } -- cgit v1.2.3