roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r493593 - in /incubator/roller/trunk: nbproject/ src/org/apache/roller/business/ src/org/apache/roller/ui/core/ src/org/apache/roller/ui/rendering/model/ src/org/apache/roller/ui/rendering/util/ src/org/apache/roller/ui/rendering/velocity/d...
Date Sat, 06 Jan 2007 23:09:19 GMT
Author: snoopdave
Date: Sat Jan  6 15:09:18 2007
New Revision: 493593

URL: http://svn.apache.org/viewvc?view=rev&rev=493593
Log:
First cut of Akismet validator

Modified:
    incubator/roller/trunk/nbproject/project.xml
    incubator/roller/trunk/src/org/apache/roller/business/Roller.java
    incubator/roller/trunk/src/org/apache/roller/business/RollerImpl.java
    incubator/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/ConfigModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
    incubator/roller/trunk/tests/org/apache/roller/ui/MockRollerContext.java
    incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties

Modified: incubator/roller/trunk/nbproject/project.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/nbproject/project.xml?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/nbproject/project.xml (original)
+++ incubator/roller/trunk/nbproject/project.xml Sat Jan  6 15:09:18 2007
@@ -190,7 +190,7 @@
                 <package-root>apps/planet/src/java</package-root>
                 <package-root>apps/planet/test/java</package-root>
                 <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>
+                <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:tools/spring-1.2/acegi-security-1.0.1.jar:tools/spring-1.2/spring.jar</classpath>
                 <source-level>1.4</source-level>
             </compilation-unit>
         </java-data>

Modified: incubator/roller/trunk/src/org/apache/roller/business/Roller.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/Roller.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/Roller.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/Roller.java Sat Jan  6 15:09:18
2007
@@ -143,5 +143,13 @@
      */
     public void shutdown();
     
+    /** Roller version */
+    public String getVersion();    
+    
+    /** Roller build time */
+    public String getBuildTime();
+        
+    /** Get username that built Roller */
+    public String getBuildUser();
 }
 

Modified: incubator/roller/trunk/src/org/apache/roller/business/RollerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/RollerImpl.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/RollerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/RollerImpl.java Sat Jan  6 15:09:18
2007
@@ -18,20 +18,15 @@
 
 package org.apache.roller.business;
 
-import java.sql.Connection;
+import java.io.IOException;
+import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.RollerException;
 import org.apache.roller.business.referrers.ReferrerQueueManager;
 import org.apache.roller.business.referrers.ReferrerQueueManagerImpl;
 import org.apache.roller.business.runnable.ThreadManagerImpl;
 import org.apache.roller.business.search.IndexManagerImpl;
-import org.apache.roller.business.utils.UpgradeDatabase;
-import org.apache.roller.business.FileManager;
 import org.apache.roller.business.search.IndexManager;
-import org.apache.roller.business.PluginManager;
-import org.apache.roller.business.Roller;
-import org.apache.roller.business.ThemeManager;
 import org.apache.roller.business.runnable.ThreadManager;
 
 
@@ -45,15 +40,28 @@
     
     private static Log mLogger = LogFactory.getLog(RollerImpl.class);
     
-    private FileManager fileManager = null;
-    private IndexManager indexManager = null;
+    private FileManager   fileManager = null;
+    private IndexManager  indexManager = null;
     private ThreadManager threadManager = null;
-    private ThemeManager themeManager = null;
+    private ThemeManager  themeManager = null;
     private PluginManager pluginManager = null;
-    
+            
+    private String version = null;
+    private String buildTime = null;
+    private String buildUser = null;
     
     public RollerImpl() {
-        // nothing to do here yet
+                
+        Properties props = new Properties();
+        try {
+            props.load(getClass().getResourceAsStream("/version.properties"));
+        } catch (IOException e) {
+            mLogger.error("version.properties not found", e);
+        }
+        
+        version = props.getProperty("ro.version", "UNKNOWN");
+        buildTime = props.getProperty("ro.buildTime", "UNKNOWN");
+        buildUser = props.getProperty("ro.buildUser", "UNKNOWN");
     }
     
     
