roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r463255 - in /incubator/roller/trunk: custom/ sandbox/scripting/groovy/ src/org/apache/roller/business/hibernate/ src/org/apache/roller/model/ src/org/apache/roller/ui/authoring/struts/actions/ tests/org/apache/roller/business/ web/WEB-INF/...
Date Thu, 12 Oct 2006 14:12:39 GMT
Author: snoopdave
Date: Thu Oct 12 07:12:36 2006
New Revision: 463255

URL: http://svn.apache.org/viewvc?view=rev&rev=463255
Log:
Bulk delete of comments

Modified:
    incubator/roller/trunk/custom/custom-ant.xmlf
    incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy
    incubator/roller/trunk/sandbox/scripting/groovy/createcomment.gy
    incubator/roller/trunk/sandbox/scripting/groovy/hibernate.cfg.xml
    incubator/roller/trunk/sandbox/scripting/groovy/run-groovy
    incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java
    incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp

Modified: incubator/roller/trunk/custom/custom-ant.xmlf
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/custom/custom-ant.xmlf?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/custom/custom-ant.xmlf (original)
+++ incubator/roller/trunk/custom/custom-ant.xmlf Thu Oct 12 07:12:36 2006
@@ -10,7 +10,7 @@
    <antcall target="init-db" />
    <nbjpdastart name="${classname}" addressproperty="jpda.address" transport="dt_socket">
       <classpath>
-        <path refid="junit.path"/>
+        <path refid="tests.run.path"/>
       </classpath>
    </nbjpdastart>
    <java classname="${classname}" fork="true" dir="${build.tests}">
@@ -19,7 +19,7 @@
       <jvmarg value="-Djava.compiler=none"/>
       <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
       <classpath>
-          <path refid="junit.path"/>
+          <path refid="tests.run.path"/>
       </classpath>
    </java>
    <antcall target="stop-db" />
@@ -34,7 +34,7 @@
    <antcall target="init-db" />   
    <nbjpdastart name="junit.textui.TestRunner" addressproperty="jpda.address" transport="dt_socket">
       <classpath>
-        <path refid="junit.path"/>
+        <path refid="tests.run.path"/>
       </classpath>
    </nbjpdastart>
    <java classname="junit.textui.TestRunner" fork="true" dir="${build.tests}">
@@ -44,7 +44,7 @@
       <jvmarg value="-Djava.compiler=none"/>
       <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
       <classpath>
-          <path refid="junit.path"/>
+          <path refid="tests.run.path"/>
       </classpath>
    </java>
    <antcall target="stop-db" />

Modified: incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy Thu Oct 12 07:12:36 2006
@@ -15,10 +15,17 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-username =    "zebulon";
+username = "admin";
 
 roller = org.apache.roller.model.RollerFactory.getRoller();
-user = roller.getUserManager().getUser(username);
-println "User ${user.userName} with id ${user.id} has roles:";
-user.getRoles().each({ item -> println "   ${item.getRole()}" });
+user = roller.getUserManager().getUserByUserName(username);
+
+println roller.getUserManager().getUsers(0,-1);
+
+if (user == null) {
+    println "User ${username} not found";
+} else {
+    println "User ${user.userName} with id ${user.id} has roles:";
+    user.getRoles().each({ item -> println "   ${item.getRole()}" });
+}
 

Modified: incubator/roller/trunk/sandbox/scripting/groovy/createcomment.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/createcomment.gy?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/createcomment.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/createcomment.gy Thu Oct 12 07:12:36 2006
@@ -15,8 +15,8 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-handle =  "scratchblog";
-name =    "Dave Johnson";
+handle =  "adminblog";
+name =    "Dave";
 email =   "dave@example.com";
 url =     "http://example.com";
 anchor =  "test_post";
@@ -24,10 +24,11 @@
 content = "Testing 1 2 3 <em>Hello World!</em>";
  
 roller = org.apache.roller.model.RollerFactory.getRoller();
-roller.begin(org.apache.roller.pojos.UserData.SYSTEM_USER);
 blog = roller.getUserManager().getWebsiteByHandle(handle);
 entry = roller.getWeblogManager().getWeblogEntryByAnchor(blog, anchor);
 
