roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r493205 [1/2] - in /incubator/roller/trunk: ./ metadata/database/ nbproject/ src/org/apache/roller/pojos/ src/org/apache/roller/ui/authoring/ajax/ src/org/apache/roller/ui/authoring/struts/actions/ src/org/apache/roller/ui/rendering/servlet...
Date Fri, 05 Jan 2007 22:03:58 GMT
Author: snoopdave
Date: Fri Jan  5 14:03:55 2007
New Revision: 493205

URL: http://svn.apache.org/viewvc?view=rev&rev=493205
Log:
Implementation Comment Validators proposal plus some bug fixes in comment features

Added:
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/BlacklistCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidationManager.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessLinksCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessSizeCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/TrackbackLinkbackCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/util/BlacklistChecker.java
      - copied, changed from r492021, incubator/roller/trunk/src/org/apache/roller/util/SpamChecker.java
    incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/
    incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java
    incubator/roller/trunk/tools/buildtime/activation.jar
      - copied unchanged from r492021, incubator/roller/trunk/tools/lib/activation.jar
    incubator/roller/trunk/tools/buildtime/mail.jar
      - copied unchanged from r492021, incubator/roller/trunk/tools/lib/mail.jar
Removed:
    incubator/roller/trunk/src/org/apache/roller/util/SpamChecker.java
    incubator/roller/trunk/tools/lib/activation.jar
    incubator/roller/trunk/tools/lib/mail.jar
Modified:
    incubator/roller/trunk/metadata/database/310-to-320-migration.vm
    incubator/roller/trunk/metadata/database/createdb.vm
    incubator/roller/trunk/nbproject/project.xml
    incubator/roller/trunk/properties.xmlf
    incubator/roller/trunk/src/org/apache/roller/pojos/CommentData.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/ajax/CommentDataServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/CommentManagementAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/TrackbackServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogCommentRequest.java
    incubator/roller/trunk/src/org/apache/roller/util/Blacklist.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/trunk/web/WEB-INF/classes/roller.properties
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagement.jsp
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/CommentManagementSidebar.jsp
    incubator/roller/trunk/web/WEB-INF/velocity/weblog.vm
    incubator/roller/trunk/web/roller-ui/authoring/editors/editor-text.jsp
    incubator/roller/trunk/web/roller-ui/authoring/editors/editor-xinha.jsp
    incubator/roller/trunk/web/roller-ui/tools/dstest.jsp
    incubator/roller/trunk/web/roller-ui/widgets/date.jsp

Modified: incubator/roller/trunk/metadata/database/310-to-320-migration.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/310-to-320-migration.vm?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/metadata/database/310-to-320-migration.vm (original)
+++ incubator/roller/trunk/metadata/database/310-to-320-migration.vm Fri Jan  5 14:03:55 2007
@@ -19,6 +19,9 @@
 #addColumnNull("folder" "path" "varchar(255)")
 create index fo_path_idx on folder( path );
 
+-- add new fields to comment table to support CommentValidators
+#addColumnNull("roller_comment" "referrer" "varchar(255)")
+#addColumnNull("roller_comment" "useragent" "varchar(255)")
 
 -- some various indexes to improve performance
 create index rhc_dailyhits_idx on roller_hitcounts( dailyhits );

Modified: incubator/roller/trunk/metadata/database/createdb.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/createdb.vm?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/metadata/database/createdb.vm (original)
+++ incubator/roller/trunk/metadata/database/createdb.vm Fri Jan  5 14:03:55 2007
@@ -253,18 +253,20 @@
 
 
 create table roller_comment (
-    id      varchar(48) not null primary key,
-    entryid varchar(48) not null,
-    name    varchar(255),
-    email   varchar(255),
-    url     varchar(255),
-    content $TEXT_SQL_TYPE,
-    posttime $TIMESTAMP_SQL_TYPE   not null,
-    spam    $BOOLEAN_SQL_TYPE_FALSE not null,
-    notify  $BOOLEAN_SQL_TYPE_FALSE not null,
+    id         varchar(48) not null primary key,
+    entryid    varchar(48) not null,
+    name       varchar(255),
+    email      varchar(255),
+    url        varchar(255),
+    content    $TEXT_SQL_TYPE,
+    posttime   $TIMESTAMP_SQL_TYPE   not null,
+    spam       $BOOLEAN_SQL_TYPE_FALSE not null,
+    notify     $BOOLEAN_SQL_TYPE_FALSE not null,
     remotehost varchar(128),
-    pending  $BOOLEAN_SQL_TYPE_TRUE not null,
-    approved  $BOOLEAN_SQL_TYPE_FALSE not null
+    pending    $BOOLEAN_SQL_TYPE_TRUE not null,
+    approved   $BOOLEAN_SQL_TYPE_FALSE not null,
+    referrer   varchar(255),
+    useragent  varchar(255)
 );
 create index co_entryid_idx on roller_comment( entryid );
 create index co_pending_idx on roller_comment( pending );

Modified: incubator/roller/trunk/nbproject/project.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/nbproject/project.xml?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/nbproject/project.xml (original)
+++ incubator/roller/trunk/nbproject/project.xml Fri Jan  5 14:03:55 2007
@@ -63,6 +63,11 @@
                     <type>java</type>
                     <location>apps/planet/test/java</location>
                 </source-folder>
+                <source-folder>
+                    <label>sandbox/jdobackend/src</label>
+                    <type>java</type>
+                    <location>sandbox/jdobackend/src</location>
+                </source-folder>
             </folders>
             <ide-actions>
                 <action name="build">
@@ -154,6 +159,10 @@
                         <label>apps/planet/test/java</label>
                         <location>apps/planet/test/java</location>
                     </source-folder>
+                    <source-folder style="packages">
+                        <label>sandbox/jdobackend/src</label>
+                        <location>sandbox/jdobackend/src</location>
+                    </source-folder>
                     <source-file>
                         <location>build.xml</location>
                     </source-file>
@@ -180,7 +189,8 @@
                 <package-root>sandbox/scripting/src</package-root>
                 <package-root>apps/planet/src/java</package-root>
                 <package-root>apps/planet/test/java</package-root>
-                <classpath mode="compile">tools/buildtime/junit-3.8.1.jar:tools/lib/activation.jar:tools/lib/commons-betwixt-1.0-beta-1.jar:tools/lib/commons-httpclient-2.0.2.jar:tools/lib/concurrent-1.3.2.jar:tools/lib/ekitapplet.jar:tools/lib/jazzy-core.jar:tools/lib/log4j-1.2.4.jar:tools/lib/lucene-1.4.3.jar:tools/lib/mail.jar:tools/lib/taglibs-string.jar:tools/lib/velocity-1.4.jar:tools/lib/velocity-dep-1.4.jar:tools/lib/velocity-tools-1.1.jar:tools/lib/xmlrpc-1.2-b1.jar:tools/struts-1.2.4/lib/antlr.jar:tools/struts-1.2.4/lib/commons-beanutils.jar:tools/struts-1.2.4/lib/commons-collections.jar:tools/struts-1.2.4/lib/commons-digester.jar:tools/struts-1.2.4/lib/commons-fileupload.jar:tools/struts-1.2.4/lib/commons-lang-2.0.jar:tools/struts-1.2.4/lib/commons-logging.jar:tools/struts-1.2.4/lib/commons-validator.jar:tools/struts-1.2.4/lib/jakarta-oro.jar:tools/struts-1.2.4/lib/struts-el.jar:tools/struts-1.2.4/lib/struts.jar:tools/buildtime/mockrunner-0.35/lib/mockrunner-servl
 et.jar:tools/buildtime/mockrunner-0.35/lib/mockrunner-struts.jar:tools/buildtime/mockrunner-0.35/lib/mockrunner.jar:tools/buildtime/mockrunner-0.35/lib/nekohtml.jar:tools/standard-1.0.3/lib/jaxen-full.jar:tools/standard-1.0.3/lib/jstl.jar:tools/standard-1.0.3/lib/standard.jar:tools/buildtime/tomcat-5.0.28/servlet-api.jar:tools/buildtime/tomcat-5.0.28/jsp-api.jar:tools/lib/jdom.jar:tools/spring-1.2/acegi-security-0.9.0.jar:tools/spring-1.2/spring.jar:tools/lib/rome-0.8.jar:tools/lib/rome-fetcher-0.8.jar:tools/lib/commons-codec-1.3.jar:tools/hibernate-3.1/hibernate3.jar:contrib/lib/textile4j-1.20.jar:tools/buildtime/derby.jar:tools/buildtime/ant-1.6.2/ant.jar:tools/buildtime/derbynet.jar:tools/lib/rome-0.9.jar:tools/lib/rome-fetcher-0.9.jar</classpath>