@@ -140,6 +148,23 @@
         } catch(Throwable e) {
             mLogger.error("Error calling Roller.shutdown()", e);
         }
+    }
+    
+    /** Roller version */
+    public String getVersion() {
+        return version;
+    }
+    
+    
+    /** Roller build time */
+    public String getBuildTime() {
+        return buildTime;
+    }
+    
+    
+    /** Get username that built Roller */
+    public String getBuildUser() {
+        return buildUser;
     }
     
 }

Modified: incubator/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java Sat Jan  6 15:09:18
2007
@@ -69,10 +69,6 @@
     
     private static Log mLogger = LogFactory.getLog(RollerContext.class);
     
-    private String mVersion = null;
-    private String mBuildTime = null;
-    private String mBuildUser = null;
-    
     public static final String ROLLER_CONTEXT = "roller.context";
     
     private static ServletContext mContext = null;
@@ -84,17 +80,6 @@
      */
     public RollerContext() {
         super();
-        
-        Properties props = new Properties();
-        try {
-            props.load(getClass().getResourceAsStream("/version.properties"));
-        } catch (IOException e) {
-            mLogger.error("version.properties not found", e);
-        }
-        
-        mVersion = props.getProperty("ro.version", "UNKNOWN");
-        mBuildTime = props.getProperty("ro.buildTime", "UNKNOWN");
-        mBuildUser = props.getProperty("ro.buildUser", "UNKNOWN");
     }
     
     
@@ -295,7 +280,7 @@
     }
     
     
