lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject svn commit: r429345 - in /lenya/trunk/src: impl/test/org/apache/lenya/transaction/ java/org/apache/lenya/cms/repository/ java/org/apache/lenya/transaction/ modules/sourcerepository/java/src/org/apache/lenya/cms/repository/
Date Mon, 07 Aug 2006 14:07:57 GMT
Author: andreas
Date: Mon Aug  7 07:07:56 2006
New Revision: 429345

URL: http://svn.apache.org/viewvc?rev=429345&view=rev
Log:
Notify unit of work when a transactionable is unlocked

Modified:
    lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java
    lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
    lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java
    lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java

Modified: lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java Mon Aug
 7 07:07:56 2006
@@ -100,6 +100,7 @@
 
     public void unlock() throws TransactionException {
         this.lock = null;
+        unit.removeLock(this);
     }
 
     public String getId() {

Modified: lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java Mon Aug  7
07:07:56 2006
@@ -72,6 +72,7 @@
             e = e1;
         }
         assertNotNull(e);
+        lenyaT1.unlock();
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java Mon Aug  7 07:07:56
2006
@@ -117,4 +117,8 @@
         return getUnitOfWork().createLock(lockable, version);
     }
 
+    public void removeLock(Lockable lockable) throws TransactionException {
+        getUnitOfWork().removeLock(lockable);
+    }
+
 }

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java Mon Aug  7 07:07:56
2006
@@ -89,4 +89,11 @@
      * @throws TransactionException if a lock is already placed on this transactionable.
      */
     Lock createLock(Lockable lockable, int version) throws TransactionException;
+    
+    /**
+     * Removes a lock.
+     * @param lockable The lockable.
+     * @throws TransactionException if no lock is placed on this transactionable.
+     */
+    void removeLock(Lockable lockable) throws TransactionException;
 }

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java Mon Aug  7 07:07:56
2006
@@ -127,7 +127,7 @@
             Transactionable t = (Transactionable) i.next();
             t.checkout();
         }
-        
+
         for (Iterator i = this.newObjects.iterator(); i.hasNext();) {
             Transactionable t = (Transactionable) i.next();
             t.createTransactionable();
@@ -229,12 +229,19 @@
 
     public Lock createLock(Lockable lockable, int version) throws TransactionException {
         if (this.locks.containsKey(lockable)) {
-            throw new TransactionException("A lock is already placed on [" + lockable +
-                    "]. A new lock could lead to inconsistent data.");
+            throw new LockException("A lock is already placed on [" + lockable
+                    + "]. A new lock could lead to inconsistent data.");
         }
         Lock lock = new Lock(version);
         this.locks.put(lockable, lock);
         return lock;
+    }
+
+    public void removeLock(Lockable lockable) throws TransactionException {
+        if (!this.locks.containsKey(lockable)) {
+            throw new LockException("No lock is already placed on [" + lockable + "]!");
+        }
+        this.locks.remove(lockable);
     }
 
 }

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java?rev=429345&r1=429344&r2=429345&view=diff
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
(original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
Mon Aug  7 07:07:56 2006
@@ -440,6 +440,11 @@
      */
     public void unlock() throws RepositoryException {
         this.lock = null;
+        try {
+            getSession().removeLock(this);
+        } catch (TransactionException e) {
+            throw new RepositoryException(e);
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Mime
View raw message