diff options
Diffstat (limited to 'src/main/java/com/c2kernel/persistency/TransactionManager.java')
| -rw-r--r-- | src/main/java/com/c2kernel/persistency/TransactionManager.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main/java/com/c2kernel/persistency/TransactionManager.java b/src/main/java/com/c2kernel/persistency/TransactionManager.java index 9f2dac4..792709a 100644 --- a/src/main/java/com/c2kernel/persistency/TransactionManager.java +++ b/src/main/java/com/c2kernel/persistency/TransactionManager.java @@ -23,7 +23,8 @@ package com.c2kernel.persistency; import java.util.ArrayList;
import java.util.HashMap;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.agent.JobList;
import com.c2kernel.events.History;
@@ -37,7 +38,7 @@ public class TransactionManager { HashMap<Object, ArrayList<TransactionEntry>> pendingTransactions;
ClusterStorageManager storage;
- public TransactionManager(Authenticator auth) throws ClusterStorageException {
+ public TransactionManager(Authenticator auth) throws PersistencyException {
storage = new ClusterStorageManager(auth);
locks = new HashMap<ItemPath, Object>();
pendingTransactions = new HashMap<Object, ArrayList<TransactionEntry>>();
@@ -61,7 +62,7 @@ public class TransactionManager { storage.close();
}
- public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException {
if (path.startsWith("/") && path.length() > 1) path = path.substring(1);
return storage.getClusterContents(itemPath, path);
}
@@ -71,8 +72,8 @@ public class TransactionManager { * Checks the transaction table first to see if the caller has uncommitted changes
*/
public C2KLocalObject get(ItemPath itemPath, String path, Object locker)
- throws ClusterStorageException,
- ObjectNotFoundException {
+ throws PersistencyException,
+ ObjectNotFound {
if (path.startsWith("/") && path.length() > 1) path = path.substring(1);
// deal out top level remote maps, if transactions aren't needed
@@ -89,7 +90,7 @@ public class TransactionManager { for (TransactionEntry thisEntry : lockerTransaction) {
if (itemPath.equals(thisEntry.itemPath) && path.equals(thisEntry.path)) {
if (thisEntry.obj == null)
- throw new ClusterStorageException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + itemPath +
+ throw new PersistencyException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + itemPath +
" but not yet committed");
return thisEntry.obj;
}
@@ -102,7 +103,7 @@ public class TransactionManager { * Public put method. Manages the transaction table keyed by the object 'locker'.
* If this object is null, transaction support is bypassed (so long as no lock exists on that object).
*/
- public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws ClusterStorageException {
+ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws PersistencyException {
Object tempLocker = null;
ArrayList<TransactionEntry> lockerTransaction;
@@ -114,7 +115,7 @@ public class TransactionManager { if (thisLocker.equals(locker)) // retrieve the transaction list
lockerTransaction = pendingTransactions.get(locker);
else // locked by someone else
- throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
+ throw new PersistencyException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
" has been locked for writing by " + thisLocker);
}
else { // no locks for this item
@@ -150,7 +151,7 @@ public class TransactionManager { /** Public delete method. Uses the put method, with null as the object value.
*/
- public void remove(ItemPath itemPath, String path, Object locker) throws ClusterStorageException {
+ public void remove(ItemPath itemPath, String path, Object locker) throws PersistencyException {
ArrayList<TransactionEntry> lockerTransaction;
Object tempLocker = null;
synchronized(locks) {
@@ -161,7 +162,7 @@ public class TransactionManager { if (thisLocker.equals(locker)) // retrieve the transaction list
lockerTransaction = pendingTransactions.get(locker);
else // locked by someone else
- throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
+ throw new PersistencyException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
" has been locked for writing by " + thisLocker);
}
else { // either we are the locker, or there is no locker
@@ -203,9 +204,9 @@ public class TransactionManager { * @param path - root path to delete
* @param locker - locking object
*
- * @throws ClusterStorageException - when deleting fails
+ * @throws PersistencyException - when deleting fails
*/
- public void removeCluster(ItemPath itemPath, String path, Object locker) throws ClusterStorageException {
+ public void removeCluster(ItemPath itemPath, String path, Object locker) throws PersistencyException {
String[] children = getClusterContents(itemPath, path);
for (String element : children)
|