-    protected void initializeSecurityFeatures(ServletContext context) {
+    protected void initializeSecurityFeatures(ServletContext context) { 
         
         ApplicationContext ctx =
                 WebApplicationContextUtils.getRequiredWebApplicationContext(context);
@@ -372,7 +357,7 @@
             InitialContext ic = new InitialContext();
             DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/rollerdb");
             Connection con = ds.getConnection();
-            UpgradeDatabase.upgradeDatabase(con, mVersion);
+            UpgradeDatabase.upgradeDatabase(con, RollerFactory.getRoller().getVersion());
             con.close();
         } catch (NamingException e) {
             mLogger.warn("Unable to access DataSource", e);
@@ -413,25 +398,7 @@
     public static ServletContext getServletContext() {
         return mContext;
     }
-    
-    
-    /** Roller version */
-    public String getRollerVersion() {
-        return mVersion;
-    }
-    
-    
-    /** Roller build time */
-    public String getRollerBuildTime() {
-        return mBuildTime;
-    }
-    
-    
-    /** Get username that built Roller */
-    public String getRollerBuildUser() {
-        return mBuildUser;
-    }
-    
+        
     /**
      * Get an instance of AutoProvision, if available in roller.properties
      * 

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/ConfigModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/ConfigModel.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/ConfigModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/ConfigModel.java Sat Jan
 6 15:09:18 2007
@@ -18,21 +18,12 @@
 
 package org.apache.roller.ui.rendering.model;
 
-import java.net.MalformedURLException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
+import org.apache.roller.business.RollerFactory;
 import org.apache.roller.config.RollerRuntimeConfig;
-import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
-import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
-import org.apache.roller.ui.core.RequestConstants;
-import org.apache.roller.ui.core.RollerContext;
-import org.apache.struts.util.RequestUtils;
-
 
 /**
  * Model which provides access to application config data like site
@@ -110,19 +101,19 @@
     
     /** Get Roller version string */
     public String getRollerVersion() {
-        return RollerContext.getRollerContext().getRollerVersion();
+        return RollerFactory.getRoller().getVersion();
     }
     
     
     /** Get timestamp of Roller build */
     public String getRollerBuildTimestamp() {
-        return RollerContext.getRollerContext().getRollerBuildTime();
+        return RollerFactory.getRoller().getBuildTime();
     }
     
     
     /** Get username who created Roller build */
     public String getRollerBuildUser() {
-        return RollerContext.getRollerContext().getRollerBuildUser();
+        return RollerFactory.getRoller().getBuildUser();
     }
     
     

Modified: 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=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/AkismetCommentValidator.java
Sat Jan  6 15:09:18 2007
@@ -18,19 +18,33 @@
 
 package org.apache.roller.ui.rendering.util;
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+import java.net.URLConnection;
 import java.util.ResourceBundle;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.business.RollerFactory;
+import org.apache.roller.config.RollerConfig;
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.util.RollerMessages;
+import org.apache.roller.util.URLUtilities;
 
 /**
- *
- * @author David M. Johnson
+ * Check against Akismet service.
+ * You can get a personal use key by signing up at wordpress.com.
+ * See Akismet site for API details (http://akismet.com/development/api/)
  */
 public class AkismetCommentValidator implements CommentValidator { 
+    private static Log log = LogFactory.getLog(AkismetCommentValidator.class);    
     private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
+    private String apikey;
     
     /** Creates a new instance of AkismetCommentValidator */
     public AkismetCommentValidator() {
+        apikey = RollerConfig.getProperty("comment.validator.akismet.apikey");
     }
 
     public String getName() {
@@ -38,7 +52,46 @@
     }
 
     public int validate(CommentData comment, RollerMessages messages) {
-        return 100;
+        StringBuffer sb = new StringBuffer();
+        sb.append("blog=").append(
+            URLUtilities.getWeblogURL(comment.getWeblogEntry().getWebsite(), null, true)).append("&");
+        sb.append("user_ip="        ).append(comment.getRemoteHost()).append("&");
+        sb.append("user_agent="     ).append(comment.getUserAgent()).append("&");
+        sb.append("referrer="       ).append(comment.getReferrer()).append("&");
+        sb.append("permalink="      ).append(comment.getWeblogEntry().getPermalink()).append("&");
+        sb.append("comment_type="   ).append("comment").append("&");
+        sb.append("comment_author=" ).append(comment.getName()).append("&");
+        sb.append("comment_author_email=").append(comment.getEmail()).append("&");
+        sb.append("comment_author_url="  ).append(comment.getUrl()).append("&");
+        sb.append("comment_content="     ).append(comment.getContent());
+
+        try {
+            URL url = new URL("http://" + apikey + ".rest.akismet.com/1.1/comment-check");
+            URLConnection conn = url.openConnection();
+            conn.setDoOutput(true);
+
+            conn.setRequestProperty("User_Agent", "Roller " + RollerFactory.getRoller().getVersion());

+            conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded;charset=utf8");

+            conn.setRequestProperty("Content-length", Integer.toString(sb.length()));
+
+            OutputStreamWriter osr = new OutputStreamWriter(conn.getOutputStream());
+            osr.write(sb.toString(), 0, sb.length());
+            osr.flush();
+            osr.close();
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));

+            String response = br.readLine();
+            if ("true".equals(response)) {
+                messages.addError("comment.validator.akismetMessage");
+                return 0;
+            }
+            else return 100;
+        } catch (Exception e) {
+            log.error("ERROR checking comment against Akismet", e);
+        }
+        return 0; // interpret error as spam: better safe than sorry? 
     }
-    
 }
+
+
+

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
Sat Jan  6 15:09:18 2007
@@ -392,9 +392,9 @@
         ctx.put("page",            TemplateWrapper.wrap(page));
         ctx.put("utilities",       new OldUtilities() );
         ctx.put("stringUtils",     new OldStringUtils() );