+println entry
+
 comment = new org.apache.roller.pojos.CommentData();
 comment.setWeblogEntry(entry);
 comment.setName(name);
@@ -35,7 +36,8 @@
 comment.setPostTime(new java.sql.Timestamp(new java.util.Date().getTime()));
 comment.setContent(content);
 comment.setNotify(Boolean.FALSE);
-comment.save();
+comment.setPending(Boolean.FALSE);
+roller.getWeblogManager().saveComment(comment);
 
-roller.commit();
+roller.flush();
 

Modified: incubator/roller/trunk/sandbox/scripting/groovy/hibernate.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/hibernate.cfg.xml?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/hibernate.cfg.xml (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/hibernate.cfg.xml Thu Oct 12 07:12:36
2006
@@ -20,15 +20,21 @@
         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
-    <session-factory>
+    <session-factory> 
         
+        <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
+        <property name="hibernate.connection.url">jdbc:derby://localhost:1527/roller31</property>
+        <property name="hibernate.connection.username">APP</property>
+        <property name="hibernate.connection.password">APP</property>
+        <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
+
+        <!--
         <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
         <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost:7475</property>
         <property name="hibernate.connection.username">sa</property>
         <property name="hibernate.connection.password"></property>
         <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
        
-        <!--
         <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
         <property name="hibernate.connection.url">jdbc:postgresql://localhost/rollerdb_20</property>
         <property name="hibernate.connection.username">scott</property>
@@ -45,9 +51,15 @@
         <property name="hibernate.cache.use_structured_entries">true</property>
                
         <!-- Map Roller pojo classes -->
+        <mapping resource="org/apache/roller/pojos/RollerPropertyData.hbm.xml" />
+        <mapping resource="org/apache/roller/pojos/UserData.hbm.xml" />
+        <mapping resource="org/apache/roller/pojos/RoleData.hbm.xml" />
+        <mapping resource="org/apache/roller/pojos/RollerConfigData.hbm.xml" />
+
+        <mapping resource="org/apache/roller/pojos/WebsiteData.hbm.xml" />
+        <mapping resource="org/apache/roller/pojos/PermissionsData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/BookmarkData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/CommentData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/EntryAttributeData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/FolderAssoc.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/FolderData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/WeblogTemplate.hbm.xml" />
@@ -56,20 +68,18 @@
         <mapping resource="org/apache/roller/pojos/PingQueueEntryData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/PingTargetData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/RefererData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/RoleData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/RollerConfigData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/UserData.hbm.xml" />
+
+        <mapping resource="org/apache/roller/pojos/WeblogEntryData.hbm.xml" />
+        <mapping resource="org/apache/roller/pojos/WeblogEntryTagData.hbm.xml" /> 
      
+        <mapping resource="org/apache/roller/pojos/WeblogEntryTagAggregateData.hbm.xml"
/>                       
+        <mapping resource="org/apache/roller/pojos/EntryAttributeData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/WeblogCategoryData.hbm.xml" />
         <mapping resource="org/apache/roller/pojos/WeblogCategoryAssoc.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/WeblogEntryData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/WebsiteData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/RollerPropertyData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PermissionsData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PlanetConfigData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PlanetGroupData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PlanetEntryData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PlanetSubscriptionData.hbm.xml" />
-        <mapping resource="org/apache/roller/pojos/PlanetGroupSubscriptionAssoc.hbm.xml"
/>
+        
+        <mapping resource="org/apache/roller/planet/pojos/PlanetConfigData.hbm.xml" />
+        <mapping resource="org/apache/roller/planet/pojos/PlanetGroupData.hbm.xml" />
+        <mapping resource="org/apache/roller/planet/pojos/PlanetEntryData.hbm.xml" />
+        <mapping resource="org/apache/roller/planet/pojos/PlanetSubscriptionData.hbm.xml"
/>
         
     </session-factory>
 </hibernate-configuration>

Modified: incubator/roller/trunk/sandbox/scripting/groovy/run-groovy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/run-groovy?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/run-groovy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/run-groovy Thu Oct 12 07:12:36 2006
@@ -1,19 +1,18 @@
 #!/bin/bash
 
-#export GROOVY_HOME=/Applications/Java/groovy
-#export ROLLER_HOME=~/roller_trunk/build/roller
-#export JDBCJAR=$CATALINA_HOME/common/lib/mysql-connector-java-3.0.11-stable-bin.jar
+export GROOVY_HOME=/Applications/Java/groovy
+export ROLLER_HOME=~/roller_trunk/build/webapp
+export JDBCJAR=$CATALINA_HOME/common/lib/derbyclient.jar
 
-export GROOVY_HOME=~/java/groovy
-export ROLLER_HOME=../../standalone/build/roller-demo/webapps/roller
-export JDBCJAR=../../standalone/build/roller-demo/common/lib/hsqldb.jar
+#export GROOVY_HOME=~/java/groovy
+#export ROLLER_HOME=../../standalone/build/roller-demo/webapps/roller
+#export JDBCJAR=../../standalone/build/roller-demo/common/lib/hsqldb.jar
 
 export CLASSPATH=.:\
 ${GROOVY_HOME}/embeddable/groovy-all-1.0-jsr-05.jar:\
 ${GROOVY_HOME}/lib/commons-cli-1.0.jar:\
-${ROLLER_HOME}/WEB-INF/lib/rollerbeans.jar:\
-${ROLLER_HOME}/WEB-INF/lib/rollercontrib.jar:\
-${ROLLER_HOME}/WEB-INF/lib/rollerweb.jar:\
+${ROLLER_HOME}/WEB-INF/lib/roller-business.jar:\
+${ROLLER_HOME}/WEB-INF/lib/roller-web.jar:\
 ${ROLLER_HOME}/WEB-INF/classes:\
 ${JDBCJAR}:\
 ${ROLLER_HOME}/WEB-INF/lib/hibernate3.jar:\

Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
Thu Oct 12 07:12:36 2006
@@ -821,8 +821,8 @@
             
             if (searchString != null) {
                 criteria.add(Expression.disjunction()
-                .add(Expression.like("url", searchString, MatchMode.ANYWHERE))
-                .add(Expression.like("content", searchString, MatchMode.ANYWHERE)));
+                   .add(Expression.like("url", searchString, MatchMode.ANYWHERE))
+                   .add(Expression.like("content", searchString, MatchMode.ANYWHERE)));
             }
             
             if (startDate != null) {
@@ -871,6 +871,93 @@
         }
     }
     
