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

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
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();
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.