+                <package-root>sandbox/jdobackend/src</package-root>
+                <classpath mode="compile">tools/buildtime/junit-3.8.1.jar:tools/lib/commons-betwixt-1.0-beta-1.jar:tools/lib/commons-httpclient-2.0.2.jar:tools/lib/concurrent-1.3.2.jar:tools/lib/ekitapplet.jar:tools/lib/jazzy-core.jar:tools/lib/log4j-1.2.4.jar:tools/lib/lucene-1.4.3.jar:tools/lib/taglibs-string.jar:tools/lib/velocity-1.4.jar:tools/lib/velocity-dep-1.4.jar:tools/lib/velocity-tools-1.1.jar:tools/lib/xmlrpc-1.2-b1.jar:tools/struts-1.2.4/lib/antlr.jar:tools/struts-1.2.4/lib/commons-beanutils.jar:tools/struts-1.2.4/lib/commons-collections.jar:tools/struts-1.2.4/lib/commons-digester.jar:tools/struts-1.2.4/lib/commons-fileupload.jar:tools/struts-1.2.4/lib/commons-lang-2.0.jar:tools/struts-1.2.4/lib/commons-logging.jar:tools/struts-1.2.4/lib/commons-validator.jar:tools/struts-1.2.4/lib/jakarta-oro.jar:tools/struts-1.2.4/lib/struts-el.jar:tools/struts-1.2.4/lib/struts.jar:tools/buildtime/mockrunner-0.35/lib/mockrunner-servlet.jar:tools/buildtime/mockrunner-0.35/lib/m
 ockrunner-struts.jar:tools/buildtime/mockrunner-0.35/lib/mockrunner.jar:tools/buildtime/mockrunner-0.35/lib/nekohtml.jar:tools/standard-1.0.3/lib/jaxen-full.jar:tools/standard-1.0.3/lib/jstl.jar:tools/standard-1.0.3/lib/standard.jar:tools/buildtime/tomcat-5.0.28/servlet-api.jar:tools/buildtime/tomcat-5.0.28/jsp-api.jar:tools/lib/jdom.jar:tools/spring-1.2/acegi-security-0.9.0.jar:tools/spring-1.2/spring.jar:tools/lib/rome-0.8.jar:tools/lib/rome-fetcher-0.8.jar:tools/lib/commons-codec-1.3.jar:tools/hibernate-3.1/hibernate3.jar:contrib/lib/textile4j-1.20.jar:tools/buildtime/derby.jar:tools/buildtime/ant-1.6.2/ant.jar:tools/buildtime/derbynet.jar:tools/lib/rome-0.9.jar:tools/lib/rome-fetcher-0.9.jar:tools/buildtime/activation.jar:tools/buildtime/mail.jar</classpath>
                 <source-level>1.4</source-level>
             </compilation-unit>
         </java-data>

Modified: incubator/roller/trunk/properties.xmlf
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/properties.xmlf?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/properties.xmlf (original)
+++ incubator/roller/trunk/properties.xmlf Fri Jan  5 14:03:55 2007
@@ -93,8 +93,6 @@
     <include name="rome-fetcher-0.9.jar"/>
     <include name="velocity-1.4.jar"/>
     <include name="velocity-dep-1.4.jar"/>
-    <include name="mail.jar"/>
-    <include name="activation.jar"/>
     <include name="xmlrpc-1.2-b1.jar"/>
 </fileset>
 
@@ -119,7 +117,7 @@
     <include name="jsp-api.jar"/>
 </fileset>
 
-<fileset id="mail.jars" dir="${ro.tools}/lib">
+<fileset id="mail.jars" dir="${ro.tools}/buildtime">
     <include name="activation.jar"/>
     <include name="mail.jar"/>
 </fileset>

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/CommentData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/CommentData.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/CommentData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/CommentData.java Fri Jan  5 14:03:55 2007
@@ -34,17 +34,23 @@
         implements java.io.Serializable {
     public static final long serialVersionUID = -6668122596726478462L;
     
-    private String id = null;
-    private String name = null;
-    private String email = null;
-    private String url = null;
-    private String content = null;
+    private String    id = null;
+    
+    private String    name = null;
+    private String    email = null;
+    private String    url = null;
+    private String    content = null;
     private Timestamp postTime = null;
-    private Boolean spam = Boolean.FALSE;
-    private Boolean notify = Boolean.FALSE;
-    private String remoteHost = null;
-    private Boolean pending = null;
-    private Boolean approved = null;        
+    
+    private Boolean   spam = Boolean.FALSE;
+    private Boolean   notify = Boolean.FALSE;
+    private Boolean   pending = Boolean.TRUE;
+    private Boolean   approved = Boolean.FALSE;        
+    
+    private String    remoteHost = null;
+    private String    referrer = null;
+    private String    userAgent = null;
+         
     private WeblogEntryData weblogEntry = null;
     
     
@@ -67,7 +73,7 @@
         this.spam = spam;
         this.notify = notify;
         this.pending = pending;
-        this.approved = approved;
+        this.setApproved(approved);
         
         weblogEntry = entry;
     }