+    public int deleteMatchingComments(
+            WebsiteData     website, 
+            WeblogEntryData entry, 
+            String  searchString, 
+            Date    startDate, 
+            Date    endDate, 
+            Boolean pending, 
+            Boolean approved, 
+            Boolean spam) throws RollerException {
+       
+        try {
+            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
+            StringBuffer queryString = new StringBuffer();
+            ArrayList params = new ArrayList();
+            queryString.append("delete CommentData c where ");
+                
+            if (entry != null) {
+                queryString.append("c.weblogEntry.anchor = ? and c.weblogEntry.website.handle
= ? ");
+                params.add(entry.getAnchor());
+                params.add(entry.getWebsite().getHandle());
+            } else if (website != null) {
+                queryString.append("c.weblogEntry.website.handle = ? ");
+                params.add(website.getHandle());
+            } 
+            
+            if (searchString != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("(c.url like ? or c.content like ?) ");
+                searchString = '%' + searchString + '%';
+                params.add(searchString);
+                params.add(searchString);
+            }
+            
+            if (startDate != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("c.postTime > ? ");
+                params.add(startDate);
+            }
+            
+            if (endDate != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("c.postTime < ? ");
+                params.add(endDate);
+            }
+            
+            if (pending != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("c.pending = ? ");
+                params.add(pending);
+            }
+            
+            if (approved != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("c.approved = ? ");
+                params.add(approved);
+            }
+            
+            if (spam != null) {
+                if (!queryString.toString().trim().endsWith("where")) {
+                    queryString.append("and ");
+                }
+                queryString.append("c.spam = ? ");
+                params.add(spam);
+            }
+            
+            Query query = session.createQuery(queryString.toString());
+            for(int i = 0; i < params.size(); i++) {
+              query.setParameter(i, params.get(i));
+            }
+            return query.executeUpdate();
+                        
+        } catch (HibernateException e) {
+            log.error(e);
+            throw new RollerException(e);
+        }
+    }
+    
     
     public WeblogCategoryData getWeblogCategory(String id)
     throws RollerException {
@@ -1024,7 +1111,8 @@
             tags,
             status,
             null,
-locale,             offset,
+            locale,             
+            offset,
             length);
         
         Calendar cal = Calendar.getInstance();
@@ -1371,6 +1459,5 @@
         
         // delete all bad counts
         session.createQuery("delete from WeblogEntryTagAggregateData where total <= 0").executeUpdate();
-    }
-    
+    }    
 }

