roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1588757 [2/25] - in /roller/branches/rome2/app/src: main/java/org/apache/roller/ main/java/org/apache/roller/planet/business/ main/java/org/apache/roller/planet/business/fetcher/ main/java/org/apache/roller/planet/business/jpa/ main/java/o...
Date Sun, 20 Apr 2014 13:39:01 GMT
Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java Sun Apr 20 13:38:51 2014
@@ -27,7 +27,7 @@ import org.apache.roller.util.UUIDGenera
 /**
  * Planet Subscription.
  */
-public class Subscription implements Serializable, Comparable {
+public class Subscription implements Serializable, Comparable<Subscription> {
     
     // attributes
     private String id = UUIDGenerator.generateUUID();
@@ -38,10 +38,10 @@ public class Subscription implements Ser
     private Date lastUpdated;
     private int inboundlinks = 0;
     private int inboundblogs = 0;
-    
+
     // associations
-    private Set groups = new HashSet();
-    private Set entries = new HashSet();
+    private Set<PlanetGroup> groups = new HashSet<PlanetGroup>();
+    private Set<SubscriptionEntry> entries = new HashSet<SubscriptionEntry>();
     
     
     public Subscription() {}
@@ -51,8 +51,7 @@ public class Subscription implements Ser
      * This ensures that feeds are sorted by title, but that identical titles 
      * don't make feeds equal.
      */
-    public int compareTo(Object o) {
-        Subscription other = (Subscription) o;
+    public int compareTo(Subscription other) {
         String otherString = other.getTitle() + other.getFeedURL();
         String thisString = getTitle() + getFeedURL();
         return thisString.compareTo(otherString);
@@ -78,7 +77,7 @@ public class Subscription implements Ser
     
     public String toString() {
         StringBuilder buf = new StringBuilder();
-        
+
         buf.append("{");
         buf.append(getFeedURL()).append(", ");
         buf.append(getSiteURL()).append(", ");
@@ -88,7 +87,6 @@ public class Subscription implements Ser
         buf.append("}");
         
         return buf.toString();
-        
     }
     
     
@@ -145,41 +143,41 @@ public class Subscription implements Ser
         this.lastUpdated = lastUpdated;
     }
     
-    
+
     public int getInboundlinks() {
         return inboundlinks;
     }
-    
+
     public void setInboundlinks(int inboundlinks) {
         this.inboundlinks = inboundlinks;
     }
-    
-    
+
+
     public int getInboundblogs() {
         return inboundblogs;
     }
-    
+
     public void setInboundblogs(int inboundblogs) {
         this.inboundblogs = inboundblogs;
     }
-    
-    
-    public Set getGroups() {
+
+
+    public Set<PlanetGroup> getGroups() {
         return groups;
     }
     
     // private because there is no need for people to do this
-    private void setGroups(Set groups) {
+    private void setGroups(Set<PlanetGroup> groups) {
         this.groups = groups;
     }
+
     
-    
-    public Set getEntries() {
+    public Set<SubscriptionEntry> getEntries() {
         return entries;
     }
     
     // private because there is no need for people to do this
-    private void setEntries(Set entries) {
+    private void setEntries(Set<SubscriptionEntry> entries) {
         this.entries = entries;
     }
     
@@ -203,8 +201,8 @@ public class Subscription implements Ser
         }
         this.getEntries().addAll(newEntries);
     }
-    
-    
+
+
     // for backwards compatability?
     public String getName() {
         return getTitle();

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java Sun Apr 20 13:38:51 2014
@@ -35,7 +35,7 @@ import org.apache.roller.util.UUIDGenera
  * it should be replaced by more complete model that can fully represent all 
  * forms of RSS and Atom.
  */
-public class SubscriptionEntry implements Serializable, Comparable {
+public class SubscriptionEntry implements Serializable, Comparable<SubscriptionEntry> {
     
     // attributes
     private String id = UUIDGenerator.generateUUID();
@@ -59,8 +59,7 @@ public class SubscriptionEntry implement
     /**
      * Compare planet entries by comparing permalinks.
      */
-    public int compareTo(Object o) {
-        SubscriptionEntry other = (SubscriptionEntry)o;
+    public int compareTo(SubscriptionEntry other) {
         return getPermalink().compareTo(other.getPermalink());
     }
     
@@ -192,9 +191,8 @@ public class SubscriptionEntry implement
      * (case-insensitive comparison).
      */
     public boolean inCategory(String category) {
-        Iterator cats = getCategories().iterator();
-        while (cats.hasNext()) {
-            String catName = ((String)cats.next()).toLowerCase();
+        for (Category cat : getCategories()) {
+            String catName = cat.getName().toLowerCase();
             if (catName.contains(category.toLowerCase())) {
                 return true;
             }
@@ -207,14 +205,13 @@ public class SubscriptionEntry implement
     /**
      * Returns categories as list of WeblogCategoryData objects.
      */
-    public List getCategories() {
-        List list = new ArrayList();
+    public List<Category> getCategories() {
+        List<Category> list = new ArrayList<Category>();
         if (getCategoriesString() != null) {
             String[] catArray = Utilities.stringToStringArray(getCategoriesString(),",");
-            for (int i=0; i<catArray.length; i++) {
+            for (String catName : catArray) {
                 Category cat = new Category();
-                cat.setName(catArray[i]);
-                cat.setPath(catArray[i]);
+                cat.setName(catName);
                 list.add(cat);
             }
         }
@@ -233,12 +230,12 @@ public class SubscriptionEntry implement
         return cat;
     }
 
-    public void setCategoriesString(List categories) {
+    public void setCategoriesString(List<String> categoryNames) {
         StringBuilder sb = new StringBuilder();
-        Iterator cats = categories.iterator();
+        Iterator cats = categoryNames.iterator();
         while (cats.hasNext()) {
-            String cat = (String)cats.next();
-            sb.append(cat);
+            String catName = (String) cats.next();
+            sb.append(catName);
             if (cats.hasNext()) {
                 sb.append(",");
             }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java Sun Apr 20 13:38:51 2014
@@ -19,14 +19,9 @@
 package org.apache.roller.planet.tasks;
 
 import java.io.File;
-import java.util.Collections;
 import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.business.Weblogger;
-import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.util.Utilities;
 //import org.apache.roller.util.UtilitiesModel;
@@ -50,8 +45,7 @@ public class GeneratePlanetTask extends 
     
     public void run() {
         try {            
-            Weblogger weblogger = WebloggerFactory.getWeblogger();
-//          PlanetManager planetManager = weblogger.getPlanetManager();
+//          PlanetManager planetManager = WebloggerFactory.getWeblogger().getPlanetManager();
                         
             // Ignore values from database
             //String mainPage = planetManager.getConfiguration().getMainPage();
@@ -93,18 +87,6 @@ public class GeneratePlanetTask extends 
                 outputDirObj.mkdirs();
             }
             
-            List groups = Collections.EMPTY_LIST;
-            // groups must be part of a planet now, so getGroupHandles() was removed
-            //List groups = planetManager.getGroupHandles();
-            for (Iterator it = groups.iterator(); it.hasNext();) {
-                String groupHandle = (String) it.next();
-                String groupDirName = outputDirObj + File.separator + groupHandle;
-                File groupDir = new File(groupDirName);
-                if (!groupDir.exists()) {
-                    groupDir.mkdirs();
-                }
-            }
-            
             // Generate files: execute control template
             Generator generator = Generator.getInstance();
             generator.setVelocityEngine(engine);

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/StaticPlanetModel.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/StaticPlanetModel.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/tasks/StaticPlanetModel.java Sun Apr 20 13:38:51 2014
@@ -18,14 +18,12 @@
 package org.apache.roller.planet.tasks;
 
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.planet.pojos.Subscription;
+import org.apache.roller.planet.pojos.SubscriptionEntry;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 
@@ -34,7 +32,6 @@ import org.apache.roller.weblogger.busin
  * to be duck-type compatible with old PlanetTool templates.
  */
 public class StaticPlanetModel {
-    private static Log logger = LogFactory.getFactory().getInstance(StaticPlanetModel.class);
     PlanetManager planetManager = null;
     
     
@@ -54,13 +51,13 @@ public class StaticPlanetModel {
     }
     
     
-    public List getFeedEntries(String feedUrl, int maxEntries) throws Exception {
+    public List<SubscriptionEntry> getFeedEntries(String feedUrl, int maxEntries) throws Exception {
         try {
             Subscription sub = planetManager.getSubscription(feedUrl);
             if(sub != null) {
                 return planetManager.getEntries(sub, 0, maxEntries);
             } else {
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -68,28 +65,11 @@ public class StaticPlanetModel {
         }
     }
        
-    // removed now that groups must be part of a planet, this method no longer makes sense
-//    public List getGroups() throws RollerException {
-//        return planetManager.getGroups();
-//    }
-    
-    // removed now that groups must be part of a planet, this method no longer makes sense
-//    public PlanetGroup getGroup(String handle) throws RollerException {
-//        return planetManager.getGroup(handle);
-//    }
-    
-    
     public List getAggregation(
             PlanetGroup group, int maxEntries) throws RollerException {
         return planetManager.getEntries(group, 0, maxEntries);
     }
     
-    
-    public Iterator getAllSubscriptions() throws RollerException {
-        return planetManager.getSubscriptions().iterator();
-    }
-    
-    
     public int getSubscriptionCount() throws RollerException {
         return planetManager.getSubscriptionCount();
     } 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/MailUtil.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/MailUtil.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/MailUtil.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/MailUtil.java Sun Apr 20 13:38:51 2014
@@ -29,7 +29,7 @@ import javax.mail.Address;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 public class MailUtil extends Object {
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/rome/ContentModuleImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/rome/ContentModuleImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/rome/ContentModuleImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/util/rome/ContentModuleImpl.java Sun Apr 20 13:38:51 2014
@@ -20,19 +20,18 @@ import com.sun.syndication.feed.CopyFrom
 import com.sun.syndication.feed.module.ModuleImpl;
 
 public class ContentModuleImpl extends ModuleImpl implements ContentModule {
-	private static final long serialVersionUID = 1L;
-    private String _encoded;
+    private String encoded;
 
     public ContentModuleImpl() {
         super(ContentModule.class,ContentModule.URI);
     }
 	@Override
     public String getEncoded() {
-        return _encoded;
+        return encoded;
     }
 	@Override
     public void setEncoded(String encoded) {
-        _encoded = encoded;
+        this.encoded = encoded;
     }
 	@Override
     public Class getInterface() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/util/DateUtil.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/util/DateUtil.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/util/DateUtil.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/util/DateUtil.java Sun Apr 20 13:38:51 2014
@@ -25,7 +25,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 
 /**

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/util/UUIDGenerator.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/util/UUIDGenerator.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/util/UUIDGenerator.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/util/UUIDGenerator.java Sun Apr 20 13:38:51 2014
@@ -24,7 +24,7 @@ import java.util.UUID;
 /**
  * Generates UUID values.
  */
-public class UUIDGenerator {
+public final class UUIDGenerator {
     
     // non-instantiable
     private UUIDGenerator() {}

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/TestUtils.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/TestUtils.java Sun Apr 20 13:38:51 2014
@@ -23,19 +23,28 @@
 
 package org.apache.roller.weblogger;
 
+import java.io.InputStream;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.planet.pojos.Subscription;
 import org.apache.roller.planet.pojos.SubscriptionEntry;
 import org.apache.roller.weblogger.business.BookmarkManager;
+import org.apache.roller.weblogger.business.DatabaseProvider;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.pings.AutoPingManager;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
+import org.apache.roller.weblogger.business.startup.ClasspathDatabaseScriptProvider;
+import org.apache.roller.weblogger.business.startup.SQLScriptRunner;
 import org.apache.roller.weblogger.business.startup.WebloggerStartup;
+import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.pojos.AutoPing;
 import org.apache.roller.weblogger.pojos.PingTarget;
 import org.apache.roller.weblogger.pojos.User;
@@ -68,6 +77,24 @@ public final class TestUtils {
             // always initialize the properties manager and flush
             WebloggerFactory.getWeblogger().initialize();
 
+            // Reset data for local tests see events-custom.properties
+            Boolean local = WebloggerConfig.getBooleanProperty(
+                    "junit.testdata.reset", false);
+
+            if (local) {
+
+                System.out
+                        .println("Reseting tables for local tests: junit.testdata.reset="
+                                + local);
+
+                try {
+                    clearTestData();
+                } catch (Exception e) {
+                    System.out.println("Error reseting tables : "
+                            + e.getMessage());
+                }
+            }
+
         }
     }
 
@@ -96,6 +123,68 @@ public final class TestUtils {
     }
 
     /**
+     * Clear test data.
+     * 
+     * @throws Exception
+     *             the exception
+     */
+    private static void clearTestData() throws Exception {
+
+        String scriptFile = "junit-cleartables-mysql.sql";
+
+        ClasspathDatabaseScriptProvider scriptProvider = new ClasspathDatabaseScriptProvider();
+        InputStream script = scriptProvider.getDatabaseScript(scriptFile);
+
+        if (script == null) {
+
+            System.out.println("File /dbscripts/" + scriptFile
+                    + " not found on class path.");
+            return;
+
+        }
+
+        // Run script to remove the junit test user
+        try {
+
+            DatabaseProvider dbp = WebloggerStartup.getDatabaseProvider();
+            Connection con = dbp.getConnection();
+
+            SQLScriptRunner runner = new SQLScriptRunner(script);
+
+            if (runner != null) {
+
+                System.out.println("Clearing files using script file : "
+                        + scriptProvider.getScriptURL(scriptFile));
+
+                // Loop script and remove invalid lines
+                List<String> updatedCommands = new ArrayList<String>();
+                List<String> commands = runner.getCommands();
+                for (String command : commands) {
+                    if (!command.startsWith("--")) {
+                        updatedCommands.add(command);
+                    }
+                }
+
+                // Run script
+                runner.setCommands(updatedCommands);
+                runner.runScript(con, true);
+
+                // Flush for this update
+                WebloggerFactory.getWeblogger().flush();
+                WebloggerFactory.getWeblogger().release();
+
+            }
+
+        } finally {
+            try {
+                script.close();
+            } catch (Exception e) {
+                // ignored
+            }
+        }
+    }
+
+    /**
      * Convenience method that creates a user and stores it.
      */
     public static User setupUser(String userName) throws Exception {
@@ -219,17 +308,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);
 
@@ -264,11 +348,31 @@ public final class TestUtils {
     }
 
     /**
-     * Convenience method for creating a weblog entry.
+     * Convenience method for creating a published weblog entry.
      */
     public static WeblogEntry setupWeblogEntry(String anchor,
             WeblogCategory cat, Weblog weblog, User user) throws Exception {
 
+        return TestUtils.setupWeblogEntry(anchor, cat, WeblogEntry.PUBLISHED,
+                weblog, user);
+    }
+
+    /**
+     * 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,
+            WeblogCategory cat, String status, Weblog weblog, User user)
+            throws Exception {
+
         WeblogEntry testEntry = new WeblogEntry();
         testEntry.setTitle(anchor);
         testEntry.setLink("testEntryLink");
@@ -278,7 +382,7 @@ public final class TestUtils {
                 .getTime()));
         testEntry.setUpdateTime(new java.sql.Timestamp(new java.util.Date()
                 .getTime()));
-        testEntry.setStatus(WeblogEntry.PUBLISHED);
+        testEntry.setStatus(status);
         testEntry.setWebsite(getManagedWebsite(weblog));
         testEntry.setCreatorUserName(getManagedUser(user).getUserName());
         testEntry.setCategory(cat);
@@ -506,20 +610,13 @@ public final class TestUtils {
     /**
      * Convenience method for creating a weblog folder.
      */
-    public static WeblogBookmarkFolder setupFolder(Weblog weblog, String name,
-            WeblogBookmarkFolder parent) throws Exception {
+    public static WeblogBookmarkFolder setupFolder(Weblog weblog, String name) throws Exception {
 
         BookmarkManager mgr = WebloggerFactory.getWeblogger()
                 .getBookmarkManager();
 
-        WeblogBookmarkFolder folderParent;
-        if (parent != null) {
-            folderParent = parent;
-        } else {
-            folderParent = mgr.getRootFolder(weblog);
-        }
         WeblogBookmarkFolder testFolder = new WeblogBookmarkFolder(
-                folderParent, name, null, weblog);
+                name, weblog);
         mgr.saveFolder(testFolder);
 
         // flush to db

Propchange: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
------------------------------------------------------------------------------
  Merged /roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java:r1546818-1588713

Propchange: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/WebloggerException.java
------------------------------------------------------------------------------
  Merged /roller/trunk/app/src/main/java/org/apache/roller/weblogger/WebloggerException.java:r1546818-1588713

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/BookmarkManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/BookmarkManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/BookmarkManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/BookmarkManager.java Sun Apr 20 13:38:51 2014
@@ -47,7 +47,7 @@ public interface BookmarkManager {
     /**
      * Remove a Folder.  
      * 
-     * Also removes any subfolders and bookmarks.
+     * Also removes any bookmarks it contains
      *
      * @param folder The folder to be removed.
      * @throws WebloggerException If there is a problem.
@@ -56,18 +56,6 @@ public interface BookmarkManager {
     
     
     /**
-     * Move a folder under another folder.
-     *
-     * This moves the src folder itself and all children and associated bookmarks.
-     */
-    void moveFolder(WeblogBookmarkFolder src,
-
-    WeblogBookmarkFolder dest
-)
-            throws WebloggerException;
-    
-    
-    /**
      * Lookup a folder by ID.
      *
      * @param id The id of the folder to lookup.
@@ -84,29 +72,28 @@ public interface BookmarkManager {
      * @return List The list of FolderData objects from the weblog.
      * @throws WebloggerException If there is a problem.
      */
-    List getAllFolders(Weblog weblog) throws WebloggerException;
+    List<WeblogBookmarkFolder> getAllFolders(Weblog weblog) throws WebloggerException;
     
     
     /** 
-     * Get root folder for a weblog.  
-     * All weblogs should have only 1 root folder.
+     * Get the weblog's default folder
      *
-     * @param weblog The weblog we want the root folder from.
-     * @return FolderData The root folder, or null if not found.
-     * @throws WebloggerException If there is a problem.
+     * @param weblog The weblog we want the default folder from.
+     * @return FolderData The default folder
+     * @throws WebloggerException If the default folder was not found
      */
-    WeblogBookmarkFolder getRootFolder(Weblog weblog) throws WebloggerException;
+    WeblogBookmarkFolder getDefaultFolder(Weblog weblog) throws WebloggerException;
     
     
     /** 
-     * Get a folder from a weblog based on its path.
+     * Get a folder from a weblog based on its name.
      *
      * @param weblog The weblog we want the folder from.
-     * @param path The full path of the folder.
+     * @param name The folder name.
      * @return FolderData The folder from the given path, or null if not found.
      * @throws WebloggerException If there is a problem.
      */
-    WeblogBookmarkFolder getFolder(Weblog weblog, String path)
+    WeblogBookmarkFolder getFolder(Weblog weblog, String name)
             throws WebloggerException;
     
     
@@ -142,11 +129,10 @@ public interface BookmarkManager {
      * Lookup all Bookmarks in a folder, optionally search recursively.
      *
      * @param folder The folder to get the bookmarks from.
-     * @param recurse True if bookmarks should be included.
      * @return List The list of bookmarks found.
      * @throws WebloggerException If there is a problem.
      */
-    List getBookmarks(WeblogBookmarkFolder folder, boolean recurse)
+    List<WeblogBookmark> getBookmarks(WeblogBookmarkFolder folder)
             throws WebloggerException;
     
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/FileContentManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/FileContentManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/FileContentManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/FileContentManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -25,9 +25,10 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.FileContent;
@@ -107,12 +108,12 @@ public class FileContentManagerImpl impl
         // create File that we are about to save
         File saveFile = new File(dirPath.getAbsolutePath() + File.separator + fileId);
         
-        byte[] buffer = new byte[8192];
-        int bytesRead = 0;
+        byte[] buffer = new byte[RollerConstants.EIGHT_KB_IN_BYTES];
+        int bytesRead;
         OutputStream bos = null;
         try {
             bos = new FileOutputStream(saveFile);
-            while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
+            while ((bytesRead = is.read(buffer, 0, RollerConstants.EIGHT_KB_IN_BYTES)) != -1) {
                 bos.write(buffer, 0, bytesRead);
             }            
             log.debug("The file has been written to ["+saveFile.getAbsolutePath()+"]");
@@ -120,8 +121,10 @@ public class FileContentManagerImpl impl
             throw new FileIOException("ERROR uploading file", e);
         } finally {
             try {
-                bos.flush();
-                bos.close();
+                if (bos != null) {
+                    bos.flush();
+                    bos.close();
+                }
             } catch (Exception ignored) {}
         }
         
@@ -156,15 +159,15 @@ public class FileContentManagerImpl impl
     public boolean overQuota(Weblog weblog) {
         
         String maxDir = WebloggerRuntimeConfig.getProperty("uploads.dir.maxsize");
-        String maxFile = WebloggerRuntimeConfig.getProperty("uploads.file.maxsize");
+
         // maxDirSize in megabytes
         BigDecimal maxDirSize = new BigDecimal(maxDir);
 
-        long maxDirBytes = (long)(1024000 * maxDirSize.doubleValue());
+        long maxDirBytes = (long)(RollerConstants.ONE_MB_IN_BYTES * maxDirSize.doubleValue());
         
         try {
-            File storageDir = this.getRealFile(weblog, null);
-            long weblogDirSize = this.getDirSize(storageDir, true);
+            File storageDirectory = this.getRealFile(weblog, null);
+            long weblogDirSize = this.getDirSize(storageDirectory, true);
             
             return weblogDirSize > maxDirBytes;
         } catch (Exception ex) {
@@ -198,7 +201,7 @@ public class FileContentManagerImpl impl
         // second check, does upload exceed max size for file?
         BigDecimal maxFileMB = new BigDecimal(
                 WebloggerRuntimeConfig.getProperty("uploads.file.maxsize"));
-        int maxFileBytes = (int)(1024000 * maxFileMB.doubleValue());
+        int maxFileBytes = (int)(RollerConstants.ONE_MB_IN_BYTES * maxFileMB.doubleValue());
         log.debug("max allowed file size = "+maxFileBytes);
         log.debug("attempted save file size = "+size);
         if (size > maxFileBytes) {
@@ -210,10 +213,10 @@ public class FileContentManagerImpl impl
         // third check, does file cause weblog to exceed quota?
         BigDecimal maxDirMB = new BigDecimal(
                 WebloggerRuntimeConfig.getProperty("uploads.dir.maxsize"));
-        long maxDirBytes = (long)(1024000 * maxDirMB.doubleValue());
+        long maxDirBytes = (long)(RollerConstants.ONE_MB_IN_BYTES * maxDirMB.doubleValue());
         try {
-            File storageDir = this.getRealFile(weblog, null);
-            long userDirSize = getDirSize(storageDir, true);
+            File storageDirectory = this.getRealFile(weblog, null);
+            long userDirSize = getDirSize(storageDirectory, true);
             if (userDirSize + size > maxDirBytes) {
                 messages.addError("error.upload.dirmax", maxDirMB.toString());
                 return false;
@@ -247,15 +250,18 @@ public class FileContentManagerImpl impl
     private long getDirSize(File dir, boolean recurse) {
         
         long size = 0;
-        if(dir.exists() && dir.isDirectory() && dir.canRead()) {
-            File[] files = dir.listFiles();
+
+        if (dir.exists() && dir.isDirectory() && dir.canRead()) {
             long dirSize = 0l;
-            for (int i=0; i < files.length; i++) {
-                if (!files[i].isDirectory()) {
-                    dirSize += files[i].length();
-                } else if(recurse) {
-                    // count a subdirectory
-                    dirSize += getDirSize(files[i], recurse);
+            File[] files = dir.listFiles();
+            if (files != null) {
+                for (File file : files) {
+                    if (!file.isDirectory()) {
+                        dirSize += file.length();
+                    } else if(recurse) {
+                        // count a subdirectory
+                        dirSize += getDirSize(file, recurse);
+                    }
                 }
             }
             size += dirSize;
@@ -272,7 +278,7 @@ public class FileContentManagerImpl impl
     private boolean checkFileType(String[] allowFiles, String[] forbidFiles,
                                   String fileName, String contentType) {
         
-        // TODO: Atom Publushing Protocol figure out how to handle file
+        // TODO: Atom Publishing Protocol figure out how to handle file
         // allow/forbid using contentType.
         // TEMPORARY SOLUTION: In the allow/forbid lists we will continue to
         // allow user to specify file extensions (e.g. gif, png, jpeg) but will

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java Sun Apr 20 13:38:51 2014
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.business.runnable.ContinuousWorkerThread;
 import org.apache.roller.weblogger.business.runnable.HitCountProcessingJob;
 import org.apache.roller.weblogger.business.runnable.WorkerThread;
@@ -40,16 +41,14 @@ import org.apache.roller.weblogger.pojos
  * TODO: we may want to make this an interface that is pluggable if there is
  *   some indication that users want to override this implementation.
  */
-public class HitCountQueue {
+public final class HitCountQueue {
     
     private static Log log = LogFactory.getLog(HitCountQueue.class);
     
     private static HitCountQueue instance = null;
     
-    private int numWorkers = 1;
-    private int sleepTime = 180000;
     private WorkerThread worker = null;
-    private List queue = null;
+    private List<String> queue = null;
     
     
     static {
@@ -59,22 +58,22 @@ public class HitCountQueue {
     
     // non-instantiable because we are a singleton
     private HitCountQueue() {
-        
+        int sleepTime = 3 * RollerConstants.MIN_IN_MS;
         String sleep = WebloggerConfig.getProperty("hitcount.queue.sleepTime", "180");
         
         try {
-            // multiply by 1000 because we expect input in seconds
-            this.sleepTime = Integer.parseInt(sleep) * 1000;
+            // convert input in seconds to ms
+            sleepTime = Integer.parseInt(sleep) * RollerConstants.SEC_IN_MS;
         } catch(NumberFormatException nfe) {
             log.warn("Invalid sleep time ["+sleep+"], using default");
         }
         
         // create the hits queue
-        this.queue = Collections.synchronizedList(new ArrayList());
+        this.queue = Collections.synchronizedList(new ArrayList<String>());
         
         // start up a worker to process the hits at intervals
         HitCountProcessingJob job = new HitCountProcessingJob();
-        worker = new ContinuousWorkerThread("HitCountQueueProcessor", job, this.sleepTime);
+        worker = new ContinuousWorkerThread("HitCountQueueProcessor", job, sleepTime);
         worker.start();
     }
     
@@ -84,7 +83,7 @@ public class HitCountQueue {
     }
     
     
-    public void processHit(Weblog weblog, String url, String referrer) {
+    public void processHit(Weblog weblog) {
         
         // if the weblog isn't null then just drop its handle in the queue
         // each entry in the queue is a weblog handle and indicates a single hit
@@ -94,8 +93,8 @@ public class HitCountQueue {
     }
     
     
-    public List getHits() {
-        return new ArrayList(this.queue);
+    public List<String> getHits() {
+        return new ArrayList<String>(this.queue);
     }
     
     
@@ -103,7 +102,7 @@ public class HitCountQueue {
      * Reset the queued hits.
      */
     public synchronized void resetHits() {
-        this.queue = Collections.synchronizedList(new ArrayList());
+        this.queue = Collections.synchronizedList(new ArrayList<String>());
     }
     
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MailProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MailProvider.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MailProvider.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MailProvider.java Sun Apr 20 13:38:51 2014
@@ -20,7 +20,6 @@ package org.apache.roller.weblogger.busi
 
 import java.util.Properties;
 import javax.mail.MessagingException;
-import javax.mail.NoSuchProviderException;
 import javax.mail.Session;
 import javax.mail.Transport;
 import javax.naming.Context;
@@ -39,7 +38,7 @@ public class MailProvider {
     
     private static final Log LOG = LogFactory.getLog(MailProvider.class);
     
-    private enum ConfigurationType {JNDI_NAME, MAIL_PROPERTIES; }
+    private enum ConfigurationType {JNDI_NAME, MAIL_PROPERTIES }
     
     private Session session = null;
     
@@ -76,7 +75,7 @@ public class MailProvider {
                 jndiName = "java:comp/env/" + jndiName;
             }
             try {
-                Context ctx = (Context) new InitialContext();
+                Context ctx = new InitialContext();
                 session = (Session) ctx.lookup(jndiName);
             } catch (NamingException ex) {
                 throw new StartupException("ERROR looking up mail-session with JNDI name: " + jndiName);
@@ -114,9 +113,9 @@ public class MailProvider {
     /**
      * Create and connect to transport, caller is responsible for closing transport.
      */
-    public Transport getTransport() throws NoSuchProviderException, MessagingException {
+    public Transport getTransport() throws MessagingException {
         
-        Transport transport = null;
+        Transport transport;
         
         if (type == ConfigurationType.MAIL_PROPERTIES) {
             // Configure transport ourselves using mail properties

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MediaFileManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MediaFileManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MediaFileManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MediaFileManager.java Sun Apr 20 13:38:51 2014
@@ -203,5 +203,4 @@ public interface MediaFileManager {
      */
     void removeMediaFileTag(String name, MediaFile entry)
             throws WebloggerException;
-
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MultiWeblogURLStrategy.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MultiWeblogURLStrategy.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MultiWeblogURLStrategy.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/MultiWeblogURLStrategy.java Sun Apr 20 13:38:51 2014
@@ -21,7 +21,7 @@ package org.apache.roller.weblogger.busi
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.Weblog;
@@ -174,10 +174,10 @@ public class MultiWeblogURLStrategy exte
         pathinfo.append(getWeblogURL(weblog, locale, absolute));
         
         String cat = null;
-        if(category != null && "/".equals(category)) {
+        if("root".equals(category)) {
             cat = null;
-        } else if(category != null && category.startsWith("/")) {
-            cat = category.substring(1);
+        } else {
+            cat = category;
         }
         
         if(cat != null && dateString == null) {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PreviewURLStrategy.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PreviewURLStrategy.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PreviewURLStrategy.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PreviewURLStrategy.java Sun Apr 20 13:38:51 2014
@@ -145,10 +145,10 @@ public class PreviewURLStrategy extends 
         }
 
         String cat = null;
-        if(category != null && "/".equals(category)) {
+        if("root".equals(category)) {
             cat = null;
-        } else if(category != null && category.startsWith("/")) {
-            cat = category.substring(1);
+        } else {
+            cat = category;
         }
         
         if(cat != null && dateString == null) {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PropertiesManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PropertiesManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PropertiesManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/PropertiesManager.java Sun Apr 20 13:38:51 2014
@@ -63,6 +63,6 @@ public interface PropertiesManager {
     /**
      * Retrieve a list of all properties
      */
-    Map getProperties() throws WebloggerException;
+    Map<String, RuntimeConfigProperty> getProperties() throws WebloggerException;
     
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/UserManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/UserManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/UserManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/UserManager.java Sun Apr 20 13:38:51 2014
@@ -124,7 +124,7 @@ public interface UserManager {
      * @return List A list of UserDatUsers which match the criteria.
      * @throws WebloggerException If there is a problem.
      */
-    List getUsers(
+    List<User> getUsers(
             Boolean enabled,
             Date    startDate,
             Date    endDate,
@@ -141,7 +141,7 @@ public interface UserManager {
      * @param enabled    True for only enalbed, false for disabled, null for all
      * @return List of (up to length) users that match startsWith string
      */
-    List getUsersStartingWith(String startsWith,
+    List<User> getUsersStartingWith(String startsWith,
             Boolean enabled, int offset, int length) throws WebloggerException;
     
     
@@ -156,7 +156,7 @@ public interface UserManager {
     /** 
      * Get collection of users whose names begin with specified letter 
      */
-    List getUsersByLetter(char letter, int offset, int length)
+    List<User> getUsersByLetter(char letter, int offset, int length)
         throws WebloggerException;
     
         
@@ -167,8 +167,8 @@ public interface UserManager {
      * Lookup a user by User attribute
      * 
      * @param name attribute name
-     * @param value sttribute value
-     * @return UsUserhe user, or null if not found or is disabled.
+     * @param value attribute value
+     * @return User the user, or null if not found or is disabled.
      * @throws WebloggerException If there is a problem
      */
     User getUserByAttribute(String name, String value) throws WebloggerException;
@@ -338,7 +338,7 @@ public interface UserManager {
         
     /**
      * Returns true if user has role specified, should be used only for testing.
-     * @deprecated User checkPermission() instead.
+     * @deprecated Use checkPermission() instead.
      */
     boolean hasRole(String roleName, User user) throws WebloggerException;
     
@@ -346,7 +346,7 @@ public interface UserManager {
     /**
      * Get roles associated with user, should be used only for testing.
      * Get all roles associated with user.
-     * @deprecated User checkPermission() instead.
+     * @deprecated Use checkPermission() instead.
      */
     List<String> getRoles(User user) throws WebloggerException;
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java Sun Apr 20 13:38:51 2014
@@ -22,12 +22,15 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.pojos.WeblogEntryComment;
-import org.apache.roller.weblogger.pojos.WeblogHitCount;
-import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.CommentSearchCriteria;
+import org.apache.roller.weblogger.pojos.StatCount;
+import org.apache.roller.weblogger.pojos.TagStat;
+import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
-import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.WeblogEntryComment;
+import org.apache.roller.weblogger.pojos.WeblogEntrySearchCriteria;
+import org.apache.roller.weblogger.pojos.WeblogHitCount;
 
 
 /**
@@ -35,9 +38,6 @@ import org.apache.roller.weblogger.pojos
  */
 public interface WeblogEntryManager {
 
-    String DESCENDING = "DESCENDING";
-    String ASCENDING = "ASCENDING";
-       
     /**
      * Save weblog entry.
      */
@@ -62,108 +62,43 @@ public interface WeblogEntryManager {
     /**
      * Get WeblogEntries by offset/length as list in reverse chronological order.
      * The range offset and list arguments enable paging through query results.
-     * @param website    Weblog or null to get for all weblogs.
-     * @param user       User or null to get for all users.
-     * @param startDate  Start date or null for no start date.
-     * @param endDate    End date or null for no end date.
-     * @param catName    Category path or null for all categories.
-     * @param status     Status of DRAFT, PENDING, PUBLISHED or null for all
-     * @param text       Text appearing in the text or summary, or null for all
-     * @param sortBy     Sort by either 'pubTime' or 'updateTime' (null for pubTime)
-     * @param sortOrder  Sort order of ASCENDING or DESCENDING (null for DESCENDING)
-     * @param offset     Offset into results for paging
-     * @param length     Max comments to return (or -1 for no limit)
-     * @return List of WeblogEntryData objects in reverse chrono order.
+     * @param wesc WeblogEntrySearchCriteria object listing desired search parameters
+     * @return List of WeblogEntry objects in order specified by search criteria
      * @throws WebloggerException
      */
-    List getWeblogEntries(
-            Weblog website,
-            User    user,
-            Date        startDate,
-            Date        endDate,
-            String      catName,
-            List        tags,
-            String      status,
-            String      text,
-            String      sortBy, 
-            String      sortOrder,
-            String      locale,             
-            int         offset,
-            int         range)
+    List<WeblogEntry> getWeblogEntries(WeblogEntrySearchCriteria wesc)
             throws WebloggerException;
-       
+
     /**
-     * Get Weblog Entries grouped by day. This method returns a Map that
-     * contains Lists, each List contains WeblogEntryData objects, and the
-     * Lists are keyed by Date objects.
-     * @param website    Weblog or null to get for all weblogs.
-     * @param startDate  Start date or null for no start date.
-     * @param endDate    End date or null for no end date.
-     * @param catName    Category path or null for all categories.
-     * @param status     Status of DRAFT, PENDING, PUBLISHED or null for all
-     * @param offset     Offset into results for paging
-     * @param length     Max comments to return (or -1 for no limit)
-     * @return Map of Lists, keyed by Date, and containing WeblogEntryData.
+     * Get Weblog Entries grouped by day.
+     * @param wesc WeblogEntrySearchCriteria object listing desired search parameters
+     * @return Map of Lists of WeblogEntries keyed by calendar day
      * @throws WebloggerException
      */
-    Map getWeblogEntryObjectMap(
-            Weblog website,
-            Date        startDate,
-            Date        endDate,
-            String      catName,
-            List        tags,            
-            String      status,
-            String      locale,
-            int         offset,
-            int         range)
+    Map<Date, List<WeblogEntry>> getWeblogEntryObjectMap(WeblogEntrySearchCriteria wesc)
             throws WebloggerException;
-        
+
     /**
      * Get Weblog Entry date strings grouped by day. This method returns a Map
-     * that contains Lists, each List contains YYYYMMDD date strings objects,
-     * and the Lists are keyed by Date objects.
-     * @param website    Weblog or null to get for all weblogs.
-     * @param startDate  Start date or null for no start date.
-     * @param endDate    End date or null for no end date.
-     * @param catName    Category path or null for all categories.
-     * @param status     Status of DRAFT, PENDING, PUBLISHED or null for all
-     * @param offset     Offset into results for paging
-     * @param length     Max comments to return (or -1 for no limit)
-     * @return Map of Lists, keyed by Date, and containing date strings.
+     * that contains one YYYYMMDD date string object for each calendar day having
+     * one or more blog entries.
+     * @param wesc WeblogEntrySearchCriteria object listing desired search parameters
+     * @return Map of date strings keyed by Date
      * @throws WebloggerException
      */
-    Map getWeblogEntryStringMap(
-            Weblog website,
-            Date        startDate,
-            Date        endDate,
-            String      catName,
-            List        tags,            
-            String      status,
-            String      locale,
-            int         offset,
-            int         range)
-            throws WebloggerException;    
+    Map<Date, String> getWeblogEntryStringMap(WeblogEntrySearchCriteria wesc)
+            throws WebloggerException;
     
     /**
-     * Get weblog entries with given category or, optionally, any sub-category
-     * of that category.
-     * @param cat     Category
-     * @param subcats True if sub-categories are to be fetched
-     * @return        List of weblog entries in category
-     */
-    List getWeblogEntries(WeblogCategory cat, boolean subcats)
-            throws WebloggerException; 
-    
-    /** 
-     * Get weblog enties ordered by descending number of comments.
+     * Get weblog entries ordered by descending number of comments.
      * @param website    Weblog or null to get for all weblogs.
      * @param startDate  Start date or null for no start date.
      * @param endDate    End date or null for no end date.
      * @param offset     Offset into results for paging
      * @param length     Max comments to return (or -1 for no limit)
-     * @return List of WeblogEntryData objects.
+     * @return List of StatCount objects.
      */
-    List getMostCommentedWeblogEntries(
+    List<StatCount> getMostCommentedWeblogEntries(
             Weblog website,             
             Date        startDate,
             Date        endDate,
@@ -193,9 +128,9 @@ public interface WeblogEntryManager {
     /**
      * Get specified number of most recent pinned and published Weblog Entries.
      * @param max Maximum number to return.
-     * @return Collection of WeblogEntryData objects.
+     * @return Collection of WeblogEntry objects.
      */
-    List getWeblogEntriesPinnedToMain(Integer max) throws WebloggerException;
+    List<WeblogEntry> getWeblogEntriesPinnedToMain(Integer max) throws WebloggerException;
 
     /**
      * Remove attribute with given name from given WeblogEntryData
@@ -228,43 +163,25 @@ public interface WeblogEntryManager {
     
     
     /**
-     * Move a category under another category.
-     *
-     * This moves the src category itself and all children and associated entries.
-     */
-    void moveWeblogCategory(WeblogCategory src, WeblogCategory dest)
-            throws WebloggerException;
-    
-    
-    /**
      * Recategorize all entries with one category to another.
      */
     void moveWeblogCategoryContents(WeblogCategory srcCat, WeblogCategory destCat)
             throws WebloggerException;
     
     /**
-     * Get top level categories for a website.
-     * @param website Website.
-     */
-    WeblogCategory getRootWeblogCategory(Weblog website) throws WebloggerException;
-    
-    
-    /**
-     * Get category specified by website and categoryPath.
+     * Get category specified by website and name.
      * @param website      Website of WeblogCategory.
-     * @param categoryPath Path of WeblogCategory, relative to category root.
+     * @param categoryName Name of WeblogCategory
      */
-    WeblogCategory getWeblogCategoryByPath(Weblog website,
-            String categoryPath) throws WebloggerException;
-    
-    
-    /** 
+    WeblogCategory getWeblogCategoryByName(Weblog website,
+            String categoryName) throws WebloggerException;
+
+    /**
      * Get WebLogCategory objects for a website. 
      */
-    List getWeblogCategories(Weblog website, boolean includeRoot)
+    List<WeblogCategory> getWeblogCategories(Weblog website)
             throws WebloggerException;
-    
-               
+
     /**
      * Save comment.
      */
@@ -282,28 +199,10 @@ public interface WeblogEntryManager {
        
     /**
      * Generic comments query method.
-     * @param website    Website or null for all comments on site
-     * @param entry      Entry or null to include all comments
-     * @param startDate  Start date or null for no restriction
-     * @param endDate    End date or null for no restriction
-     * @param status     The status of the comment, or null for any
-     * @param reverseChrono True for results in reverse chrono order
-     * @param offset     Offset into results for paging
-     * @param length     Max comments to return (or -1 for no limit)
+     * @param csc CommentSearchCriteria object with fields indicating search criteria
+     * @return list of comments fitting search criteria
      */
-    List getComments(
-            
-            Weblog          website,
-            WeblogEntry     entry,
-            String          searchString,
-            Date            startDate,
-            Date            endDate,
-            String          status,
-            boolean         reverseChrono,
-            int             offset,
-            int             length
-            
-            ) throws WebloggerException;
+    List<WeblogEntryComment> getComments(CommentSearchCriteria csc) throws WebloggerException;
 
     /**
      * Deletes comments that match paramters.
@@ -362,7 +261,7 @@ public interface WeblogEntryManager {
      * @return
      * @throws WebloggerException
      */
-    List getPopularTags(Weblog website, Date startDate, int offset, int limit)
+    List<TagStat> getPopularTags(Weblog website, Date startDate, int offset, int limit)
             throws WebloggerException;
     
     /**
@@ -374,7 +273,7 @@ public interface WeblogEntryManager {
      * @return
      * @throws WebloggerException
      */
-    List getTags(Weblog website, String sortBy, String startsWith, int offset, int limit)
+    List<TagStat> getTags(Weblog website, String sortBy, String startsWith, int offset, int limit)
             throws WebloggerException;    
     
     /**
@@ -444,7 +343,7 @@ public interface WeblogEntryManager {
      * @return The list of HitCountData objects ranked by hit count, descending.
      * @throws WebloggerException If there was a problem with the backend.
      */
-    List getHotWeblogs(int sinceDays, int offset, int length)
+    List<WeblogHitCount> getHotWeblogs(int sinceDays, int offset, int length)
         throws WebloggerException;
     
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java Sun Apr 20 13:38:51 2014
@@ -22,6 +22,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.pojos.StatCount;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogTemplate;
@@ -90,9 +91,9 @@ public interface WeblogManager {
      * @param endDate   Restrict to those created before (or null for all)
      * @param offset    Offset into results (for paging)
      * @param length    Maximum number of results to return (for paging)
-     * @return List of WebsiteData objects.
+     * @return List of Weblog objects.
      */
-    List getWeblogs(
+    List<Weblog> getWeblogs(
             Boolean  enabled,
             Boolean  active,
             Date     startDate,
@@ -106,18 +107,18 @@ public interface WeblogManager {
      * Get websites of a user.
      * @param user        Get all weblogs for this user
      * @param enabledOnly Include only enabled weblogs?
-     * @return List of WebsiteData objects.
+     * @return List of Weblog objects.
      */
-    List getUserWeblogs(User user, boolean enabledOnly) throws WebloggerException;
+    List<Weblog> getUserWeblogs(User user, boolean enabledOnly) throws WebloggerException;
     
     
     /**
      * Get users of a weblog.
-     * @param user        Get all users for this weblog
+     * @param weblog Weblog to retrieve users for
      * @param enabledOnly Include only enabled users?
      * @return List of WebsiteData objects.
      */
-    List getWeblogUsers(Weblog weblog, boolean enabledOnly) throws WebloggerException;
+    List<User> getWeblogUsers(Weblog weblog, boolean enabledOnly) throws WebloggerException;
     
     
     /**
@@ -125,10 +126,10 @@ public interface WeblogManager {
      * @param startDate Restrict to those created after (or null for all)
      * @param endDate Restrict to those created before (or null for all)
      * @param offset    Offset into results (for paging)
-     * @param len       Maximum number of results to return (for paging)
-     * @return List of WebsiteData objects.
+     * @param length       Maximum number of results to return (for paging)
+     * @return List of StatCount objects.
      */
-    List getMostCommentedWeblogs(
+    List<StatCount> getMostCommentedWeblogs(
             Date startDate,
             Date endDate,
             int  offset,
@@ -147,7 +148,7 @@ public interface WeblogManager {
     /** 
      * Get collection of weblogs whose handles begin with specified letter 
      */
-    List getWeblogsByLetter(char letter, int offset, int length)
+    List<Weblog> getWeblogsByLetter(char letter, int offset, int length)
         throws WebloggerException;
     
         /**
@@ -200,7 +201,7 @@ public interface WeblogManager {
     /**
      * Get website's pages
      */
-    List getPages(Weblog w) throws WebloggerException;
+    List<WeblogTemplate> getPages(Weblog w) throws WebloggerException;
    
     
     /**

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerFactory.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerFactory.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerFactory.java Sun Apr 20 13:38:51 2014
@@ -29,22 +29,16 @@ import org.apache.roller.weblogger.confi
  */
 public final class WebloggerFactory {
     
-    private static final Log log = LogFactory.getLog(WebloggerFactory.class);
+    private static final Log LOG = LogFactory.getLog(WebloggerFactory.class);
     
     // our configured weblogger provider
     private static WebloggerProvider webloggerProvider = null;
 
-	public static Object getweblogger() {
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-	}
-    
-    
     // non-instantiable
     private WebloggerFactory() {
         // hello all you beautiful people
     }
-    
-    
+
     /**
      * True if bootstrap process has been completed, False otherwise.
      */
@@ -127,9 +121,9 @@ public final class WebloggerFactory {
             throw new NullPointerException("WebloggerProvider is null");
         }
         
-        log.info("Bootstrapping Roller Weblogger business tier");
+        LOG.info("Bootstrapping Roller Weblogger business tier");
         
-        log.info("Weblogger Provider = "+provider.getClass().getName());
+        LOG.info("Weblogger Provider = " + provider.getClass().getName());
         
         // save reference to provider
         webloggerProvider = provider;
@@ -142,9 +136,9 @@ public final class WebloggerFactory {
             throw new BootstrapException("Bootstrapping failed, Weblogger instance is null");
         }
         
-        log.info("Roller Weblogger business tier successfully bootstrapped");
-        log.info("   Version: " + webloggerProvider.getWeblogger().getVersion());
-        log.info("   Revision: " + webloggerProvider.getWeblogger().getRevision());
+        LOG.info("Roller Weblogger business tier successfully bootstrapped");
+        LOG.info("   Version: " + webloggerProvider.getWeblogger().getVersion());
+        LOG.info("   Revision: " + webloggerProvider.getWeblogger().getRevision());
     }
     
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java Sun Apr 20 13:38:51 2014
@@ -373,12 +373,6 @@ public abstract class WebloggerImpl impl
             // Initialize ping variants
             PingConfig.initializePingVariants();
             
-            // Remove custom ping targets if they have been disallowed
-            if (PingConfig.getDisallowCustomTargets()) {
-                log.info("Custom ping targets have been disallowed.  Removing any existing custom targets.");
-                WebloggerFactory.getWeblogger().getPingTargetManager().removeAllCustomPingTargets();
-            }
-            
             // Remove all autoping configurations if ping usage has been disabled.
             if (PingConfig.getDisablePingUsage()) {
                 log.info("Ping usage has been disabled.  Removing any existing auto ping configurations.");

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -28,8 +28,6 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.Weblog;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import javax.persistence.Query;
 import org.apache.roller.weblogger.business.Weblogger;
@@ -96,37 +94,26 @@ public class JPAAutoPingManagerImpl impl
         }
 
         PingQueueManager pingQueueMgr = roller.getPingQueueManager();
-        List applicableAutopings = getApplicableAutoPings(changedWeblogEntry);
-        for (Iterator i = applicableAutopings.iterator(); i.hasNext();) {
-            AutoPing autoPing = (AutoPing) i.next();
+        List<AutoPing> applicableAutopings = getApplicableAutoPings(changedWeblogEntry);
+        for (AutoPing autoPing : applicableAutopings) {
             pingQueueMgr.addQueueEntry(autoPing);
         }
     }
 
-    public List getAutoPingsByWebsite(Weblog website) throws WebloggerException {
+    public List<AutoPing> getAutoPingsByWebsite(Weblog website) throws WebloggerException {
         Query q = strategy.getNamedQuery("AutoPing.getByWebsite");
         q.setParameter(1, website);
         return q.getResultList();
     }
 
-    public List getAutoPingsByTarget(PingTarget pingTarget) throws WebloggerException {
+    public List<AutoPing> getAutoPingsByTarget(PingTarget pingTarget) throws WebloggerException {
         Query q = strategy.getNamedQuery("AutoPing.getByPingTarget");
         q.setParameter(1, pingTarget);
         return q.getResultList();
     }
 
-    public List getApplicableAutoPings(WeblogEntry changedWeblogEntry) throws WebloggerException {
+    public List<AutoPing> getApplicableAutoPings(WeblogEntry changedWeblogEntry) throws WebloggerException {
         return getAutoPingsByWebsite(changedWeblogEntry.getWebsite());
-        //        return (List)strategy.newQuery(AutoPing.class, "AutoPing.getByWebsite")
-        //            .execute(changedWeblogEntry.getWebsite());
-    }
-
-    public List getCategoryRestrictions(AutoPing autoPing) throws WebloggerException {
-        return Collections.EMPTY_LIST;
-    }
-
-    public void setCategoryRestrictions(AutoPing autoPing, Collection newCategories) {
-        // NOT YET IMPLEMENTED
     }
 
     public void release() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -19,13 +19,13 @@
 package org.apache.roller.weblogger.business.jpa;
 
 import java.io.StringReader;
-import java.util.Iterator;
 import java.util.List;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.BookmarkManager;
 import org.apache.roller.weblogger.business.Weblogger;
@@ -70,7 +70,7 @@ public class JPABookmarkManagerImpl impl
         boolean exists = getBookmark(bookmark.getId()) != null;        
         if (!exists) {
             // New object make sure that relationship is set on managed copy of other side
-            bookmark.getFolder().getBookmarks().add(bookmark);
+            bookmark.getFolder().addBookmark(bookmark);
         }
 
         this.strategy.store(bookmark);
@@ -97,102 +97,29 @@ public class JPABookmarkManagerImpl impl
     }
 
     public void saveFolder(WeblogBookmarkFolder folder) throws WebloggerException {
-        
-        if (folder.getId() == null || this.getFolder(folder.getId()) == null) {
-            // New folder, so make sure name is unique
-            if (isDuplicateFolderName(folder)) {
-                throw new WebloggerException("Duplicate folder name");
-            }
 
-            // And If it has a parent, maintain relationship from both sides
-            WeblogBookmarkFolder parent = folder.getParent();
-            if(parent != null) {
-                parent.getFolders().add(folder);
-            }
+        // If new folder make sure name is unique
+        if ((folder.getId() == null || this.getFolder(folder.getId()) == null) && isDuplicateFolderName(folder)) {
+            throw new WebloggerException("Duplicate folder name");
         }
 
         this.strategy.store(folder);
 
-        // update weblog last modified date.  date updated by saveWebsite()
-        roller.getWeblogManager().saveWeblog(folder.getWebsite());
+        // update weblog last modified date.  date updated by saveWeblog()
+        roller.getWeblogManager().saveWeblog(folder.getWeblog());
     }
 
     public void removeFolder(WeblogBookmarkFolder folder) throws WebloggerException {
-        WeblogBookmarkFolder parent = folder.getParent();
-        if (parent != null) {
-            parent.getFolders().remove(folder);
-        }
-        String websiteid = folder.getWebsite().getId();
+        Weblog weblog = folder.getWeblog();
+        weblog.getBookmarkFolders().remove(folder);
         this.strategy.remove(folder);
 
-        // update weblog last modified date.  date updated by saveWebsite()
-        Weblog weblog = roller.getWeblogManager().getWeblog(websiteid);
+        // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
     }
-    
-    public void moveFolder(WeblogBookmarkFolder srcFolder, WeblogBookmarkFolder destFolder)
-            throws WebloggerException {
-        
-        // TODO: this check should be made before calling this method?
-        if (destFolder.descendentOf(srcFolder)) {
-            throw new WebloggerException(
-                    "ERROR cannot move parent folder into it's own child");
-        }
-        
-        log.debug("Moving folder " + srcFolder.getPath() + " under " +
-            destFolder.getPath());
-        
-        // Manage relationships
-        WeblogBookmarkFolder oldParent = srcFolder.getParent();
-        if(oldParent != null) {
-            oldParent.getFolders().add(srcFolder);
-        }
-        srcFolder.setParent(destFolder);
-        destFolder.getFolders().add(srcFolder);
-        
-        if("/".equals(destFolder.getPath())) {
-            srcFolder.setPath("/"+srcFolder.getName());
-        } else {
-            srcFolder.setPath(destFolder.getPath() + "/" + srcFolder.getName());
-        }
-        saveFolder(srcFolder);
-        
-        // the main work to be done for a category move is to update the 
-        // path attribute of the category and all descendent categories
-        updatePathTree(srcFolder);
-    }    
-
-    // updates the paths of all descendents of the given folder
-    private void updatePathTree(WeblogBookmarkFolder folder) throws WebloggerException {
-        
-        log.debug("Updating path tree for folder "+folder.getPath());
-        
-        WeblogBookmarkFolder childFolder = null;
-        Iterator childFolders = folder.getFolders().iterator();
-        while(childFolders.hasNext()) {
-            childFolder = (WeblogBookmarkFolder) childFolders.next();
-            
-            log.debug("OLD child folder path was "+childFolder.getPath());
-            
-            // update path and save
-            if("/".equals(folder.getPath())) {
-                childFolder.setPath("/" + childFolder.getName());
-            } else {
-                childFolder.setPath(folder.getPath() + "/" + 
-                    childFolder.getName());
-            }
-            saveFolder(childFolder);
-            
-            log.debug("NEW child folder path is "+ childFolder.getPath());
-            
-            // then make recursive call to update this folders children
-            updatePathTree(childFolder);
-        }
-    }
 
-    
     /**
-     * Retrieve folder and lazy-load it's sub-folders and bookmarks.
+     * Retrieve folder and lazy-load its bookmarks.
      */
     public WeblogBookmarkFolder getFolder(String id) throws WebloggerException {
         return (WeblogBookmarkFolder) strategy.load(WeblogBookmarkFolder.class, id);
@@ -212,19 +139,15 @@ public class JPABookmarkManagerImpl impl
             WeblogBookmarkFolder newFolder = getFolder(website, folderName);
             if (newFolder == null) {
                 newFolder = new WeblogBookmarkFolder(
-                        getRootFolder(website), 
-                        folderName, folderName, website);
+                        folderName, website);
                 this.strategy.store(newFolder);
             }
 
             // Iterate through children of OPML body, importing each
             Element body = doc.getRootElement().getChild("body");
-            Iterator iter = body.getChildren().iterator();
-            while (iter.hasNext()) {
-                Element elem = (Element)iter.next();
-                importOpmlElement( website, elem, newFolder );
+            for (Object elem : body.getChildren()) {
+                importOpmlElement((Element) elem, newFolder );
             }
-
         } catch (Exception ex) {
             throw new WebloggerException(ex);
         }
@@ -232,15 +155,14 @@ public class JPABookmarkManagerImpl impl
 
     // convenience method used when importing bookmarks
     // NOTE: this method does not commit any changes; 
-    // that is done by importBookmarks()
+    // that is done higher up in execution chain
     private void importOpmlElement(
-            Weblog website, Element elem, WeblogBookmarkFolder parent)
+            Element elem, WeblogBookmarkFolder folder)
             throws WebloggerException {
         String text = elem.getAttributeValue("text");
         String title = elem.getAttributeValue("title");
         String desc = elem.getAttributeValue("description");
         String url = elem.getAttributeValue("url");
-        //String type = elem.getAttributeValue("type");
         String xmlUrl = elem.getAttributeValue("xmlUrl");
         String htmlUrl = elem.getAttributeValue("htmlUrl");
 
@@ -251,17 +173,19 @@ public class JPABookmarkManagerImpl impl
         
         // better to truncate imported OPML fields than to fail import or drop whole bookmark
         // TODO: add way to notify user that fields were truncated
-        if (title != null && title.length() > 254) {
-            title = title.substring(0,  254);
+        int maxLength = RollerConstants.TEXTWIDTH_255;
+
+        if (title != null && title.length() > maxLength) {
+            title = title.substring(0,  maxLength);
         }
-        if (desc != null && desc.length() > 254) {
-            desc = desc.substring(0, 254);
+        if (desc != null && desc.length() > maxLength) {
+            desc = desc.substring(0, maxLength);
         }
-        if (url != null && url.length() > 254) {
-            url = url.substring(0, 254);
+        if (url != null && url.length() > maxLength) {
+            url = url.substring(0, maxLength);
         }
-        if (xmlUrl != null && xmlUrl.length() > 254) {
-            xmlUrl = xmlUrl.substring(0, 254);
+        if (xmlUrl != null && xmlUrl.length() > maxLength) {
+            xmlUrl = xmlUrl.substring(0, maxLength);
         }
 
         if (elem.getChildren().size()==0) {
@@ -271,100 +195,64 @@ public class JPABookmarkManagerImpl impl
             // trying to skip invalid ones, but was letting ones 
             // with an xml url and no html url through
             // which could result in a db exception.
-            // TODO: Consider providing error feedback instead of 
-            // silently skipping the invalid bookmarks here.
             if (null != title && null != url) {
-                WeblogBookmark bd = new WeblogBookmark(parent,
+                WeblogBookmark bd = new WeblogBookmark(folder,
                         title,
                         desc,
                         url,
                         xmlUrl,
-                        0,
-                        100,
                         null);
-                parent.addBookmark(bd);
-                // TODO: maybe this should be saving the folder?
+                folder.addBookmark(bd);
                 this.strategy.store(bd);
             }
         } else {
-            // Store a folder
-            WeblogBookmarkFolder fd = new WeblogBookmarkFolder(
-                    parent,
-                    title,
-                    desc,
-                    parent.getWebsite());
-            this.strategy.store(fd);
-
-            // Import folder's children
-            Iterator iter = elem.getChildren("outline").iterator();
-            while ( iter.hasNext() ) {
-                Element subelem = (Element)iter.next();
-                importOpmlElement( website, subelem, fd  );
+            // Import suboutline's children into folder
+            for (Object subelem : elem.getChildren("outline")) {
+                importOpmlElement((Element) subelem, folder );
             }
         }
     }
 
-
-    public WeblogBookmarkFolder getFolder(Weblog website, String path)
+    /**
+     * @see org.apache.roller.weblogger.business.BookmarkManager#getBookmarks(
+     *      org.apache.roller.weblogger.pojos.WeblogBookmarkFolder)
+     */
+    public List<WeblogBookmark> getBookmarks(WeblogBookmarkFolder folder)
             throws WebloggerException {
+        Query query;
+        List<WeblogBookmark> results;
 
-        if (path == null || path.trim().equals("/")) {
-            return getRootFolder(website);
-        } else {
-            String folderPath = path;
-
-            // all folder paths must begin with a '/'
-            if(!folderPath.startsWith("/")) {
-                folderPath = "/"+folderPath;
-            }
+        query = strategy.getNamedQuery("BookmarkData.getByFolder");
+        query.setParameter(1, folder);
+        results = query.getResultList();
 
-            // now just do simple lookup by path
-            Query query = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite&Path");
-            query.setParameter(1, website);
-            query.setParameter(2, folderPath);
-            try {
-                return (WeblogBookmarkFolder)query.getSingleResult();
-            } catch (NoResultException e) {
-                return null;
-            }
-        }
+        return results;
     }
 
-    /**
-     * @see org.apache.roller.weblogger.model.BookmarkManager#retrieveBookmarks(
-     *      org.apache.roller.weblogger.pojos.WeblogBookmarkFolder, boolean)
-     */
-    public List getBookmarks(WeblogBookmarkFolder folder, boolean subfolders) 
+    public WeblogBookmarkFolder getFolder(Weblog website, String name)
             throws WebloggerException {
-        Query query = null;
-        List results = null;
 
-        if(!subfolders) {
-            // if no subfolders then this is an equals query
-            query = strategy.getNamedQuery("BoomarkData.getByFolder");
-            query.setParameter(1, folder);
-            results = query.getResultList();
-        } else {
-            // if we are doing subfolders then do a case sensitive
-            // query using folder path
-            query = strategy.getNamedQuery( 
-                "BoomarkData.getByFolder.pathLike&Folder.website");
-            query.setParameter(1, folder.getPath() + '%');
-            query.setParameter(2, folder.getWebsite());
-            results = query.getResultList();
+        // Do simple lookup by name
+        Query query = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite&Name");
+        query.setParameter(1, website);
+        query.setParameter(2, name);
+        try {
+            return (WeblogBookmarkFolder) query.getSingleResult();
+        } catch (NoResultException e) {
+            return null;
         }
-            
-        return results;
     }
 
-    public WeblogBookmarkFolder getRootFolder(Weblog website)
+    public WeblogBookmarkFolder getDefaultFolder(Weblog weblog)
             throws WebloggerException {
-        if (website == null) {
-            throw new WebloggerException("website is null");
+
+        if (weblog == null) {
+            throw new WebloggerException("weblog is null");
         }
         
-        Query q = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite&ParentNull");
-        q.setParameter(1, website);
+        Query q = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite&Name");
+        q.setParameter(1, weblog);
+        q.setParameter(2, "default");
         try {
             return (WeblogBookmarkFolder)q.getSingleResult();
         } catch (NoResultException e) {
@@ -372,7 +260,7 @@ public class JPABookmarkManagerImpl impl
         }
     }
 
-    public List getAllFolders(Weblog website)
+    public List<WeblogBookmarkFolder> getAllFolders(Weblog website)
             throws WebloggerException {
         if (website == null) {
             throw new WebloggerException("Website is null");
@@ -390,13 +278,8 @@ public class JPABookmarkManagerImpl impl
     private boolean isDuplicateFolderName(WeblogBookmarkFolder folder) 
         throws WebloggerException {
 
-        // ensure that no sibling categories share the same name
-        WeblogBookmarkFolder parent = folder.getParent();
-        if (null != parent) {
-            return (getFolder(folder.getWebsite(), folder.getPath()) != null);
-        }
-        
-        return false;
+        // ensure that no sibling folders share the same name
+        return getFolder(folder.getWeblog(), folder.getName()) != null;
     }
 
 



Mime
View raw message