@@ -77,21 +83,26 @@
     }
     
     /**
+     * Database ID of comment
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.id column="id"
-     *  generator-class="uuid.hex" unsaved-value="null"
+     *    generator-class="uuid.hex" unsaved-value="null"
      */
     public java.lang.String getId() {
         return this.id;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Database ID of comment
+     * @ejb:persistent-field 
+     */
     public void setId(java.lang.String id) {
         this.id = id;
     }
     
     /**
+     * Weblog entry assocaited with comment
      * @roller.wrapPojoMethod type="pojo"
      * @ejb:persistent-field
      * @hibernate.many-to-one column="entryid" cascade="none" not-null="true"
@@ -100,12 +111,16 @@
         return weblogEntry;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Weblog entry assocaited with comment
+     * @ejb:persistent-field 
+     */
     public void setWeblogEntry(WeblogEntryData entry) {
         weblogEntry = entry;
     }
     
     /**
+     * Name of person who wrote comment.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="name" non-null="true" unique="false"
@@ -114,14 +129,16 @@
         return this.name;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Name of person who wrote comment.
+     * @ejb:persistent-field 
+     */
     public void setName(java.lang.String name) {
         this.name = name;
     }
     
     /**
-     * Email
-     *
+     * Email of person who wrote comment.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="email" non-null="true" unique="false"
@@ -130,12 +147,16 @@
         return this.email;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Email of person who wrote comment.
+     * @ejb:persistent-field 
+     */
     public void setEmail(java.lang.String email) {
         this.email = email;
     }
     
     /**
+     * URL of person who wrote comment.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="url" non-null="true" unique="false"
@@ -144,12 +165,16 @@
         return this.url;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * URL of person who wrote comment.
+     * @ejb:persistent-field 
+     */
     public void setUrl(java.lang.String url) {
         this.url = url;
     }
     
     /**
+     * Content of comment.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="content" non-null="true" unique="false"
@@ -158,12 +183,16 @@
         return this.content;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Content of comment.
+     * @ejb:persistent-field 
+     */
     public void setContent(java.lang.String content) {
         this.content = content;
     }
     
     /**
+     * Time that comment was posted.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="posttime" non-null="true" unique="false"
@@ -172,12 +201,16 @@
         return this.postTime;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Time that comment was posted.
+     * @ejb:persistent-field 
+     */
     public void setPostTime(java.sql.Timestamp postTime) {
         this.postTime = postTime;
     }
     
     /**
+     * Indicates that weblog owner considers this comment to be spam.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="spam" non-null="false" unique="false"
@@ -186,12 +219,17 @@
         return this.spam;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * Indicates that weblog owner considers this comment to be spam.
+     * @ejb:persistent-field 
+     */
     public void setSpam(Boolean spam) {
         this.spam = spam;
     }
     
     /**
+     * True if person who wrote comment wishes to be notified of new comments
+     * on the same weblog entry.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="notify" non-null="false" unique="false"
@@ -200,12 +238,17 @@
         return this.notify;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * True if person who wrote comment wishes to be notified of new comments
+     * on the same weblog entry.
+     * @ejb:persistent-field 
+     */
     public void setNotify(Boolean notify) {
         this.notify = notify;
     }
     
     /**
+     * True if comment has is pending approval.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="pending" non-null="false" unique="false"
@@ -214,12 +257,16 @@
         return this.pending;
     }
     
-    /** @ejb:persistent-field */
+    /** 
+     * True if comment has is pending approval.
+     * @ejb:persistent-field 
+     */
     public void setPending(Boolean pending) {
         this.pending = pending;
     }
     
     /**
+     * Indicates that comment has been approved for display on weblog.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="approved" non-null="false" unique="false"
@@ -228,12 +275,16 @@
         return this.approved;
     }
     
-    /** @ejb:persistent-field */
+    /**
+     * Indicates that comment has been approved for display on weblog.
+     * @ejb:persistent-field 
+     */
     public void setApproved(Boolean approved) {
         this.approved = approved;
     }
     
     /**
+     * Host name or IP of person who wrote comment.
      * @ejb:persistent-field
      */
     public void setRemoteHost(String remoteHost) {
@@ -241,6 +292,7 @@
     }
         
     /**
+     * Host name or IP of person who wrote comment.
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field
      * @hibernate.property column="remotehost" non-null="true" unique="false"
@@ -249,6 +301,56 @@
         return this.remoteHost;
     }
     
+    /** 
+     * HTTP referrer from comment post request 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="referrer" non-null="true" unique="false"
+     */
+    public String getReferrer() {
+        return referrer;
+    }
+
+    /** 
+     * HTTP referrer from comment post request 
+     * @ejb:persistent-field
+     */
+    public void setReferrer(String referrer) {
+        this.referrer = referrer;
+    }
+
+    /**
+     * HTTP user-agent from comment post request 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="useragent" non-null="true" unique="false"
+     */
+    public String getUserAgent() {
+        return userAgent;
+    }
+
+    /**
+     * HTTP user-agent from comment post request 
+     * @ejb:persistent-field
+     */
+    public void setUserAgent(String userAgent) {
+        this.userAgent = userAgent;
+    }
+    
+    /**
+     * Timestamp to be used to formulate comment permlink.
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String getTimestamp() {
+        if (postTime != null) {
+            return Long.toString(postTime.getTime());
+        }
+        return null;
+    }
+    
+    /** No-op to please XDoclet */      
+    public void setTimestamp(String timeStamp) {}
+
     public String toString() {
         StringBuffer str = new StringBuffer("{");
         
@@ -261,7 +363,9 @@
                 "spam=" + spam +
                 "notify=" + notify +
                 "pending" + pending +
-                "approved" + approved);
+                "approved" + getApproved() + 
+                "referrer" + getReferrer() + 
+                "userAgent" + getUserAgent());
         str.append('}');
         
         return (str.toString());
@@ -282,7 +386,9 @@
             lEquals = PojoUtil.equals(lEquals, this.spam, lTest.getSpam());
             lEquals = PojoUtil.equals(lEquals, this.notify, lTest.getNotify());
             lEquals = PojoUtil.equals(lEquals, this.pending, lTest.getPending());
-            lEquals = PojoUtil.equals(lEquals, this.approved, lTest.getApproved());
+            lEquals = PojoUtil.equals(lEquals, this.getApproved(), lTest.getApproved());
+            lEquals = PojoUtil.equals(lEquals, this.getReferrer(), lTest.getApproved());
+            lEquals = PojoUtil.equals(lEquals, this.getUserAgent(), lTest.getUserAgent());
             return lEquals;
         } else {
             return false;
@@ -301,8 +407,9 @@
         result = PojoUtil.addHashCode(result, this.spam);
         result = PojoUtil.addHashCode(result, this.notify);
         result = PojoUtil.addHashCode(result, this.pending);
-        result = PojoUtil.addHashCode(result, this.approved);
-        
+        result = PojoUtil.addHashCode(result, this.getApproved());               
+        result = PojoUtil.addHashCode(result, this.getReferrer());        
+        result = PojoUtil.addHashCode(result, this.getUserAgent());        
         return result;
     }
     
@@ -322,20 +429,10 @@
         this.spam = otherComment.getSpam();
         this.notify = otherComment.getNotify();
         this.pending = otherComment.getPending();
-        this.approved = otherComment.getApproved();
-    }
-    
-    /**
-     * Timestamp to be used to formulate comment permlink.
-     * @roller.wrapPojoMethod type="simple"
-     */
-    public String getTimestamp() {
-        if (postTime != null) {
-            return Long.toString(postTime.getTime());
-        }
-        return null;
+        this.setApproved(otherComment.getApproved());
+        this.setReferrer(otherComment.getReferrer());
+        this.setUserAgent(otherComment.getUserAgent());
     }
     
-    /** No-op to please XDoclet */      
-    public void setTimestamp(String timeStamp) {}
-}
\ No newline at end of file
+}
+

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/ajax/CommentDataServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/ajax/CommentDataServlet.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/ajax/CommentDataServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/ajax/CommentDataServlet.java Fri Jan  5 14:03:55 2007
@@ -61,7 +61,7 @@
             response.flushBuffer();
             response.getWriter().flush();
             response.getWriter().close();
-        } catch (RollerException e) {
+        } catch (Exception e) {
             throw new ServletException(e.getMessage());
         }
     }

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=493205&r1=493204&r2=493205
==============================================================================
--- 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 Fri Jan  5 14:03:55 2007
@@ -51,6 +51,7 @@
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.roller.ui.rendering.servlets.CommentServlet;
 import org.apache.roller.ui.authoring.struts.formbeans.CommentManagementForm;