Modified: incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/model/WeblogManager.java Thu Oct 12 07:12:36
2006
@@ -328,7 +328,7 @@
      * @param startDate  Start date or null for no restriction
      * @param endDate    End date or null for no restriction
      * @param pending    Pending flag value or null for no restriction
-     * @param pending    Approved flag value or null for no restriction
+     * @param approved   Approved flag value or null for no restriction
      * @param reverseChrono True for results in reverse chrono order
      * @param spam       Spam flag value or null for no restriction
      * @param offset     Offset into results for paging
@@ -346,6 +346,27 @@
             boolean         reverseChrono,
             int             offset,
             int             length
+            ) throws RollerException;
+
+    /**
+     * Deletes comments that match paramters.
+     * @param website    Website or null for all comments on site
+     * @param entry      Entry or null to include all comments
+     * @param startDate  Start date or null for no restriction
+     * @param endDate    End date or null for no restriction
+     * @param approved   Pending flag value or null for no restriction
+     * @param pending    Approved flag value or null for no restriction
+     * @return Number of comments deleted
+     */
+    public int deleteMatchingComments(
+            WebsiteData     website,
+            WeblogEntryData entry,
+            String          searchString,
+            Date            startDate,
+            Date            endDate,
+            Boolean         pending,
+            Boolean         approved,
+            Boolean         spam
             ) throws RollerException;
         
     /**

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java
Thu Oct 12 07:12:36 2006
@@ -87,6 +87,20 @@
         RollerRequest rreq = RollerRequest.getRollerRequest(request);
         RollerSession rses = RollerSession.getRollerSession(request);
         
+        ActionForward fwd = null;
+        // Ensure user is authorized to view comments in weblog
+        if (rreq.getWebsite() != null && rses.isUserAuthorized(rreq.getWebsite()))
{
+            fwd =  mapping.findForward("commentManagement.page");
+        }
+        // Ensure only global admins can see all comments
+        else if (rses.isGlobalAdminUser()) {
+            fwd =  mapping.findForward("commentManagementGlobal.page");
+        } 
+        else {
+            // And everybody else gets...
+            return mapping.findForward("access-denied");
+        }        
+        
         if (rreq.getWeblogEntry() != null) {
             queryForm.setEntryid(rreq.getWeblogEntry().getId());
             queryForm.setWeblog(rreq.getWeblogEntry().getWebsite().getHandle());
@@ -99,20 +113,37 @@
         if (request.getAttribute("commentManagementForm") == null) {
             request.setAttribute("commentManagementForm", actionForm);
         }
-        
-        // Ensure user is authorized to view comments in weblog
-        if (rreq.getWebsite() != null && rses.isUserAuthorized(rreq.getWebsite()))
{
-            return mapping.findForward("commentManagement.page");
-        }
-        // And ensure only global admins can see all comments
-        else if (rses.isGlobalAdminUser()) {
-            return mapping.findForward("commentManagementGlobal.page");
-        } 
-        else {
-            return mapping.findForward("access-denied");
-        }
+        return fwd;
     }
 
+    public ActionForward bulkDelete(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response) 
+            throws Exception {
+        if ("POST".equals(request.getMethod())) {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if (rreq.getWebsite() != null && rses.isUserAuthorized(rreq.getWebsite())
+                || rses.isGlobalAdminUser()) {
+                WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+                CommentManagementForm queryForm = (CommentManagementForm)actionForm;
+                wmgr.deleteMatchingComments(
+                    rreq.getWebsite(),
+                    rreq.getWeblogEntry(), 
+                    queryForm.getSearchString(),
+                    queryForm.getStartDate(request.getLocale()),  
+                    queryForm.getEndDate(request.getLocale()), 
+                    queryForm.getPending(),
+                    queryForm.getApproved(),
+                    queryForm.getSpam());
+            }  
+            CommentManagementForm queryForm = (CommentManagementForm)actionForm;
+        }
+        return query(mapping, actionForm, request, response);
+    }
+        
     public ActionForward update(
             ActionMapping       mapping,
             ActionForm          actionForm,
@@ -258,10 +289,12 @@
     }
     
     public class CommentManagementPageModel extends BasePageModel {
-        private List comments = new ArrayList();
-        private WeblogEntryData weblogEntry = null;
+        private List                  comments = new ArrayList();
+        private WeblogEntryData       weblogEntry = null;
         private CommentManagementForm queryForm = null;
-        private boolean more = false;
+        private boolean               more = false;
+        private int                   totalMatchingCommentCount = 0;
+        private boolean               showBulkDeleteLink = false;
         
         public CommentManagementPageModel(
                 String titleKey,
@@ -283,7 +316,7 @@
                 website = rreq.getWebsite();
             }
             WeblogManager blogmgr = roller.getWeblogManager();
-
+         
             int offset = queryForm.getOffset();
             comments = blogmgr.getComments(
                 website,
@@ -302,6 +335,30 @@
                 comments.remove(comments.size()-1);
             }
             this.queryForm.loadCheckboxes(comments);
+            
+            // If we have a query POST, then we know we're responding to a query so 
+            // we need to decide whether or not to show the bulk comment prompt.
+            if ("POST".equals(request.getMethod()) 
+                && "query".equals(request.getParameter("method"))) {
+                
+                // So we run the query again, except this time with no limit.
+                List allMatchingComments = blogmgr.getComments( 
+                    website,
+                    weblogEntry, 
+                    queryForm.getSearchString(),
+                    queryForm.getStartDate(request.getLocale()), 
+                    queryForm.getEndDate(request.getLocale()), 
+                    queryForm.getPending(),
+                    queryForm.getApproved(),
+                    queryForm.getSpam(),
+                    true, 
+                    0, -1);                
+                totalMatchingCommentCount = allMatchingComments.size();
+                
+                // If there are more comments than can be shown on one 
+                // page, then present the bulk-comment delete prompt.
+                showBulkDeleteLink = totalMatchingCommentCount > queryForm.getCount();
+            }
         }    
         
         public List getComments() {
@@ -390,6 +447,14 @@
             sb.append("&count=");
             sb.append(queryForm.getCount());
             return sb.toString();
+        }
+
+        public int getTotalMatchingCommentCount() {
+            return totalMatchingCommentCount;
+        }
+
+        public boolean isShowBulkDeleteLink() {
+            return showBulkDeleteLink;
         }
     }
 }

Modified: incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java Thu Oct 12 07:12:36
2006
@@ -199,6 +199,92 @@
         TestUtils.endSession(true);
     }
     
+    public void testBulkCommentDelete() throws Exception {
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+        List comments = null;
+        
+        // we need some comments to play with
+        CommentData comment1 = TestUtils.setupComment("deletemeXXX", testEntry);
+        CommentData comment2 = TestUtils.setupComment("XXXdeleteme", testEntry);
+        CommentData comment3 = TestUtils.setupComment("deleteme", testEntry);
+        CommentData comment4 = TestUtils.setupComment("saveme", testEntry);
+        CommentData comment5 = TestUtils.setupComment("saveme", testEntry);
+        CommentData comment6 = TestUtils.setupComment("saveme", testEntry);
+        TestUtils.endSession(true);
+        
+        // get all comments
+        comments = null;
+        comments = mgr.getComments(
+            null, // website
+            null, // entry
+            null, // searchString
+            null, // startDate
+            null, // endDate
+            null, // pending
+            null, // approved
+            null, // spam
+            true, // reverseChrono
+             0,   // offset
+            -1);  // length
+        assertNotNull(comments);
+        assertEquals(6, comments.size());
+        
+        comments = mgr.getComments(
+            null, // website
+            null, // entry
+            "deleteme", // searchString
+            null, // startDate
+            null, // endDate
+            null, // pending
+            null, // approved
+            null, // spam
+            true, // reverseChrono
+             0,   // offset
+            -1);  // length
+        assertNotNull(comments);
+        assertEquals(3, comments.size());
+       
+        int countDeleted = mgr.deleteMatchingComments(
+            null,         // website
+            null,         // entry
+            "deleteme",  // searchString
+            null,         // startDate
+            null,         // endDate
+            null,         // pending
+            null,         // approved
+            null);        // spam        
+        assertEquals(3, countDeleted);
+        
+        comments = mgr.getComments(
+            null, // website
+            null, // entry
+            null, // searchString
+            null, // startDate
+            null, // endDate
+            null, // pending
+            null, // approved
+            null, // spam
+            true, // reverseChrono
+             0,   // offset
+            -1);  // length
+        assertNotNull(comments);
+        assertEquals(3, comments.size());
+        
+        // remove test comments
+        countDeleted = mgr.deleteMatchingComments(
+            null,         // website
+            null,         // entry
+            "saveme",    // searchString
+            null,         // startDate
+            null,         // endDate
+            null,         // pending
+            null,         // approved
+            null);        // spam        
+        assertEquals(3, countDeleted);
+        TestUtils.endSession(true);
+    }
+    
     
     /**
      * Test extra CRUD methods ... removeComments(ids), removeCommentsForEntry

Modified: incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Thu Oct 12
07:12:36 2006
@@ -242,6 +242,10 @@
 commentManagement.endDate=End date
 commentManagement.startDate=Start date
 
+commentManagement.bulkDeletePrompt1=Your query matched {0} comments, 
+commentManagement.bulkDeletePrompt2=delete them all?
+commentManagement.confirmBulkDelete=Are you sure you want to delete all {0} selected by your
query?
+
 commentManagement.pendingStatus=Pending status
 commentManagement.onlyPending=Pending only
 commentManagement.onlyApproved=Approved only

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp?view=diff&rev=463255&r1=463254&r2=463255
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp Thu Oct 12 07:12:36
2006
@@ -32,6 +32,12 @@
         }
     }
 }
+function bulkDelete() {
+    if (window.confirm('<fmt:message key="commentManagement.confirmBulkDelete"><fmt:param
value="${model.totalMatchingCommentCount}" /></fmt:message>')) {
+        document.commentQueryForm.method.value = "bulkDelete";
+        document.commentQueryForm.submit();
+    }
+}
 -->
 </script>
 
@@ -155,6 +161,21 @@
 
         
         <%-- ============================================================= --%>
+        <%-- Bulk comment delete link --%>
+        <%-- ============================================================= --%>
+        
+        <c:if test="${model.showBulkDeleteLink}">
+            <p>
+            <fmt:message key="commentManagement.bulkDeletePrompt1">
+                <fmt:param value="${model.totalMatchingCommentCount}" />
+            </fmt:message>
+            <a href="#" onclick="bulkDelete()">
+                <fmt:message key="commentManagement.bulkDeletePrompt2" />
+            </a>
+            </p>
+        </c:if>
+        
+        <%-- ============================================================= --%>
         <%-- Comment table / form with checkboxes --%>
         <%-- ============================================================= --%>
         
@@ -362,7 +383,7 @@
         <%-- Save changes and  cancel buttons --%>
         <%-- ========================================================= --%>
             
-        <input type="submit" name="submit" 
+        <input type="submit" name="submitButton" 
             value='<fmt:message key="commentManagement.update" />' />
         &nbsp;
         



Mime
View raw message