roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r453752 - in /incubator/roller/trunk/src/org/apache/roller: business/hibernate/HibernateWeblogManagerImpl.java model/WeblogManager.java
Date Fri, 06 Oct 2006 20:28:12 GMT
Author: snoopdave
Date: Fri Oct  6 13:28:11 2006
New Revision: 453752

URL: http://svn.apache.org/viewvc?view=rev&rev=453752
Log:
Fix for delete in-use and add duplicate-named category problems (ROL-1165, ROL-1163)

Modified:
    incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java

Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?view=diff&rev=453752&r1=453751&r2=453752
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
Fri Oct  6 13:28:11 2006
@@ -90,7 +90,7 @@
     public void saveWeblogCategory(WeblogCategoryData cat) throws RollerException {
         
         if(this.isDuplicateWeblogCategoryName(cat)) {
-            throw new RollerException("Duplicate category name");
+            throw new RollerException("Duplicate category name, cannot save new category");
         }
         
         // update weblog last modified date.  date updated by saveWebsite()
@@ -127,32 +127,24 @@
     }
     
     
-    public void moveWeblogCategoryContents(String srcId, String destId)
+    public void moveWeblogCategoryContents(WeblogCategoryData srcCat, WeblogCategoryData
destCat)
             throws RollerException {
-        
-        WeblogCategoryData srcCd =
-                (WeblogCategoryData) this.strategy.load(
-                srcId, WeblogCategoryData.class);
-        
-        WeblogCategoryData destCd =
-                (WeblogCategoryData) this.strategy.load(
-                destId, WeblogCategoryData.class);
-        
+                
         // TODO: this check should be made before calling this method?
-        if (destCd.descendentOf(srcCd)) {
+        if (destCat.descendentOf(srcCat)) {
             throw new RollerException(
                     "ERROR cannot move parent category into it's own child");
         }
         
         // get all entries in category and subcats
-        List results = getWeblogEntries(srcCd, true);
+        List results = srcCat.retrieveWeblogEntries(true);
         
         // Loop through entries in src cat, assign them to dest cat
         Iterator iter = results.iterator();
-        WebsiteData website = destCd.getWebsite();
+        WebsiteData website = destCat.getWebsite();
         while (iter.hasNext()) {
             WeblogEntryData entry = (WeblogEntryData) iter.next();
-            entry.setCategory(destCd);
+            entry.setCategory(destCat);
             entry.setWebsite(website);
             this.strategy.store(entry);
         }
@@ -160,16 +152,16 @@
         // Make sure website's default and bloggerapi categories
         // are valid after the move
         
-        if (srcCd.getWebsite().getDefaultCategory().getId().equals(srcId)
-        || srcCd.getWebsite().getDefaultCategory().descendentOf(srcCd)) {
-            srcCd.getWebsite().setDefaultCategory(destCd);
-            this.strategy.store(srcCd.getWebsite());
+        if (srcCat.getWebsite().getDefaultCategory().getId().equals(srcCat.getId())
+        || srcCat.getWebsite().getDefaultCategory().descendentOf(srcCat)) {
+            srcCat.getWebsite().setDefaultCategory(destCat);
+            this.strategy.store(srcCat.getWebsite());
         }
         
-        if (srcCd.getWebsite().getBloggerCategory().getId().equals(srcId)
-        || srcCd.getWebsite().getBloggerCategory().descendentOf(srcCd)) {
-            srcCd.getWebsite().setBloggerCategory(destCd);
-            this.strategy.store(srcCd.getWebsite());
+        if (srcCat.getWebsite().getBloggerCategory().getId().equals(srcCat.getId())
+        || srcCat.getWebsite().getBloggerCategory().descendentOf(srcCat)) {
+            srcCat.getWebsite().setBloggerCategory(destCat);
+            this.strategy.store(srcCat.getWebsite());
         }
     }
     
@@ -680,7 +672,7 @@
             } catch (HibernateException e) {
                 throw new RollerException(e);
             }
-            if (sameNames.size() > 1) {
+            if (sameNames.size() > 0) {
                 return true;
             }
         }

Modified: incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java?view=diff&rev=453752&r1=453751&r2=453752
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java Fri Oct  6 13:28:11
2006
@@ -240,7 +240,7 @@
     /**
      * Recategorize all entries with one category to another.
      */
-    public void moveWeblogCategoryContents(String srcId, String destId) 
+    public void moveWeblogCategoryContents(WeblogCategoryData srcCat, WeblogCategoryData
destCat) 
             throws RollerException;
     
     /**



Mime
View raw message