+import org.apache.roller.util.RollerMessages;
 import org.apache.roller.util.Utilities;
 
 /**
@@ -281,7 +282,9 @@
             CommentData comment = (CommentData)iter.next();
             
             // Send email notifications because a new comment has been approved
-            CommentServlet.sendEmailNotification(comment, rootURL);
+            RollerMessages systemMessages = new RollerMessages();
+            systemMessages.addMessage("commentManagement.sendingApprovalNotification");
+            CommentServlet.sendEmailNotification(comment, true, systemMessages, rootURL);
             
             // Send approval notification to author of approved comment
             CommentServlet.sendEmailApprovalNotification(comment, rootURL);

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java Fri Jan  5 14:03:55 2007
@@ -20,7 +20,7 @@
 
 import java.io.IOException;
 import java.sql.Timestamp;
-import java.util.ArrayList;
+import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
@@ -53,13 +53,15 @@
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.rendering.model.UtilitiesModel;
 import org.apache.roller.ui.rendering.util.CommentAuthenticator;
+import org.apache.roller.ui.rendering.util.CommentValidationManager;
 import org.apache.roller.ui.rendering.util.DefaultCommentAuthenticator;
 import org.apache.roller.ui.rendering.util.WeblogCommentRequest;
 import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.util.GenericThrottle;
 import org.apache.roller.util.IPBanList;
 import org.apache.roller.util.MailUtil;
-import org.apache.roller.util.SpamChecker;
+import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.RollerMessages.RollerMessage;
 import org.apache.roller.util.URLUtilities;
 import org.apache.roller.util.Utilities;
 import org.apache.roller.util.cache.CacheManager;
@@ -68,10 +70,10 @@
 
 /**
  * The CommentServlet handles all incoming weblog entry comment posts.
- * 
+ *
  * We validate each incoming comment based on various comment settings and
  * if all checks are passed then the comment is saved.
- * 
+ *
  * Incoming comments are tested against the MT Blacklist. If they are found
  * to be spam, then they are marked as spam and hidden from view.
  *
@@ -84,16 +86,16 @@
 public class CommentServlet extends HttpServlet {
     
     private static Log log = LogFactory.getLog(CommentServlet.class);
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
     
     private static final String EMAIL_ADDR_REGEXP = "^.*@.*[.].{2,}$";
     
-    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
-    
-    private CommentAuthenticator authenticator = null;
-    private GenericThrottle commentThrottle = null;
+    private CommentAuthenticator     authenticator = null;
+    private CommentValidationManager commentValidationManager = null;
+    private GenericThrottle          commentThrottle = null;
     
     
-    /** 
+    /**
      * Initialization.
      */
     public void init(ServletConfig servletConfig) throws ServletException {
@@ -102,6 +104,8 @@
         
         log.info("Initializing CommentServlet");
         
+        commentValidationManager = new CommentValidationManager();
+        
         // lookup the authenticator we are going to use and instantiate it
         try {
             String name = RollerConfig.getProperty("comment.authenticator.classname");
@@ -113,7 +117,8 @@
             log.error(e);
             this.authenticator = new DefaultCommentAuthenticator();
         }
-
+        
+        
         // are we doing throttling?
         if(RollerConfig.getBooleanProperty("comment.throttle.enabled")) {
             
@@ -147,7 +152,7 @@
             log.info("Comment Throttling DISABLED");
         }
     }
-
+    
     
     /**
      * Handle incoming http GET requests.
@@ -155,7 +160,7 @@
      * The CommentServlet does not support GET requests, it's a 404.
      */
     public void doGet(HttpServletRequest request, HttpServletResponse response)
