You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/08/10 11:59:25 UTC

svn commit: r564532 - in /lenya/trunk/src: java/org/apache/lenya/cms/rc/RCML.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java

Author: andreas
Date: Fri Aug 10 02:59:23 2007
New Revision: 564532

URL: http://svn.apache.org/viewvc?view=rev&rev=564532
Log:
Fixed revision control issue: Don't consider only backup entries when checking for the last modified version.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java?view=diff&rev=564532&r1=564531&r2=564532
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java Fri Aug 10 02:59:23 2007
@@ -45,10 +45,9 @@
      * Check the RCML in.
      * @param node The node.
      * @param backup If a backup shall be created.
-     * @param newVersion If a new version shall be created.
      * @throws RevisionControlException if an error occurs.
      */
-    void checkIn(Node node, boolean backup, boolean newVersion) throws RevisionControlException;
+    void checkIn(Node node, boolean backup) throws RevisionControlException;
     
     /**
      * Check the RCML out.
@@ -119,18 +118,6 @@
      * @return boolean dirty
      */
     boolean isDirty();
-
-    /**
-     * Delete the latest check in
-     * @throws Exception if an error occurs
-     */
-    void deleteFirstCheckIn() throws Exception;
-
-    /**
-     * Delete the latest check in
-     * @throws Exception if an error occurs
-     */
-    void deleteFirstCheckOut() throws Exception;
 
     /**
      * get the time's value of the backups

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?view=diff&rev=564532&r1=564531&r2=564532
==============================================================================
--- 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 Fri Aug 10 02:59:23 2007
@@ -34,6 +34,7 @@
 import org.apache.lenya.cms.observation.DocumentEvent;
 import org.apache.lenya.cms.observation.RepositoryEvent;
 import org.apache.lenya.cms.observation.RepositoryEventFactory;
+import org.apache.lenya.cms.rc.CheckInEntry;
 import org.apache.lenya.cms.rc.RCML;
 import org.apache.lenya.cms.rc.RevisionControlException;
 import org.apache.lenya.transaction.Lock;
@@ -109,8 +110,7 @@
                     throw new RepositoryException("Cannot check in node [" + getSourceURI()
                             + "]: not checked out by this session!");
                 }
-                boolean newVersion = getSession().isDirty(this);
-                rcml.checkIn(this, exists(), newVersion);
+                rcml.checkIn(this, exists());
             } catch (Exception e) {
                 throw new RepositoryException(e);
             }
@@ -125,7 +125,7 @@
                     throw new RepositoryException("Cannot check in node [" + getSourceURI()
                             + "]: not checked out!");
                 }
-                rcml.checkIn(this, false, false);
+                rcml.checkIn(this, false);
             } catch (Exception e) {
                 throw new RepositoryException(e);
             }
@@ -193,12 +193,18 @@
         }
     }
 
-    protected int getCurrentRevisionNumber() {
-        if (getHistory().getRevisionNumbers().length > 0) {
-            return getHistory().getLatestRevision().getNumber();
+    protected int getCurrentRevisionNumber() throws RepositoryException {
+        CheckInEntry entry;
+        try {
+            entry = getRcml().getLatestCheckInEntry();
+        } catch (RevisionControlException e) {
+            throw new RepositoryException(e);
         }
-        else {
+        if (entry == null) {
             return 0;
+        }
+        else {
+            return entry.getVersion();
         }
     }
 

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java?view=diff&rev=564532&r1=564531&r2=564532
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java Fri Aug 10 02:59:23 2007
@@ -250,7 +250,7 @@
      */
     public RCMLEntry getLatestEntry(short type) throws RevisionControlException {
         Vector entries = getEntries();
-        for (Iterator i = entries.iterator(); i.hasNext(); ) {
+        for (Iterator i = entries.iterator(); i.hasNext();) {
             RCMLEntry entry = (RCMLEntry) i.next();
             if (entry.getType() == type) {
                 return entry;
@@ -263,8 +263,7 @@
         Vector entries = getEntries();
         if (entries.isEmpty()) {
             return null;
-        }
-        else {
+        } else {
             return (RCMLEntry) entries.firstElement();
         }
     }
@@ -375,7 +374,8 @@
         restoreBackup(sourceNode.getMetaSource(), time);
     }
 
-    protected synchronized void restoreBackup(SourceWrapper wrapper, long time) throws RevisionControlException {
+    protected synchronized void restoreBackup(SourceWrapper wrapper, long time)
+            throws RevisionControlException {
         String backupSourceUri = getBackupSourceUri(wrapper, time);
         SourceResolver resolver = null;
         try {
@@ -422,7 +422,8 @@
         setDirty();
     }
 
-    protected synchronized void deleteBackup(String sourceUri, long time) throws RevisionControlException {
+    protected synchronized void deleteBackup(String sourceUri, long time)
+            throws RevisionControlException {
         String uri = getBackupSourceUri(sourceUri, time);
         try {
             SourceUtil.delete(uri, this.manager);
@@ -455,28 +456,6 @@
     }
 
     /**
-     * Delete the latest check in
-     * @throws RevisionControlException if an error occurs
-     */
-    public synchronized void deleteFirstCheckIn() throws RevisionControlException {
-        deleteLatestEntry(ci);
-    }
-
-    /**
-     * Delete the latest check in
-     * @throws RevisionControlException if an error occurs
-     */
-    public synchronized void deleteFirstCheckOut() throws RevisionControlException {
-        deleteLatestEntry(co);
-    }
-
-    protected synchronized void deleteLatestEntry(short type) throws RevisionControlException {
-        RCMLEntry entry = getLatestEntry(type);
-        this.entries.remove(entry);
-        setDirty();
-    }
-
-    /**
      * get the time's value of the backups
      * @return String[] the times
      * @throws Exception if an error occurs
@@ -485,7 +464,7 @@
 
         Vector entries = getEntries();
         List times = new ArrayList();
-        for (Iterator i = entries.iterator(); i.hasNext(); ) {
+        for (Iterator i = entries.iterator(); i.hasNext();) {
             RCMLEntry entry = (RCMLEntry) i.next();
             if (entry.getType() == ci && ((CheckInEntry) entry).hasBackup()) {
                 times.add(Long.toString(entry.getTime()));
@@ -582,19 +561,14 @@
         return entry != null && entry.getType() == RCML.co;
     }
 
-    public synchronized void checkIn(Node node, boolean backup, boolean newVersion)
-            throws RevisionControlException {
+    public synchronized void checkIn(Node node, boolean backup) throws RevisionControlException {
         long time = new Date().getTime();
 
         if (backup) {
             makeBackup(time);
         }
 
-        if (newVersion) {
-            checkOutIn(node, RCML.ci, time, backup);
-        } else {
-            deleteFirstCheckOut();
-        }
+        checkOutIn(node, RCML.ci, time, backup);
         pruneEntries();
         write();
     }



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


Re: svn commit: r564532 - in /lenya/trunk/src: java/org/apache/lenya/cms/rc/RCML.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java

Posted by Andreas Hartmann <an...@apache.org>.
Jörn Nettingsmeier schrieb:
> andreas@apache.org wrote:
>> Author: andreas
>> Date: Fri Aug 10 02:59:23 2007
>> New Revision: 564532
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=564532
>> Log:
>> Fixed revision control issue: Don't consider only backup entries when
>> checking for the last modified version.
> 
> how did this bug show from a user pov? is it related to the weird
> revision numbers we used to have?

The problem was that B could force a check-in while A was editing
a document, and A was still able to save it afterwards.

I introduced this problem because I relied on Node.getHistory() to
check the latest changed revision. But since the history only contains
the revisions which have a backup (not sure if this makes sense), the
version of the forced check-in was not considered. Changing it back
from the history to the RCML object solved the issue.

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


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


Re: svn commit: r564532 - in /lenya/trunk/src: java/org/apache/lenya/cms/rc/RCML.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java

Posted by Jörn Nettingsmeier <ne...@apache.org>.
andreas@apache.org wrote:
> Author: andreas
> Date: Fri Aug 10 02:59:23 2007
> New Revision: 564532
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=564532
> Log:
> Fixed revision control issue: Don't consider only backup entries when checking for the last modified version.

how did this bug show from a user pov? is it related to the weird 
revision numbers we used to have?

-- 
Jörn Nettingsmeier

"One of my most productive days was throwing away 1000 lines of code."
   - Ken Thompson.

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