roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r394186 - in /incubator/roller/branches/roller-newbackend/src/org/roller: business/hibernate/HibernateWeblogManagerImpl.java model/WeblogManager.java
Date Fri, 14 Apr 2006 20:19:23 GMT
Author: agilliland
Date: Fri Apr 14 13:19:18 2006
New Revision: 394186

URL: http://svn.apache.org/viewcvs?rev=394186&view=rev
Log:
add new method removeWeblogCategory() and tidy things up for category operations.


Modified:
    incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/branches/roller-newbackend/src/org/roller/model/WeblogManager.java

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=394186&r1=394185&r2=394186&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
Fri Apr 14 13:19:18 2006
@@ -80,7 +80,58 @@
     
     
     public void storeWeblogCategory(WeblogCategoryData cat) throws RollerException {
-        // TODO BACKEND: new method
+        
+        if(this.isDuplicateWeblogCategoryName(cat)) {
+            throw new RollerException("Duplicate category name");
+        }
+        
+        this.strategy.storeAndCommit(cat);
+    }
+    
+    
+    public void removeWeblogCategory(WeblogCategoryData cat) throws RollerException {
+        
+        if(cat.retrieveWeblogEntries(true).size() > 0) {
+            throw new RollerException("Cannot remove category with entries");
+        }
+        
+        try {
+            // begin transaction
+            this.strategy.getSession().beginTransaction();
+            
+            // remove cat
+            this.strategy.remove(cat);
+            
+            // update website default cats if needed
+            if(cat.getWebsite().getBloggerCategory().equals(cat)) {
+                WeblogCategoryData rootCat = this.getRootWeblogCategory(cat.getWebsite());
+                cat.getWebsite().setBloggerCategory(rootCat);
+                this.strategy.store(cat.getWebsite());
+            }
+            
+            if(cat.getWebsite().getDefaultCategory().equals(cat)) {
+                WeblogCategoryData rootCat = this.getRootWeblogCategory(cat.getWebsite());
+                cat.getWebsite().setDefaultCategory(rootCat);
+                this.strategy.store(cat.getWebsite());
+            }
+            
+            // commit changes
+            this.strategy.getSession().getTransaction().commit();
+        } catch (Throwable ex) {
+            
+            try {
+                this.strategy.getSession().getTransaction().rollback();
+            } catch(Throwable he) {
+                log.error("Error doing rollback", he);
+            }
+            
+            strategy.release();
+            
+            throw new RollerException(ex);
+        }
+        
+        
+        
     }
     
     

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/model/WeblogManager.java?rev=394186&r1=394185&r2=394186&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/model/WeblogManager.java Fri
Apr 14 13:19:18 2006
@@ -45,9 +45,6 @@
      */
     public WeblogCategoryData retrieveWeblogCategory(String id)
         throws RollerException;
-
-    
-    public void storeWeblogEntry(WeblogEntryData entry) throws RollerException;
     
     
     /**
@@ -65,6 +62,9 @@
     public void storeWeblogCategory(WeblogCategoryData cat) throws RollerException;
     
     
+    public void removeWeblogCategory(WeblogCategoryData cat) throws RollerException;
+    
+    
     /** Get WebLogCategory objects for a website. */
     public List getWeblogCategories(WebsiteData website)
         throws RollerException;
@@ -187,6 +187,9 @@
      * Get weblog entry by ID
      */
     public WeblogEntryData retrieveWeblogEntry(String id) throws RollerException;
+    
+    
+    public void storeWeblogEntry(WeblogEntryData entry) throws RollerException;
     
     
     public void removeWeblogEntry(WeblogEntryData entry) throws RollerException;



Mime
View raw message