-        throws IOException, ServletException {
+    throws IOException, ServletException {
         
         response.sendError(HttpServletResponse.SC_NOT_FOUND);
     }
@@ -167,18 +172,28 @@
      * Here we handle incoming comment postings.
      */
     public void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws IOException, ServletException {
+    throws IOException, ServletException {
         
         String error = null;
-        String message = null;
         String dispatch_url = null;
         
         WebsiteData weblog = null;
         WeblogEntryData entry = null;
         
+        String message = null;
+        RollerMessages messages = new RollerMessages();
+        
         // are we doing a preview?  or a post?
         String method = request.getParameter("method");
-        boolean preview = (method != null && method.equals("preview")) ? true : false;
+        final boolean preview;
+        if (method != null && method.equals("preview")) {
+            preview = true;
+            messages.addMessage("commentServlet.previewCommentOnly");
+            log.debug("Handling comment preview post");
+        } else {
+            preview = false;
+            log.debug("Handling regular comment post");
+        }
         
         // throttling protection against spammers
         if(commentThrottle != null &&
@@ -242,14 +257,17 @@
         
         WeblogEntryCommentForm cf = new WeblogEntryCommentForm();
         cf.setData(comment);
+        if (preview) {
+            cf.setPreview(comment);
+        }
         
         // check if comments are allowed for this entry
         // this checks site-wide settings, weblog settings, and entry settings
         if(!entry.getCommentsStillAllowed() || !entry.isPublished()) {
             error = bundle.getString("comments.disabled");
-        
-        // make sure comment authentication passed
-        } else if(!this.authenticator.authenticate(request)) {
+            
+            // if this is a real comment post then authenticate request
+        } else if(!preview && !this.authenticator.authenticate(request)) {
             error = bundle.getString("error.commentAuthFailed");
             log.debug("Comment failed authentication");
         }
@@ -263,31 +281,19 @@
             return;
         }
         
+        int validationScore = commentValidationManager.validateComment(comment, messages);
+        log.debug("Comment Validation score: " + validationScore);
         
-        if (preview) {
-            // TODO: i18n
-            message = "This is a comment preview only";
-            cf.setPreview(comment);
-            
-            // If comment contains blacklisted text, warn commenter
-            SpamChecker checker = new SpamChecker();
-            if (checker.checkComment(comment)) {
-                error = bundle.getString("commentServlet.previewMarkedAsSpam");
-                log.debug("Comment marked as spam");
-            }
-            log.debug("Comment is a preview");
-            
-        } else {
-            // If comment contains blacklisted text, mark as spam
-            SpamChecker checker = new SpamChecker();
-            if (checker.checkComment(comment)) {
+        if (!preview) {
+            // If validation score is not perfect, mark as spam
+            if (validationScore != 100) {
                 comment.setSpam(Boolean.TRUE);
                 error = bundle.getString("commentServlet.commentMarkedAsSpam");
                 log.debug("Comment marked as spam");
             }
             
-            // If comment moderation is on, set comment as pending
-            if (weblog.getCommentModerationRequired()) {
+            // If moderation is enabled or comment is spam, put comment into moderation
+            if (weblog.getCommentModerationRequired() || validationScore != 100) {
                 comment.setPending(Boolean.TRUE);
                 comment.setApproved(Boolean.FALSE);
                 message = bundle.getString("commentServlet.submittedToModerator");
@@ -296,11 +302,20 @@
                 comment.setApproved(Boolean.TRUE);
             }
             
-            try {
+            try {               
+                
+                // Send email notifications, but only to subscribers if comment is 100% valid
+                boolean notifySubscribers = (validationScore == 100);
+                String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
+                if (rootURL == null || rootURL.trim().length()==0) {
+                    rootURL = RequestUtils.serverURL(request) + request.getContextPath();
+                }
+                sendEmailNotification(comment, notifySubscribers, messages, rootURL);
+                
                 WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                 mgr.saveComment(comment);
                 RollerFactory.getRoller().flush();
-                
+
                 // only re-index/invalidate the cache if comment isn't moderated
                 if(!weblog.getCommentModerationRequired()) {
                     reindexEntry(entry);
@@ -309,13 +324,6 @@
                     CacheManager.invalidate(comment);
                 }
                 
-                // Send email notifications
-                String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
-                if (rootURL == null || rootURL.trim().length()==0) {
-                    rootURL = RequestUtils.serverURL(request) + request.getContextPath();
-                }
-                sendEmailNotification(comment, rootURL);
-                
                 // comment was successful, clear the comment form
                 cf = new WeblogEntryCommentForm();
                 
@@ -325,12 +333,14 @@
             }
         }
         
-
+        
         // the work has been done, now send the user back to the entry page
-        if (error != null)
+        if (error != null) {
             cf.setError(error);
-        if (message != null)
+        }
+        if (message != null) {
             cf.setMessage(message);
+        }
         request.setAttribute("commentForm", cf);
         
         log.debug("comment processed, forwarding to "+dispatch_url);
@@ -338,13 +348,13 @@
                 request.getRequestDispatcher(dispatch_url);
         dispatcher.forward(request, response);
     }
-
+    
     
     /**
      * Re-index the WeblogEntry so that the new comment gets indexed.
      */
-    private void reindexEntry(WeblogEntryData entry) 
-        throws RollerException {
+    private void reindexEntry(WeblogEntryData entry)
+    throws RollerException {
         
         IndexManager manager = RollerFactory.getRoller().getIndexManager();
         
@@ -356,19 +366,27 @@
             manager.addEntryIndexOperation(entry);
         }
     }
-        
+    
     
     /**
-     * Send email notification of comment.
-     *
+     * Send email notification of new or newly approved comment.
      * TODO: Make the addressing options configurable on a per-website basis.
+     *
+     * @param commentObject      The new comment
+     * @param notifySubscribers  True if subscribers are to be notified
+     * @param messages           Messages to be included in e-mail (or null). 
+     *                           Errors will be assumed to be "validation errors" 
+     *                           and messages will be assumed to be "from the system"
+     * @param rootURL            Root URL of the Roller site
      */
-    public static void sendEmailNotification(CommentData cd, String rootURL) {
+    public static void sendEmailNotification(
+            CommentData commentObject, boolean notifySubscribers,
+            RollerMessages messages, String rootURL) {
         
         // Send commment notifications in locale of server
         ResourceBundle resources = ResourceBundle.getBundle("ApplicationResources");
-
-        WeblogEntryData entry = cd.getWeblogEntry();
+        
+        WeblogEntryData entry = commentObject.getWeblogEntry();
         WebsiteData site = entry.getWebsite();
         UserData user = entry.getCreator();
         
@@ -378,10 +396,8 @@
             log.debug("Comment notification enabled ... preparing email");
             
             // Determine message and addressing options from init parameters
-            boolean separateMessages =
-                    RollerConfig.getBooleanProperty("comment.notification.separateOwnerMessage");
-            boolean hideCommenterAddrs =
-                    RollerConfig.getBooleanProperty("comment.notification.hideCommenterAddresses");
+            boolean hideCommenterAddrs = RollerConfig.getBooleanProperty(
+                    "comment.notification.hideCommenterAddresses");
             
             //------------------------------------------
             // --- Determine the "from" address
@@ -397,23 +413,31 @@
             
             List comments = entry.getComments(true, true);
             
-            // Get all the subscribers to this comment thread
             Set subscribers = new TreeSet();
-            for (Iterator it = comments.iterator(); it.hasNext();) {
-                CommentData comment = (CommentData) it.next();
-                if (!StringUtils.isEmpty(comment.getEmail())) {
-                    // If user has commented twice,
-                    // count the most recent notify setting
-                    if (comment.getNotify().booleanValue()) {
-                        // only add those with valid email
-                        if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
-                            subscribers.add(comment.getEmail());
+            
+            // If we are to notify subscribers, then...
+            if (notifySubscribers) {
+                log.debug("Sending notification email to all subscribers");
+                
+                // Get all the subscribers to this comment thread
+                for (Iterator it = comments.iterator(); it.hasNext();) {
+                    CommentData comment = (CommentData) it.next();
+                    if (!StringUtils.isEmpty(comment.getEmail())) {
+                        // If user has commented twice,
+                        // count the most recent notify setting
+                        if (comment.getNotify().booleanValue()) {
+                            // only add those with valid email
+                            if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
+                                subscribers.add(comment.getEmail());
+                            }
+                        } else {
+                            // remove user who doesn't want to be notified
+                            subscribers.remove(comment.getEmail());
                         }
-                    } else {
-                        // remove user who doesn't want to be notified
-                        subscribers.remove(comment.getEmail());
                     }
                 }
+            } else {
+                log.debug("Sending notification email only to weblog owner");
             }
             
             // Form array of commenter addrs
@@ -421,35 +445,37 @@
             
             //------------------------------------------
             // --- Form the messages to be sent -
-            // For simplicity we always build separate owner and commenter messages even if sending a single one
+            // Build separate owner and commenter (aka subscriber) messages
             
             // Determine with mime type to use for e-mail
             StringBuffer msg = new StringBuffer();
             StringBuffer ownermsg = new StringBuffer();
             boolean escapeHtml = RollerRuntimeConfig.getBooleanProperty("users.comments.escapehtml");
             
+            // first the commenter message
+            
             if (!escapeHtml) {
                 msg.append("<html><body style=\"background: white; ");
                 msg.append(" color: black; font-size: 12px\">");
             }
             
-            if (!StringUtils.isEmpty(cd.getName())) {
-                msg.append(cd.getName() + " "
+            if (!StringUtils.isEmpty(commentObject.getName())) {
+                msg.append(commentObject.getName() + " "
                         + resources.getString("email.comment.wrote")+": ");
             } else {
                 msg.append(resources.getString("email.comment.anonymous")+": ");
             }
             
             msg.append((escapeHtml) ? "\n\n" : "<br /><br />");
-                        
-            msg.append((escapeHtml) ? Utilities.escapeHTML(cd.getContent()) 
-                : UtilitiesModel.transformToHTMLSubset(Utilities.escapeHTML(cd.getContent())));
+            
+            msg.append((escapeHtml) ? Utilities.escapeHTML(commentObject.getContent())
+            : UtilitiesModel.transformToHTMLSubset(Utilities.escapeHTML(commentObject.getContent())));
             
             msg.append((escapeHtml) ? "\n\n----\n"
                     : "<br /><br /><hr /><span style=\"font-size: 11px\">");
             msg.append(resources.getString("email.comment.respond") + ": ");
             msg.append((escapeHtml) ? "\n" : "<br />");
-
+            
             // Build link back to comment
             StringBuffer commentURL = new StringBuffer(rootURL);
             commentURL.append(entry.getPermaLink());
@@ -461,6 +487,42 @@
                 msg.append("<a href=\""+commentURL+"\">"+commentURL+"</a></span>");
             }
             
+            // next the owner message
+            
+            // First, list any messages from the system that were passed in:
+            if (messages.getMessageCount() > 0) {
+                ownermsg.append((escapeHtml) ? "" : "<p>");
+                ownermsg.append(resources.getString("commentServlet.email.thereAreSystemMessages"));
+                ownermsg.append((escapeHtml) ? "\n\n" : "</p>");
+                ownermsg.append((escapeHtml) ? "" : "<ul>");
+            }
+            for (Iterator it = messages.getMessages(); it.hasNext();) {
+                RollerMessage rollerMessage = (RollerMessage)it.next();
+                ownermsg.append((escapeHtml) ? "" : "<li>");
+                ownermsg.append(MessageFormat.format(resources.getString(rollerMessage.getKey()), rollerMessage.getArgs()) );
+                ownermsg.append((escapeHtml) ? "\n\n" : "</li>");
+            }
+            if (messages.getMessageCount() > 0) {
+                ownermsg.append((escapeHtml) ? "\n\n" : "</ul>");
+            }
+            
+            // Next, list any validation error messages that were passed in:
+            if (messages.getErrorCount() > 0) {
+                ownermsg.append((escapeHtml) ? "" : "<p>");
+                ownermsg.append(resources.getString("commentServlet.email.thereAreErrorMessages"));
+                ownermsg.append((escapeHtml) ? "\n\n" : "</p>");
+                ownermsg.append((escapeHtml) ? "" : "<ul>");
+            }
+            for (Iterator it = messages.getErrors(); it.hasNext();) {
+                RollerMessage rollerMessage = (RollerMessage)it.next();
+                ownermsg.append((escapeHtml) ? "" : "<li>");
+                ownermsg.append(MessageFormat.format(resources.getString(rollerMessage.getKey()), rollerMessage.getArgs()) );
+                ownermsg.append((escapeHtml) ? "\n\n" : "</li>");
+            }
+            if (messages.getErrorCount() > 0) {
+                ownermsg.append((escapeHtml) ? "\n\n" : "</ul>");
+            }
+            
             ownermsg.append(msg);
             
             // add link to weblog edit page so user can login to manage comments
@@ -483,7 +545,7 @@
             
             String subject = null;
             if ((subscribers.size() > 1) ||
-                    (StringUtils.equals(cd.getEmail(), user.getEmailAddress()))) {
+                    (StringUtils.equals(commentObject.getEmail(), user.getEmailAddress()))) {
                 subject= "RE: "+resources.getString("email.comment.title")+": ";
             } else {
                 subject = resources.getString("email.comment.title") + ": ";
@@ -497,23 +559,15 @@
                 new InitialContext().lookup("java:comp/env");
                 Session session = (Session)ctx.lookup("mail/Session");
                 boolean isHtml = !escapeHtml;
-                if (separateMessages) {
-                    // Send separate messages to owner and commenters
-                    sendMessage(session, from,
-                            new String[]{user.getEmailAddress()}, null, null, subject, ownermsg.toString(), isHtml);
-                            if (commenterAddrs.length > 0) {
-                                // If hiding commenter addrs, they go in Bcc: otherwise in the To: of the second message
-                                String[] to = hideCommenterAddrs ? null : commenterAddrs;
-                                String[] bcc = hideCommenterAddrs ? commenterAddrs : null;
-                                sendMessage(session, from, to, null, bcc, subject, msg.toString(), isHtml);
-                                
-                            }
-                } else {
-                    // Single message.  User in To: header, commenters in either cc or bcc depending on hiding option
-                    String[] cc = hideCommenterAddrs ? null : commenterAddrs;
+                // Send separate messages to owner and commenters
+                sendMessage(session, from,
+                        new String[]{user.getEmailAddress()}, null, null, subject, ownermsg.toString(), isHtml);
+                if (notifySubscribers && commenterAddrs.length > 0) {
+                    // If hiding commenter addrs, they go in Bcc: otherwise in the To: of the second message
+                    String[] to = hideCommenterAddrs ? null : commenterAddrs;
                     String[] bcc = hideCommenterAddrs ? commenterAddrs : null;
-                    sendMessage(session, from, new String[]{user.getEmailAddress()}, cc, bcc, subject,
-                            ownermsg.toString(), isHtml);
+                    sendMessage(session, from, to, null, bcc, subject, msg.toString(), isHtml);
+
                 }
             } catch (NamingException ne) {
                 log.error("Unable to lookup mail session.  Check configuration.  NamingException: " + ne.getMessage());
@@ -544,14 +598,14 @@
         WeblogEntryData entry = cd.getWeblogEntry();
         WebsiteData site = entry.getWebsite();
         UserData user = entry.getCreator();
-            
+        
         // Only send email if email notificaiton is enabled
         boolean notify = RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
         if (notify && site.getEmailComments().booleanValue()) {
             log.debug("Comment notification enabled ... preparing email");
             
-
-                                
+            
+            
             //------------------------------------------
             // --- Determine the "from" address
             // --- Use either the site configured from address or the user's address
@@ -560,7 +614,7 @@
                     (StringUtils.isEmpty(site.getEmailFromAddress()))
                     ? user.getEmailAddress()
                     : site.getEmailFromAddress();
-                        
+            
             //------------------------------------------
             // --- Form the message to be sent -
             
@@ -568,7 +622,7 @@
             
             StringBuffer msg = new StringBuffer();
             msg.append(resources.getString("email.comment.commentApproved"));
-
+            
             // Build link back to comment
             StringBuffer commentURL = new StringBuffer(rootURL);
             commentURL.append(entry.getPermaLink());
@@ -583,11 +637,11 @@
                 Session session = (Session)ctx.lookup("mail/Session");
                 String[] cc = null;
                 String[] bcc = null;
-                sendMessage(session, from, 
-                    new String[] {cd.getEmail()}, 
-                    null, // cc
-                    null, // bcc
-                    subject, msg.toString(), false);
+                sendMessage(session, from,
+                        new String[] {cd.getEmail()},
+                        null, // cc
+                        null, // bcc
+                        subject, msg.toString(), false);
             } catch (NamingException ne) {
                 log.error("Unable to lookup mail session.  Check configuration.  NamingException: " + ne.getMessage());
             } catch (Exception e) {
@@ -605,7 +659,7 @@
     
     
     /*
-     * This is somewhat ridiculous, but avoids duplicating a bunch of logic 
+     * This is somewhat ridiculous, but avoids duplicating a bunch of logic
      * in the already messy sendEmailNotification.
      */
     static void sendMessage(Session session, String from, String[] to, String[] cc, String[] bcc, String subject,

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java Fri Jan  5 14:03:55 2007
@@ -55,7 +55,7 @@
 import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.ui.rendering.util.cache.WeblogPageCache;
 import org.apache.roller.ui.rendering.util.ModDateHeaderUtil;
-import org.apache.roller.util.SpamChecker;
+import org.apache.roller.util.BlacklistChecker;
 
 
 /**
@@ -551,7 +551,7 @@
                     
                     if (referrerUrl.matches(requestSite + ".*\\.do.*")) {
                         referrerUrl = null;
-                    } else if(SpamChecker.checkReferrer(pageRequest.getWeblog(), referrerUrl)) {
+                    } else if(BlacklistChecker.checkReferrer(pageRequest.getWeblog(), referrerUrl)) {
                         return true;
                     }
                 }

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/TrackbackServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/TrackbackServlet.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/TrackbackServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/TrackbackServlet.java Fri Jan  5 14:03:55 2007
@@ -22,6 +22,7 @@
 import java.io.PrintWriter;
 import java.sql.Timestamp;
 import java.util.Date;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -36,9 +37,11 @@
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.ui.rendering.util.CommentValidationManager;
+import org.apache.roller.ui.rendering.util.TrackbackLinkbackCommentValidator;
 import org.apache.roller.ui.rendering.util.WeblogTrackbackRequest;
 import org.apache.roller.util.LinkbackExtractor;
-import org.apache.roller.util.SpamChecker;
+import org.apache.roller.util.RollerMessages;
 import org.apache.roller.util.URLUtilities;
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.struts.util.RequestUtils;
@@ -56,7 +59,8 @@
     
     private static Log logger = LogFactory.getLog(TrackbackServlet.class);
     
-    
+    private CommentValidationManager commentValidationManager = null;
+        
     /**
      * Handle incoming http GET requests.
      *
@@ -67,7 +71,15 @@
         
         response.sendError(HttpServletResponse.SC_NOT_FOUND);
     }
-    
+
+    public void init(ServletConfig config) throws ServletException {
+        commentValidationManager = new CommentValidationManager();
+        
+        // use configured comment validators, plus linkback validator if enabled
+        if (RollerRuntimeConfig.getBooleanProperty("site.trackbackVerification.enabled")) {
+            commentValidationManager.addCommentValidator(new TrackbackLinkbackCommentValidator());
+        }
+    }
     
     /**
      * Service incoming POST requests.
@@ -83,8 +95,10 @@
         WebsiteData weblog = null;
         WeblogEntryData entry = null;
         
+        RollerMessages messages = new RollerMessages();
+        
         WeblogTrackbackRequest trackbackRequest = null;
-        if(!RollerRuntimeConfig.getBooleanProperty("users.trackbacks.enabled")) {
+        if (!RollerRuntimeConfig.getBooleanProperty("users.trackbacks.enabled")) {
             // TODO: i18n
             error = "Trackbacks are disabled for this site";
         } else {
@@ -92,14 +106,14 @@
             try {
                 trackbackRequest = new WeblogTrackbackRequest(request);
                 
-                if((trackbackRequest.getTitle() == null) ||
+                if ((trackbackRequest.getTitle() == null) ||
                         "".equals(trackbackRequest.getTitle())) {
                     trackbackRequest.setTitle(trackbackRequest.getUrl());
                 }
                 
-                if(trackbackRequest.getExcerpt() == null) {
+                if (trackbackRequest.getExcerpt() == null) {
                     trackbackRequest.setExcerpt("");
-                } else if(trackbackRequest.getExcerpt().length() >= 255) {
+                } else if (trackbackRequest.getExcerpt().length() >= 255) {
                     trackbackRequest.setExcerpt(trackbackRequest.getExcerpt().substring(0, 252)+"...");
                 }
                 
@@ -107,7 +121,7 @@
                 UserManager uMgr = RollerFactory.getRoller().getUserManager();
                 weblog = uMgr.getWebsiteByHandle(trackbackRequest.getWeblogHandle());
                 
-                if(weblog == null) {
+                if (weblog == null) {
                     throw new RollerException("unable to lookup weblog: "+
                             trackbackRequest.getWeblogHandle());
                 }
@@ -116,7 +130,7 @@
                 WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
                 entry = weblogMgr.getWeblogEntryByAnchor(weblog, trackbackRequest.getWeblogAnchor());
                 
-                if(entry == null) {
+                if (entry == null) {
                     throw new RollerException("unable to lookup entry: "+
                             trackbackRequest.getWeblogAnchor());
                 }
@@ -128,14 +142,12 @@
             }
         }
         
-        if(error != null) {
+        if (error != null) {
             pw.println(this.getErrorResponse(error));
             return;
         }
         
-        try {
-            boolean verified = true;
-            
+        try {            
             // check if trackbacks are allowed for this entry
             // this checks site-wide settings, weblog settings, and entry settings
             if (entry != null && entry.getCommentsStillAllowed() && entry.isPublished()) {
@@ -150,37 +162,24 @@
                 comment.setPostTime(new Timestamp(new Date().getTime()));
                 
                 // If comment contains blacklisted text, mark as spam
-                SpamChecker checker = new SpamChecker();
-                if (checker.checkTrackback(comment)) {
-                    comment.setSpam(Boolean.TRUE);
-                    logger.debug("Trackback blacklisted: "+comment.getUrl());
-                    error = "REJECTED: trackback contains spam words";
-                }
-                // Else, if trackback verification is on...
-                else if (RollerRuntimeConfig.getBooleanProperty(
-                        "site.trackbackVerification.enabled")) {
-                    
-                    // ...ensure trackbacker actually links to us
-                    LinkbackExtractor linkback = new LinkbackExtractor(
-                            comment.getUrl(), URLUtilities.getWeblogEntryURL(weblog, null, entry.getAnchor(), true));
-                    if (linkback.getExcerpt() == null) {
-                        comment.setPending(Boolean.TRUE);
-                        comment.setApproved(Boolean.FALSE);
-                        verified = false;
-                        // if we can't verify trackback, then reject it
-                        error = "REJECTED: trackback failed verification";
-                        logger.debug("Trackback failed verification: "+comment.getUrl());
-                    }
-                }
-                
+                int validationScore = commentValidationManager.validateComment(comment, messages);
+                logger.debug("Comment Validation score: " + validationScore);
+                                
                 if (error == null) {
-                    // If comment moderation is on, set comment as pending
-                    if (verified && weblog.getCommentModerationRequired()) {
+                    
+                    if (validationScore == 100 && weblog.getCommentModerationRequired()) {
+                        // Valid comments go into moderation if required
                         comment.setPending(Boolean.TRUE);
                         comment.setApproved(Boolean.FALSE);
-                    } else if (verified) {
+                    } else if (validationScore == 100) {
+                        // else they're approved
                         comment.setPending(Boolean.FALSE);
                         comment.setApproved(Boolean.TRUE);
+                    } else {
+                        // Invalid comments are marked as spam and put into moderation
+                        comment.setSpam(Boolean.TRUE);
+                        comment.setPending(Boolean.TRUE);
+                        comment.setApproved(Boolean.FALSE);
                     }
                     
                     // save, commit, send response
@@ -199,7 +198,7 @@
                     if (rootURL == null || rootURL.trim().length()==0) {
                         rootURL = RequestUtils.serverURL(request) + request.getContextPath();
                     }
-                    CommentServlet.sendEmailNotification(comment, rootURL);
+                    CommentServlet.sendEmailNotification(comment, validationScore == 100, messages, rootURL);
                     
                     if(comment.getPending().booleanValue()) {
                         pw.println(this.getSuccessResponse("Trackback submitted to moderator"));

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.util.ResourceBundle;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.RollerMessages;
+
+/**
+ *
+ * @author David M. Johnson
+ */
+public class AkismetCommentValidator implements CommentValidator { 
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
+    
+    /** Creates a new instance of AkismetCommentValidator */
+    public AkismetCommentValidator() {
+    }
+
+    public String getName() {
+        return bundle.getString("comment.validator.akismetName");
+    }
+
+    public int validate(CommentData comment, RollerMessages messages) {
+        return 100;
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/BlacklistCommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/BlacklistCommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/BlacklistCommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/BlacklistCommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.util.ResourceBundle;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.BlacklistChecker;
+
+/**
+ * Validates comment if comment does not contain blacklisted words.
+ */
+public class BlacklistCommentValidator implements CommentValidator {
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");       
+    private BlacklistChecker checker = new BlacklistChecker();
+
+    public String getName() {
+        return bundle.getString("comment.validator.blacklistName");
+    }
+
+    public int validate(CommentData comment, RollerMessages messages) {
+        if (checker.checkComment(comment)) {
+            messages.addError("comment.validator.blacklistMessage");
+            return 0;
+        }
+        return 100; 
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidationManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidationManager.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidationManager.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidationManager.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.ui.rendering.servlets.CommentServlet;
+import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.Utilities;
+
+/**
+ * Responsible for loading validators and using them to validate comments.
+ */
+public class CommentValidationManager {
+    private static Log     log = LogFactory.getLog(CommentServlet.class);
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
+    private List           validators = new ArrayList();
+    
+    public CommentValidationManager() {
+        
+        // instantiate the validators that are configured
+        try {
+            String vals = RollerConfig.getProperty("comment.validator.classnames");
+            String[] valsarray = Utilities.stringToStringArray(vals, ",");
+            for(int i=0; i < valsarray.length; i++) {
+                try {
+                    Class valClass = Class.forName(valsarray[i]);
+                    CommentValidator val = (CommentValidator)valClass.newInstance();
+                    validators.add(val);
+                    log.info("Configured CommentValidator: " + val.getName() + " / " + valClass.getName());
+                } catch (ClassNotFoundException cnfe) {
+                    log.warn("Error finding comment validator: " + valsarray[i]);
+                } catch (InstantiationException ie) {
+                    log.warn("Error insantiating comment validator: " + valsarray[i]);
+                } catch (IllegalAccessException iae) {
+                    log.warn("Error accessing comment validator: " + valsarray[i]);
+                }
+            }
+                        
+        } catch (Exception e) {
+            log.error("Error instantiating comment validators");
+        }
+        log.info("Configured " + validators.size() + " CommentValidators");
+    }
+    
+    /**
+     * Add validator to those managed by this manager (testing purposes).
+     */
+    public void addCommentValidator(CommentValidator val) {
+        validators.add(val);
+    }
+    
+    /**
+     * Return total number of validators (for teasting purposes).
+     */
+    public int getValidatorCount() {
+        return validators.size();
+    }
+    
+    /**
+     * @param comment Comment to be validated
+     * @param messages Messages object to which errors will be added
+     * @return Number indicating confidence that comment is valid (100 meaning 100%)
+     */
+    public int validateComment(CommentData comment, RollerMessages messages) {
+        int total = 0;
+        if (validators.size() > 0) {
+            for (Iterator it = validators.iterator(); it.hasNext();) {
+                CommentValidator val = (CommentValidator) it.next();
+                total += val.validate(comment, messages);
+            }
+            total = total / validators.size();
+        } else {
+            // When no validators: consider all comments valid
+            total = 100;
+        }
+        return total;
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/CommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import javax.servlet.http.HttpServletRequest;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.RollerMessages;
+
+/** Interface for comment validation plugin */
+public interface CommentValidator {  
+    
+    /**
+     * Plain text name of validator for display purposes.
+     */
+    public String getName();
+
+    /**
+     * @param comment Comment to be validated
+     * @param messages Messages object to which errors will added
+     * @return Number indicating confidence that comment is valid (100 meaning 100%)
+     */
+    public int validate(CommentData comment, RollerMessages messages);   
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessLinksCommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessLinksCommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessLinksCommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessLinksCommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.RollerMessages;
+
+/**
+ * Validates comment only if it has fewer links than comment.validator.excessSize.threshold
+ */
+public class ExcessLinksCommentValidator implements CommentValidator {
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");  
+    private Pattern linkPattern = Pattern.compile("<a\\s*href\\s*=");    
+    private int threshold;
+        
+    public ExcessLinksCommentValidator() {
+        threshold = RollerConfig.getIntProperty("comment.validator.excessLinks.threshold");
+    }
+        
+    public String getName() {
+        return bundle.getString("comment.validator.excessLinksName");
+    }
+
+    public int validate(CommentData comment, RollerMessages messages) {
+        Matcher m = linkPattern.matcher(comment.getContent());
+        int count = 0;
+        while (m.find()) {
+            if (count++ > threshold) {
+                messages.addError("comment.validator.excessLinksMessage", Integer.toString(threshold));
+                return 0;
+            }
+        }
+        return 100;
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessSizeCommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessSizeCommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessSizeCommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/ExcessSizeCommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.util.ResourceBundle;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.RollerMessages;
+
+/**
+ * Validates comment only if it has less than comment.validator.excessSize.threshold characters
+ */
+public class ExcessSizeCommentValidator implements CommentValidator {
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");  
+    private int threshold;
+    
+    public ExcessSizeCommentValidator() {
+        threshold = RollerConfig.getIntProperty("comment.validator.excessSize.threshold");
+    }
+    
+    public String getName() {
+        return bundle.getString("comment.validator.excessSizeName");
+    }
+
+    public int validate(CommentData comment, RollerMessages messages) {
+        if (comment.getContent() != null && comment.getContent().length() > threshold) {
+            messages.addError("comment.validator.excessSizeMessage", Integer.toString(threshold));
+            return 0;
+        }
+        return 100;
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/TrackbackLinkbackCommentValidator.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/TrackbackLinkbackCommentValidator.java?view=auto&rev=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/TrackbackLinkbackCommentValidator.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/TrackbackLinkbackCommentValidator.java Fri Jan  5 14:03:55 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ResourceBundle;
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.util.LinkbackExtractor;
+import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.URLUtilities;
+
+/**
+ * Validates comment if comment's URL links back to the comment's entry, 
+ * intended for use with trackbacks only.
+ */
+public class TrackbackLinkbackCommentValidator implements CommentValidator {
+    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");  
+        
+    public String getName() {
+        return bundle.getString("comment.validator.trackbackLinkbackName");
+    }
+
+    public int validate(CommentData comment, RollerMessages messages) {
+        int ret = 0;
+        LinkbackExtractor linkback = null;
+        try {
+            linkback = new LinkbackExtractor(
+                    comment.getUrl(), 
+                    URLUtilities.getWeblogEntryURL(
+                        comment.getWeblogEntry().getWebsite(), 
+                        null, 
+                        comment.getWeblogEntry().getAnchor(), 
+                        true));
+        } catch (MalformedURLException ignored1) {
+        } catch (IOException ignored2) {}
+        
+        if (linkback == null && linkback.getExcerpt() != null) {
+            ret = 100;
+        } else {
+            messages.addError("comment.validator.trackbackLinkbackMessage");
+        }
+        return ret;
+    }
+    
+}

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogCommentRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogCommentRequest.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogCommentRequest.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogCommentRequest.java Fri Jan  5 14:03:55 2007
@@ -137,7 +137,7 @@
         }
         
         if(request.getParameter("notify") != null) {
-            this.notify = Boolean.valueOf(request.getParameter("notify")).booleanValue();
+            this.notify = true;
         }
         
         if(log.isDebugEnabled()) {

Modified: incubator/roller/trunk/src/org/apache/roller/util/Blacklist.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/util/Blacklist.java?view=diff&rev=493205&r1=493204&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/util/Blacklist.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/util/Blacklist.java Fri Jan  5 14:03:55 2007
@@ -211,9 +211,9 @@
             
         } catch (Exception e) {
             // Roller keeps a copy in the webapp just in case
-            txtStream = getClass().getResourceAsStream("/"+blacklistFile);           
-            mLogger.warn("Couldn't find downloaded blacklist, " 
-                        + "loading from classpath instead");
+            txtStream = getClass().getResourceAsStream("/blacklist.txt");           
+            mLogger.warn(
+                "Couldn't find downloaded blacklist, loaded blacklist.txt from classpath instead");
         }
         
         if (txtStream != null) {

Copied: incubator/roller/trunk/src/org/apache/roller/util/BlacklistChecker.java (from r492021, incubator/roller/trunk/src/org/apache/roller/util/SpamChecker.java)
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/util/BlacklistChecker.java?view=diff&rev=493205&p1=incubator/roller/trunk/src/org/apache/roller/util/SpamChecker.java&r1=492021&p2=incubator/roller/trunk/src/org/apache/roller/util/BlacklistChecker.java&r2=493205
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/util/SpamChecker.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/util/BlacklistChecker.java Fri Jan  5 14:03:55 2007
@@ -34,10 +34,13 @@
  * @author Lance Lavandowska
  * @author Dave Johnson
  */
-public class SpamChecker { 
-    private static Log mLogger = LogFactory.getLog(SpamChecker.class);
+public class BlacklistChecker { 
+    private static Log mLogger = LogFactory.getLog(BlacklistChecker.class);
     
-    /** Test comment, applying all blacklists, if configured */
+    /** 
+     * Test comment, applying all blacklists, if configured 
+     * @return True if comment matches blacklist term
+     */
     public static boolean checkComment(CommentData comment) {
         if (RollerConfig.getBooleanProperty("site.blacklist.enable.comments")) {
             return testComment(comment);
@@ -45,7 +48,10 @@
         return false;
     }
     
-    /** Test trackback comment, applying all blacklists, if configured */
+    /** 
+     * Test trackback comment, applying all blacklists, if configured 
+     * @return True if comment matches blacklist term
+     */
     public static boolean checkTrackback(CommentData comment) {
         if (RollerConfig.getBooleanProperty("site.blacklist.enable.trackbacks")) {
             return testComment(comment);
@@ -53,7 +59,10 @@
         return false;
     }
 
-    /** Test referrer URL, applying blacklist and website blacklist only if configured */
+    /** 
+     * Test referrer URL, applying blacklist and website blacklist only if configured 
+     * @return True if comment matches blacklist term
+     */
     public static boolean checkReferrer(WebsiteData website, String referrerURL) {
         if (RollerConfig.getBooleanProperty("site.blacklist.enable.referrers")) {
             List stringRules = new ArrayList();
@@ -69,7 +78,10 @@
         return false;
     }
 
-    /** Test comment against built in blacklist, site blacklist and website blacklist */
+    /** 
+     * Test comment against built in blacklist, site blacklist and website blacklist 
+     * @return True if comment matches blacklist term
+     */
     private static boolean testComment(CommentData c) {
         boolean ret = false;
         List stringRules = new ArrayList();



Mime
View raw message