roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r500032 - in /incubator/roller/trunk: src/org/apache/roller/pojos/FolderData.java tests/org/apache/roller/business/BookmarkTest.java
Date Thu, 25 Jan 2007 22:46:31 GMT
Author: agilliland
Date: Thu Jan 25 14:46:30 2007
New Revision: 500032

URL: http://svn.apache.org/viewvc?view=rev&rev=500032
Log:
add method hasFolder(name) to folder pojo to check if a given folder has the named child folder.
 unit test included.


Modified:
    incubator/roller/trunk/src/org/apache/roller/pojos/FolderData.java
    incubator/roller/trunk/tests/org/apache/roller/business/BookmarkTest.java

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/FolderData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/FolderData.java?view=diff&rev=500032&r1=500031&r2=500032
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/FolderData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/FolderData.java Thu Jan 25 14:46:30
2007
@@ -19,6 +19,7 @@
 package org.apache.roller.pojos;
 
 import java.io.Serializable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -298,6 +299,25 @@
     public List retrieveBookmarks(boolean subfolders) throws RollerException {
         BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
         return bmgr.getBookmarks(this, subfolders);
+    }
+    
+    
+    /**
+     * Does this folder have a child folder with the specified name?
+     *
+     * @param name The name of the folder to check for.
+     * @return boolean true if child folder exists, false otherwise.
+     */
+    public boolean hasFolder(String name) {
+        Iterator folders = this.getFolders().iterator();
+        FolderData folder = null;
+        while(folders.hasNext()) {
+            folder = (FolderData) folders.next();
+            if(name.equals(folder.getName())) {
+                return true;
+            }
+        }
+        return false;
     }
     
     

Modified: incubator/roller/trunk/tests/org/apache/roller/business/BookmarkTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/BookmarkTest.java?view=diff&rev=500032&r1=500031&r2=500032
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/BookmarkTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/BookmarkTest.java Thu Jan 25 14:46:30
2007
@@ -195,6 +195,27 @@
     
     
     /**
+     * Test the hasFolder() method on FolderData.
+     */
+    public void testHasFolder() throws Exception {
+        
+        BookmarkManager bmgr = getRoller().getBookmarkManager();
+        
+        FolderData root = bmgr.getRootFolder(testWeblog);
+        
+        // add a test folder
+        FolderData f1 = new FolderData(root, "f1", null, TestUtils.getManagedWebsite(testWeblog));
+        bmgr.saveFolder(f1);
+        
+        TestUtils.endSession(true);
+        
+        // check that root has category c1
+        root = bmgr.getRootFolder(testWeblog);
+        assertTrue(root.hasFolder("f1"));
+    }
+    
+    
+    /**
      * Test all folder lookup methods.
      */
     public void testFolderLookups() throws Exception {



Mime
View raw message