-        ctx.put("rollerVersion",   rollerCtx.getRollerVersion() );
-        ctx.put("rollerBuildTime", rollerCtx.getRollerBuildTime() );
-        ctx.put("rollerBuildUser", rollerCtx.getRollerBuildUser() );
+        ctx.put("rollerVersion",   RollerFactory.getRoller().getVersion() );
+        ctx.put("rollerBuildTime", RollerFactory.getRoller().getBuildTime() );
+        ctx.put("rollerBuildUser", RollerFactory.getRoller().getBuildUser() );
         ctx.put("newsfeedCache",   NewsfeedCache.getInstance() );
         
         ctx.put("requestParameters", request.getParameterMap());

Modified: incubator/roller/trunk/tests/org/apache/roller/ui/MockRollerContext.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/ui/MockRollerContext.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/ui/MockRollerContext.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/ui/MockRollerContext.java Sat Jan  6 15:09:18
2007
@@ -1 +1 @@
-/*
 * 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.
*/
/*
 * Created on Mar 4, 2004
 */
package org.apache.roller.ui;
import java.io.File;

import
javax.servlet.ServletContext;
import javax.servlet.ServletC
 ontextEvent;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory;
import org.apache.roller.RollerException;
import org.apache.roller.ui.core.*;

/**
* @author lance.lavandowska
 */
public class MockRollerContext extends RollerContext {
  
 private static Log mLogger =
            LogFactory.getFactory().getInstance(MockRollerContext.class);
   
    private static ServletContext mContext = null;
    
    public void init(ServletContext
sc) {
        mLogger.debug("MockRollerContext initializing");
        
        // initialize
super
        super.contextInitialized(new ServletContextEvent(sc));
        
        // Save
context in self and self in context
        mContext = sc;
        mContext.setAttribute(ROLLER_CONTEXT,
this);
        mContext.setAttribute("org.apache.roller.absoluteContextURL", "/");
    }
   //-----------------------------------------------------------------------
    /** B
 ecause I cannot set the super's values, I have to
     * overide the methods as well */
   public static RollerContext getRollerContext() {
        // get roller from servlet context
       return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT);
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public static ServletContext getServletContext() {
        return mContext;
    }
   
