roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r395457 - in /incubator/roller/trunk/src/org/roller: business/ business/hibernate/ model/ presentation/website/actions/
Date Thu, 20 Apr 2006 01:14:05 GMT
Author: snoopdave
Date: Wed Apr 19 18:14:02 2006
New Revision: 395457

URL: http://svn.apache.org/viewcvs?rev=395457&view=rev
Log:
Moving applyCommentDefaults to WeblogManager

Modified:
    incubator/roller/trunk/src/org/roller/business/ThemeManagerImpl.java
    incubator/roller/trunk/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
    incubator/roller/trunk/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/trunk/src/org/roller/model/UserManager.java
    incubator/roller/trunk/src/org/roller/model/WeblogManager.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java

Modified: incubator/roller/trunk/src/org/roller/business/ThemeManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/ThemeManagerImpl.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/ThemeManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/roller/business/ThemeManagerImpl.java Wed Apr 19 18:14:02
2006
@@ -363,7 +363,7 @@
             }
             
             // save our updated website
-            userMgr.saveWebsite(website, false);
+            userMgr.saveWebsite(website);
             
         } catch (Exception e) {
             mLogger.error("ERROR in action",e);

Modified: incubator/roller/trunk/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/hibernate/HibernateUserManagerImpl.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
Wed Apr 19 18:14:02 2006
@@ -68,15 +68,10 @@
     }
    
     /**
-     * Update existing website and optionally apply new comment defaults to all
-     * existing weblog entries in website.
-     * @param website              The website to be updated
-     * @param applyCommentDefaults True to apply website's comment defaults to 
-     *                             all existing comments
+     * Update existing website.
      */
-    public void saveWebsite(WebsiteData website, boolean applyCommentDefaults) throws RollerException
{
+    public void saveWebsite(WebsiteData website) throws RollerException {
         strategy.store(website);
-        if (applyCommentDefaults) applyCommentDefaults(website);
     }    
     
     public void removeWebsite(WebsiteData weblog) throws RollerException {
@@ -787,32 +782,7 @@
         public IgnoreCaseEqExpression(String property, Object value) {
             super(property, value, "=", true);
         }
-    }
-    
-    /**
-     * Apply comment defaults (defaultAllowComments and defaultCommentDays) to
-     * all existing entries in a website using a single HQL query.
-     * @param website Website where comment defaults are from/to be applied.
-     */
-    private void applyCommentDefaults(WebsiteData website) throws RollerException {
-        if (log.isDebugEnabled()) {
-            log.debug("applyCommentDefaults");
-        }       
-        try {
-            Session session = strategy.getSession();
-            String updateString = "update WeblogEntryData set "
-                +"allowComments=:allowed, commentDays=:days, "
-                +"pubTime=pubTime, updateTime=updateTime " // ensure timestamps are NOT reset
-                +"where website=:site";
-            Query update = session.createQuery(updateString);
-            update.setParameter("allowed", website.getDefaultAllowComments());
-            update.setParameter("days", new Integer(website.getDefaultCommentDays()));
-            update.setParameter("site", website);
-            update.executeUpdate();            
-        } catch (Exception e) {
-            log.error("EXCEPTION applying comment defaults",e);
-        }
-    }  
+    } 
 }
 
 

Modified: incubator/roller/trunk/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
Wed Apr 19 18:14:02 2006
@@ -33,6 +33,7 @@
 import java.util.Map;
 import java.util.TreeMap;
 import org.apache.commons.collections.comparators.ReverseComparator;
+import org.hibernate.Query;
 import org.hibernate.criterion.MatchMode;
 import org.roller.model.WeblogManager;
 import org.roller.util.DateUtil;
@@ -1006,5 +1007,29 @@
     
     
     public void release() {}
