roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1566434 - in /roller/trunk: app/src/main/java/org/apache/roller/weblogger/business/jpa/ app/src/main/java/org/apache/roller/weblogger/pojos/ app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/ app/src/main/java/org/apache/roller/w...
Date Sun, 09 Feb 2014 21:37:59 GMT
Author: gmazza
Date: Sun Feb  9 21:37:58 2014
New Revision: 1566434

URL: http://svn.apache.org/r1566434
Log:
Converted most functionality from using category paths to names.

Modified:
    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/pojos/wrapper/WeblogWrapper.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/main/webapp/WEB-INF/velocity/weblog.vm
    roller/trunk/docs/roller-template-guide.odt

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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -371,7 +371,7 @@ public class JPAWeblogEntryManagerImpl i
         }
         
         if (catPath != null) {
-            category = getWeblogCategoryByName(current.getWebsite(), catPath.substring(1));
+            category = getWeblogCategoryByName(current.getWebsite(), catPath);
             if (category != null) {
                 params.add(size++, category);
                 whereClause.append(" AND e.category = ?" + size);
@@ -472,7 +472,7 @@ public class JPAWeblogEntryManagerImpl i
         
         WeblogCategory cat = null;
         if (StringUtils.isNotEmpty(catPath) && website != null) {
-            cat = getWeblogCategoryByName(website, catPath.substring(1));
+            cat = getWeblogCategoryByName(website, catPath);
             if (cat == null) {
                 catPath = null;
             }

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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -755,43 +755,24 @@ public class Weblog implements Serializa
         WeblogCategory category = this.getDefaultCategory();
         return category.getWeblogCategories();
     }
-    
-    
-    @Deprecated
-    public Set<WeblogCategory> getWeblogCategories(String categoryPath) {
-        Set<WeblogCategory> ret = new HashSet<WeblogCategory>();
-        try {
-            Weblogger roller = WebloggerFactory.getWeblogger();
-            WeblogEntryManager wmgr = roller.getWeblogEntryManager();            
-            WeblogCategory category = null;
-            if (categoryPath != null && !categoryPath.equals("nil")) {
-                category = wmgr.getWeblogCategoryByName(this, categoryPath.substring(1));
-            } else {
-                category = this.getDefaultCategory();
-            }
-            ret = category.getWeblogCategories();
-        } catch (WebloggerException e) {
-            log.error("ERROR: fetching categories for path: " + categoryPath, e);
-        }
-        return ret;
-    }
 
-    public WeblogCategory getWeblogCategory(String categoryPath) {
+
+    public WeblogCategory getWeblogCategory(String categoryName) {
         WeblogCategory category = null;
         try {
             Weblogger roller = WebloggerFactory.getWeblogger();
             WeblogEntryManager wmgr = roller.getWeblogEntryManager();
-            if (categoryPath != null && !categoryPath.equals("nil")) {
-                category = wmgr.getWeblogCategoryByName(this, categoryPath.substring(1));
+            if (categoryName != null && !categoryName.equals("nil")) {
+                category = wmgr.getWeblogCategoryByName(this, categoryName);
             } else {
                 category = this.getDefaultCategory();
             }
         } catch (WebloggerException e) {
-            log.error("ERROR: fetching category at path: " + categoryPath, e);
+            log.error("ERROR: fetching category: " + categoryName, e);
         }
         return category;
     }
-    
+
     
     /**
      * Get up to 100 most recent published entries in weblog.

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java?rev=1566434&r1=1566433&r2=1566434&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
Sun Feb  9 21:37:58 2014
@@ -307,8 +307,8 @@ public final class WeblogWrapper {
     public WeblogEntryWrapper getWeblogEntry(String anchor) {
         return WeblogEntryWrapper.wrap(this.pojo.getWeblogEntry(anchor), urlStrategy);
     }
-    
-    
+
+
     public List<WeblogCategoryWrapper> getWeblogCategories() {
         Set<WeblogCategory> unwrapped = this.pojo.getWeblogCategories();
         List<WeblogCategoryWrapper> wrapped = new ArrayList<WeblogCategoryWrapper>(unwrapped.size());
@@ -320,25 +320,11 @@ public final class WeblogWrapper {
         }
         return wrapped;
     }
-    
-    
-    public List<WeblogCategoryWrapper> getWeblogCategories(String categoryPath) {
-        Set<WeblogCategory> unwrapped = this.pojo.getWeblogCategories(categoryPath);
-        List<WeblogCategoryWrapper> wrapped = new ArrayList<WeblogCategoryWrapper>(unwrapped.size());
 
-        int i = 0;
-        for (WeblogCategory category : unwrapped) {
-            wrapped.add(i,WeblogCategoryWrapper.wrap(category, urlStrategy));
-            i++;
-        }
-        return wrapped;
+    public WeblogCategoryWrapper getWeblogCategory(String categoryName) {
+        return WeblogCategoryWrapper.wrap(this.pojo.getWeblogCategory(categoryName), urlStrategy);
     }
-    
-    
-    public WeblogCategoryWrapper getWeblogCategory(String categoryPath) {
-        return WeblogCategoryWrapper.wrap(this.pojo.getWeblogCategory(categoryPath), urlStrategy);
-    }
-    
+
     
     public List<WeblogEntryWrapper> getRecentWeblogEntries(String cat,int length) {
         List<WeblogEntry> unwrapped = this.pojo.getRecentWeblogEntries(cat, length);

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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -122,11 +122,6 @@ public class WeblogFeedRequest extends W
         if(request.getParameter("cat") != null) {
             this.weblogCategoryName =
                     URLUtilities.decode(request.getParameter("cat"));
-            
-            // all categories must start with a /
-            if(!this.weblogCategoryName.startsWith("/")) {
-                this.weblogCategoryName = "/"+this.weblogCategoryName;
-            }
         }
         
         if(request.getParameter("tags") != null) {
@@ -213,7 +208,7 @@ public class WeblogFeedRequest extends W
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName);
             } 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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -108,7 +108,7 @@ public class WeblogPageRequest extends W
          */
         if(pathInfo != null && pathInfo.trim().length() > 0) {
             
-            // all views use 2 path elements, except category
+            // all views use 2 path elements
             String[] pathElements = pathInfo.split("/", 2);
             
             // the first part of the path always represents the context
@@ -130,12 +130,6 @@ public class WeblogPageRequest extends W
                     
                 } else if("category".equals(this.context)) {
                     this.weblogCategoryName = URLUtilities.decode(pathElements[1]);
-                    
-                    // all categories must start with a /
-                    if(!this.weblogCategoryName.startsWith("/")) {
-                        this.weblogCategoryName = "/"+this.weblogCategoryName;
-                    }
-                    
                 } else if("page".equals(this.context)) {
                     this.weblogPageName = pathElements[1];
                     String tagsString = request.getParameter("tags");
@@ -207,11 +201,6 @@ public class WeblogPageRequest extends W
                 if(request.getParameter("cat") != null) {
                     this.weblogCategoryName =
                             URLUtilities.decode(request.getParameter("cat"));
-                    
-                    // all categories must start with a /
-                    if(!this.weblogCategoryName.startsWith("/")) {
-                        this.weblogCategoryName = "/"+this.weblogCategoryName;
-                    }
                 }
             }
         }
@@ -365,7 +354,7 @@ public class WeblogPageRequest extends W
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName);
             } 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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -97,13 +97,8 @@ public class WeblogSearchRequest extends
         
         if(request.getParameter("cat") != null &&
                 request.getParameter("cat").trim().length() > 0) {
-            this.weblogCategoryName = 
+            this.weblogCategoryName =
                     URLUtilities.decode(request.getParameter("cat"));
-            
-            // all categories must start with a /
-            if(!this.weblogCategoryName.startsWith("/")) {
-                this.weblogCategoryName = "/"+this.weblogCategoryName;
-            }
         }
     }
 
