roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1568146 [1/2] - in /roller/trunk: app/src/main/java/org/apache/roller/weblogger/ app/src/main/java/org/apache/roller/weblogger/business/ app/src/main/java/org/apache/roller/weblogger/business/jpa/ app/src/main/java/org/apache/roller/weblog...
Date Thu, 13 Feb 2014 23:34:13 GMT
Author: gmazza
Date: Thu Feb 13 23:34:12 2014
New Revision: 1568146

URL: http://svn.apache.org/r1568146
Log:
Finished up removal of weblog subcategories:  removed parent, childcategory elements from WeblogCategory class.

Removed:
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryParentDeletesTest.java
Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Entries.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAdd.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfigBean.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java
    roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml
    roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/Categories.jsp
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryEdit.jsp
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp
    roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java
    roller/trunk/app/src/test/resources/roller-custom.properties
    roller/trunk/docs/roller-template-guide.odt

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java Thu Feb 13 23:34:12 2014
@@ -26,6 +26,7 @@ package org.apache.roller.weblogger;
 import java.io.InputStream;
 import java.sql.Connection;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.roller.planet.business.PlanetManager;
@@ -308,17 +309,12 @@ public final class TestUtils {
      * Convenience method for creating a weblog category.
      */
     public static WeblogCategory setupWeblogCategory(Weblog weblog,
-            String name, WeblogCategory parent) throws Exception {
+            String name) throws Exception {
 
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger()
                 .getWeblogEntryManager();
-        WeblogCategory root = mgr.getRootWeblogCategory(weblog);
 
-        WeblogCategory catParent = root;
-        if (parent != null) {
-            catParent = parent;
-        }
-        WeblogCategory testCat = new WeblogCategory(weblog, catParent, name,
+        WeblogCategory testCat = new WeblogCategory(weblog, name,
                 null, null);
         mgr.saveWeblogCategory(testCat);
 
@@ -363,6 +359,15 @@ public final class TestUtils {
     }
 
     /**
+     * Convenience method for creating a published weblog entry with the blog's default category
+     */
+    public static WeblogEntry setupWeblogEntry(String anchor, Weblog weblog, User user) throws Exception {
+
+        return TestUtils.setupWeblogEntry(anchor, weblog.getDefaultCategory(), WeblogEntry.PUBLISHED,
+                weblog, user);
+    }
+
+    /**
      * Convenience method for creating a weblog entry
      */
     public static WeblogEntry setupWeblogEntry(String anchor,

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java Thu Feb 13 23:34:12 2014
@@ -234,13 +234,6 @@ public interface WeblogEntryManager {
             throws WebloggerException;
     
     /**
-     * Get top level categories for a website.
-     * @param website Website.
-     */
-    WeblogCategory getRootWeblogCategory(Weblog website) throws WebloggerException;
-    
-    
-    /**
      * Get category specified by website and name.
      * @param website      Website of WeblogCategory.
      * @param categoryName Name of WeblogCategory
@@ -251,7 +244,7 @@ public interface WeblogEntryManager {
     /**
      * Get WebLogCategory objects for a website. 
      */
-    List<WeblogCategory> getWeblogCategories(Weblog website, boolean includeRoot)
+    List<WeblogCategory> getWeblogCategories(Weblog website)
             throws WebloggerException;
 
     /**

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java Thu Feb 13 23:34:12 2014
@@ -18,17 +18,8 @@
 
 package org.apache.roller.weblogger.business.jpa;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.text.SimpleDateFormat;
-import java.util.TreeMap;
 import java.sql.Timestamp;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
@@ -104,16 +95,10 @@ public class JPAWeblogEntryManagerImpl i
             if (isDuplicateWeblogCategoryName(cat)) {
                 throw new WebloggerException("Duplicate category name, cannot save category");
             }
-            // Newly added object. If it has a parent,
-            // maintain relationship from both sides
-            WeblogCategory parent = cat.getParent();
-            if(parent != null) {
-                parent.getWeblogCategories().add(cat);
-            }
         }
         
         // update weblog last modified date.  date updated by saveWebsite()
-        roller.getWeblogManager().saveWeblog(cat.getWebsite());        
+        roller.getWeblogManager().saveWeblog(cat.getWeblog());
         this.strategy.store(cat);
     }
     
@@ -125,31 +110,20 @@ public class JPAWeblogEntryManagerImpl i
         if(cat.retrieveWeblogEntries(false).size() > 0) {
             throw new WebloggerException("Cannot remove category with entries");
         }
-        
+
+        Weblog testWeblog = cat.getWeblog();
+        cat.getWeblog().getWeblogCategories().remove(cat);
+
         // remove cat
         this.strategy.remove(cat);
-        //relationship management for the other side
-        WeblogCategory parent = cat.getParent();
-        if(parent != null) {
-            parent.getWeblogCategories().remove(cat);
-        }
-        
-        // update website default cats if needed
-        if(cat.getWebsite().getBloggerCategory().equals(cat)) {
-            WeblogCategory rootCat = this.getRootWeblogCategory(cat.getWebsite());
-            cat.getWebsite().setBloggerCategory(rootCat);
-            this.strategy.store(cat.getWebsite());
-        }
-        
-        if(cat.getWebsite().getDefaultCategory().equals(cat)) {
-            WeblogCategory rootCat = this.getRootWeblogCategory(cat.getWebsite());
-            cat.getWebsite().setDefaultCategory(rootCat);
-            this.strategy.store(cat.getWebsite());
+
+        if(cat.equals(cat.getWeblog().getBloggerCategory())) {
+            cat.getWeblog().setBloggerCategory(cat.getWeblog().getDefaultCategory());
+            this.strategy.store(cat.getWeblog());
         }
-        
+
         // update weblog last modified date.  date updated by saveWebsite()
-        roller.getWeblogManager().saveWeblog(
-                cat.getWebsite());
+        roller.getWeblogManager().saveWeblog(cat.getWeblog());
     }
 
     /**
@@ -159,38 +133,22 @@ public class JPAWeblogEntryManagerImpl i
             WeblogCategory destCat)
             throws WebloggerException {
         
-        // TODO: this check should be made before calling this method?
-        if (destCat.descendentOf(srcCat)) {
-            throw new WebloggerException(
-                    "ERROR cannot move parent category into it's own child");
-        }
-        
         // get all entries in category and subcats
         List<WeblogEntry> results = srcCat.retrieveWeblogEntries(false);
         
         // Loop through entries in src cat, assign them to dest cat
-        Weblog website = destCat.getWebsite();
+        Weblog website = destCat.getWeblog();
         for (WeblogEntry entry : results) {
             entry.setCategory(destCat);
             entry.setWebsite(website);
             this.strategy.store(entry);
         }
         
-        // Make sure website's default and bloggerapi categories
-        // are valid after the move
-        
-        if (srcCat.getWebsite().getDefaultCategory().getId()
-        .equals(srcCat.getId())
-        || srcCat.getWebsite().getDefaultCategory().descendentOf(srcCat)) {
-            srcCat.getWebsite().setDefaultCategory(destCat);
-            this.strategy.store(srcCat.getWebsite());
-        }
-        
-        if (srcCat.getWebsite().getBloggerCategory().getId()
-        .equals(srcCat.getId())
-        || srcCat.getWebsite().getBloggerCategory().descendentOf(srcCat)) {
-            srcCat.getWebsite().setBloggerCategory(destCat);
-            this.strategy.store(srcCat.getWebsite());
+        // Update Blogger API category if applicable
+        WeblogCategory bloggerCategory = srcCat.getWeblog().getBloggerCategory();
+        if (bloggerCategory != null && bloggerCategory.getId().equals(srcCat.getId())) {
+            srcCat.getWeblog().setBloggerCategory(destCat);
+            this.strategy.store(srcCat.getWeblog());
         }
     }
     
@@ -221,13 +179,11 @@ public class JPAWeblogEntryManagerImpl i
     public void saveWeblogEntry(WeblogEntry entry) throws WebloggerException {
 
         if (entry.getCategory() == null) {
-
             // Entry is invalid without category, so use weblog client cat
             WeblogCategory cat = entry.getWebsite().getBloggerCategory();
             if (cat == null) {
-                // Sill no category, so use first one found
-                cat = (WeblogCategory)
-                    entry.getWebsite().getWeblogCategories().iterator().next();
+                // Still no category, so use first one found
+                cat = entry.getWebsite().getWeblogCategories().iterator().next();
             }
             entry.setCategory(cat);
         }
@@ -402,44 +358,7 @@ public class JPAWeblogEntryManagerImpl i
     /**
      * @inheritDoc
      */
-    public WeblogCategory getRootWeblogCategory(Weblog website)
-    throws WebloggerException {
-        if (website == null) {
-            throw new WebloggerException("website is null");
-        }
-        
-        Query q = strategy.getNamedQuery(
-                "WeblogCategory.getByWebsite&ParentNull");
-        q.setParameter(1, website);
-        try {
-            return (WeblogCategory)q.getSingleResult();
-        } catch (NoResultException e) {
-            return null;
-        }
-    }
-    
-    /**
-     * @inheritDoc
-     */
-    public List<WeblogCategory> getWeblogCategories(Weblog website, boolean includeRoot)
-    throws WebloggerException {
-        if (website == null) {
-            throw new WebloggerException("website is null");
-        }
-        
-        if (includeRoot) {
-            return getWeblogCategories(website);
-        }
-        
-        Query q = strategy.getNamedQuery(
-                "WeblogCategory.getByWebsite&ParentNotNull");
-        q.setParameter(1, website);
-        return q.getResultList();
-    }
-    
-    /**
-     * @inheritDoc
-     */
+    @Override
     public List<WeblogCategory> getWeblogCategories(Weblog website)
     throws WebloggerException {
         if (website == null) {
@@ -447,7 +366,7 @@ public class JPAWeblogEntryManagerImpl i
         }
         
         Query q = strategy.getNamedQuery(
-                "WeblogCategory.getByWebsite");
+                "WeblogCategory.getByWeblog");
         q.setParameter(1, website);
         return q.getResultList();
     }
@@ -757,15 +676,8 @@ public class JPAWeblogEntryManagerImpl i
      */
     public boolean isDuplicateWeblogCategoryName(WeblogCategory cat)
     throws WebloggerException {
-        
-        // ensure that no sibling categories share the same name
-        WeblogCategory parent = cat.getParent();
-        if (null != parent) {
-            return (getWeblogCategoryByName(
-                    cat.getWebsite(), cat.getName()) != null);
-        }
-        
-        return false;
+        return (getWeblogCategoryByName(
+                cat.getWeblog(), cat.getName()) != null);
     }
     
     /**
@@ -782,17 +694,7 @@ public class JPAWeblogEntryManagerImpl i
             return true;
         }
         
-        for (WeblogCategory childCat : cat.getWeblogCategories()) {
-            if (childCat.isInUse()) {
-                return true;
-            }
-        }
-
-        if (cat.getWebsite().getBloggerCategory().equals(cat)) {
-            return true;
-        }
-        
-        if (cat.getWebsite().getDefaultCategory().equals(cat)) {
+        if (cat.getWeblog().getBloggerCategory().equals(cat)) {
             return true;
         }
         
@@ -925,34 +827,19 @@ public class JPAWeblogEntryManagerImpl i
     /**
      * @inheritDoc
      */
-    public WeblogCategory getWeblogCategoryByName(Weblog website,
+    public WeblogCategory getWeblogCategoryByName(Weblog weblog,
             String categoryName) throws WebloggerException {
-        return getWeblogCategoryByName(website, null, categoryName);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    // TODO: ditch this method in favor of getWeblogCategoryByName(weblog, name)
-    public WeblogCategory getWeblogCategoryByName(Weblog website,
-            WeblogCategory category, String name) throws WebloggerException {
-        
-        if (name == null) {
-            return getRootWeblogCategory(website);
-        } else {
-            // now just do simple lookup by name
-            Query q = strategy.getNamedQuery(
-                    "WeblogCategory.getByName&Website");
-            q.setParameter(1, name);
-            q.setParameter(2, website);
-            try {
-                return (WeblogCategory)q.getSingleResult();
-            } catch (NoResultException e) {
-                return null;
-            }
+        Query q = strategy.getNamedQuery(
+                "WeblogCategory.getByWeblog&Name");
+        q.setParameter(1, weblog);
+        q.setParameter(2, categoryName);
+        try {
+            return (WeblogCategory)q.getSingleResult();
+        } catch (NoResultException e) {
+            return null;
         }
     }
-    
+
     /**
      * @inheritDoc
      */

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java Thu Feb 13 23:34:12 2014
@@ -225,15 +225,9 @@ public class JPAWeblogManagerImpl implem
         }
         this.strategy.flush();
         
-        // remove categories
-        WeblogCategory rootCat = emgr.getRootWeblogCategory(website);
-        if (null != rootCat) {
-            this.strategy.remove(rootCat);
-        }
-
         // delete all weblog categories
         Query removeCategories= strategy.getNamedUpdate(
-                "WeblogCategory.removeByWebsite");
+                "WeblogCategory.removeByWeblog");
         removeCategories.setParameter(1, website);
         removeCategories.executeUpdate();
 
@@ -284,7 +278,7 @@ public class JPAWeblogManagerImpl implem
     }
     
     public void addWeblog(Weblog newWeblog) throws WebloggerException {
-        
+
         this.strategy.store(newWeblog);
         this.strategy.flush();
         this.addWeblogContents(newWeblog);
@@ -299,42 +293,32 @@ public class JPAWeblogManagerImpl implem
         roller.getUserManager().grantWeblogPermission(
                 newWeblog, newWeblog.getCreator(), actions);
         
-        // add default category
-        WeblogCategory rootCat = new WeblogCategory(
-                newWeblog, // newWeblog
-                null,      // parent
-                "root",    // name
-                "root",    // description
-                null );    // image
-        this.strategy.store(rootCat);
-        
         String cats = WebloggerConfig.getProperty("newuser.categories");
-        WeblogCategory firstCat = rootCat;
-        if (cats != null && cats.trim().length() > 0) {
-            String[] splitcats = cats.split(",");
-            for (int i=0; i<splitcats.length; i++) {
-                WeblogCategory c = new WeblogCategory(
-                        newWeblog,       // newWeblog
-                        rootCat,         // parent
-                        splitcats[i],    // name
-                        splitcats[i],    // description
-                        null );          // image
-                if (i == 0) {
-                    firstCat = c;
-                }
-                rootCat.getWeblogCategories().add(c);
-                this.strategy.store(c);
+        WeblogCategory firstCat = null;
+        String[] splitcats = cats.split(",");
+        for (int i=0; i<splitcats.length; i++) {
+            if (splitcats[i].trim().length() == 0) {
+                continue;
+            }
+            WeblogCategory c = new WeblogCategory(
+                    newWeblog,       // newWeblog
+                    splitcats[i],    // name
+                    null,            // description
+                    null );          // image
+            if (firstCat == null) {
+                firstCat = c;
             }
+            // TODO: Have weblog add category instead of latter in its constructor?
+            this.strategy.store(c);
         }
-        
+
         // Use first category as default for Blogger API
-        newWeblog.setBloggerCategory(firstCat);
-        
-        // But default category for weblog itself should be  root
-        newWeblog.setDefaultCategory(rootCat);
-        
+        if (firstCat != null) {
+            newWeblog.setBloggerCategory(firstCat);
+        }
+
         this.strategy.store(newWeblog);
-        
+
         // add default bookmarks
         WeblogBookmarkFolder root = new WeblogBookmarkFolder(
                 null, "root", "root", newWeblog);
@@ -363,10 +347,10 @@ public class JPAWeblogManagerImpl implem
         }
 
         roller.getMediaFileManager().createRootMediaFileDirectory(newWeblog);
-        
+
         // flush so that all data up to this point can be available in db
         this.strategy.flush();
-        
+
         // add any auto enabled ping targets
         PingTargetManager pingTargetMgr = roller.getPingTargetManager();
         AutoPingManager autoPingMgr = roller.getAutopingManager();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java Thu Feb 13 23:34:12 2014
@@ -19,16 +19,8 @@
 package org.apache.roller.weblogger.pojos;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
+import java.util.*;
+
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.roller.weblogger.WebloggerException;
@@ -97,10 +89,29 @@ public class Weblog implements Serializa
 
     // Associated objects
     private WeblogCategory bloggerCategory = null;
-    private WeblogCategory defaultCategory = null;
-    
+
     private Map<String, WeblogEntryPlugin> initializedPlugins = null;
-    
+
+    private List<WeblogCategory> weblogCategories = new ArrayList<WeblogCategory>();
+
+
+    public List<WeblogCategory> getWeblogCategories() {
+        return weblogCategories;
+    }
+
+    public void setWeblogCategories(List<WeblogCategory> cats) {
+        this.weblogCategories = cats;
+    }
+
+    public boolean hasCategory(String name) {
+        for (WeblogCategory cat : getWeblogCategories()) {
+            if(name.equals(cat.getName())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public Weblog() {    
     }
     
@@ -160,14 +171,6 @@ public class Weblog implements Serializa
             .toHashCode();
     } 
     
-    /*public List getPermissions() {
-        return permissions;
-    }
-    public void setPermissions(List perms) {
-        permissions = perms;
-    }*/
-    
-    
     /**
      * Get the Theme object in use by this weblog, or null if no theme selected.
      */
@@ -299,6 +302,9 @@ public class Weblog implements Serializa
     }
     
     public WeblogCategory getBloggerCategory() {
+        if (bloggerCategory == null) {
+            bloggerCategory = getDefaultCategory();
+        }
         return bloggerCategory;
     }
     
@@ -306,19 +312,13 @@ public class Weblog implements Serializa
         this.bloggerCategory = bloggerCategory;
     }
     
-    /**
-     * By default,the default category for a weblog is the root and all macros
-     * work with the top level categories that are immediately under the root.
-     * Setting a different default category allows you to partition your weblog.
-     */
     public WeblogCategory getDefaultCategory() {
-        return defaultCategory;
-    }
-    
-    public void setDefaultCategory(WeblogCategory defaultCategory) {
-        this.defaultCategory = defaultCategory;
+        if (weblogCategories.size() == 0) {
+            return null;
+        }
+        return weblogCategories.iterator().next();
     }
-    
+
     public String getEditorPage() {
         return this.editorPage;
     }
@@ -465,7 +465,6 @@ public class Weblog implements Serializa
         this.setWeblogDayPageId(other.getWeblogDayPageId());
         this.setEnableBloggerApi(other.getEnableBloggerApi());
         this.setBloggerCategory(other.getBloggerCategory());
-        this.setDefaultCategory(other.getDefaultCategory());
         this.setEditorPage(other.getEditorPage());
         this.setBlacklist(other.getBlacklist());
         this.setAllowComments(other.getAllowComments());
@@ -481,6 +480,7 @@ public class Weblog implements Serializa
         this.setEntryDisplayCount(other.getEntryDisplayCount());
         this.setActive(other.getActive());
         this.setLastModified(other.getLastModified());
+        this.setWeblogCategories(other.getWeblogCategories());
     }
     
     
@@ -747,15 +747,6 @@ public class Weblog implements Serializa
         }
         return entry;
     }
-    
-    /**
-     * Returns categories under the default category of the weblog.
-     */
-    public Set<WeblogCategory> getWeblogCategories() {
-        WeblogCategory category = this.getDefaultCategory();
-        return category.getWeblogCategories();
-    }
-
 
     public WeblogCategory getWeblogCategory(String categoryName) {
         WeblogCategory category = null;
@@ -765,7 +756,7 @@ public class Weblog implements Serializa
             if (categoryName != null && !categoryName.equals("nil")) {
                 category = wmgr.getWeblogCategoryByName(this, categoryName);
             } else {
-                category = this.getDefaultCategory();
+                category = getWeblogCategories().iterator().next();
             }
         } catch (WebloggerException e) {
             log.error("ERROR: fetching category: " + categoryName, e);
@@ -1009,4 +1000,24 @@ public class Weblog implements Serializa
         }
         return theme;
     }
+
+    /**
+     * Add a category as a child of this category.
+     */
+    public void addCategory(WeblogCategory category) {
+
+        // make sure category is not null
+        if(category == null || category.getName() == null) {
+            throw new IllegalArgumentException("Category cannot be null and must have a valid name");
+        }
+
+        // make sure we don't already have a category with that name
+        if(hasCategory(category.getName())) {
+            throw new IllegalArgumentException("Duplicate category name '"+category.getName()+"'");
+        }
+
+        // add it to our list of child categories
+        getWeblogCategories().add(category);
+    }
+
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java Thu Feb 13 23:34:12 2014
@@ -48,16 +48,13 @@ public class WeblogCategory implements S
     private String image = null;
 
     // associations
-    private Weblog website = null;
-    private WeblogCategory parentCategory = null;
-    private Set<WeblogCategory> childCategories = new HashSet<WeblogCategory>();
+    private Weblog weblog = null;
 
     public WeblogCategory() {
     }
     
     public WeblogCategory(
-            Weblog website,
-            WeblogCategory parent,
+            Weblog weblog,
             String name,
             String description,
             String image) {
@@ -66,8 +63,8 @@ public class WeblogCategory implements S
         this.description = description;
         this.image = image;
         
-        this.website = website;
-        this.parentCategory = parent;
+        this.weblog = weblog;
+        weblog.getWeblogCategories().add(this);
     }
     
     
@@ -82,6 +79,7 @@ public class WeblogCategory implements S
         return buf.toString();
     }
     
+    @Override
     public boolean equals(Object other) {
         
         if (other == null) {
@@ -89,19 +87,20 @@ public class WeblogCategory implements S
         }
         
         if (other instanceof WeblogCategory) {
-            WeblogCategory o = (WeblogCategory)other;
+            WeblogCategory o = (WeblogCategory) other;
             return new EqualsBuilder()
                 .append(getName(), o.getName())
-                .append(getWebsite(), o.getWebsite())
+                .append(getWeblog(), o.getWeblog())
                 .isEquals();
         }        
         return false;
     }
-        
+
+    @Override
     public int hashCode() {
         return new HashCodeBuilder()
             .append(getName())
-            .append(getWebsite())
+            .append(getWeblog())
             .toHashCode();
     }
     
@@ -162,39 +161,14 @@ public class WeblogCategory implements S
     /**
      * Get the weblog which owns this category.
      */
-    public Weblog getWebsite() {
-        return website;
-    }
-    
-    public void setWebsite(Weblog website) {
-        this.website = website;
-    }
-    
-    
-    /**
-     * Get parent category, or null if category is root of hierarchy.
-     */
-    public WeblogCategory getParent() {
-        return this.parentCategory;
+    public Weblog getWeblog() {
+        return weblog;
     }
     
-    public void setParent(WeblogCategory parent) {
-        this.parentCategory = parent;
+    public void setWeblog(Weblog weblog) {
+        this.weblog = weblog;
     }
 
-    
-    /**
-     * Get child categories of this category.
-     */
-    public Set<WeblogCategory> getWeblogCategories() {
-        return this.childCategories;
-    }
-    
-    private void setWeblogCategories(Set<WeblogCategory> cats) {
-        this.childCategories = cats;
-    }
-    
-    
     /**
      * Retrieve all weblog entries in this category and, optionally, include
      * weblog entries all sub-categories.
@@ -208,59 +182,6 @@ public class WeblogCategory implements S
         return wmgr.getWeblogEntries(this, publishedOnly);
     }
     
-    
-    /**
-     * Add a category as a child of this category.
-     */
-    public void addCategory(WeblogCategory category) {
-        
-        // make sure category is not null
-        if(category == null || category.getName() == null) {
-            throw new IllegalArgumentException("Category cannot be null and must have a valid name");
-        }
-        
-        // make sure we don't already have a category with that name
-        if(this.hasCategory(category.getName())) {
-            throw new IllegalArgumentException("Duplicate category name '"+category.getName()+"'");
-        }
-        
-        // set ourselves as the parent of the category
-        category.setParent(this);
-        
-        // add it to our list of child categories
-        getWeblogCategories().add(category);
-    }
-    
-    
-    /**
-     * Does this category have a child category with the specified name?
-     *
-     * @param name The name of the category to check for.
-     * @return boolean true if child category exists, false otherwise.
-     */
-    public boolean hasCategory(String name) {
-        for (WeblogCategory cat : getWeblogCategories()) {
-            if(name.equals(cat.getName())) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    
-    /**
-     * Is this category a descendent of the other category?
-     */
-    public boolean descendentOf(WeblogCategory ancestor) {
-        
-        if (parentCategory == ancestor) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    
     /**
      * Determine if category is in use. Returns true if any weblog entries
      * use this category or any of its subcategories.
@@ -272,8 +193,6 @@ public class WeblogCategory implements S
             throw new RuntimeException(e);
         }
     }
-    
-    
 
     // convenience method for updating the category name, which triggers a path tree rebuild
     public void updateName(String newName) throws WebloggerException {
@@ -281,7 +200,6 @@ public class WeblogCategory implements S
         // update name
         setName(newName);
 
-        // update path tree for all children
         WebloggerFactory.getWeblogger().getWeblogEntryManager().saveWeblogCategory(this);
     }
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java Thu Feb 13 23:34:12 2014
@@ -77,33 +77,9 @@ public final class WeblogCategoryWrapper
     }
 
     public WeblogWrapper getWebsite() {
-        return WeblogWrapper.wrap(this.pojo.getWebsite(), urlStrategy);
+        return WeblogWrapper.wrap(this.pojo.getWeblog(), urlStrategy);
     }
-    
-    
-    public WeblogCategoryWrapper getParent() {
-        return WeblogCategoryWrapper.wrap(this.pojo.getParent(), urlStrategy);
-    }
-    
-    
-    public List getWeblogCategories() {
-        Set initialCollection = this.pojo.getWeblogCategories();
-        
-        // iterate through and wrap
-        // we force the use of an ArrayList because it should be good enough to cover
-        // for any Collection type we encounter.
-        ArrayList wrappedCollection = new ArrayList(initialCollection.size());
-        Iterator it = initialCollection.iterator();
-        int i = 0;
-        while(it.hasNext()) {
-            wrappedCollection.add(i,WeblogCategoryWrapper.wrap((WeblogCategory) it.next(), urlStrategy));
-            i++;
-        }
-        
-        return wrappedCollection;
-    }
-    
-    
+
     public List retrieveWeblogEntries(boolean publishedOnly)
             throws WebloggerException {
         
@@ -124,12 +100,6 @@ public final class WeblogCategoryWrapper
     }
     
     
-    // TODO: this method doesn't work and propably doesn't need to be here anyways?
-    public boolean descendentOf(WeblogCategory ancestor) {
-        return this.pojo.descendentOf(ancestor);
-    }
-    
-    
     public boolean isInUse() {
         return this.pojo.isInUse();
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java Thu Feb 13 23:34:12 2014
@@ -310,7 +310,7 @@ public final class WeblogWrapper {
 
 
     public List<WeblogCategoryWrapper> getWeblogCategories() {
-        Set<WeblogCategory> unwrapped = this.pojo.getWeblogCategories();
+        List<WeblogCategory> unwrapped = this.pojo.getWeblogCategories();
         List<WeblogCategoryWrapper> wrapped = new ArrayList<WeblogCategoryWrapper>(unwrapped.size());
 
         int i = 0;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java Thu Feb 13 23:34:12 2014
@@ -404,8 +404,8 @@ public class SiteWideCache implements Ca
      * A category has changed.
      */
     public void invalidate(WeblogCategory category) {
-        if(WebloggerRuntimeConfig.isSiteWideWeblog(category.getWebsite().getHandle())) {
-            invalidate(category.getWebsite());
+        if(WebloggerRuntimeConfig.isSiteWideWeblog(category.getWeblog().getHandle())) {
+            invalidate(category.getWeblog());
         }
     }
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java Thu Feb 13 23:34:12 2014
@@ -20,7 +20,6 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
-import java.util.LinkedList;
 import java.util.Set;
 import java.util.TreeSet;
 import org.apache.commons.lang3.StringUtils;
@@ -41,12 +40,6 @@ public class Categories extends UIAction
 
 	private static Log log = LogFactory.getLog(Categories.class);
 
-	// the id of the category we are viewing
-	private String categoryId = null;
-
-	// the category we are viewing
-	private WeblogCategory category = null;
-
 	// list of category ids to move
 	private String[] selectedCategories = null;
 
@@ -54,10 +47,7 @@ public class Categories extends UIAction
 	private String targetCategoryId = null;
 
 	// all categories from the action weblog
-	private Set allCategories = Collections.EMPTY_SET;
-
-	// path of categories representing selected categories hierarchy
-	private List categoryPath = Collections.EMPTY_LIST;
+	private Set<WeblogCategory> allCategories = Collections.EMPTY_SET;
 
 	public Categories() {
 		this.actionName = "categories";
@@ -70,51 +60,18 @@ public class Categories extends UIAction
 		return Collections.singletonList(WeblogPermission.POST);
 	}
 
-	public void myPrepare() {
-		try {
-			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
-					.getWeblogEntryManager();
-			if (!StringUtils.isEmpty(getCategoryId())
-					&& !"/".equals(getCategoryId())) {
-				setCategory(wmgr.getWeblogCategory(getCategoryId()));
-			} else {
-				setCategory(wmgr.getRootWeblogCategory(getActionWeblog()));
-			}
-		} catch (WebloggerException ex) {
-			log.error("Error looking up category", ex);
-		}
-	}
-
 	public String execute() {
 
 		// build list of categories for display
-		TreeSet allCategories = new TreeSet(new WeblogCategoryPathComparator());
+		TreeSet<WeblogCategory> allCategories = new TreeSet<WeblogCategory>(new WeblogCategoryPathComparator());
 
 		try {
 			// Build list of all categories, except for current one, sorted by
 			// path.
-			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
-					.getWeblogEntryManager();
-			List<WeblogCategory> cats = wmgr.getWeblogCategories(
-					getActionWeblog(), true);
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
+			List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog());
 			for (WeblogCategory cat : cats) {
-				if (getCategoryId() == null && cat.getParent() == null) {
-					// Root folder so do not show the root /
-				} else if (!cat.getId().equals(getCategoryId())) {
-					allCategories.add(cat);
-				}
-			}
-
-			// build category path
-			WeblogCategory parent = getCategory().getParent();
-			if (parent != null) {
-				List categoryPath = new LinkedList();
-				categoryPath.add(0, getCategory());
-				while (parent != null) {
-					categoryPath.add(0, parent);
-					parent = parent.getParent();
-				}
-				setCategoryPath(categoryPath);
+			    allCategories.add(cat);
 			}
 		} catch (WebloggerException ex) {
 			log.error("Error building categories list", ex);
@@ -134,22 +91,6 @@ public class Categories extends UIAction
 		return execute();
 	}
 
-	public String getCategoryId() {
-		return categoryId;
-	}
-
-	public void setCategoryId(String categoryId) {
-		this.categoryId = categoryId;
-	}
-
-	public WeblogCategory getCategory() {
-		return category;
-	}
-
-	public void setCategory(WeblogCategory category) {
-		this.category = category;
-	}
-
 	public String[] getSelectedCategories() {
 		return selectedCategories;
 	}
@@ -173,13 +114,4 @@ public class Categories extends UIAction
 	public void setAllCategories(Set allCategories) {
 		this.allCategories = allCategories;
 	}
-
-	public List getCategoryPath() {
-		return categoryPath;
-	}
-
-	public void setCategoryPath(List categoryPath) {
-		this.categoryPath = categoryPath;
-	}
-
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java Thu Feb 13 23:34:12 2014
@@ -48,21 +48,18 @@ public class CategoryAdd extends UIActio
     
     // bean for managing form data
     private CategoryBean bean = new CategoryBean();
-    
-    
+
     public CategoryAdd() {
         this.actionName = "categoryAdd";
         this.desiredMenu = "editor";
         this.pageTitle = "categoryForm.add.title";
     }
-    
-    
+
     // author perms required
     public List<String> requiredWeblogPermissionActions() {
         return Collections.singletonList(WeblogPermission.ADMIN);
     }
-    
-    
+
     public void myPrepare() {
         try {
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
@@ -73,20 +70,12 @@ public class CategoryAdd extends UIActio
             log.error("Error looking up category", ex);
         }
     }
-    
-    
+
     /**
      * Show category form.
      */
     @SkipValidation
     public String execute() {
-        
-        if(getCategory() == null) {
-            // TODO: i18n
-            addError("Cannot add category to null parent category");
-            return ERROR;
-        }
-        
         return INPUT;
     }
 
@@ -95,13 +84,6 @@ public class CategoryAdd extends UIActio
      * Save new category.
      */
     public String save() {
-        
-        if(getCategory() == null) {
-            // TODO: i18n
-            addError("Cannot add category to null parent category");
-            return ERROR;
-        }
-        
         // validation
         myValidate();
         
@@ -110,14 +92,10 @@ public class CategoryAdd extends UIActio
 
                 WeblogCategory newCategory = new WeblogCategory(
                         getActionWeblog(),
-                        getCategory(),
                         getBean().getName(),
                         getBean().getDescription(),
                         getBean().getImage());
 
-                // add new folder to parent
-                getCategory().addCategory(newCategory);
-
                 // save changes
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
                 wmgr.saveWeblogCategory(newCategory);
@@ -141,19 +119,15 @@ public class CategoryAdd extends UIActio
         return INPUT;
     }
 
-    
-    // TODO: validation
     public void myValidate() {
-        
-        // name is required, has max length, no html
-        
+        // TODO: Check max length & no html
+
         // make sure new name is not a duplicate of an existing folder
-        if(getCategory().hasCategory(getBean().getName())) {
+        if(getActionWeblog().hasCategory(getBean().getName())) {
             addError("categoryForm.error.duplicateName", getBean().getName());
         }
     }
 
-    
     public String getCategoryId() {
         return categoryId;
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java Thu Feb 13 23:34:12 2014
@@ -139,8 +139,7 @@ public class CategoryEdit extends UIActi
         
         // make sure new name is not a duplicate of an existing category
         if(!getCategory().getName().equals(getBean().getName())) {
-            WeblogCategory parent = getCategory().getParent();
-            if(parent != null && parent.hasCategory(getBean().getName())) {
+            if(getCategory().getWeblog().hasCategory(getBean().getName())) {
                 addError("categoryForm.error.duplicateName", getBean().getName());
             }
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java Thu Feb 13 23:34:12 2014
@@ -90,7 +90,7 @@ public class CategoryRemove extends UIAc
         try {
             // Build list of all categories, except for current one, sorted by path.
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog(), false);
+            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog());
             for(WeblogCategory cat : cats) {
                 if (!cat.getId().equals(getRemoveId())) {
                     allCategoriesSet.add(cat);

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Entries.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Entries.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Entries.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Entries.java Thu Feb 13 23:34:12 2014
@@ -173,7 +173,7 @@ public class Entries extends UIAction {
         List<WeblogCategory> weblogCats = Collections.EMPTY_LIST;
         try {
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            weblogCats = wmgr.getWeblogCategories(getActionWeblog(), false);
+            weblogCats = wmgr.getWeblogCategories(getActionWeblog());
         } catch (WebloggerException ex) {
             log.error("Error getting category list for weblog - "+getWeblog(), ex);
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAdd.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAdd.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAdd.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAdd.java Thu Feb 13 23:34:12 2014
@@ -232,7 +232,7 @@ public final class EntryAdd extends Entr
 		try {
 			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
 					.getWeblogEntryManager();
-			return wmgr.getWeblogCategories(getActionWeblog(), false);
+			return wmgr.getWeblogCategories(getActionWeblog());
 		} catch (WebloggerException ex) {
 			log.error(
 					"Error getting category list for weblog - " + getWeblog(),

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java Thu Feb 13 23:34:12 2014
@@ -306,7 +306,7 @@ public class EntryBean {
             
             if(cat == null) {
                 throw new WebloggerException("Category could not be found - "+getCategoryId());
-            } else if(!entry.getWebsite().equals(cat.getWebsite())) {
+            } else if(!entry.getWebsite().equals(cat.getWeblog())) {
                 throw new WebloggerException("Illegal category, not owned by action weblog");
             } else {
                 entry.setCategory(cat);

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java Thu Feb 13 23:34:12 2014
@@ -318,7 +318,7 @@ public final class EntryEdit extends Ent
         try {
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
                     .getWeblogEntryManager();
-            return wmgr.getWeblogCategories(getActionWeblog(), false);
+            return wmgr.getWeblogCategories(getActionWeblog());
         } catch (WebloggerException ex) {
             log.error(
                     "Error getting category list for weblog - " + getWeblog(),

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.java Thu Feb 13 23:34:12 2014
@@ -79,7 +79,7 @@ public class WeblogConfig extends UIActi
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
             
             // set categories list
-            setWeblogCategories(wmgr.getWeblogCategories(getActionWeblog(), false));
+            setWeblogCategories(wmgr.getWeblogCategories(getActionWeblog()));
             
             // set the Editor Page list
             UIPluginManager pmgr = RollerContext.getUIPluginManager();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfigBean.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfigBean.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfigBean.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/WeblogConfigBean.java Thu Feb 13 23:34:12 2014
@@ -54,7 +54,6 @@ public class WeblogConfigBean {
     private String about = null;
     
     private String bloggerCategoryId = null;
-    private String defaultCategoryId = null;
     private String[] defaultPluginsArray = null;
     private boolean applyCommentDefaults = false;
     
@@ -246,15 +245,7 @@ public class WeblogConfigBean {
     public void setBloggerCategoryId(String bloggerCategoryId) {
         this.bloggerCategoryId = bloggerCategoryId;
     }
-    
-    public String getDefaultCategoryId() {
-        return defaultCategoryId;
-    }
-    
-    public void setDefaultCategoryId(String defeaultCategoryId) {
-        this.defaultCategoryId = defeaultCategoryId;
-    }
-    
+
     public String[] getDefaultPluginsArray() {
         return defaultPluginsArray;
     }
@@ -307,10 +298,6 @@ public class WeblogConfigBean {
         this.pageModels = dataHolder.getPageModels();
         setIcon(dataHolder.getIconPath());
         setAbout(dataHolder.getAbout());
-        
-        if (dataHolder.getDefaultCategory() != null) {
-            defaultCategoryId = dataHolder.getDefaultCategory().getId();
-        }
         if (dataHolder.getBloggerCategory() != null) {
             bloggerCategoryId = dataHolder.getBloggerCategory().getId();
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java Thu Feb 13 23:34:12 2014
@@ -91,7 +91,7 @@ public class RollerAtomService extends A
                     Categories cats = new Categories();
                     cats.setFixed(true);
                     cats.setScheme(getWeblogCategoryScheme(weblog));
-                    List<WeblogCategory> rollerCats = roller.getWeblogEntryManager().getWeblogCategories(weblog, false);
+                    List<WeblogCategory> rollerCats = roller.getWeblogEntryManager().getWeblogCategories(weblog);
                     for (WeblogCategory rollerCat : rollerCats) {
                         Category cat = new Category();
                         cat.setTerm(rollerCat.getName());

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java Thu Feb 13 23:34:12 2014
@@ -84,7 +84,7 @@ public class MetaWeblogAPIHandler extend
         try {
             Hashtable result = new Hashtable();
             WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
-            List<WeblogCategory> cats = weblogMgr.getWeblogCategories(website, false);
+            List<WeblogCategory> cats = weblogMgr.getWeblogCategories(website);
             for (WeblogCategory category : cats) {
                 result.put(category.getName(),
                         createCategoryStruct(category, userid));
@@ -502,11 +502,11 @@ public class MetaWeblogAPIHandler extend
         Weblogger roller = WebloggerFactory.getWeblogger();
         URLStrategy strategy = roller.getUrlStrategy();
         
-        String catUrl = strategy.getWeblogCollectionURL(category.getWebsite(),
+        String catUrl = strategy.getWeblogCollectionURL(category.getWeblog(),
         		null, category.getName(), null, null, 0, true);
         struct.put("htmlUrl", catUrl);
         
-        String rssUrl = strategy.getWeblogFeedURL(category.getWebsite(),
+        String rssUrl = strategy.getWeblogFeedURL(category.getWeblog(),
                null, "entries", "rss", category.getName(), null, null, false, true);
         struct.put("rssUrl",rssUrl);
         

Modified: roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml (original)
+++ roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml Thu Feb 13 23:34:12 2014
@@ -33,33 +33,11 @@
 			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1
                                                ORDER BY w.dateCreated DESC</query>
 		</named-query>
-		<!--
-        <named-query name="Weblog.getByEndDate&amp;StartDate&amp;Enabled&amp;Permissions.user&amp;Permissions.pendingOrderByDateCreatedDesc">
-			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1 AND w.dateCreated &gt; ?2
-                                                 AND w.enabled = ?3
-                                                 AND EXISTS (SELECT p from WeblogPermission p where
-                                                         p.weblog = w
-                                                         AND p.user = ?4
-                                                         AND p.pending = ?5 )
-                                               ORDER BY w.dateCreated DESC</query>
-		</named-query>
-        -->
 		<named-query name="Weblog.getByEndDate&amp;StartDate&amp;ActiveOrderByDateCreatedDesc">
 			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1 AND w.dateCreated &gt; ?2
                                                  AND w.active = ?3
                                                ORDER BY w.dateCreated DESC</query>
 		</named-query>
-		<!--
-        <named-query name="Weblog.getByEndDate&amp;Enabled&amp;Active&amp;Permissions.user&amp;Permissions.pendingOrderByDateCreatedDesc">
-			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1
-                                                AND w.enabled = ?2 AND w.active = ?3
-                                                AND EXISTS (SELECT p from WeblogPermission p where
-                                                           p.weblog = w
-                                                           AND p.user = ?4
-                                                           AND p.pending = ?5 )
-                                             ORDER BY w.dateCreated DESC</query>
-		</named-query>
-        -->
 		<named-query name="Weblog.getByEndDate&amp;Enabled&amp;ActiveOrderByDateCreatedDesc">
 			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1
                                                  AND w.enabled = ?2 AND w.active = ?3
@@ -76,16 +54,6 @@
                                                  AND w.active = ?2
                                                ORDER BY w.dateCreated DESC</query>
 		</named-query>
-		<!--
-        <named-query name="Weblog.getByEndDate&amp;Permissions.user&amp;Permissions.pendingOrderByDateCreatedDesc">
-			<query>SELECT w FROM Weblog w WHERE w.dateCreated &lt; ?1
-                                                AND EXISTS (SELECT p from WeblogPermission p where
-                                                        p.weblog = w
-                                                        AND p.user = ?2
-                                                        AND p.pending = ?3 )
-                                              ORDER BY w.dateCreated DESC</query>
-		</named-query>
-        -->
 		<named-query name="Weblog.getCountAllDistinct">
 			<!-- DISTINCT is not required here -->
             <query>SELECT COUNT(w) FROM Weblog w</query>
@@ -195,10 +163,11 @@
 			<many-to-one name="bloggerCategory" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory">
 				<join-column name="bloggercatid" insertable="true" updatable="true"/>
 			</many-to-one>
-			<many-to-one name="defaultCategory" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory">
-				<join-column name="defaultcatid" insertable="true" updatable="true"/>
-			</many-to-one>
-
+            <one-to-many name="weblogCategories" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory" mapped-by="weblog" fetch="EAGER">
+                <cascade>
+                    <cascade-remove/>
+                </cascade>
+            </one-to-many>
 			<transient name="theme"/>
 			<transient name="creator"/>
 			<transient name="defaultPage"/>
@@ -212,7 +181,7 @@
 			<transient name="userCount"/>
 			<transient name="entryCount"/>
             <transient name="initializedPlugins"/>
-            <transient name="weblogCategories"/>
+            <transient name="defaultCategory"/>
             <transient name="localeInstance"/>
             <transient name="timeZoneInstance" />
 		</attributes>

Modified: roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml (original)
+++ roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml Thu Feb 13 23:34:12 2014
@@ -7,20 +7,14 @@
     <entity metadata-complete="true" name="WeblogCategory"
             class="org.apache.roller.weblogger.pojos.WeblogCategory" access="PROPERTY">
         <table name="weblogcategory"/>
-        <named-query name="WeblogCategory.getByName&amp;Website">
-                <query>SELECT w FROM WeblogCategory w WHERE w.name = ?1 AND w.website = ?2</query>
+        <named-query name="WeblogCategory.getByWeblog">
+                <query>SELECT w FROM WeblogCategory w WHERE w.weblog = ?1</query>
         </named-query>
-        <named-query name="WeblogCategory.getByWebsite">
-                <query>SELECT w FROM WeblogCategory w WHERE w.website = ?1</query>
+        <named-query name="WeblogCategory.getByWeblog&amp;Name">
+            <query>SELECT w FROM WeblogCategory w WHERE w.weblog = ?1 AND w.name = ?2</query>
         </named-query>
-        <named-query name="WeblogCategory.getByWebsite&amp;ParentNull">
-                <query>SELECT w FROM WeblogCategory w WHERE w.website = ?1 AND w.parent IS NULL</query>
-        </named-query>
-        <named-query name="WeblogCategory.getByWebsite&amp;ParentNotNull">
-                <query>SELECT w FROM WeblogCategory w WHERE w.website = ?1 AND w.parent IS NOT NULL</query>
-        </named-query>
-        <named-query name="WeblogCategory.removeByWebsite">
-            <query>DELETE FROM WeblogCategory w WHERE w.website = ?1</query>
+        <named-query name="WeblogCategory.removeByWeblog">
+            <query>DELETE FROM WeblogCategory w WHERE w.weblog = ?1</query>
         </named-query>
         <attributes>
             <id name="id">
@@ -35,18 +29,10 @@
             <basic name="image">
                 <column name="image" insertable="true" updatable="true" unique="false"/>
             </basic>
-            <many-to-one name="website" target-entity="org.apache.roller.weblogger.pojos.Weblog">
+            <many-to-one name="weblog" target-entity="org.apache.roller.weblogger.pojos.Weblog">
                 <join-column name="websiteid" insertable="true" updatable="true" nullable="false"/>
             </many-to-one>
-            <many-to-one name="parent" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory">
-                <join-column name="parentid" insertable="true" updatable="true" nullable="true"/>
-            </many-to-one>
-            <one-to-many name="weblogCategories" mapped-by="parent" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory" fetch="LAZY">
-                <cascade>
-                    <cascade-remove/>
-                </cascade>
-            </one-to-many>
-            <transient name="inUse"/> 
+            <transient name="inUse"/>
         </attributes>
     </entity>
 </entity-mappings>

Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/Categories.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/Categories.jsp?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/Categories.jsp (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/Categories.jsp Thu Feb 13 23:34:12 2014
@@ -59,7 +59,7 @@ function onMove()
         <s:if test="AllCategories != null && !AllCategories.isEmpty">
         
         <%-- Categories --%>
-        <s:iterator id="category" value="category.weblogCategories" status="rowstatus">
+        <s:iterator id="category" value="AllCategories" status="rowstatus">
             <s:if test="#rowstatus.odd == true">
                 <tr class="rollertable_odd">
             </s:if>
@@ -84,7 +84,7 @@ function onMove()
                 </td>
                 
                 <td class="rollertable" align="center">
-                    <s:if test="!categoryPath.isEmpty || category.weblogCategories.size() > 1">
+                    <s:if test="AllCategories.size() > 1">
                         <s:url id="removeUrl" action="categoryRemove">
                             <s:param name="weblog" value="%{actionWeblog.handle}" />
                             <s:param name="removeId" value="#category.id" />

Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryEdit.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryEdit.jsp?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryEdit.jsp (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryEdit.jsp Thu Feb 13 23:34:12 2014
@@ -31,8 +31,8 @@
     <s:hidden name="bean.id" />
     
     <%-- if we cancel then we need this attribute --%>
-    <s:hidden name="categoryId" value="%{category.parent.id}" />
-    
+    <s:hidden name="categoryId" value="%{category.website.defaultCategory.id}" />
+
     <table>
         
         <tr>

Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp Thu Feb 13 23:34:12 2014
@@ -28,8 +28,8 @@
     <s:hidden name="removeId" />
     
     <%-- if we cancel then we need this attribute --%>
-    <s:hidden name="categoryId" value="%{category.parent.id}" />
-    
+    <s:hidden name="categoryId" value="%{category.website.defaultCategory.id}" />
+
     <s:if test="category.inUse" >
         <br />
         <span class="warning">

Modified: roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm Thu Feb 13 23:34:12 2014
@@ -560,11 +560,11 @@ Show weblog's categories in specified pa
     #if(!$expanding && !$subcats)
         <ul class="rCategory">
         #if ($model.weblogCategory || $model.permalink)
-            <li><a href="$url.category($categoryObject.name)">$text.get("macro.weblog.allcategories")</a></li>
+            <li><a href="$url.home">$text.get("macro.weblog.allcategories")</a></li>
         #else
-            <li class="selected"><a href="$url.category($categoryObject.name)">$text.get("macro.weblog.allcategories")</a></li>
+            <li class="selected"><a href="$url.home">$text.get("macro.weblog.allcategories")</a></li>
         #end
-        #set($cats = $categoryObject.getWeblogCategories())
+        #set($cats = $categoryObject.website.getWeblogCategories())
         #foreach($cat in $cats)
             #if ($model.weblogCategory && $model.weblogCategory.name == $cat.name || ($model.permalink && $model.weblogEntry.category.name == $cat.name))
                 <li class="selected"><a href="$url.category($cat.name)">$cat.name</a></li>
@@ -588,12 +588,12 @@ Show weblog's categories in specified pa
           <h2>Categories</h2>
           <ul data-role="listview">
             #if ($model.weblogCategory || $model.permalink)
-              <li><a href="$url.category($categoryObject.name)" data-transition="fade">$text.get("macro.weblog.allcategories")</a></li>
+              <li><a href="$url.home" data-transition="fade">$text.get("macro.weblog.allcategories")</a></li>
             #else
-              <li class="ui-btn-active"><a href="$url.category($categoryObject.name)" data-transition="fade">$text.get("macro.weblog.allcategories")</a></li>
+              <li class="ui-btn-active"><a href="$url.home" data-transition="fade">$text.get("macro.weblog.allcategories")</a></li>
             #end
             #set($active = $text.get("macro.weblog.allcategories"))
-            #set($cats = $categoryObject.getWeblogCategories())
+            #set($cats = $categoryObject.website.getWeblogCategories())
             #foreach($cat in $cats)
               #if ($model.weblogCategory && $model.weblogCategory.name == $cat.name || ($model.permalink && $model.weblogEntry.category.name == $cat.name))
                 <li class="ui-btn-active"><a href="$url.category($cat.name)" data-transition="fade">$cat.name</a></li>

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java (original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java Thu Feb 13 23:34:12 2014
@@ -18,11 +18,9 @@
 
 package org.apache.roller.weblogger.business;
 
-import java.util.List;
 import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.TestUtils;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
@@ -87,15 +85,12 @@ public class WeblogCategoryCRUDTest exte
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        WeblogCategory testCat = new WeblogCategory(testWeblog, null, "root", "root", null);
-        assertTrue(root.equals(testCat));
-        mgr.removeWeblogCategory(testCat);
 
-        testCat = new WeblogCategory(testWeblog, root, "other name", "root", null);
-        assertFalse(root.equals(testCat));
+        WeblogCategory testCat = new WeblogCategory(testWeblog, "root", "desc", null);
+        WeblogCategory testCat2 = new WeblogCategory(testWeblog, "root2", "desc2", null);
+        assertFalse(testCat2.equals(testCat));
         mgr.removeWeblogCategory(testCat);
+        mgr.removeWeblogCategory(testCat2);
 
         log.info("END");
     }
@@ -110,17 +105,15 @@ public class WeblogCategoryCRUDTest exte
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         WeblogCategory cat = null;
-        List cats = null;
-        
+
         // root category is always available
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        // make sure we are starting with 0 categories (beneath root)
-        assertEquals(0, root.getWeblogCategories().size());
-        
+
+        // make sure we are starting with 1 categories
+        assertEquals(1, testWeblog.getWeblogCategories().size());
+
         // add a new category
-        WeblogCategory newCat = new WeblogCategory(testWeblog, root, "catTestCategory", null, null);
+        WeblogCategory newCat = new WeblogCategory(testWeblog, "catTestCategory", null, null);
         mgr.saveWeblogCategory(newCat);
         TestUtils.endSession(true);
         
@@ -132,24 +125,24 @@ public class WeblogCategoryCRUDTest exte
         
         // make sure category count increased
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        
+        assertEquals(2, testWeblog.getWeblogCategories().size());
+
         // update category
         cat.setName("testtest");
         mgr.saveWeblogCategory(cat);
         TestUtils.endSession(true);
-        
+
         // verify category was updated
         cat = null;
         cat = mgr.getWeblogCategory(newCat.getId());
         assertNotNull(cat);
         assertEquals("testtest", cat.getName());
-        
+        assertEquals(2, testWeblog.getWeblogCategories().size());
+
         // remove category
         mgr.removeWeblogCategory(cat);
         TestUtils.endSession(true);
-        
+
         // make sure cat was removed
         cat = null;
         cat = mgr.getWeblogCategory(newCat.getId());
@@ -157,8 +150,7 @@ public class WeblogCategoryCRUDTest exte
         
         // make sure category count decreased
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(0, root.getWeblogCategories().size());
+        assertEquals(1, testWeblog.getWeblogCategories().size());
         
         log.info("END");
     }
@@ -175,31 +167,27 @@ public class WeblogCategoryCRUDTest exte
         
         // root category is always available
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        // add a category child item /subcat
-        WeblogCategory subcat = new WeblogCategory(testWeblog, root, "subcatTest1", null, null);
-        root.addCategory(subcat);
-        mgr.saveWeblogCategory(subcat);
+
+        // add a category above default one
+        WeblogCategory testCat = new WeblogCategory(testWeblog, "SampleCategory", null, null);
+        mgr.saveWeblogCategory(testCat);
         TestUtils.endSession(true);
         
-        // check that subcat tree can be navigated
+        // check that testCat can be retrieved
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        subcat = (WeblogCategory) root.getWeblogCategories().iterator().next();
-        assertEquals("subcatTest1", subcat.getName());
-        assertEquals(0, subcat.getWeblogCategories().size());
+
+        assertEquals(2, testWeblog.getWeblogCategories().size());
+        testCat = testWeblog.getWeblogCategories().get(1);
+        assertEquals("SampleCategory", testCat.getName());
 
         // now delete category and subcats should be deleted by cascade
-        mgr.removeWeblogCategory(subcat);
+        mgr.removeWeblogCategory(testCat);
         TestUtils.endSession(true);
         
         // verify cascading delete succeeded
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(0, root.getWeblogCategories().size());
-        assertNull(mgr.getWeblogCategoryByName(TestUtils.getManagedWebsite(testWeblog), "subcatTest1"));
+        assertEquals(1, testWeblog.getWeblogCategories().size());
+        assertNull(mgr.getWeblogCategoryByName(TestUtils.getManagedWebsite(testWeblog), "SampleCategory"));
         
         log.info("END");
     }

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java?rev=1568146&r1=1568145&r2=1568146&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java (original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java Thu Feb 13 23:34:12 2014
@@ -60,13 +60,13 @@ public class WeblogCategoryFunctionality
             testUser = TestUtils.setupUser("categoryTestUser");
             testWeblog = TestUtils.setupWeblog("categoryTestWeblog", testUser);
             
-            // setup a category tree to use for testing
-            cat1 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat1", null);
-            cat2 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat2", cat1);
-            cat3 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat3", cat2);
+            // setup several categories for testing
+            cat1 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat1");
+            cat2 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat2");
+            cat3 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat3");
             
             // a simple test cat at the root level
-            testCat = TestUtils.setupWeblogCategory(testWeblog, "catTest-testCat", null);
+            testCat = TestUtils.setupWeblogCategory(testWeblog, "catTest-testCat");
             
             TestUtils.endSession(true);
         } catch (Throwable t) {
@@ -90,71 +90,16 @@ public class WeblogCategoryFunctionality
         
         log.info("END");
     }
-    
-    
-    /**
-     * Test that we can walk a category tree.
-     */
-    public void testWalkCategoryTree() throws Exception {
-        
-        log.info("BEGIN");
-        
-        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        
-        // start at root
-        WeblogCategory root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
-        
-        // walk first level
-        Set cats = root.getWeblogCategories();
-        assertEquals(2, cats.size());
-        assertTrue(cats.contains(testCat));
-        
-        // find cat1
-        WeblogCategory cat = null;
-        for(Iterator it = cats.iterator(); it.hasNext(); ) {
-            cat = (WeblogCategory) it.next();
-            if(cat.getName().equals(cat1.getName())) {
-                break;
-            }
-        }
-        
-        // walk second level
-        cats = cat.getWeblogCategories();
-        assertEquals(1, cats.size());
-        assertTrue(cats.contains(cat2));
-        
-        // find cat2
-        cat = (WeblogCategory) cats.iterator().next();
-        
-        // walk third level
-        cats = cat.getWeblogCategories();
-        assertEquals(1, cats.size());
-        assertTrue(cats.contains(cat3));
-        
-        // find cat3
-        cat = (WeblogCategory) cats.iterator().next();
-        
-        // make sure this is the end of the tree
-        cats = cat.getWeblogCategories();
-        assertEquals(0, cats.size());
-        
-        log.info("END");
-    }
-    
-    
+
     /**
      * Test the hasCategory() method on WeblogCategory.
      */
     public void testHasCategory() throws Exception {
         
         log.info("BEGIN");
-        
-        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        
-        WeblogCategory root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
-        
+
         // check that root has category
-        assertTrue(root.hasCategory(testCat.getName()));
+        assertTrue(testWeblog.hasCategory(testCat.getName()));
         
         log.info("END");
     }
@@ -213,17 +158,11 @@ public class WeblogCategoryFunctionality
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
-        // including root
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        List cats = mgr.getWeblogCategories(testWeblog, true);
+        List cats = mgr.getWeblogCategories(testWeblog);
         assertNotNull(cats);
         assertEquals(5, cats.size());
         
-        // not including root
-        cats = mgr.getWeblogCategories(testWeblog, false);
-        assertNotNull(cats);
-        assertEquals(4, cats.size());
-        
         log.info("END");
     }
 
@@ -235,40 +174,27 @@ public class WeblogCategoryFunctionality
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         WeblogEntry e1 = null;
         WeblogEntry e2 = null; 
-        WeblogEntry e3 = null;
-        WeblogEntry e4 = null;
         try {
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
             testUser = TestUtils.getManagedUser(testUser);
-            WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
 
             // add some categories and entries to test with
-            WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
-            mgr.saveWeblogCategory(dest);
-
-            WeblogCategory c1 = new WeblogCategory(testWeblog, root, "c1", null, null);
+            WeblogCategory c1 = new WeblogCategory(testWeblog, "c1", null, null);
             mgr.saveWeblogCategory(c1);
 
-            WeblogCategory c2 = new WeblogCategory(testWeblog, c1, "c2", null, null);
-            mgr.saveWeblogCategory(c2);
-
-            WeblogCategory c3 = new WeblogCategory(testWeblog, c2, "c3", null, null);
-            mgr.saveWeblogCategory(c3);
+            WeblogCategory dest = new WeblogCategory(testWeblog, "dest", null, null);
+            mgr.saveWeblogCategory(dest);
 
             TestUtils.endSession(true);
 
             c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
             dest = mgr.getWeblogCategory(dest.getId());
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
             testUser = TestUtils.getManagedUser(testUser);
             e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
             e2 = TestUtils.setupWeblogEntry("e2", c1, WeblogEntry.DRAFT, testWeblog, testUser);
-            e3 = TestUtils.setupWeblogEntry("e3", c2, testWeblog, testUser);
-            e4 = TestUtils.setupWeblogEntry("e4", c3, testWeblog, testUser);
 
             TestUtils.endSession(true);
 
@@ -301,8 +227,6 @@ public class WeblogCategoryFunctionality
         } finally {
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e1));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e2));
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e3));
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e4));
         }
         
         log.info("END");



Mime
View raw message