roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1561615 - /roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
Date Mon, 27 Jan 2014 09:08:17 GMT
Author: ghuber
Date: Mon Jan 27 09:08:16 2014
New Revision: 1561615

URL: http://svn.apache.org/r1561615
Log:
Test fix for java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'ROLLER_MEDIAFILEDIR'

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java?rev=1561615&r1=1561614&r2=1561615&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
Mon Jan 27 09:08:16 2014
@@ -31,6 +31,8 @@ import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -365,6 +367,7 @@ public class JPAMediaFileManagerImpl imp
             cmgr.saveFileContent(mediaFile.getWeblog(), mediaFile.getId()
                     + "_sm", new ByteArrayInputStream(baos.toByteArray()));
 
+            roller.flush();
             // Refresh associated parent for changes
             strategy.refresh(mediaFile.getDirectory());
 
@@ -381,6 +384,7 @@ public class JPAMediaFileManagerImpl imp
         mediaFile.setLastUpdated(new Timestamp(System.currentTimeMillis()));
         strategy.store(mediaFile);
 
+        roller.flush();
         // Refresh associated parent for changes
         strategy.refresh(mediaFile.getDirectory());
 
@@ -396,6 +400,10 @@ public class JPAMediaFileManagerImpl imp
         mediaFile.setLastUpdated(new Timestamp(System.currentTimeMillis()));
         strategy.store(mediaFile);
 
+        roller.flush();
+        // Refresh associated parent for changes
+        strategy.refresh(mediaFile.getDirectory());
+
         // update weblog last modified date. date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
 
@@ -408,9 +416,6 @@ public class JPAMediaFileManagerImpl imp
         }
         cmgr.saveFileContent(weblog, mediaFile.getId(), is);
 
-        // Refresh associated parent for changes
-        strategy.refresh(mediaFile.getDirectory());
-
         if (mediaFile.isImageFile()) {
             updateThumbnail(mediaFile);
         }
@@ -954,25 +959,18 @@ public class JPAMediaFileManagerImpl imp
             }
             this.strategy.remove(mf);
         }
-        
+
         // Children
         roller.flush();
-        
-        Set<MediaFileDirectory> dirs = dir.getChildDirectories();
+
+        // Set<MediaFileDirectory> dirs = dir.getChildDirectories();
         // Recursive fix ConcurrentModificationException
-        List<MediaFileDirectory> concurrentFix = new ArrayList<MediaFileDirectory>();
+        Set<MediaFileDirectory> dirs = Collections
+                .synchronizedSet(new HashSet<MediaFileDirectory>(dir
+                        .getChildDirectories()));
         for (MediaFileDirectory md : dirs) {
-            concurrentFix.add(md);
-        }
-        for (Iterator<MediaFileDirectory> i = concurrentFix.iterator(); i
-                .hasNext();) {
-            MediaFileDirectory md = i.next();
             removeMediaFileDirectory(md);
         }
-        // for (MediaFileDirectory md : dirs) {
-        // see Recursive fix above
-        // removeMediaFileDirectory(md);
-        // }
 
         this.strategy.remove(dir);
 



Mime
View raw message