roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1566380 - in /roller/trunk/app/src: main/java/org/apache/roller/weblogger/business/ main/java/org/apache/roller/weblogger/business/jpa/ main/java/org/apache/roller/weblogger/pojos/ main/java/org/apache/roller/weblogger/ui/rendering/util/ m...
Date Sun, 09 Feb 2014 19:51:31 GMT
Author: gmazza
Date: Sun Feb  9 19:51:30 2014
New Revision: 1566380

URL: http://svn.apache.org/r1566380
Log:
Replaced WeblogEntryManager.getWeblogCategoryByPath with ...ByName, using .substring(1) in
a few cases that still haven't been converted from using category paths to just names.

Modified:
    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/pojos/Weblog.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/MetaWeblogAPIHandler.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java

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=1566380&r1=1566379&r2=1566380&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
Sun Feb  9 19:51:30 2014
@@ -67,7 +67,7 @@ public interface WeblogEntryManager {
      * @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 catPath    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)
@@ -82,7 +82,7 @@ public interface WeblogEntryManager {
             User    user,
             Date        startDate,
             Date        endDate,
-            String      catName,
+            String      catPath,
             List        tags,
             String      status,
             String      text,
@@ -100,7 +100,7 @@ public interface WeblogEntryManager {
      * @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 catPath    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 range
@@ -111,7 +111,7 @@ public interface WeblogEntryManager {
             Weblog website,
             Date        startDate,
             Date        endDate,
-            String      catName,
+            String      catPath,
             List        tags,            
             String      status,
             String      locale,
@@ -126,7 +126,7 @@ public interface WeblogEntryManager {
      * @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 catPath    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 range
@@ -137,7 +137,7 @@ public interface WeblogEntryManager {
             Weblog website,
             Date        startDate,
             Date        endDate,
-            String      catName,
+            String      catPath,
             List        tags,            
             String      status,
             String      locale,
@@ -248,23 +248,12 @@ public interface WeblogEntryManager {
     WeblogCategory getWeblogCategoryByName(Weblog website,
             String categoryName) throws WebloggerException;
 
-
-    /**
-     * Get category specified by website and name. Will be removed soon, as all categories
-     * are now top-level.
-     * @param website      Website of WeblogCategory.
-     * @param categoryName Path of WeblogCategory
-     */
-    WeblogCategory getWeblogCategoryByPath(Weblog website,
-                                           String categoryPath) throws WebloggerException;
-
     /**
      * Get WebLogCategory objects for a website. 
      */
     List<WeblogCategory> getWeblogCategories(Weblog website, boolean includeRoot)
             throws WebloggerException;
-    
-               
+
     /**
      * Save comment.
      */

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=1566380&r1=1566379&r2=1566380&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
Sun Feb  9 19:51:30 2014
@@ -335,7 +335,7 @@ public class JPAWeblogEntryManagerImpl i
         this.entryAnchorToIdMap.remove(entry.getWebsite().getHandle()+":"+entry.getAnchor());
     }
     
-    public List getNextPrevEntries(WeblogEntry current, String catName,
+    public List getNextPrevEntries(WeblogEntry current, String catPath,
             String locale, int maxEntries, boolean next)
             throws WebloggerException {
 
@@ -344,8 +344,8 @@ public class JPAWeblogEntryManagerImpl i
 			return Collections.emptyList();
 		}
 
-        Query query = null;
-        WeblogCategory category = null;
+        Query query;
+        WeblogCategory category;
         
         List params = new ArrayList();
         int size = 0;
@@ -370,13 +370,13 @@ public class JPAWeblogEntryManagerImpl i
             }
         }
         
-        if (catName != null) {
-            category = getWeblogCategoryByPath(current.getWebsite(), catName);
+        if (catPath != null) {
+            category = getWeblogCategoryByName(current.getWebsite(), catPath.substring(1));
             if (category != null) {
                 params.add(size++, category);
                 whereClause.append(" AND e.category = ?" + size);
             } else {
-                throw new WebloggerException("Cannot find category: " + catName);
+                throw new WebloggerException("Cannot find category: " + catPath);
             } 
         }
         
@@ -460,7 +460,7 @@ public class JPAWeblogEntryManagerImpl i
             User    user,
             Date        startDate,
             Date        endDate,
-            String      catName,
+            String      catPath,
             List        tags,
             String      status,
             String      text,
@@ -471,16 +471,13 @@ public class JPAWeblogEntryManagerImpl i
             int         length) throws WebloggerException {
         
         WeblogCategory cat = null;
-        if (StringUtils.isNotEmpty(catName) && website != null) {
-            cat = getWeblogCategoryByPath(website, catName);
+        if (StringUtils.isNotEmpty(catPath) && website != null) {
+            cat = getWeblogCategoryByName(website, catPath.substring(1));
             if (cat == null) {
-                catName = null;
+                catPath = null;
             }
         }
-        if (catName != null && catName.trim().equals("/")) {
-            catName = null;
-        }
-        
+
         List params = new ArrayList();
         int size = 0;
         StringBuilder queryString = new StringBuilder();
@@ -933,22 +930,17 @@ public class JPAWeblogEntryManagerImpl i
         return getWeblogCategoryByName(website, null, categoryName);
     }
 
-    public WeblogCategory getWeblogCategoryByPath(Weblog website,
-                                                  String categoryPath) throws WebloggerException
{
-        return getWeblogCategoryByName(website, null, categoryPath.substring(1));
-    }
-
     /**
      * @inheritDoc
      */
-    // TODO: ditch this method in favor of getWeblogCategoryByPath(weblog, path)
+    // 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 path
+            // now just do simple lookup by name
             Query q = strategy.getNamedQuery(
                     "WeblogCategory.getByName&Website");
             q.setParameter(1, name);

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=1566380&r1=1566379&r2=1566380&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 Sun Feb 
9 19:51:30 2014
@@ -757,6 +757,7 @@ public class Weblog implements Serializa
     }
     
     
+    @Deprecated
     public Set<WeblogCategory> getWeblogCategories(String categoryPath) {
         Set<WeblogCategory> ret = new HashSet<WeblogCategory>();
         try {
@@ -764,7 +765,7 @@ public class Weblog implements Serializa
             WeblogEntryManager wmgr = roller.getWeblogEntryManager();            
             WeblogCategory category = null;
             if (categoryPath != null && !categoryPath.equals("nil")) {
-                category = wmgr.getWeblogCategoryByPath(this, categoryPath);
+                category = wmgr.getWeblogCategoryByName(this, categoryPath.substring(1));
             } else {
                 category = this.getDefaultCategory();
             }
@@ -781,7 +782,7 @@ public class Weblog implements Serializa
             Weblogger roller = WebloggerFactory.getWeblogger();
             WeblogEntryManager wmgr = roller.getWeblogEntryManager();
             if (categoryPath != null && !categoryPath.equals("nil")) {
-                category = wmgr.getWeblogCategoryByPath(this, categoryPath);
+                category = wmgr.getWeblogCategoryByName(this, categoryPath.substring(1));
             } else {
                 category = this.getDefaultCategory();
             }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.java?rev=1566380&r1=1566379&r2=1566380&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.java
Sun Feb  9 19:51:30 2014
@@ -213,7 +213,7 @@ public class WeblogFeedRequest extends W
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByPath(getWeblog(), weblogCategoryName);
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
             } catch (WebloggerException ex) {
                 log.error("Error getting weblog category "+weblogCategoryName, ex);
             }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java?rev=1566380&r1=1566379&r2=1566380&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
Sun Feb  9 19:51:30 2014
@@ -365,7 +365,7 @@ public class WeblogPageRequest extends W
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByPath(getWeblog(), weblogCategoryName);
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
             } catch (WebloggerException ex) {
                 log.error("Error getting weblog category "+weblogCategoryName, ex);
             }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.java?rev=1566380&r1=1566379&r2=1566380&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.java
Sun Feb  9 19:51:30 2014
@@ -136,9 +136,9 @@ public class WeblogSearchRequest extends
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByPath(getWeblog(), weblogCategoryName);
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
             } catch (WebloggerException ex) {
-                log.error("Error getting weblog category "+weblogCategoryName, ex);
+                log.error("Error getting weblog category " + weblogCategoryName, ex);
             }
         }
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java?rev=1566380&r1=1566379&r2=1566380&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java
Sun Feb  9 19:51:30 2014
@@ -434,8 +434,8 @@ public class EntryCollection {
                     String catString = cat.getTerm();
                     if (catString != null) {
                         WeblogCategory rollerCat =
-                                roller.getWeblogEntryManager().getWeblogCategoryByPath(
-                                rollerEntry.getWebsite(), catString);
+                                roller.getWeblogEntryManager().getWeblogCategoryByName(
+                                rollerEntry.getWebsite(), catString.substring(1));
                         if (rollerCat != null) {
                             // Found a valid category, so break out
                             rollerEntry.setCategory(rollerCat);

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=1566380&r1=1566379&r2=1566380&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
Sun Feb  9 19:51:30 2014
@@ -174,7 +174,7 @@ public class MetaWeblogAPIHandler extend
             if ( cat != null ) {
                 // Use first category specified by request
                 WeblogCategory cd =
-                        weblogMgr.getWeblogCategoryByPath(entry.getWebsite(), cat);
+                        weblogMgr.getWeblogCategoryByName(entry.getWebsite(), cat);
                 entry.setCategory(cd);
             }
             
@@ -284,7 +284,7 @@ public class MetaWeblogAPIHandler extend
                     mLogger.debug("cat to string - "+cats[0].toString());
                     for (int i=0; i<cats.length; i++) {
                         Object cat = cats[i];
-                        rollerCat = weblogMgr.getWeblogCategoryByPath(website, (String)cat);
+                        rollerCat = weblogMgr.getWeblogCategoryByName(website, (String)cat);
                         if (rollerCat != null) {
                             entry.setCategory(rollerCat);
                             break;

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=1566380&r1=1566379&r2=1566380&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
Sun Feb  9 19:51:30 2014
@@ -199,7 +199,7 @@ public class WeblogCategoryCRUDTest exte
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         root = mgr.getRootWeblogCategory(testWeblog);
         assertEquals(0, root.getWeblogCategories().size());
-        assertNull(mgr.getWeblogCategoryByPath(TestUtils.getManagedWebsite(testWeblog), "/subcatTest1"));
+        assertNull(mgr.getWeblogCategoryByName(TestUtils.getManagedWebsite(testWeblog), "subcatTest1"));
         
         log.info("END");
     }



Mime
View raw message