    //-----------------------------------------------------------------------
    /**
Because I cannot set the super's values, I have to
     * overide the methods as well */
   public String getRollerVersion() {
        return super.getRollerVersion();
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getRoller
 BuildTime() {
        return super.getRollerBuildTime();
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getRollerBuildUser() {
        return super.getRollerBuildUser();
  
 }
    
    //-----------------------------------------------------------------------
   
/** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getAbsoluteContextUrl() {
        return "";
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getAbsoluteContextUrl(HttpServletRequest request) {
        return "http://localhost:8080/roller";
   }
    //-----------------------------------------------------------------------
    /**
Because I cannot set the sup
 er's values, I have to
     * overide the methods as well */
    /* not available anymore
... use the new config classes instead -- Allen G
    public RollerConfigData getRollerConfig()
   {
        return super.getRollerConfig();
    }
     */
    //------------------------------------------------------------------------
   public String getConfigPath() {
        String root = System.getProperty("ro.build");
       String configPath =
                root
                + File.separator
        
       + "roller"
                + File.separator
                + "WEB-INF"
          
     + File.separator
                + "roller-config.xml";
        return configPath;
 
  }
    protected void upgradeDatabaseIfNeeded() throws RollerException {
        // for now,
this is a no-op
    }
    
}
\ No newline at end of file
+/*
 * 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.
*/
/*
 * Created on Mar 4, 2004
 */
package org.apache.roller.ui;
import java.io.File;

import
javax.servlet.ServletContext;
import javax.servlet.ServletC
 ontextEvent;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory;
import org.apache.roller.RollerException;
import org.apache.roller.ui.core.*;

/**
* @author lance.lavandowska
 */
public class MockRollerContext extends RollerContext {
  
 private static Log mLogger =
            LogFactory.getFactory().getInstance(MockRollerContext.class);
   
    private static ServletContext mContext = null;
    
    public void init(ServletContext
sc) {
        mLogger.debug("MockRollerContext initializing");
        
        // initialize
super
        super.contextInitialized(new ServletContextEvent(sc));
        
        // Save
context in self and self in context
        mContext = sc;
        mContext.setAttribute(ROLLER_CONTEXT,
this);
        mContext.setAttribute("org.apache.roller.absoluteContextURL", "/");
    }
   //-----------------------------------------------------------------------
    /** B
 ecause I cannot set the super's values, I have to
     * overide the methods as well */
   public static RollerContext getRollerContext() {
        // get roller from servlet context
       return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT);
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public static ServletContext getServletContext() {
        return mContext;
    }
       
    //-----------------------------------------------------------------------
   
/** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getAbsoluteContextUrl() {
        return "";
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    public String getAbsoluteContextUrl(
 HttpServletRequest request) {
        return "http://localhost:8080/roller";
    }
    //-----------------------------------------------------------------------
   /** Because I cannot set the super's values, I have to
     * overide the methods as well
*/
    /* not available anymore ... use the new config classes instead -- Allen G
    public
RollerConfigData getRollerConfig()
    {
        return super.getRollerConfig();
    }
  
  */
    //------------------------------------------------------------------------
    public
String getConfigPath() {
        String root = System.getProperty("ro.build");
        String
configPath =
                root
                + File.separator
                + "roller"
               + File.separator
                + "WEB-INF"
                + File.separator
               + "roller-config.xml";
        return configPath;
    }
    protected void
upgradeDatabaseIfNeeded() throws RollerException {
        // for now, this is a no
 -op
    }
    
}
\ No newline at end of file

Modified: incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java?view=diff&rev=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java
(original)
+++ incubator/roller/trunk/tests/org/apache/roller/ui/rendering/util/CommentValidatorTest.java
Sat Jan  6 15:09:18 2007
@@ -59,11 +59,6 @@
         TestUtils.teardownUser(user.getId());
     }
     
-    public void testInitialization() {
-        // by default, we provide 3 comment validators
-        assertEquals(3, mgr.getValidatorCount());
-    }
-    
     public void testExcessSizeCommentValidator() {
         RollerMessages msgs = new RollerMessages();
         CommentData comment = createEmptyComment();
@@ -109,6 +104,20 @@
         comment.setContent("blah blah 01-suonerie.com blah"); 
         assertTrue(mgr.validateComment(comment, msgs) != 100);
     }  
+    
+// To run this test add the Akismet validator to comment.validator.classnames
+// and put your Akismet key in comment.validator.akismet.apikey
+//
+//     public void testAkismetCommentValidator() {
+//        RollerMessages msgs = new RollerMessages();
+//        CommentData comment = createEmptyComment();       
+//        comment.setContent("nice friendly stuff"); 
+//        
+//        assertEquals(100, mgr.validateComment(comment, msgs));
+//
+//        comment.setName("viagra-test-123");
+//        assertTrue(mgr.validateComment(comment, msgs) != 100);
+//    }
     
     private CommentData createEmptyComment() {
         CommentData comment = new CommentData();

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=493593&r1=493592&r2=493593
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Sat Jan  6
15:09:18 2007
@@ -209,7 +209,10 @@
 comment.validator.blacklistMessage=Comment contains blackisted/ignored words
 
 comment.validator.trackbackLinkbackName=Trackback Linkback Comment Validator
-comment.validator.trackbackLinkbackMessage=Trackback from site that does not link to your
weblog entry
+comment.validator.trackbackLinkbackMessage=Trackback from site/page that does not link to
your weblog entry
+
+comment.validator.akismetName=Akismet Comment Validator
+comment.validator.akismetMessage=Akismet service (akismet.com) says comment is spam
 
 # -------------------------------------------------------- comments-preview.jsp
 



Mime
View raw message