Update of /var/cvs/src/org/mmbase/bridge/implementation
In directory james.mmbase.org:/tmp/cvs-serv24638

Modified Files:
      Tag: MMBase-1_8
        BasicCloud.java BasicTransaction.java 
Log Message:
  MMB-1671


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/bridge/implementation
See also: http://www.mmbase.org/jira/browse/MMB-1671


Index: BasicCloud.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/implementation/BasicCloud.java,v
retrieving revision 1.161.2.5
retrieving revision 1.161.2.6
diff -u -b -r1.161.2.5 -r1.161.2.6
--- BasicCloud.java     28 Jun 2008 11:57:23 -0000      1.161.2.5
+++ BasicCloud.java     1 Jul 2008 15:32:00 -0000       1.161.2.6
@@ -28,7 +28,7 @@
  * @author Rob Vermeulen
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: BasicCloud.java,v 1.161.2.5 2008/06/28 11:57:23 nklasens Exp $
+ * @version $Id: BasicCloud.java,v 1.161.2.6 2008/07/01 15:32:00 michiel Exp $
  */
 public class BasicCloud implements Cloud, Cloneable, Comparable, 
SizeMeasurable, Serializable  {
 
@@ -45,7 +45,7 @@
     private static int lastRequestId = Integer.MIN_VALUE;
 
 
-    private final long count = ++counter;
+    protected final long count = ++counter;
 
     // link to cloud context
     private CloudContext cloudContext = null;
@@ -226,9 +226,10 @@
     public Node getNode(String nodeNumber) throws NotFoundException {
         MMObjectNode node;
         try {
-            node = BasicCloudContext.tmpObjectManager.getNode(account, 
nodeNumber);
+            BasicCloudContext.tmpObjectManager.getObject(getAccount(), 
nodeNumber, nodeNumber);
+            node = BasicCloudContext.tmpObjectManager.getNode(getAccount(), 
nodeNumber);
         } catch (RuntimeException e) {
-            throw new NotFoundException("Something went wrong while getting 
node with number '" + nodeNumber + "': " + e.getMessage() + " by cloud with 
account " + account, e);
+            throw new NotFoundException("Something went wrong while getting 
node with number '" + nodeNumber + "': " + e.getMessage() + " by cloud with 
account " + getAccount(), e);
         }
         if (node == null) {
             throw new NotFoundException("Node with number '" + nodeNumber + "' 
does not exist.");
@@ -266,7 +267,7 @@
     private boolean hasNode(String nodeNumber, boolean isrelation) {
         MMObjectNode node;
         try {
-            node = BasicCloudContext.tmpObjectManager.getNode(account, 
nodeNumber);
+            node = BasicCloudContext.tmpObjectManager.getNode(getAccount(), 
nodeNumber);
         } catch (Throwable e) {
             return false; // error - node inaccessible or does not exist
         }
@@ -561,11 +562,12 @@
     public Transaction getTransaction(String name) {
         Transaction tran = (Transaction)transactions.get(name);
         if (tran == null) {
-            tran = createTransaction(name, false);
+            return createTransaction(name, false);
         } else {
-        }
+            log.debug("Using existing transaction " + tran);
         return tran;
     }
+    }
 
     public CloudContext getCloudContext() {
         return cloudContext;
@@ -868,7 +870,7 @@
     public boolean mayRead(String nodeNumber) {
         MMObjectNode node;
         try {
-            node = BasicCloudContext.tmpObjectManager.getNode(account, 
nodeNumber);
+            node = BasicCloudContext.tmpObjectManager.getNode(getAccount(), 
nodeNumber);
         } catch (RuntimeException e) {
             throw new NotFoundException("Something went wrong while getting 
node with number '" + nodeNumber + "': " + e.getMessage(), e);
         }
@@ -1087,8 +1089,21 @@
         }
     }
 
+
+    protected void finalize() throws Throwable {
+        log.debug("Finalizing cloud of " + getUser() + " with id " + 
getAccount() + " transactions: " + transactions.keySet());
+        super.finalize();
+    }
+
     public String toString() {
         UserContext uc = getUser();
         return  "BasicCloud " + count +  "'" + getName() + "' of " + (uc != 
null ? uc.getIdentifier() : "NO USER YET") + " @" + 
Integer.toHexString(hashCode());
     }
+
+    /*
+    public Cloud getNonTransactionalCloud() {
+        return this;
+    }
+    */
+
 }


Index: BasicTransaction.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/implementation/BasicTransaction.java,v
retrieving revision 1.25.2.8
retrieving revision 1.25.2.9
diff -u -b -r1.25.2.8 -r1.25.2.9
--- BasicTransaction.java       1 Apr 2008 14:46:07 -0000       1.25.2.8
+++ BasicTransaction.java       1 Jul 2008 15:32:00 -0000       1.25.2.9
@@ -23,7 +23,7 @@
  * which means that chanegs are committed only if you commit the transaction 
itself.
  * This mechanism allows you to rollback changes if something goes wrong.
  * @author Pierre van Rooden
- * @version $Id: BasicTransaction.java,v 1.25.2.8 2008/04/01 14:46:07 michiel 
Exp $
+ * @version $Id: BasicTransaction.java,v 1.25.2.9 2008/07/01 15:32:00 michiel 
Exp $
  */
 public class BasicTransaction extends BasicCloud implements Transaction {
 
@@ -74,6 +74,12 @@
         }
     }
 
+    /**
+     */
+    String getAccount() {
+        return transactionContext;
+    }
+
 
     public synchronized boolean commit() {
         if (canceled) {
@@ -151,7 +157,7 @@
      */
     void add(String currentObjectContext) {
         try {
-            BasicCloudContext.transactionManager.addNode(transactionContext, 
account, currentObjectContext);
+            BasicCloudContext.transactionManager.addNode(transactionContext, 
getAccount(), currentObjectContext);
         } catch (TransactionManagerException e) {
             throw new BridgeException(e.getMessage(), e);
         }
@@ -163,7 +169,7 @@
      */
     void remove(String currentObjectContext) {
         try {
-            
BasicCloudContext.transactionManager.removeNode(transactionContext, account, 
currentObjectContext);
+            
BasicCloudContext.transactionManager.removeNode(transactionContext, 
getAccount(), currentObjectContext);
         } catch (TransactionManagerException e) {
             throw new BridgeException(e.getMessage(), e);
         }
@@ -178,7 +184,7 @@
      */
     void delete(String currentObjectContext) {
         try {
-            
BasicCloudContext.transactionManager.deleteObject(transactionContext, account, 
currentObjectContext);
+            
BasicCloudContext.transactionManager.deleteObject(transactionContext, 
getAccount(), currentObjectContext);
         } catch (TransactionManagerException e) {
             throw new BridgeException(e.getMessage(), e);
         }
@@ -190,7 +196,7 @@
             return false;
         }
         try {
-            Collection transaction = 
BasicCloudContext.transactionManager.get(account, transactionContext);
+            Collection transaction = 
BasicCloudContext.transactionManager.get(getAccount(), transactionContext);
             return transaction.contains(node);
         } catch (TransactionManagerException tme) {
             throw new BridgeException(tme.getMessage(), tme);
@@ -276,7 +282,7 @@
 
     public String toString() {
         UserContext uc = getUser();
-        return  "BasicTransaction '" + getName() + "' of " + 
parentCloud.toString();
+        return  "BasicTransaction" + count + " '" + getName() + "' of " + 
parentCloud.toString();
     }
 
     /*
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to