@@ -136,7 +131,7 @@ public class WeblogSearchRequest extends
         if(weblogCategory == null && weblogCategoryName != null) {
             try {
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName.substring(1));
+                weblogCategory = wmgr.getWeblogCategoryByName(getWeblog(), weblogCategoryName);
             } catch (WebloggerException 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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -348,7 +348,7 @@ public class EntryCollection {
         List<Category> categories = new ArrayList<Category>();
         Category atomCat = new Category();
         atomCat.setScheme(RollerAtomService.getWeblogCategoryScheme(entry.getWebsite()));
-        atomCat.setTerm(entry.getCategory().getPath().substring(1));
+        atomCat.setTerm(entry.getCategory().getName());
         categories.add(atomCat);
         
         // Add Atom categories for each Weblogger tag with null scheme
@@ -435,7 +435,7 @@ public class EntryCollection {
                     if (catString != null) {
                         WeblogCategory rollerCat =
                                 roller.getWeblogEntryManager().getWeblogCategoryByName(
-                                rollerEntry.getWebsite(), catString.substring(1));
+                                rollerEntry.getWebsite(), catString);
                         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=1566434&r1=1566433&r2=1566434&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 21:37:58 2014
@@ -86,7 +86,7 @@ public class MetaWeblogAPIHandler extend
             WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
             List<WeblogCategory> cats = weblogMgr.getWeblogCategories(website, false);
             for (WeblogCategory category : cats) {
-                result.put(category.getPath(),
+                result.put(category.getName(),
                         createCategoryStruct(category, userid));
             }
             return result;
@@ -486,7 +486,7 @@ public class MetaWeblogAPIHandler extend
         struct.put("author", entry.getCreator().getEmailAddress());
         
         Vector catArray = new Vector();
-        catArray.addElement(entry.getCategory().getPath());
+        catArray.addElement(entry.getCategory().getName());
         struct.put("categories", catArray);
         
         return struct;
@@ -496,8 +496,8 @@ public class MetaWeblogAPIHandler extend
     private Hashtable createCategoryStruct(WeblogCategory category, String userid) {
         
         Hashtable struct = new Hashtable();
-        struct.put("title", category.getPath());
-        struct.put("description", category.getPath());
+        struct.put("title", category.getName());
+        struct.put("description", category.getName());
         
         Weblogger roller = WebloggerFactory.getWeblogger();
         URLStrategy strategy = roller.getUrlStrategy();

Modified: roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm?rev=1566434&r1=1566433&r2=1566434&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm Sun Feb  9 21:37:58 2014
@@ -703,7 +703,7 @@ Recursively display a bookmark folder an
     <li><a href="$url.feed.entries.atom">$text.get("macro.rss.all")</a></li>
     #set($categories = $weblog.weblogCategories )
     #foreach( $cat in $categories )
-        <li><a href="$url.feed.entries.atom($cat.path, false)">$cat.path</a></li>
+        <li><a href="$url.feed.entries.atom($cat.name, false)">$cat.name</a></li>
     #end
     <li><a href="$url.feed.comments.atom">Comments</a></li>
     </ul>
@@ -718,7 +718,7 @@ Recursively display a bookmark folder an
     <li><a href="$url.feed.entries.rss">$text.get("macro.rss.all")</a></li>
     #set($categories = $weblog.weblogCategories )
     #foreach( $cat in $categories )
-        <li><a href="$url.feed.entries.rss($cat.path, false)">$cat.path</a></li>
+        <li><a href="$url.feed.entries.rss($cat.name, false)">$cat.name</a></li>
     #end
     <li><a href="$url.feed.comments.rss">Comments</a></li>
     </ul>
@@ -857,7 +857,7 @@ Show search form for a weblog.
         <p>
           <input type="text" id="q" name="q" size="10" class="text small" maxlength="255"
value="#if($model.term)$model.term#end" />
           #if( $showCatChooser )
-            #set( $cats = $model.weblog.getWeblogCategories("nil") )
+            #set( $cats = $model.weblog.getWeblogCategories())
             <select name="cat">
             <option value="">- $text.get("mainPage.category") -</option>
             #foreach( $cat in $cats )
@@ -885,7 +885,7 @@ Show search form for a weblog.
         <p>
           <input type="search" id="q" name="q" placeholder="Search..." maxlength="255"
value="#if($model.term)$model.term#end" />
           #if( $showCatChooser )
-            #set( $cats = $model.weblog.getWeblogCategories("nil") )
+            #set( $cats = $model.weblog.getWeblogCategories())
             <select name="cat">
             <option value="">- $text.get("mainPage.category") -</option>
             #foreach( $cat in $cats )
@@ -922,7 +922,7 @@ Show search again form for a weblog.
         $text.get( "macro.weblog.searchhits", [$model.hits])
         <form method="get" action="$url.search" style="margin: 5px">
             <input type="text" id="q" name="q" class="text medium" maxlength="255" value="$model.term"
style="padding-left: 1px" /><br />
-            #set( $cats = $model.weblog.getWeblogCategories("nil") )
+            #set( $cats = $model.weblog.getWeblogCategories())
             <select name="cat" class="select">
             <option value="">$text.get( "macro.searchresults.incategory" )</option>
             #foreach( $cat in $cats )
@@ -943,7 +943,7 @@ Show search again form for a weblog.
         $text.get( "macro.weblog.searchhits", [$model.hits])
         <form method="get" action="$url.search" style="margin: 5px">
             <input type="search" id="q" name="q" placeholder="Search..." maxlength="255"
value="$model.term" />
-            #set( $cats = $model.weblog.getWeblogCategories("nil") )
+            #set( $cats = $model.weblog.getWeblogCategories())
             <select name="cat" class="select">
             <option value="">$text.get( "macro.searchresults.incategory" )</option>
             #foreach( $cat in $cats )

Modified: roller/trunk/docs/roller-template-guide.odt
URL: http://svn.apache.org/viewvc/roller/trunk/docs/roller-template-guide.odt?rev=1566434&r1=1566433&r2=1566434&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message