roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1588757 [12/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/...
Date Sun, 20 Apr 2014 13:39:01 GMT
Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetEditBase.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetEditBase.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetEditBase.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetEditBase.java Sun Apr 20 13:38:51 2014
@@ -18,7 +18,7 @@
 
 package org.apache.roller.weblogger.ui.struts2.common;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetsBase.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetsBase.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetsBase.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetsBase.java Sun Apr 20 13:38:51 2014
@@ -20,7 +20,7 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
@@ -36,7 +36,7 @@ import org.apache.roller.weblogger.ui.st
 public abstract class PingTargetsBase extends UIAction {
     
     // list of available ping targets
-    private List pingTargets = Collections.EMPTY_LIST;
+    private List<PingTarget> pingTargets = Collections.emptyList();
     
     // ping target we are working on, if any
     private PingTarget pingTarget = null;
@@ -124,11 +124,11 @@ public abstract class PingTargetsBase ex
     }
     
     
-    public List getPingTargets() {
+    public List<PingTarget> getPingTargets() {
         return pingTargets;
     }
 
-    public void setPingTargets(List pingTargets) {
+    public void setPingTargets(List<PingTarget> pingTargets) {
         this.pingTargets = pingTargets;
     }
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java Sun Apr 20 13:38:51 2014
@@ -18,8 +18,8 @@
 
 package org.apache.roller.weblogger.ui.struts2.core;
 
-import org.apache.commons.lang.CharSetUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.CharSetUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/MainMenu.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/MainMenu.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/MainMenu.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/MainMenu.java Sun Apr 20 13:38:51 2014
@@ -27,6 +27,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.WeblogPermission;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 
@@ -99,21 +100,21 @@ public class MainMenu extends UIAction {
         return SUCCESS;
     }
 
-    public List getExistingPermissions() {
+    public List<WeblogPermission> getExistingPermissions() {
         try {
             UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
             return mgr.getWeblogPermissions(getAuthenticatedUser());
         } catch(Exception e) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }
     
-    public List getPendingPermissions() {
+    public List<WeblogPermission> getPendingPermissions() {
         try {
             UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
             return mgr.getPendingWeblogPermissions(getAuthenticatedUser());
         } catch(Exception e) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/OAuthAuthorize.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/OAuthAuthorize.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/OAuthAuthorize.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/OAuthAuthorize.java Sun Apr 20 13:38:51 2014
@@ -53,12 +53,9 @@ public class OAuthAuthorize extends UIAc
     public String execute() {
         try {
             User ud = getAuthenticatedUser();
-
-
         } catch (Exception ex) {
             log.error("ERROR fetching user information", ex);
         }
-
         return SUCCESS;
     }
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java Sun Apr 20 13:38:51 2014
@@ -17,7 +17,7 @@
  */
 package org.apache.roller.weblogger.ui.struts2.core;
 
-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.weblogger.WebloggerException;
@@ -145,12 +145,9 @@ public class Profile extends UIAction {
 
     
     public void myValidate() {
-
-        // check that passwords match if they were specified
-        if (!StringUtils.isEmpty(getBean().getPasswordText())) {
-            if (!getBean().getPasswordText().equals(getBean().getPasswordConfirm())) {
-                addError("Register.error.passowordMismatch");
-            }
+        // check that passwords match if they were specified (w/StringUtils.equals, null == null)
+        if (!StringUtils.equals(getBean().getPasswordText(), getBean().getPasswordConfirm())) {
+            addError("userRegister.error.mismatchedPasswords");
         }
     }
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java Sun Apr 20 13:38:51 2014
@@ -21,9 +21,9 @@ package org.apache.roller.weblogger.ui.s
 import java.util.TimeZone;
 import java.util.UUID;
 import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.lang.CharSetUtils;
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.CharSetUtils;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -33,6 +33,7 @@ import org.apache.roller.weblogger.confi
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.UserAttribute;
+import org.apache.roller.weblogger.ui.core.RollerSession;
 import org.apache.roller.weblogger.ui.core.security.CustomUserRegistry;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.MailUtil;
@@ -41,7 +42,6 @@ import org.apache.struts2.interceptor.va
 //import org.springframework.security.userdetails.openid.OpenIDUserAttribute;
 
 
-
 /**
  * Actions for registering a new user.
  */
@@ -54,7 +54,7 @@ public class Register extends UIAction i
     // this is a no-no, we should not need this
     private HttpServletRequest servletRequest = null;
     
-    private boolean fromSS0 = false;
+    private boolean fromSSO = false;
     private String activationStatus = null;
     
     private String activationCode = null;
@@ -101,15 +101,14 @@ public class Register extends UIAction i
         
         /* TODO: when Spring Security 2.1 is release comment out this stuff, 
          * which pre-populates the user bean with info from OpenID provider.
-         * 
+         *
         Collection attrsCollect = (Collection)WebloggerFactory.getWeblogger()
                 .getUserManager().userAttributes.get(UserAttribute.Attributes.openidUrl.toString());
         
         if (attrsCollect != null) {
             ArrayList attrs = new ArrayList(attrsCollect);
-            for (Iterator it = attrs.iterator(); it.hasNext();) {                
-                OpenIDUserAttribute attr = (OpenIDUserAttribute) it.next();    
-                if (attr.getName().equals(OpenIDUserAttribute.Attributes.country.toString())) {                                        
+            for (OpenIDUserAttribute attr : attrs) {
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.country.toString())) {
                     getBean().setLocale(UIUtils.getLocale(attr.getValue()));
                 }                
                if (attr.getName().equals(OpenIDUserAttribute.Attributes.email.toString())) {
@@ -136,18 +135,18 @@ public class Register extends UIAction i
             boolean usingSSO = WebloggerConfig.getBooleanProperty("users.sso.enabled");
             if (usingSSO) {
                 // See if user is already logged in via Spring Security
-                User fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication(getServletRequest());
-                if (fromSSO != null) {
+                User fromSSOUser = CustomUserRegistry.getUserDetailsFromAuthentication(getServletRequest());
+                if (fromSSOUser != null) {
                     // Copy user details from Spring Security, including LDAP attributes
-                    getBean().copyFrom(fromSSO);
-                    setFromSso(true);
+                    getBean().copyFrom(fromSSOUser);
+                    setFromSSO(true);
                 }
                 // See if user is already logged in via CMA
                 else if (getServletRequest().getUserPrincipal() != null) {
                     // Only detail we get is username, sadly no LDAP attributes
                     getBean().setUserName(getServletRequest().getUserPrincipal().getName());
                     getBean().setScreenName(getServletRequest().getUserPrincipal().getName());
-                    setFromSso(true);
+                    setFromSSO(true);
                 }
             }
             
@@ -249,15 +248,16 @@ public class Register extends UIAction i
                         // send activation mail to the user
                         MailUtil.sendUserActivationEmail(ud);
                     } catch (WebloggerException ex) {
-                        log.error("Error sending activation email to - "+ud.getEmailAddress(), ex);
+                        log.error("Error sending activation email to - " + ud.getEmailAddress(), ex);
                     }
 
                     setActivationStatus("pending");
                 }
 
                 // Invalidate session, otherwise new user who was originally
-                // authenticated via LDAP/SSO will remain logged in with
-                // a but without a valid Roller role.
+                // authenticated via LDAP/SSO will remain logged in but
+                // without a valid Roller role.
+                getServletRequest().getSession().removeAttribute(RollerSession.ROLLER_SESSION);
                 getServletRequest().getSession().invalidate();
 
                 // set a special page title
@@ -320,22 +320,22 @@ public class Register extends UIAction i
     public void myValidate() {
         
         // if usingSSO, we don't want to error on empty password/username from HTML form.
-        setFromSso(false);
+        setFromSSO(false);
         boolean usingSSO = WebloggerConfig.getBooleanProperty("users.sso.enabled");
         if (usingSSO) {
             boolean storePassword = WebloggerConfig.getBooleanProperty("users.sso.passwords.saveInRollerDb");
             String password = WebloggerConfig.getProperty("users.sso.passwords.defaultValue", "<unknown>");
             
             // Preserve username and password, Spring Security case
-            User fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication(getServletRequest());
-            if (fromSSO != null) {
+            User fromSSOUser = CustomUserRegistry.getUserDetailsFromAuthentication(getServletRequest());
+            if (fromSSOUser != null) {
                 if (storePassword) {
-                    password = fromSSO.getPassword();
+                    password = fromSSOUser.getPassword();
                 }
                 getBean().setPasswordText(password);
                 getBean().setPasswordConfirm(password);
-                getBean().setUserName(fromSSO.getUserName());
-                setFromSso(true);
+                getBean().setUserName(fromSSOUser.getUserName());
+                setFromSSO(true);
             }
 
             // Preserve username and password, CMA case             
@@ -343,7 +343,7 @@ public class Register extends UIAction i
                 getBean().setUserName(getServletRequest().getUserPrincipal().getName());
                 getBean().setPasswordText(password);
                 getBean().setPasswordConfirm(password);
-                setFromSso(true);
+                setFromSSO(true);
             }
         }
         
@@ -359,7 +359,7 @@ public class Register extends UIAction i
         }
         
         // check password, it is required if OpenID and SSO are disabled
-        if (getOpenIdConfiguration().equals("disabled") && !getFromSso()
+        if (getOpenIdConfiguration().equals("disabled") && !getFromSSO()
                 && StringUtils.isEmpty(getBean().getPasswordText())) {
                 addError("error.add.user.passwordEmpty");
                 return;
@@ -411,12 +411,12 @@ public class Register extends UIAction i
         this.bean = bean;
     }
 
-    public boolean getFromSso() {
-        return fromSS0;
+    public boolean getFromSSO() {
+        return fromSSO;
     }
 
-    public void setFromSso(boolean fromSS0) {
-        this.fromSS0 = fromSS0;
+    public void setFromSSO(boolean fromSSO) {
+        this.fromSSO = fromSSO;
     }
 
     public String getActivationStatus() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkAdd.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkAdd.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkAdd.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkAdd.java Sun Apr 20 13:38:51 2014
@@ -22,7 +22,8 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.List;
-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.weblogger.WebloggerException;
@@ -103,10 +104,12 @@ public class BookmarkAdd extends UIActio
         
         if(!hasActionErrors()) {
             try {
-
-                WeblogBookmark newBookmark = new WeblogBookmark();
-                newBookmark.setFolder(getFolder());
-                getBean().copyTo(newBookmark);
+                WeblogBookmark newBookmark = new WeblogBookmark(getFolder(),
+                        getBean().getName(),
+                        getBean().getDescription(),
+                        getBean().getUrl(),
+                        getBean().getFeedUrl(),
+                        getBean().getImage());
 
                 BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
                 bmgr.saveBookmark(newBookmark);
@@ -114,8 +117,7 @@ public class BookmarkAdd extends UIActio
 
                 CacheManager.invalidate(newBookmark);
 
-                // TODO: i18n
-                addMessage("bookmark added");
+                addMessage("bookmarkForm.created");
 
                 // Set for next action
                 getBean().setId(newBookmark.getId());
@@ -133,22 +135,19 @@ public class BookmarkAdd extends UIActio
         return INPUT;
     }
 
+    /**
+     * Cancel.
+     * 
+     * @return the string
+     */
+    public String cancel() {
+        return CANCEL;
+    }
     
-    // TODO: validation
     public void myValidate() {
-        
         // name is required, max length, no html
-        
-        // url is required, valid url
-        
-        if (StringUtils.isNotEmpty(getBean().getUrl()) && !validURL(getBean().getUrl())) {
-            addError("bookmarkForm.error.invalidURL", getBean().getUrl());
-        }
-        if (StringUtils.isNotEmpty(getBean().getFeedUrl()) && !validURL(getBean().getFeedUrl())) {
-            addError("bookmarkForm.error.invalidURL", getBean().getFeedUrl());
-        }
-        if (StringUtils.isNotEmpty(getBean().getImage()) && !validURL(getBean().getImage())) {
-            addError("bookmarkForm.error.invalidURL", getBean().getImage());
+        if (getFolder().hasBookmarkOfName(getBean().getName())) {
+            addError("bookmarkForm.error.duplicateName", getBean().getUrl());
         }
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkBean.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkBean.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkBean.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkBean.java Sun Apr 20 13:38:51 2014
@@ -30,8 +30,6 @@ public class BookmarkBean {
     private String name = null;
     private String description = null;
     private String url = null;
-    private Integer weight = 0;
-    private Integer priority = 0;
     private String image = null;
     private String feedUrl = null;
     
@@ -68,22 +66,6 @@ public class BookmarkBean {
         this.url = url;
     }
     
-    public Integer getWeight() {
-        return this.weight;
-    }
-    
-    public void setWeight( Integer weight ) {
-        this.weight = weight;
-    }
-    
-    public Integer getPriority() {
-        return this.priority;
-    }
-    
-    public void setPriority( Integer priority ) {
-        this.priority = priority;
-    }
-    
     public String getImage() {
         return this.image;
     }
@@ -105,8 +87,6 @@ public class BookmarkBean {
         dataHolder.setName(this.name);
         dataHolder.setDescription(this.description);
         dataHolder.setUrl(this.url);
-        dataHolder.setWeight(this.weight);
-        dataHolder.setPriority(this.priority);
         dataHolder.setImage(this.image);
         dataHolder.setFeedUrl(this.feedUrl);
     }
@@ -117,8 +97,6 @@ public class BookmarkBean {
         this.name = dataHolder.getName();
         this.description = dataHolder.getDescription();
         this.url = dataHolder.getUrl();
-        this.weight = dataHolder.getWeight();
-        this.priority = dataHolder.getPriority();
         this.image = dataHolder.getImage();
         this.feedUrl = dataHolder.getFeedUrl();
     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java Sun Apr 20 13:38:51 2014
@@ -22,7 +22,8 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.List;
-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.weblogger.WebloggerException;
@@ -42,6 +43,9 @@ public class BookmarkEdit extends UIActi
     
     private static Log log = LogFactory.getLog(BookmarkEdit.class);
     
+    // the id of the folder we are working with
+    private String folderId = null;
+    
     // the bookmark we are editing
     private WeblogBookmark bookmark = null;
     
@@ -110,8 +114,8 @@ public class BookmarkEdit extends UIActi
 
                 CacheManager.invalidate(getBookmark());
 
-                // TODO: i18n
-                addMessage("bookmark updated");
+                addMessage("bookmarkForm.changesSaved");
+
             } catch(Exception ex) {
                 log.error("Error saving bookmark", ex);
                 // TODO: i18n
@@ -122,6 +126,14 @@ public class BookmarkEdit extends UIActi
         return INPUT;
     }
 
+    /**
+     * Cancel.
+     * 
+     * @return the string
+     */
+    public String cancel() {
+        return CANCEL;
+    }
     
     public void myValidate() {
         if (StringUtils.isNotEmpty(getBean().getUrl()) && !validURL(getBean().getUrl())) {
@@ -144,6 +156,13 @@ public class BookmarkEdit extends UIActi
         return valid;
     }
     
+    public String getFolderId() {
+        return folderId;
+    }
+
+    public void setFolderId(String folderId) {
+        this.folderId = folderId;
+    }
     
     public WeblogBookmark getBookmark() {
         return bookmark;

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java Sun Apr 20 13:38:51 2014
@@ -18,13 +18,11 @@
 
 package org.apache.roller.weblogger.ui.struts2.editor;
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-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.weblogger.WebloggerException;
@@ -37,289 +35,255 @@ import org.apache.roller.weblogger.ui.st
 import org.apache.roller.weblogger.util.cache.CacheManager;
 
 /**
- * List bookmarks and folders and allow for moving them around and deleting
- * them.
+ * List bookmarks and folders and allow for moving them around and deleting them.
  */
 public class Bookmarks extends UIAction {
 
-	private static Log log = LogFactory.getLog(Bookmarks.class);
+    private static Log log = LogFactory.getLog(Bookmarks.class);
 
-	// the id of folder being viewed
-	private String folderId = null;
+    // the id of folder being viewed
+    private String folderId = null;
 
-	// the folder being viewed
-	private WeblogBookmarkFolder folder = null;
+    // the folder being viewed
+    private WeblogBookmarkFolder folder = null;
 
-	// the list of folders to move/delete
-	private String[] selectedFolders = null;
-
-	// the list of bookmarks to move/delete
-	private String[] selectedBookmarks = null;
-
-	// the target folder to move items to
-	private String targetFolderId = null;
-
-	// all folders from the action weblog
-	private Set allFolders = Collections.EMPTY_SET;
-
-	// path of folders representing selected folders hierarchy
-	private List folderPath = Collections.EMPTY_LIST;
-
-	public Bookmarks() {
-		this.actionName = "bookmarks";
-		this.desiredMenu = "editor";
-		this.pageTitle = "bookmarksForm.rootTitle";
-	}
-
-	// admin perms required
-	public List<String> requiredWeblogPermissionActions() {
-		return Collections.singletonList(WeblogPermission.ADMIN);
-	}
-
-	public void myPrepare() {
-		try {
-			BookmarkManager bmgr = WebloggerFactory.getWeblogger()
-					.getBookmarkManager();
-			if (!StringUtils.isEmpty(getFolderId())
-					&& !"/".equals(getFolderId())) {
-				setFolder(bmgr.getFolder(getFolderId()));
-			} else {
-				setFolder(bmgr.getRootFolder(getActionWeblog()));
-			}
-		} catch (WebloggerException ex) {
-			log.error("Error looking up folder", ex);
-		}
-	}
-
-	/**
-	 * Present the bookmarks and subfolders available in the folder specified by
-	 * the request.
-	 */
-	public String execute() {
-
-		// build list of folders for display
-		TreeSet newFolders = new TreeSet(new FolderPathComparator());
-
-		try {
-			// Build list of all folders, except for current one, sorted by
-			// path.
-			BookmarkManager bmgr = WebloggerFactory.getWeblogger()
-					.getBookmarkManager();
-			List<WeblogBookmarkFolder> folders = bmgr
-					.getAllFolders(getActionWeblog());
-			for (WeblogBookmarkFolder fd : folders) {
-				if (getFolderId() == null && fd.getParent() == null) {
-					// Root folder so do not show the root /
-				} else if (!fd.getId().equals(getFolderId())) {
-					newFolders.add(fd);
-				}
-			}
-
-			// build folder path
-			WeblogBookmarkFolder parent = getFolder().getParent();
-			if (parent != null) {
-				List inFolderPath = new LinkedList();
-				inFolderPath.add(0, getFolder());
-				while (parent != null) {
-					inFolderPath.add(0, parent);
-					parent = parent.getParent();
-				}
-				setFolderPath(inFolderPath);
-			}
-		} catch (WebloggerException ex) {
-			log.error("Error building folders list", ex);
-			// TODO: i18n
-			addError("Error building folders list");
-		}
-
-		if (newFolders.size() > 0) {
-			setAllFolders(newFolders);
-		}
-
-		return LIST;
-	}
-
-	/**
-	 * Delete folders and bookmarks.
-	 */
-	public String delete() {
-
-		BookmarkManager bmgr = WebloggerFactory.getWeblogger()
-				.getBookmarkManager();
-
-		log.debug("Deleting selected folders and bookmarks.");
-
-		try {
-			String folders[] = getSelectedFolders();
-			if (null != folders && folders.length > 0) {
-				if (log.isDebugEnabled()) {
-                    log.debug("Processing delete of " + folders.length
-                            + " folders.");
+    // the list of bookmarks to move or delete
+    private String[] selectedBookmarks = null;
+
+    // the target folder to move items to
+    private String targetFolderId = null;
+
+    // a new folder the user wishes to view
+    private String viewFolderId = null;
+
+    // all folders from the action weblog
+    private List<WeblogBookmarkFolder> allFolders = Collections.emptyList();
+
+    public Bookmarks() {
+        this.actionName = "bookmarks";
+        this.desiredMenu = "editor";
+        this.pageTitle = "bookmarksForm.rootTitle";
+    }
+
+    // admin perms required
+    public List<String> requiredWeblogPermissionActions() {
+        return Collections.singletonList(WeblogPermission.ADMIN);
+    }
+
+    public void myPrepare() {
+        try {
+            BookmarkManager bmgr = WebloggerFactory.getWeblogger()
+                    .getBookmarkManager();
+            if (!StringUtils.isEmpty(getFolderId())) {
+                setFolder(bmgr.getFolder(getFolderId()));
+            } else {
+                setFolder(bmgr.getDefaultFolder(getActionWeblog()));
+                setFolderId(getFolder().getId());
+            }
+        } catch (WebloggerException ex) {
+            log.error("Error looking up folder", ex);
+        }
+    }
+
+    /**
+     * Present the bookmarks available in the folder specified by the request.
+     */
+    public String execute() {
+
+        // build list of folders that the user can navigate to
+        List<WeblogBookmarkFolder> newFolders = new ArrayList<WeblogBookmarkFolder>();
+
+        try {
+            // Build list of all folders, except for current one
+            BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
+            List<WeblogBookmarkFolder> folders = bmgr.getAllFolders(getActionWeblog());
+            for (WeblogBookmarkFolder fd : folders) {
+                if (!fd.getId().equals(getFolderId())) {
+                    newFolders.add(fd);
                 }
-				for (int i = 0; i < folders.length; i++) {
-					if (log.isDebugEnabled()) {
-                        log.debug("Deleting folder - " + folders[i]);
-                    }
-					WeblogBookmarkFolder fd = bmgr.getFolder(folders[i]);
-					if (fd != null) {
-						bmgr.removeFolder(fd); // removes child folders and
-						// bookmarks too
-					}
-				}
-			}
-
-			WeblogBookmark bookmark = null;
-			String bookmarks[] = getSelectedBookmarks();
-			if (null != bookmarks && bookmarks.length > 0) {
-				if (log.isDebugEnabled()) {
+            }
+
+        } catch (WebloggerException ex) {
+            log.error("Error building folders list", ex);
+            addError("Error building folders list");
+        }
+
+        if (newFolders.size() > 0) {
+            setAllFolders(newFolders);
+        }
+
+        return LIST;
+    }
+
+    /**
+     * Delete bookmarks.
+     */
+    public String delete() {
+
+        BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
+
+        try {
+            WeblogBookmark bookmark;
+            String bookmarks[] = getSelectedBookmarks();
+            if (null != bookmarks && bookmarks.length > 0) {
+                if (log.isDebugEnabled()) {
                     log.debug("Processing delete of " + bookmarks.length
                             + " bookmarks.");
                 }
-				for (int j = 0; j < bookmarks.length; j++) {
-					if (log.isDebugEnabled()) {
-						log.debug("Deleting bookmark - " + bookmarks[j]);
+                for (int j = 0; j < bookmarks.length; j++) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Deleting bookmark - " + bookmarks[j]);
+                    }
+                    bookmark = bmgr.getBookmark(bookmarks[j]);
+                    if (bookmark != null) {
+                        bmgr.removeBookmark(bookmark);
                     }
-					bookmark = bmgr.getBookmark(bookmarks[j]);
-					if (bookmark != null) {
-						bmgr.removeBookmark(bookmark);
-					}
-
-				}
-			}
-
-			// flush changes
-			WebloggerFactory.getWeblogger().flush();
-
-			// notify caches
-			CacheManager.invalidate(getActionWeblog());
-
-		} catch (WebloggerException ex) {
-			log.error("Error doing folder/bookmark deletes", ex);
-			// TODO: i18n
-			addError("Error doing folder/bookmark deletes");
-		}
-
-		return execute();
-	}
-
-	/**
-	 * Move folders and bookmarks to a new folder.
-	 */
-	public String move() {
-
-		try {
-			BookmarkManager bmgr = WebloggerFactory.getWeblogger()
-					.getBookmarkManager();
 
-			if (log.isDebugEnabled()) {
-                log.debug("Moving folders and bookmarks to folder - "
+                }
+            }
+
+            // flush changes
+            WebloggerFactory.getWeblogger().flush();
+
+            // notify caches
+            CacheManager.invalidate(getActionWeblog());
+
+        } catch (WebloggerException ex) {
+            log.error("Error doing bookmark deletes", ex);
+            addError("Error doing bookmark deletes");
+        }
+
+        return execute();
+    }
+
+    public String deleteFolder() {
+
+        try {
+            BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
+            WeblogBookmarkFolder fd = bmgr.getFolder(getFolderId());
+            if (fd != null) {
+                bmgr.removeFolder(fd);
+
+                // flush changes
+                WebloggerFactory.getWeblogger().flush();
+
+                // notify caches
+                CacheManager.invalidate(getActionWeblog());
+
+                // re-route to default folder
+                setFolder(bmgr.getDefaultFolder(getActionWeblog()));
+                setFolderId(getFolder().getId());
+            }
+        } catch (WebloggerException ex) {
+            log.error("Error deleting folder", ex);
+        }
+        return execute();
+    }
+
+
+    /**
+     * View the contents of another bookmark folder.
+     */
+    public String view() {
+
+        try {
+            BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
+            if (!StringUtils.isEmpty(viewFolderId)) {
+                setFolder(bmgr.getFolder(viewFolderId));
+                setFolderId(viewFolderId);
+            }
+        } catch (WebloggerException ex) {
+            log.error("Error looking up folder", ex);
+        }
+        return execute();
+    }
+
+    /**
+     * Move bookmarks to a new folder.
+     */
+    public String move() {
+
+        try {
+            BookmarkManager bmgr = WebloggerFactory.getWeblogger()
+                    .getBookmarkManager();
+
+            if (log.isDebugEnabled()) {
+                log.debug("Moving bookmarks to folder - "
                         + getTargetFolderId());
             }
 
-			// Move folders to new parent folder.
-			String folders[] = getSelectedFolders();
-			WeblogBookmarkFolder parent = bmgr.getFolder(getTargetFolderId());
-			if (null != folders && folders.length > 0) {
-				for (int i = 0; i < folders.length; i++) {
-					WeblogBookmarkFolder fd = bmgr.getFolder(folders[i]);
-
-					// Don't move folder into itself.
-					if (!fd.getId().equals(parent.getId())
-							&& !parent.descendentOf(fd)) {
-						bmgr.moveFolder(fd, parent);
-					} else {
-						addMessage("bookmarksForm.warn.notMoving", fd.getName());
-					}
-				}
-			}
-
-			// Move bookmarks to new parent folder.
-			String bookmarks[] = getSelectedBookmarks();
-			if (null != bookmarks && bookmarks.length > 0) {
-				for (int j = 0; j < bookmarks.length; j++) {
-					// maybe we should be using folder.addBookmark()?
-					WeblogBookmark bd = bmgr.getBookmark(bookmarks[j]);
-					bd.setFolder(parent);
-					bmgr.saveBookmark(bd);
-				}
-			}
-
-			// flush changes
-			WebloggerFactory.getWeblogger().flush();
-
-			// notify caches
-			CacheManager.invalidate(getActionWeblog());
-
-		} catch (WebloggerException e) {
-			log.error("Error doing folder/bookmark move", e);
-			addError("bookmarksForm.error.move");
-		}
-
-		return execute();
-	}
-
-	private static final class FolderPathComparator implements Comparator {
-		public int compare(Object o1, Object o2) {
-			WeblogBookmarkFolder f1 = (WeblogBookmarkFolder) o1;
-			WeblogBookmarkFolder f2 = (WeblogBookmarkFolder) o2;
-			return f1.getPath().compareTo(f2.getPath());
-		}
-	}
-
-	public String getFolderId() {
-		return folderId;
-	}
-
-	public void setFolderId(String folderId) {
-		this.folderId = folderId;
-	}
-
-	public String[] getSelectedFolders() {
-		return selectedFolders;
-	}
-
-	public void setSelectedFolders(String[] folders) {
-		this.selectedFolders = folders;
-	}
-
-	public String[] getSelectedBookmarks() {
-		return selectedBookmarks;
-	}
-
-	public void setSelectedBookmarks(String[] bookmarks) {
-		this.selectedBookmarks = bookmarks;
-	}
-
-	public String getTargetFolderId() {
-		return targetFolderId;
-	}
-
-	public void setTargetFolderId(String targetFolderId) {
-		this.targetFolderId = targetFolderId;
-	}
-
-	public Set getAllFolders() {
-		return allFolders;
-	}
-
-	public void setAllFolders(Set allFolders) {
-		this.allFolders = allFolders;
-	}
-
-	public WeblogBookmarkFolder getFolder() {
-		return folder;
-	}
-
-	public void setFolder(WeblogBookmarkFolder folder) {
-		this.folder = folder;
-	}
-
-	public List getFolderPath() {
-		return folderPath;
-	}
-
-	public void setFolderPath(List folderPath) {
-		this.folderPath = folderPath;
-	}
+            // Move bookmarks to new parent folder.
+            WeblogBookmarkFolder newFolder = bmgr.getFolder(getTargetFolderId());
+            String bookmarks[] = getSelectedBookmarks();
+            if (null != bookmarks && bookmarks.length > 0) {
+                for (int j = 0; j < bookmarks.length; j++) {
+                    WeblogBookmark bd = bmgr.getBookmark(bookmarks[j]);
+                    newFolder.addBookmark(bd);
+                    bd.setFolder(newFolder);
+                    bmgr.saveBookmark(bd);
+                    folder.getBookmarks().remove(bd);
+                }
+            }
+
+            // flush changes
+            WebloggerFactory.getWeblogger().flush();
+
+            // notify caches
+            CacheManager.invalidate(getActionWeblog());
 
+        } catch (WebloggerException e) {
+            log.error("Error doing bookmark move", e);
+            addError("bookmarksForm.error.move");
+        }
+
+        return execute();
+    }
+
+    public String getFolderId() {
+        return folderId;
+    }
+
+    public void setFolderId(String folderId) {
+        this.folderId = folderId;
+    }
+
+    public String[] getSelectedBookmarks() {
+        return selectedBookmarks;
+    }
+
+    public void setSelectedBookmarks(String[] bookmarks) {
+        this.selectedBookmarks = bookmarks;
+    }
+
+    public String getTargetFolderId() {
+        return targetFolderId;
+    }
+
+    public void setTargetFolderId(String targetFolderId) {
+        this.targetFolderId = targetFolderId;
+    }
+
+    public List<WeblogBookmarkFolder> getAllFolders() {
+        return allFolders;
+    }
+
+    public void setAllFolders(List<WeblogBookmarkFolder> allFolders) {
+        this.allFolders = allFolders;
+    }
+
+    public WeblogBookmarkFolder getFolder() {
+        return folder;
+    }
+
+    public void setFolder(WeblogBookmarkFolder folder) {
+        this.folder = folder;
+    }
+
+    public String getViewFolderId() {
+        return viewFolderId;
+    }
+
+    public void setViewFolderId(String viewFolderId) {
+        this.viewFolderId = viewFolderId;
+    }
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarksImport.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarksImport.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarksImport.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarksImport.java Sun Apr 20 13:38:51 2014
@@ -28,6 +28,7 @@ import java.util.Date;
 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.BookmarkManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
@@ -93,9 +94,9 @@ public final class BookmarksImport exten
                     stream = new FileInputStream(getOpmlFile());
                     ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-                    byte[] buffer = new byte[8192];
+                    byte[] buffer = new byte[RollerConstants.EIGHT_KB_IN_BYTES];
                     int bytesRead = 0;
-                    while ((bytesRead=stream.read(buffer,0,8192)) != -1) {
+                    while ((bytesRead=stream.read(buffer,0,RollerConstants.EIGHT_KB_IN_BYTES)) != -1) {
                         baos.write(buffer, 0, bytesRead);
                     }
                     String data = new String(baos.toByteArray());
@@ -123,7 +124,7 @@ public final class BookmarksImport exten
                 } else {
                     String data = "The file is greater than " + WRITE_THRESHOLD_IN_MB
                             +" MB, and has not been written to stream."
-                            +" File Size: "+getOpmlFile().length()+" bytes. "
+                            +" File Size: " + getOpmlFile().length() + " bytes. "
                             +" This is a limitation of this particular "
                             +" web application";
                     addError("bookmarksImport.error", data);

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java Sun Apr 20 13:38:51 2014
@@ -20,17 +20,12 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.TreeSet;
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
-import org.apache.roller.weblogger.pojos.WeblogCategoryPathComparator;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
@@ -41,23 +36,8 @@ public class Categories extends UIAction
 
 	private static Log log = LogFactory.getLog(Categories.class);
 
-	// the id of the category we are viewing
-	private String categoryId = null;
-
-	// the category we are viewing
-	private WeblogCategory category = null;
-
-	// list of category ids to move
-	private String[] selectedCategories = null;
-
-	// category id of the category to move to
-	private String targetCategoryId = null;
-
 	// all categories from the action weblog
-	private Set allCategories = Collections.EMPTY_SET;
-
-	// path of categories representing selected categories hierarchy
-	private List categoryPath = Collections.EMPTY_LIST;
+	private List<WeblogCategory> allCategories;
 
 	public Categories() {
 		this.actionName = "categories";
@@ -70,150 +50,27 @@ public class Categories extends UIAction
 		return Collections.singletonList(WeblogPermission.POST);
 	}
 
-	public void myPrepare() {
-		try {
-			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
-					.getWeblogEntryManager();
-			if (!StringUtils.isEmpty(getCategoryId())
-					&& !"/".equals(getCategoryId())) {
-				setCategory(wmgr.getWeblogCategory(getCategoryId()));
-			} else {
-				setCategory(wmgr.getRootWeblogCategory(getActionWeblog()));
-			}
-		} catch (WebloggerException ex) {
-			log.error("Error looking up category", ex);
-		}
-	}
-
 	public String execute() {
-
-		// build list of categories for display
-		TreeSet allCategories = new TreeSet(new WeblogCategoryPathComparator());
-
 		try {
-			// Build list of all categories, except for current one, sorted by
-			// path.
-			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
-					.getWeblogEntryManager();
-			List<WeblogCategory> cats = wmgr.getWeblogCategories(
-					getActionWeblog(), true);
-			for (WeblogCategory cat : cats) {
-				if (getCategoryId() == null && cat.getParent() == null) {
-					// Root folder so do not show the root /
-				} else if (!cat.getId().equals(getCategoryId())) {
-					allCategories.add(cat);
-				}
-			}
-
-			// build category path
-			WeblogCategory parent = getCategory().getParent();
-			if (parent != null) {
-				List categoryPath = new LinkedList();
-				categoryPath.add(0, getCategory());
-				while (parent != null) {
-					categoryPath.add(0, parent);
-					parent = parent.getParent();
-				}
-				setCategoryPath(categoryPath);
-			}
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
+			allCategories = wmgr.getWeblogCategories(getActionWeblog());
 		} catch (WebloggerException ex) {
 			log.error("Error building categories list", ex);
-			// TODO: i18n
 			addError("Error building categories list");
 		}
 
-		if (allCategories.size() > 0) {
-			setAllCategories(allCategories);
-		}
-
 		return LIST;
 	}
 
 	public String move() {
-
-		try {
-			WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
-					.getWeblogEntryManager();
-
-			log.debug("Moving categories to category - "
-					+ getTargetCategoryId());
-
-			// Move subCategories to new category.
-			String[] cats = getSelectedCategories();
-			WeblogCategory parent = wmgr
-					.getWeblogCategory(getTargetCategoryId());
-			if (cats != null) {
-				for (int i = 0; i < cats.length; i++) {
-					WeblogCategory cd = wmgr.getWeblogCategory(cats[i]);
-
-					// Don't move category into itself.
-					if (!cd.getId().equals(parent.getId())
-							&& !parent.descendentOf(cd)) {
-						wmgr.moveWeblogCategory(cd, parent);
-					} else {
-						addMessage("categoriesForm.warn.notMoving",
-								cd.getName());
-					}
-				}
-
-				// flush changes
-				WebloggerFactory.getWeblogger().flush();
-			}
-
-		} catch (WebloggerException ex) {
-			log.error("Error moving categories", ex);
-			addError("categoriesForm.error.move");
-		}
-
 		return execute();
 	}
 
-	public String getCategoryId() {
-		return categoryId;
-	}
-
-	public void setCategoryId(String categoryId) {
-		this.categoryId = categoryId;
-	}
-
-	public WeblogCategory getCategory() {
-		return category;
-	}
-
-	public void setCategory(WeblogCategory category) {
-		this.category = category;
-	}
-
-	public String[] getSelectedCategories() {
-		return selectedCategories;
-	}
-
-	public void setSelectedCategories(String[] selectedCategories) {
-		this.selectedCategories = selectedCategories;
-	}
-
-	public String getTargetCategoryId() {
-		return targetCategoryId;
-	}
-
-	public void setTargetCategoryId(String targetCategoryId) {
-		this.targetCategoryId = targetCategoryId;
-	}
-
-	public Set getAllCategories() {
+	public List<WeblogCategory> getAllCategories() {
 		return allCategories;
 	}
 
-	public void setAllCategories(Set allCategories) {
+	public void setAllCategories(List<WeblogCategory> allCategories) {
 		this.allCategories = allCategories;
 	}
-
-	public List getCategoryPath() {
-		return categoryPath;
-	}
-
-	public void setCategoryPath(List categoryPath) {
-		this.categoryPath = categoryPath;
-	}
-
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryAdd.java Sun Apr 20 13:38:51 2014
@@ -20,10 +20,9 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
-import org.apache.commons.lang.StringUtils;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
@@ -34,59 +33,31 @@ import org.apache.struts2.interceptor.va
 
 
 /**
- * Add a new subCategory to an existing Category.
+ * Add a new WeblogCategory to the weblog
  */
 public class CategoryAdd extends UIAction {
     
     private static Log log = LogFactory.getLog(CategoryAdd.class);
     
-    // the id of the Category we are adding the new subCategory into
-    private String categoryId = null;
-    
-    // the category we are adding the new subcategory into
-    private WeblogCategory category = null;
-    
     // bean for managing form data
     private CategoryBean bean = new CategoryBean();
-    
-    
+
     public CategoryAdd() {
         this.actionName = "categoryAdd";
         this.desiredMenu = "editor";
         this.pageTitle = "categoryForm.add.title";
     }
-    
-    
+
     // author perms required
     public List<String> requiredWeblogPermissionActions() {
         return Collections.singletonList(WeblogPermission.ADMIN);
     }
-    
-    
-    public void myPrepare() {
-        try {
-            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            if(!StringUtils.isEmpty(getCategoryId())) {
-                setCategory(wmgr.getWeblogCategory(getCategoryId()));
-            }
-        } catch (WebloggerException ex) {
-            log.error("Error looking up category", ex);
-        }
-    }
-    
-    
+
     /**
      * Show category form.
      */
     @SkipValidation
     public String execute() {
-        
-        if(getCategory() == null) {
-            // TODO: i18n
-            addError("Cannot add category to null parent category");
-            return ERROR;
-        }
-        
         return INPUT;
     }
 
@@ -95,13 +66,6 @@ public class CategoryAdd extends UIActio
      * Save new category.
      */
     public String save() {
-        
-        if(getCategory() == null) {
-            // TODO: i18n
-            addError("Cannot add category to null parent category");
-            return ERROR;
-        }
-        
         // validation
         myValidate();
         
@@ -110,14 +74,10 @@ public class CategoryAdd extends UIActio
 
                 WeblogCategory newCategory = new WeblogCategory(
                         getActionWeblog(),
-                        getCategory(),
                         getBean().getName(),
                         getBean().getDescription(),
                         getBean().getImage());
 
-                // add new folder to parent
-                getCategory().addCategory(newCategory);
-
                 // save changes
                 WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
                 wmgr.saveWeblogCategory(newCategory);
@@ -126,8 +86,7 @@ public class CategoryAdd extends UIActio
                 // notify caches
                 CacheManager.invalidate(newCategory);
 
-                // TODO: i18n
-                addMessage("category added");
+                addMessage("categoryForm.created");
 
                 return SUCCESS;
 
@@ -141,35 +100,24 @@ public class CategoryAdd extends UIActio
         return INPUT;
     }
 
+    /**
+     * Cancel.
+     * 
+     * @return the string
+     */
+    public String cancel() {
+        return CANCEL;
+    }
     
-    // TODO: validation
     public void myValidate() {
-        
-        // name is required, has max length, no html
-        
+        // TODO: Check max length & no html
+
         // make sure new name is not a duplicate of an existing folder
-        if(getCategory().hasCategory(getBean().getName())) {
+        if(getActionWeblog().hasCategory(getBean().getName())) {
             addError("categoryForm.error.duplicateName", getBean().getName());
         }
     }
 
-    
-    public String getCategoryId() {
-        return categoryId;
-    }
-
-    public void setCategoryId(String categoryId) {
-        this.categoryId = categoryId;
-    }
-
-    public WeblogCategory getCategory() {
-        return category;
-    }
-
-    public void setCategory(WeblogCategory category) {
-        this.category = category;
-    }
-
     public CategoryBean getBean() {
         return bean;
     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java Sun Apr 20 13:38:51 2014
@@ -20,7 +20,7 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
-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.weblogger.WebloggerException;
@@ -78,7 +78,7 @@ public class CategoryEdit extends UIActi
     @SkipValidation
     public String execute() {
         
-        if(getCategory() == null) {
+        if (getCategory() == null) {
             // TODO: i18n
             addError("Cannot edit null category");
             return ERROR;
@@ -118,8 +118,7 @@ public class CategoryEdit extends UIActi
                 // notify caches
                 CacheManager.invalidate(getCategory());
 
-                // TODO: i18n
-                addMessage("category updated");
+                addMessage("categoryForm.changesSaved");
 
             } catch(Exception ex) {
                 log.error("Error saving category", ex);
@@ -131,6 +130,14 @@ public class CategoryEdit extends UIActi
         return INPUT;
     }
 
+    /**
+     * Cancel.
+     * 
+     * @return the string
+     */
+    public String cancel() {
+        return CANCEL;
+    }
     
     // TODO: validation
     public void myValidate() {
@@ -138,11 +145,9 @@ public class CategoryEdit extends UIActi
         // name is required, has max length, no html
         
         // make sure new name is not a duplicate of an existing category
-        if(!getCategory().getName().equals(getBean().getName())) {
-            WeblogCategory parent = getCategory().getParent();
-            if(parent != null && parent.hasCategory(getBean().getName())) {
-                addError("categoryForm.error.duplicateName", getBean().getName());
-            }
+        if (!getCategory().getName().equals(bean.getName()) &&
+            getCategory().getWeblog().hasCategory(bean.getName())) {
+            addError("categoryForm.error.duplicateName", bean.getName());
         }
     }
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java Sun Apr 20 13:38:51 2014
@@ -18,18 +18,17 @@
 
 package org.apache.roller.weblogger.ui.struts2.editor;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-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.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
-import org.apache.roller.weblogger.pojos.WeblogCategoryPathComparator;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
@@ -50,9 +49,9 @@ public class CategoryRemove extends UIAc
     
     // category id of the category to move to
     private String targetCategoryId = null;
-    
+
     // all categories from the action weblog
-    private Set allCategories = Collections.EMPTY_SET;
+    private List<WeblogCategory> allCategories = new ArrayList<WeblogCategory>();
     
     
     public CategoryRemove() {
@@ -83,33 +82,22 @@ public class CategoryRemove extends UIAc
      * Display the remove template confirmation.
      */
     public String execute() {
-        
-        // build list of categories for display
-        TreeSet allCategoriesSet = new TreeSet(new WeblogCategoryPathComparator());
-        
         try {
-            // Build list of all categories, except for current one, sorted by path.
+            // Build list of categories that the removed category's blog entries (if any) can be moved to
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog(), true);
-            for(WeblogCategory cat : cats) {
+            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog());
+            for (WeblogCategory cat : cats) {
                 if (!cat.getId().equals(getRemoveId())) {
-                    allCategoriesSet.add(cat);
+                    allCategories.add(cat);
                 }
             }
         } catch (WebloggerException ex) {
             log.error("Error building categories list", ex);
-            // TODO: i18n
             addError("Error building categories list");
         }
-        
-        if (allCategoriesSet.size() > 0) {
-            setAllCategories(allCategoriesSet);
-        }
-        
         return INPUT;
     }
-    
-    
+
     /**
      * Remove a new template.
      */
@@ -147,6 +135,14 @@ public class CategoryRemove extends UIAc
         return execute();
     }
 
+    /**
+     * Cancel.
+     * 
+     * @return the string
+     */
+    public String cancel() {
+        return CANCEL;
+    }
     
     public String getRemoveId() {
         return removeId;
@@ -172,11 +168,11 @@ public class CategoryRemove extends UIAc
         this.targetCategoryId = targetCategoryId;
     }
 
-    public Set getAllCategories() {
+    public List<WeblogCategory> getAllCategories() {
         return allCategories;
     }
 
-    public void setAllCategories(Set allCategories) {
+    public void setAllCategories(List<WeblogCategory> allCategories) {
         this.allCategories = allCategories;
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Comments.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Comments.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Comments.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Comments.java Sun Apr 20 13:38:51 2014
@@ -26,7 +26,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-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.weblogger.WebloggerException;
@@ -34,6 +35,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.config.WebloggerConfig;
+import org.apache.roller.weblogger.pojos.CommentSearchCriteria;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
@@ -45,388 +47,408 @@ import org.apache.roller.weblogger.util.
 import org.apache.roller.weblogger.util.MailUtil;
 import org.apache.roller.weblogger.util.Utilities;
 
-
 /**
  * Action for managing weblog comments.
  */
 public class Comments extends UIAction {
-    
+
+    private static final long serialVersionUID = -104973988372024709L;
+
     private static Log log = LogFactory.getLog(Comments.class);
-    
+
     // number of comments to show per page
     private static final int COUNT = 30;
-    
+
     // bean for managing submitted data
     private CommentsBean bean = new CommentsBean();
-    
+
     // pager for the comments we are viewing
     private CommentsPager pager = null;
-    
+
     // first comment in the list
     private WeblogEntryComment firstComment = null;
-    
+
     // last comment in the list
     private WeblogEntryComment lastComment = null;
-    
+
     // entry associated with comments or null if none
     private WeblogEntry queryEntry = null;
-    
+
     // indicates number of comments that would be deleted by bulk removal
     // a non-zero value here indicates bulk removal is a valid option
     private int bulkDeleteCount = 0;
-    
-    
+
     public Comments() {
         this.actionName = "comments";
         this.desiredMenu = "editor";
         this.pageTitle = "commentManagement.title";
     }
-    
-    
+
     @Override
     public List<String> requiredWeblogPermissionActions() {
         return Collections.singletonList(WeblogPermission.POST);
     }
-    
-    
+
     public void loadComments() {
-        
-        List comments = Collections.EMPTY_LIST;
+
+        List<WeblogEntryComment> comments = Collections.emptyList();
         boolean hasMore = false;
         try {
-            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
+                    .getWeblogEntryManager();
+
             // lookup weblog entry if necessary
             if (!StringUtils.isEmpty(getBean().getEntryId())) {
                 setQueryEntry(wmgr.getWeblogEntry(getBean().getEntryId()));
             }
-            
-            // query for comments
-            List rawComments = wmgr.getComments(
-                    getActionWeblog(),
-                    getQueryEntry(),
-                    getBean().getSearchString(),
-                    getBean().getStartDate(),
-                    getBean().getEndDate(),getBean().getStatus(),
-                    true, // reverse  chrono order
-                    getBean().getPage() * COUNT,
-                    COUNT + 1);
-            comments = new ArrayList();
-            comments.addAll(rawComments);            
-            if(comments != null && comments.size() > 0) {
-                if(comments.size() > COUNT) {
-                    comments.remove(comments.size()-1);
+
+            CommentSearchCriteria csc = new CommentSearchCriteria();
+            csc.setWeblog(getActionWeblog());
+            csc.setEntry(getQueryEntry());
+            csc.setSearchText(getBean().getSearchString());
+            csc.setStartDate(getBean().getStartDate());
+            csc.setEndDate(getBean().getEndDate());
+            csc.setStatus(getBean().getStatus());
+            csc.setReverseChrono(true);
+            csc.setOffset(getBean().getPage() * COUNT);
+            csc.setMaxResults(COUNT + 1);
+
+            List<WeblogEntryComment> rawComments = wmgr.getComments(csc);
+            comments = new ArrayList<WeblogEntryComment>();
+            comments.addAll(rawComments);
+            if (comments.size() > 0) {
+                if (comments.size() > COUNT) {
+                    comments.remove(comments.size() - 1);
                     hasMore = true;
                 }
-                
-                setFirstComment((WeblogEntryComment)comments.get(0));
-                setLastComment((WeblogEntryComment)comments.get(comments.size()-1));
+
+                setFirstComment(comments.get(0));
+                setLastComment(comments.get(comments
+                        .size() - 1));
             }
         } catch (WebloggerException ex) {
             log.error("Error looking up comments", ex);
             // TODO: i18n
             addError("Error looking up comments");
         }
-        
+
         // build comments pager
         String baseUrl = buildBaseUrl();
-        setPager(new CommentsPager(baseUrl, getBean().getPage(), comments, hasMore));
+        setPager(new CommentsPager(baseUrl, getBean().getPage(), comments,
+                hasMore));
     }
-    
-    
-    // use the action data to build a url representing this action, including query data
+
+    // use the action data to build a url representing this action, including
+    // query data
     private String buildBaseUrl() {
-        
-        Map<String, String> params = new HashMap();
-        
-        if(!StringUtils.isEmpty(getBean().getEntryId())) {
+
+        Map<String, String> params = new HashMap<String, String>();
+
+        if (!StringUtils.isEmpty(getBean().getEntryId())) {
             params.put("bean.entryId", getBean().getEntryId());
         }
-        if(!StringUtils.isEmpty(getBean().getSearchString())) {
+        if (!StringUtils.isEmpty(getBean().getSearchString())) {
             params.put("bean.searchString", getBean().getSearchString());
         }
-        if(!StringUtils.isEmpty(getBean().getStartDateString())) {
+        if (!StringUtils.isEmpty(getBean().getStartDateString())) {
             params.put("bean.startDateString", getBean().getStartDateString());
         }
-        if(!StringUtils.isEmpty(getBean().getEndDateString())) {
+        if (!StringUtils.isEmpty(getBean().getEndDateString())) {
             params.put("bean.endDateString", getBean().getEndDateString());
         }
-        if(!StringUtils.isEmpty(getBean().getApprovedString())) {
+        if (!StringUtils.isEmpty(getBean().getApprovedString())) {
             params.put("bean.approvedString", getBean().getApprovedString());
         }
-        if(!StringUtils.isEmpty(getBean().getSpamString())) {
+        if (!StringUtils.isEmpty(getBean().getSpamString())) {
             params.put("bean.spamString", getBean().getSpamString());
         }
-        
-        return WebloggerFactory.getWeblogger().getUrlStrategy().getActionURL("comments", "/roller-ui/authoring", 
-                getActionWeblog().getHandle(), params, false);
+
+        return WebloggerFactory
+                .getWeblogger()
+                .getUrlStrategy()
+                .getActionURL("comments", "/roller-ui/authoring",
+                        getActionWeblog().getHandle(), params, false);
     }
-    
-    
+
     public String execute() {
-        
+
         // load list of comments from query
         loadComments();
-        
+
         // load bean data using comments list
         getBean().loadCheckboxes(getPager().getItems());
-        
+
         return LIST;
     }
-    
-    
+
     /**
      * Query for a specific subset of comments based on various criteria.
      */
     public String query() {
-        
+
         // load list of comments from query
         loadComments();
-        
+
         // load bean data using comments list
         getBean().loadCheckboxes(getPager().getItems());
-        
+
         try {
-            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            List allMatchingComments = wmgr.getComments(
-                    getActionWeblog(),
-                    null,
-                    getBean().getSearchString(),
-                    getBean().getStartDate(),
-                    getBean().getEndDate(),
-                    getBean().getStatus(),
-                    true, // reverse  chrono order
-                    0,
-                    -1);
-            
-            if(allMatchingComments.size() > COUNT) {
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
+                    .getWeblogEntryManager();
+
+            CommentSearchCriteria csc = new CommentSearchCriteria();
+            csc.setWeblog(getActionWeblog());
+            csc.setSearchText(getBean().getSearchString());
+            csc.setStartDate(getBean().getStartDate());
+            csc.setEndDate(getBean().getEndDate());
+            csc.setStatus(getBean().getStatus());
+            csc.setReverseChrono(true);
+
+            List<WeblogEntryComment> allMatchingComments = wmgr.getComments(csc);
+            if (allMatchingComments.size() > COUNT) {
                 setBulkDeleteCount(allMatchingComments.size());
             }
-            
+
         } catch (WebloggerException ex) {
             log.error("Error looking up comments", ex);
             // TODO: i18n
             addError("Error looking up comments");
         }
-        
+
         return LIST;
     }
-    
-    
+
     /**
      * Bulk delete all comments matching query criteria.
      */
     public String delete() {
-        
+
         try {
-            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
+                    .getWeblogEntryManager();
+
             // if search is enabled, we will need to re-index all entries with
             // comments that have been deleted, so build a list of those entries
             Set<WeblogEntry> reindexEntries = new HashSet<WeblogEntry>();
-            if (WebloggerConfig.getBooleanProperty("search.enabled")) {                 
-                List<WeblogEntryComment> targetted = (List<WeblogEntryComment>)wmgr.getComments(
-                    getActionWeblog(), 
-                    getQueryEntry(), 
-                    getBean().getSearchString(),
-                    getBean().getStartDate(),
-                    getBean().getEndDate(),
-                    getBean().getStatus(), 
-                    true, 
-                    0, -1);
+            if (WebloggerConfig.getBooleanProperty("search.enabled")) {
+
+                CommentSearchCriteria csc = new CommentSearchCriteria();
+                csc.setWeblog(getActionWeblog());
+                csc.setEntry(getQueryEntry());
+                csc.setSearchText(getBean().getSearchString());
+                csc.setStartDate(getBean().getStartDate());
+                csc.setEndDate(getBean().getEndDate());
+                csc.setStatus(getBean().getStatus());
+                csc.setReverseChrono(true);
+
+                List<WeblogEntryComment> targetted = wmgr.getComments(csc);
                 for (WeblogEntryComment comment : targetted) {
                     reindexEntries.add(comment.getWeblogEntry());
                 }
             }
-            
-            int deleted = wmgr.removeMatchingComments(
-                    getActionWeblog(),
-                    null,
-                    getBean().getSearchString(),
-                    getBean().getStartDate(),
-                    getBean().getEndDate(),
-                    getBean().getStatus());
-            
+
+            int deleted = wmgr.removeMatchingComments(getActionWeblog(), null,
+                    getBean().getSearchString(), getBean().getStartDate(),
+                    getBean().getEndDate(), getBean().getStatus());
+
             // if we've got entries to reindex then do so
             if (!reindexEntries.isEmpty()) {
-                IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
+                IndexManager imgr = WebloggerFactory.getWeblogger()
+                        .getIndexManager();
                 for (WeblogEntry entry : reindexEntries) {
                     imgr.addEntryReIndexOperation(entry);
                 }
             }
-                    
-            addMessage("commentManagement.deleteSuccess", Integer.toString(deleted));
-            
+
+            addMessage("commentManagement.deleteSuccess",
+                    Integer.toString(deleted));
+
             // reset form and load fresh comments list
             setBean(new CommentsBean());
-            
+
             return execute();
-            
+
         } catch (WebloggerException ex) {
             log.error("Error doing bulk delete", ex);
             // TODO: i18n
             addError("Bulk delete failed due to unexpected error");
         }
-        
+
         return LIST;
     }
-    
-    
+
     /**
      * Update a list of comments.
      */
     public String update() {
-        
+
         try {
-            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            
-            List<WeblogEntryComment> flushList = new ArrayList();
+            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger()
+                    .getWeblogEntryManager();
+
+            List<WeblogEntryComment> flushList = new ArrayList<WeblogEntryComment>();
 
             // if search is enabled, we will need to re-index all entries with
-            // comments that have been approved, so build a list of those entries
+            // comments that have been approved, so build a list of those
+            // entries
             Set<WeblogEntry> reindexList = new HashSet<WeblogEntry>();
-            
+
             // delete all comments with delete box checked
             List<String> deletes = Arrays.asList(getBean().getDeleteComments());
-            if(deletes != null && deletes.size() > 0) {
-                log.debug("Processing deletes - "+deletes.size());
-                
+            if (deletes.size() > 0) {
+                log.debug("Processing deletes - " + deletes.size());
+
                 WeblogEntryComment deleteComment = null;
-                for(String deleteId : deletes) {
+                for (String deleteId : deletes) {
                     deleteComment = wmgr.getComment(deleteId);
-                    
+
                     // make sure comment is tied to action weblog
-                    if(getActionWeblog().equals(deleteComment.getWeblogEntry().getWebsite())) {
+                    if (getActionWeblog().equals(
+                            deleteComment.getWeblogEntry().getWebsite())) {
                         flushList.add(deleteComment);
                         reindexList.add(deleteComment.getWeblogEntry());
                         wmgr.removeComment(deleteComment);
                     }
                 }
             }
-            
+
             // loop through IDs of all comments displayed on page
-            List<String> approvedIds = Arrays.asList(getBean().getApprovedComments());
+            List<String> approvedIds = Arrays.asList(getBean()
+                    .getApprovedComments());
             List<String> spamIds = Arrays.asList(getBean().getSpamComments());
-            log.debug(spamIds.size()+" comments marked as spam");
-            
+            log.debug(spamIds.size() + " comments marked as spam");
+
+            // Determine whether we want approval emails
+            boolean approvalNotification = WebloggerConfig.getBooleanProperty(
+                    "comment.notification.onapproval", false);
+
             // track comments approved via moderation
-            List<WeblogEntryComment> approvedComments = new ArrayList();
-            
-            String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
-            for (int i=0; i < ids.length; i++) {
-                log.debug("processing id - "+ ids[i]);
-                
+            List<WeblogEntryComment> approvedComments = new ArrayList<WeblogEntryComment>();
+
+            String[] ids = Utilities.stringToStringArray(getBean().getIds(),
+                    ",");
+            for (int i = 0; i < ids.length; i++) {
+                log.debug("processing id - " + ids[i]);
+
                 // if we already deleted it then skip forward
-                if(deletes.contains(ids[i])) {
-                    log.debug("Already deleted, skipping - "+ids[i]);
+                if (deletes.contains(ids[i])) {
+                    log.debug("Already deleted, skipping - " + ids[i]);
                     continue;
                 }
-                
+
                 WeblogEntryComment comment = wmgr.getComment(ids[i]);
-                
+
                 // make sure comment is tied to action weblog
-                if(getActionWeblog().equals(comment.getWeblogEntry().getWebsite())) {
+                if (getActionWeblog().equals(
+                        comment.getWeblogEntry().getWebsite())) {
                     // comment approvals and mark/unmark spam
-                    if(approvedIds.contains(ids[i])) {
+                    if (approvedIds.contains(ids[i])) {
                         // if a comment was previously PENDING then this is
-                        // it's first approval, so track it for notification
-                        if(WeblogEntryComment.PENDING.equals(comment.getStatus())) {
+                        // its first approval, so track it for notification
+                        if (WeblogEntryComment.PENDING.equals(comment
+                                .getStatus())) {
                             approvedComments.add(comment);
                         }
-                        
-                        log.debug("Marking as approved - "+comment.getId());
+
+                        log.debug("Marking as approved - " + comment.getId());
                         comment.setStatus(WeblogEntryComment.APPROVED);
                         wmgr.saveComment(comment);
-                        
+
                         flushList.add(comment);
                         reindexList.add(comment.getWeblogEntry());
-                        
-                    } else if(spamIds.contains(ids[i])) {
-                        log.debug("Marking as spam - "+comment.getId());
+
+                    } else if (spamIds.contains(ids[i])) {
+                        log.debug("Marking as spam - " + comment.getId());
                         comment.setStatus(WeblogEntryComment.SPAM);
                         wmgr.saveComment(comment);
-                        
+
                         flushList.add(comment);
                         reindexList.add(comment.getWeblogEntry());
 
-                    } else if(!WeblogEntryComment.DISAPPROVED.equals(comment.getStatus())) {
-                        log.debug("Marking as disapproved - "+comment.getId());
+                    } else if (!WeblogEntryComment.DISAPPROVED.equals(comment
+                            .getStatus())) {
+                        log.debug("Marking as disapproved - " + comment.getId());
                         comment.setStatus(WeblogEntryComment.DISAPPROVED);
                         wmgr.saveComment(comment);
-                        
+
                         flushList.add(comment);
                         reindexList.add(comment.getWeblogEntry());
                     }
                 }
             }
-            
+
             WebloggerFactory.getWeblogger().flush();
-            
+
             // notify caches of changes by flushing whole site because we can't
             // invalidate deleted comment objects (JPA nulls the fields out).
             CacheManager.invalidate(getActionWeblog());
-            
-            // send notification for all comments changed
-            if (MailUtil.isMailConfigured()) {
-                I18nMessages resources = 
-                    I18nMessages.getMessages(getActionWeblog().getLocaleInstance());
-                MailUtil.sendEmailApprovalNotifications(approvedComments, resources);
+
+            // if required, send notification for all comments changed
+            if (approvalNotification && MailUtil.isMailConfigured()) {
+                I18nMessages resources = I18nMessages
+                        .getMessages(getActionWeblog().getLocaleInstance());
+                MailUtil.sendEmailApprovalNotifications(approvedComments,
+                        resources);
             }
-            
+
             // if we've got entries to reindex then do so
             if (!reindexList.isEmpty()) {
-                IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
+                IndexManager imgr = WebloggerFactory.getWeblogger()
+                        .getIndexManager();
                 for (WeblogEntry entry : reindexList) {
                     imgr.addEntryReIndexOperation(entry);
                 }
-            }            
-            
+            }
+
             addMessage("commentManagement.updateSuccess");
-            
+
             // reset form and load fresh comments list
             CommentsBean freshBean = new CommentsBean();
-            
+
             // but if we're editing an entry's comments stick with that entry
             if (bean.getEntryId() != null) {
                 freshBean.setEntryId(bean.getEntryId());
             }
             setBean(freshBean);
-                        
+
             return execute();
-            
+
         } catch (Exception ex) {
             log.error("ERROR updating comments", ex);
             addError("commentManagement.updateError", ex.toString());
         }
-        
+
         return LIST;
     }
-    
-    
-    public List getCommentStatusOptions() {
-        
-        List opts = new ArrayList();
-        
+
+    public List<KeyValueObject> getCommentStatusOptions() {
+
+        List<KeyValueObject> opts = new ArrayList<KeyValueObject>();
+
         opts.add(new KeyValueObject("ALL", getText("commentManagement.all")));
-        opts.add(new KeyValueObject("ONLY_PENDING", getText("commentManagement.onlyPending")));
-        opts.add(new KeyValueObject("ONLY_APPROVED", getText("commentManagement.onlyApproved")));
-        opts.add(new KeyValueObject("ONLY_DISAPPROVED", getText("commentManagement.onlyDisapproved")));
-        
+        opts.add(new KeyValueObject("ONLY_PENDING",
+                getText("commentManagement.onlyPending")));
+        opts.add(new KeyValueObject("ONLY_APPROVED",
+                getText("commentManagement.onlyApproved")));
+        opts.add(new KeyValueObject("ONLY_DISAPPROVED",
+                getText("commentManagement.onlyDisapproved")));
+
         return opts;
     }
-    
-    public List getSpamStatusOptions() {
-        
-        List opts = new ArrayList();
-        
+
+    public List<KeyValueObject> getSpamStatusOptions() {
+
+        List<KeyValueObject> opts = new ArrayList<KeyValueObject>();
+
         opts.add(new KeyValueObject("ALL", getText("commentManagement.all")));
-        opts.add(new KeyValueObject("NO_SPAM", getText("commentManagement.noSpam")));
-        opts.add(new KeyValueObject("ONLY_SPAM", getText("commentManagement.onlySpam")));
-        
+        opts.add(new KeyValueObject("NO_SPAM",
+                getText("commentManagement.noSpam")));
+        opts.add(new KeyValueObject("ONLY_SPAM",
+                getText("commentManagement.onlySpam")));
+
         return opts;
     }
-    
-    
+
     public CommentsBean getBean() {
         return bean;
     }
@@ -473,5 +495,5 @@ public class Comments extends UIAction {
 
     public void setQueryEntry(WeblogEntry queryEntry) {
         this.queryEntry = queryEntry;
-    }    
+    }
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CommentsBean.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CommentsBean.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CommentsBean.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CommentsBean.java Sun Apr 20 13:38:51 2014
@@ -22,9 +22,8 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.roller.util.DateUtil;
 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
 import org.apache.roller.weblogger.util.Utilities;
@@ -51,15 +50,13 @@ public class CommentsBean {
     private String ids = null;
     
     
-    public void loadCheckboxes(List comments) {
+    public void loadCheckboxes(List<WeblogEntryComment> comments) {
         
-        List<String> allComments = new ArrayList();
-        List<String> approvedList = new ArrayList();
-        List<String> spamList = new ArrayList();
+        List<String> allComments = new ArrayList<String>();
+        List<String> approvedList = new ArrayList<String>();
+        List<String> spamList = new ArrayList<String>();
         
-        Iterator it = comments.iterator();
-        while (it.hasNext()) {
-            WeblogEntryComment comment = (WeblogEntryComment)it.next();
+        for (WeblogEntryComment comment : comments) {
             allComments.add(comment.getId());
             
             if(WeblogEntryComment.APPROVED.equals(comment.getStatus())) {
@@ -70,14 +67,14 @@ public class CommentsBean {
         }
         
         // list of ids we are working on
-        String[] idArray = (String[]) allComments.toArray(new String[allComments.size()]);
+        String[] idArray = allComments.toArray(new String[allComments.size()]);
         setIds(Utilities.stringArrayToString(idArray,","));
         
         // approved ids list
-        setApprovedComments((String[])approvedList.toArray(new String[approvedList.size()]));
+        setApprovedComments(approvedList.toArray(new String[approvedList.size()]));
         
         // spam ids list
-        setSpamComments((String[])spamList.toArray(new String[spamList.size()]));
+        setSpamComments(spamList.toArray(new String[spamList.size()]));
     }
     
     



Mime
View raw message