roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r453805 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller: business/hibernate/ business/search/operations/ model/ ui/authoring/struts/actions/ ui/rendering/
Date Fri, 06 Oct 2006 23:20:23 GMT
Author: snoopdave
Date: Fri Oct  6 16:20:23 2006
New Revision: 453805

URL: http://svn.apache.org/viewvc?view=rev&rev=453805
Log:
Fixes for category delete and save problems (ROL-1163 and ROL-1165)

Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/
  (props changed)
    incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategoryDeleteAction.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategorySaveAction.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?view=diff&rev=453805&r1=453804&r2=453805
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
Fri Oct  6 16:20:23 2006
@@ -30,7 +30,6 @@
 import java.util.Map;
 import java.util.TreeMap;
 import org.apache.commons.collections.comparators.ReverseComparator;
-import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
@@ -86,8 +85,8 @@
     
     public void saveWeblogCategory(WeblogCategoryData cat) throws RollerException {
         
-        if(this.isDuplicateWeblogCategoryName(cat)) {
-            throw new RollerException("Duplicate category name");
+        if (StringUtils.isEmpty(cat.getId()) && isDuplicateWeblogCategoryName(cat))
{
+            throw new RollerException("Duplicate category name, cannot save new category");
         }
         
         // update weblog last modified date.  date updated by saveWebsite()
@@ -124,32 +123,24 @@
     }
     
     
-    public void moveWeblogCategoryContents(String srcId, String destId)
+    public void moveWeblogCategoryContents(WeblogCategoryData srcCat, WeblogCategoryData
destCat)
             throws RollerException {
-        
-        WeblogCategoryData srcCd =
-                (WeblogCategoryData) this.strategy.load(
-                srcId, WeblogCategoryData.class);
-        
-        WeblogCategoryData destCd =
-                (WeblogCategoryData) this.strategy.load(
-                destId, WeblogCategoryData.class);
-        
+                
         // TODO: this check should be made before calling this method?
-        if (destCd.descendentOf(srcCd)) {
+        if (destCat.descendentOf(srcCat)) {
             throw new RollerException(
                     "ERROR cannot move parent category into it's own child");
         }
         
         // get all entries in category and subcats
-        List results = getWeblogEntries(srcCd, true);
+        List results = srcCat.retrieveWeblogEntries(true);
         
         // Loop through entries in src cat, assign them to dest cat
         Iterator iter = results.iterator();
-        WebsiteData website = destCd.getWebsite();
+        WebsiteData website = destCat.getWebsite();
         while (iter.hasNext()) {
             WeblogEntryData entry = (WeblogEntryData) iter.next();
-            entry.setCategory(destCd);
+            entry.setCategory(destCat);
             entry.setWebsite(website);
             this.strategy.store(entry);
         }
@@ -157,16 +148,16 @@
         // Make sure website's default and bloggerapi categories
         // are valid after the move
         
-        if (srcCd.getWebsite().getDefaultCategory().getId().equals(srcId)
-        || srcCd.getWebsite().getDefaultCategory().descendentOf(srcCd)) {
-            srcCd.getWebsite().setDefaultCategory(destCd);
-            this.strategy.store(srcCd.getWebsite());
+        if (srcCat.getWebsite().getDefaultCategory().getId().equals(srcCat.getId())
+        || srcCat.getWebsite().getDefaultCategory().descendentOf(srcCat)) {
+            srcCat.getWebsite().setDefaultCategory(destCat);
+            this.strategy.store(srcCat.getWebsite());
         }
         
-        if (srcCd.getWebsite().getBloggerCategory().getId().equals(srcId)
-        || srcCd.getWebsite().getBloggerCategory().descendentOf(srcCd)) {
-            srcCd.getWebsite().setBloggerCategory(destCd);
-            this.strategy.store(srcCd.getWebsite());
+        if (srcCat.getWebsite().getBloggerCategory().getId().equals(srcCat.getId())
+        || srcCat.getWebsite().getBloggerCategory().descendentOf(srcCat)) {
+            srcCat.getWebsite().setBloggerCategory(destCat);
+            this.strategy.store(srcCat.getWebsite());
         }
     }
     
@@ -674,7 +665,7 @@
             } catch (HibernateException e) {
                 throw new RollerException(e);
             }
-            if (sameNames.size() > 1) {
+            if (sameNames.size() > 0) {
                 return true;
             }
         }

Propchange: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Oct  6 16:20:23 2006
@@ -1 +1,2 @@
 .LCKIndexOperation.java~
+.LCKReIndexEntryOperation.java~

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java?view=diff&rev=453805&r1=453804&r2=453805
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java Fri
Oct  6 16:20:23 2006
@@ -236,7 +236,7 @@
     /**
      * Recategorize all entries with one category to another.
      */
-    public void moveWeblogCategoryContents(String srcId, String destId) 
+    public void moveWeblogCategoryContents(WeblogCategoryData srcCat, WeblogCategoryData
destCat) 
             throws RollerException;
     
     /**

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategoryDeleteAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategoryDeleteAction.java?view=diff&rev=453805&r1=453804&r2=453805
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategoryDeleteAction.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategoryDeleteAction.java
Fri Oct  6 16:20:23 2006
@@ -85,8 +85,7 @@
                     // root and the sub-cats of the category being deleted.
                     if (!cat.getId().equals(catid) 
                         && cat.getParent()!=null
-                        && !cat.descendentOf(catToDelete)
-                        && cat.retrieveWeblogEntries(true).size() < 1)
+                        && !cat.descendentOf(catToDelete))
                     {
                         destCats.add(cat);
                     }                    
@@ -113,15 +112,32 @@
                 
                 // User clicked YES to delete
                 // remove cat to delete
+                if (form.getMoveToWeblogCategoryId() != null) 
+                {
+                    WeblogCategoryData destCat = 
+                        wmgr.getWeblogCategory(form.getMoveToWeblogCategoryId());
+                    if (rses.isUserAuthorizedToAuthor(destCat.getWebsite())) 
+                    {
+                        wmgr.moveWeblogCategoryContents(catToDelete, destCat);          
     
+                        RollerFactory.getRoller().flush();
+                    } 
+                    else 
+                    {
+                        return mapping.findForward("access-denied");
+                    }
+                }
+                                
+                catToDelete = wmgr.getWeblogCategory(catToDelete.getId());
                 wmgr.removeWeblogCategory(catToDelete);
                 RollerFactory.getRoller().flush();
-                
+
                 // notify caches of invalidated object
                 CacheManager.invalidate(catToDelete);
-                
-                if (null != returnId) {
+
+                if (null != returnId) 
+                {
                     request.setAttribute(RequestConstants.WEBLOGCATEGORY_ID, returnId);
-                }               
+                }  
             }
             else 
             {

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategorySaveAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategorySaveAction.java?view=diff&rev=453805&r1=453804&r2=453805
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategorySaveAction.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CategorySaveAction.java
Fri Oct  6 16:20:23 2006
@@ -38,6 +38,7 @@
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.roller.ui.authoring.struts.formbeans.WeblogCategoryFormEx;
 import org.apache.roller.ui.core.RequestConstants;
+import org.apache.roller.RollerException;
 
 /**
  * @struts.action path="/roller-ui/authoring/categorySave" name="weblogCategoryFormEx"
@@ -78,11 +79,18 @@
             rses.getAuthenticatedUser(), PermissionsData.AUTHOR))
         {
             form.copyTo(cd, request.getLocale());
-            wmgr.saveWeblogCategory(cd);
-            RollerFactory.getRoller().flush();
-            
-            // notify caches of object invalidation
-            CacheManager.invalidate(cd);
+            try {
+                wmgr.saveWeblogCategory(cd);
+                RollerFactory.getRoller().flush();
+                
+                // notify caches of object invalidation
+                CacheManager.invalidate(cd);
+            } catch (RollerException re) {
+                ActionErrors errors = new ActionErrors();
+                errors.add(ActionErrors.GLOBAL_ERROR,
+                    new ActionError("error.untranslated", re.getMessage())); 
+                saveErrors(request, errors);
+            }            
         }
         else
         {

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java?view=diff&rev=453805&r1=453804&r2=453805
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
Fri Oct  6 16:20:23 2006
@@ -25,6 +25,7 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.config.RollerConfig;
@@ -103,6 +104,12 @@
         // figure out potential weblog handle
         String servlet = request.getServletPath();
         String pathInfo = null;
+        
+        // WAS6.1 returns "" for servletPath use pathInfo instead
+        if (StringUtils.isEmpty(request.getServletPath())) {
+            servlet = request.getPathInfo();
+        }
+        
         if(servlet != null && servlet.trim().length() > 1) {
             
             // strip off the leading slash



Mime
View raw message