svn commit: r571429 - in /lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository: SourceNode.java SourceWrapper.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Fri Aug 31 03:55:51 2007
New Revision: 571429

URL: http://svn.apache.org/viewvc?rev=571429&view=rev
Log:
Added check to SourceNode if it was loaded when it is locked. This can help to uncover situations where the repository might become corrupted. See bug 43136, comment #18.

Modified:
    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/SourceWrapper.java

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=571429&r1=571428&r2=571429&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 Fri Aug 31 03:55:51 2007
@@ -116,7 +116,7 @@
             }
         }
     }
-    
+
     public void forceCheckIn() throws RepositoryException {
         RCML rcml = getRcml();
         synchronized (rcml) {
@@ -171,7 +171,7 @@
             }
         }
     }
-    
+
     public void checkout() throws RepositoryException {
         checkout(true);
     }
@@ -200,15 +200,13 @@
         }
         if (entry == null) {
             return 0;
-        }
-        else {
+        } else {
             return entry.getVersion();
         }
     }
 
     /**
-     * @return The document node, if this is a meta data node, or the node
-     *         itself otherwise.
+     * @return The document node, if this is a meta data node, or the node itself otherwise.
      * @throws ServiceException
      * @throws RepositoryException
      */
@@ -246,6 +244,11 @@
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Locking [" + this + "]");
         }
+        if (getContentSource().isLoaded() || getMetaSource().isLoaded()) {
+            throw new RepositoryException("Node [" + this
+                    + "] is already loaded, locking would have no effect "
+                    + "and could lead to an inconsistent repository.");
+        }
         try {
             int currentVersion = getCurrentRevisionNumber();
             this.lock = getSession().createLock(this, currentVersion);
@@ -404,7 +407,7 @@
     }
 
     public long getLastModified() throws RepositoryException {
-        
+
         if (!exists()) {
             throw new RepositoryException("The node [" + this + "] does not exist!");
         }
@@ -483,5 +486,5 @@
     public Persistable getPersistable() {
         return this.persistable;
     }
-    
+
 }

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java?rev=571429&r1=571428&r2=571429&view=diff
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java Fri Aug 31 03:55:51 2007
@@ -204,6 +204,7 @@
     }
 
     private boolean deleted;
+    private boolean loaded = false;
 
     protected void delete() {
         this.deleted = true;
@@ -261,6 +262,7 @@
                 this.manager.release(resolver);
             }
         }
+        this.loaded = true;
     }
 
     /**
@@ -414,6 +416,10 @@
             getLogger().debug("Get OutputStream for " + getSourceUri());
         loadData();
         return new NodeOutputStream();
+    }
+    
+    protected boolean isLoaded() {
+        return this.loaded;
     }
 
 }
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.