-    
+
+    /**
+     * Apply comment defaults (defaultAllowComments and defaultCommentDays) to
+     * all existing entries in a website using a single HQL query.
+     * @param website Website where comment defaults are from/to be applied.
+     */
+    public void applyCommentDefaultsToEntries(WebsiteData website) throws RollerException
{
+        if (log.isDebugEnabled()) {
+            log.debug("applyCommentDefaults");
+        }       
+        try {
+            Session session = strategy.getSession();
+            String updateString = "update WeblogEntryData set "
+                +"allowComments=:allowed, commentDays=:days, "
+                +"pubTime=pubTime, updateTime=updateTime " // ensure timestamps are NOT reset
+                +"where website=:site";
+            Query update = session.createQuery(updateString);
+            update.setParameter("allowed", website.getDefaultAllowComments());
+            update.setParameter("days", new Integer(website.getDefaultCommentDays()));
+            update.setParameter("site", website);
+            update.executeUpdate();            
+        } catch (Exception e) {
+            log.error("EXCEPTION applying comment defaults",e);
+        }
+    }     
 }

Modified: incubator/roller/trunk/src/org/roller/model/UserManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/model/UserManager.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/model/UserManager.java (original)
+++ incubator/roller/trunk/src/org/roller/model/UserManager.java Wed Apr 19 18:14:02 2006
@@ -13,8 +13,7 @@
  * Manages users, weblogs, permissions, and weblog pages.
  */
 public interface UserManager {
-    
-    
+        
     /**
      * Add new user object to Roller. User will be given the global editor role,
      * unless it's the first user, who will get the global admin role.
@@ -90,7 +89,7 @@
     /**
      * Store a single weblog.
      */
-    public void saveWebsite(WebsiteData data, boolean applyCommentDefaults) throws RollerException;
+    public void saveWebsite(WebsiteData data) throws RollerException;
     
     
     public void removeWebsite(WebsiteData website) throws RollerException;

Modified: incubator/roller/trunk/src/org/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/model/WeblogManager.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/model/WeblogManager.java (original)
+++ incubator/roller/trunk/src/org/roller/model/WeblogManager.java Wed Apr 19 18:14:02 2006
@@ -20,11 +20,9 @@
 public interface WeblogManager {
     
     public static final String CATEGORY_ATT = "category.att";
-    
-    
+       
     public void saveWeblogEntry(WeblogEntryData entry) throws RollerException;
-    
-    
+        
     public void removeWeblogEntry(WeblogEntryData entry) throws RollerException;
     
     
@@ -366,6 +364,10 @@
      */
     public String getUrl(WebsiteData website, String contextUrl) throws RollerException;
     
+    /**
+     * Apply comment default settings from website to all of website's entries.
+     */
+    public void applyCommentDefaultsToEntries(WebsiteData website) throws RollerException;
     
     /**
      * Release all resources associated with Roller session.

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
Wed Apr 19 18:14:02 2006
@@ -280,7 +280,7 @@
                         website.setEditorTheme(newTheme);
                         
                         UserManager userMgr = RollerFactory.getRoller().getUserManager();
-                        userMgr.saveWebsite(website, false);
+                        userMgr.saveWebsite(website);
                         RollerFactory.getRoller().flush();
                         
                         mLogger.debug("Saved theme "+newTheme+" for "+username);

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java?rev=395457&r1=395456&r2=395457&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
Wed Apr 19 18:14:02 2006
@@ -152,13 +152,14 @@
                     
                     // ROL-485: comments not be allowed on inactive weblogs
                     wd.setAllowComments(wd.getActive());
+                                        
+                    umgr.saveWebsite(wd);  
                     
                     // ROL-1050: apply comment defaults to existing entries
-                    boolean applyCommentDefaults = form.isApplyCommentDefaults();
-                        //BooleanUtils.toBoolean(form.isApplyCommentDefaults());
-                    
-                    umgr.saveWebsite(wd, applyCommentDefaults);  
-                    
+                    if (form.isApplyCommentDefaults()) {
+                        wmgr.applyCommentDefaultsToEntries(wd);
+                    }
+
                     RollerFactory.getRoller().getRefererManager().applyRefererFilters(wd);
                     
                     RollerFactory.getRoller().flush();



Mime
View raw message