* anti-abuse upgrade: filters now stored in the database (experimental)
authorzapata <zapata>
Sun, 9 Jan 2005 20:37:06 +0000 (20:37 +0000)
committerzapata <zapata>
Sun, 9 Jan 2005 20:37:06 +0000 (20:37 +0000)
* count(*) queries used less often

132 files changed:
bundles/admin_en.properties
dbscripts/create_pg.sql
dbscripts/updates/update20050109.sql [new file with mode: 0755]
etc/objectstore.properties [deleted file]
source/Mir.java
source/default.properties
source/mir/entity/AbstractEntity.java
source/mir/entity/Entity.java
source/mir/entity/adapter/EntityAdapterEngine.java
source/mir/entity/adapter/EntityAdapterFailure.java
source/mir/entity/adapter/EntityAdapterModel.java
source/mir/entity/adapter/EntityIteratorAdapter.java
source/mir/entity/adapter/ToManyRelationField.java [new file with mode: 0755]
source/mir/entity/adapter/ToOneRelationField.java [new file with mode: 0755]
source/mir/generator/FreemarkerGenerator.java
source/mir/generator/VelocityGenerator.java
source/mir/log/Logger.java
source/mir/log/LoggerEngine.java
source/mir/log/LoggerWrapper.java
source/mir/log/log4j/LoggerImpl.java
source/mir/media/MediaHandler.java
source/mir/module/AbstractModule.java
source/mir/producer/reader/ScriptedProducerFactory.java
source/mir/rss/RSS091Reader.java
source/mir/rss/RSSReader.java
source/mir/servlet/ServletModule.java
source/mir/storage/Database.java
source/mir/storage/StorageObject.java
source/mir/storage/store/StoreIdentifier.java
source/mir/util/CachingRewindableIterator.java
source/mir/util/ExceptionFunctions.java
source/mir/util/HTTPClientHelper.java
source/mir/util/HTTPRequestParser.java
source/mir/util/ParameterExpander.java
source/mir/util/PropertiesManipulator.java
source/mir/util/StructuredContentParser.java
source/mir/util/generator/ReflectionGeneratorFunctionAdapter.java
source/mircoders/abuse/AbstractFilterType.java [new file with mode: 0755]
source/mircoders/abuse/AbuseExc.java [new file with mode: 0755]
source/mircoders/abuse/AbuseFailure.java [new file with mode: 0755]
source/mircoders/abuse/FilterEngine.java [new file with mode: 0755]
source/mircoders/abuse/FilterInstance.java [new file with mode: 0755]
source/mircoders/abuse/FilterParseExc.java [new file with mode: 0755]
source/mircoders/abuse/FilterType.java [new file with mode: 0755]
source/mircoders/abuse/IPFilterType.java [new file with mode: 0755]
source/mircoders/abuse/RegularExpressionFilterType.java [new file with mode: 0755]
source/mircoders/abuse/ThrottleFilter.java [new file with mode: 0755]
source/mircoders/entity/EntityAudio.java
source/mircoders/entity/EntityComment.java
source/mircoders/entity/EntityContent.java
source/mircoders/entity/EntityImages.java
source/mircoders/entity/EntityOther.java
source/mircoders/entity/EntityTopics.java
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/entity/EntityUsers.java
source/mircoders/entity/EntityVideo.java
source/mircoders/global/Abuse.java
source/mircoders/global/MRUCache.java
source/mircoders/global/MirGlobal.java
source/mircoders/global/ProducerEngine.java
source/mircoders/localizer/MirAntiAbuseFilterType.java [deleted file]
source/mircoders/localizer/basic/MirBasicAdminInterfaceLocalizer.java
source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java [deleted file]
source/mircoders/localizer/basic/MirBasicArticlePostingHandler.java
source/mircoders/localizer/basic/MirBasicCommentPostingHandler.java
source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java
source/mircoders/localizer/basic/MirBasicEmailArticleHandler.java
source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
source/mircoders/localizer/basic/MirBasicProducerLocalizer.java
source/mircoders/localizer/basic/MirBasicTranslationPostingHandler.java
source/mircoders/localizer/basic/MirBasicUtilityFunctions.java
source/mircoders/localizer/basic/filters/ThrottleFilter.java [deleted file]
source/mircoders/media/MediaHandlerImages.java
source/mircoders/media/MediaHandlerOgg.java
source/mircoders/media/MediaHandlerRealAudio.java
source/mircoders/media/MediaUploadProcessor.java
source/mircoders/module/ModuleBreaking.java
source/mircoders/module/ModuleLanguage.java
source/mircoders/module/ModuleMediafolder.java
source/mircoders/pdf/PDFGenerator.java
source/mircoders/producer/PDFPreFormattingProducerNode.java
source/mircoders/producer/RadicalendarProducerNode.java
source/mircoders/search/AudioSearchTerm.java
source/mircoders/search/ImagesSearchTerm.java
source/mircoders/search/VideoSearchTerm.java
source/mircoders/servlet/ServletModuleAbuse.java
source/mircoders/servlet/ServletModuleAudio.java
source/mircoders/servlet/ServletModuleBreaking.java
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/servlet/ServletModuleFileEdit.java
source/mircoders/servlet/ServletModuleLocalizer.java
source/mircoders/servlet/ServletModuleMediafolder.java
source/mircoders/servlet/ServletModuleMessage.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleProducer.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
source/mircoders/servlet/ServletModuleUsers.java
source/mircoders/storage/DatabaseArticleType.java
source/mircoders/storage/DatabaseAudio.java
source/mircoders/storage/DatabaseBreaking.java
source/mircoders/storage/DatabaseComment.java
source/mircoders/storage/DatabaseCommentStatus.java
source/mircoders/storage/DatabaseCommentToMedia.java
source/mircoders/storage/DatabaseContent.java
source/mircoders/storage/DatabaseContentToMedia.java
source/mircoders/storage/DatabaseContentToTopics.java
source/mircoders/storage/DatabaseFilter.java [new file with mode: 0755]
source/mircoders/storage/DatabaseFilterGroup.java [new file with mode: 0755]
source/mircoders/storage/DatabaseImageColor.java
source/mircoders/storage/DatabaseImageFormat.java
source/mircoders/storage/DatabaseImageLayout.java
source/mircoders/storage/DatabaseImageType.java
source/mircoders/storage/DatabaseImages.java
source/mircoders/storage/DatabaseLanguage.java
source/mircoders/storage/DatabaseMediaType.java
source/mircoders/storage/DatabaseMediafolder.java
source/mircoders/storage/DatabaseOther.java
source/mircoders/storage/DatabaseRights.java
source/mircoders/storage/DatabaseTopics.java
source/mircoders/storage/DatabaseUploadedMedia.java
source/mircoders/storage/DatabaseUsers.java
source/mircoders/storage/DatabaseVideo.java
templates/admin/abuse.filter.template [deleted file]
templates/admin/abuse.filters.template [deleted file]
templates/admin/abuse.template
templates/admin/contentlist.template
templates/admin/error.template
templates/admin/filter.template [new file with mode: 0755]
templates/admin/filtergroup.template [new file with mode: 0755]
templates/admin/filtergrouplist.template [new file with mode: 0755]
templates/admin/filterlist.template [new file with mode: 0755]

index 6e7f4fa..162e853 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: english
-# $Id: admin_en.properties,v 1.48.2.23 2004/11/21 22:07:12 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.24 2005/01/09 20:37:06 zapata Exp $
 
 languagename=English
 
@@ -480,7 +480,7 @@ abuse.articleaction=Action for blocked article
 abuse.commentaction=Action for blocked comment
 
 abuse.showlog=Show the IP log
-abuse.showfilters=Manage filters
+abuse.showfiltergroups=Manage filters
 
 abuse.log.time=Time
 abuse.log.address=IP number
@@ -490,30 +490,41 @@ abuse.log.filtertype=Filter type
 abuse.log.filterexpression=Expression
 
 abuse.filters = Filters
-abuse.filters.movedown = down
-abuse.filters.moveup = up
-abuse.filters.movebottom = bottom
-abuse.filters.movetop = top
-
-abuse.filter.type = Type
-abuse.filter.expression = Expression
-abuse.filter.articleaction = Article 
-abuse.filter.commentaction = Comment 
-abuse.filter.comments = Comments (internal usage)
-abuse.filter.lasthit = Last hit
-abuse.filter.htmltitle = Edit filter
-
-abuse.filtertype.ip = IP Number
-abuse.filtertype.regexp = Regular expression
-abuse.filtertype.useragent= User Agent
-abuse.filtertype.throttle = Throttle
-abuse.filtertype.hostname = Host name
-
-abuse.filtererror.title = Error:
-abuse.filtererror.invalidtype = Invalid filter type
-abuse.filtererror.invalidexpression = Invalid expression for this type
-
-abuse.filters.htmltitle = Anti-abuse filter rules
+filters.movedown = down
+filters.moveup = up
+filters.movebottom = bottom
+filters.movetop = top
+
+filter.type = Type
+filter.expression = Expression
+filter.articleaction = Article 
+filter.commentaction = Comment 
+filter.comment = Comments (internal usage)
+filter.last_hit = Last hit
+filter.htmltitle = Edit filter
+filter.tag = tag
+
+filtertype.ip = IP Number
+filtertype.regexp = Regular expression
+filtertype.useragent= User Agent
+filtertype.throttle = Throttle
+filtertype.hostname = Host name
+
+filtererror.title = Error:
+filtererror.invalidtype = Invalid filter type
+filtererror.invalidexpression = Invalid expression for this type
+
+filterlist.htmltitle = Filter rules
+
+filtergroup.name = Name
+filtergroup.moveup = up
+filtergroup.movedown = down
+filtergroup.listfilters = filters
+filtergroup.delete = delete
+filtergrouplist.htmltitle = Filter groups
+
+
+
 abuse.log.htmltitle = Anti-abuse open posting log
 
 # head
index 31fba74..2726939 100755 (executable)
@@ -393,3 +393,36 @@ CREATE TABLE "messages" (
   "webdb_create" timestamp with time zone NOT NULL
 );
 
+
+--
+-- filter
+--
+
+CREATE SEQUENCE "filter_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+
+CREATE TABLE "filter" (
+  "id" integer DEFAULT nextval('filter_id_seq'::text) NOT NULL,
+  "priority" integer,
+  "filter_group_id" integer,
+  "type" character varying(255) NOT NULL,
+  "expression" character varying(255) NOT NULL,
+  "tag" character varying(255) NOT NULL,
+       "comment" text,
+  "articleaction" character varying(255) NOT NULL,
+  "commentaction" character varying(255) NOT NULL,
+       "last_hit" timestamp with time zone
+);
+
+--
+-- filter_group
+--
+
+CREATE SEQUENCE "filter_group_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+
+CREATE TABLE "filter_group" (
+  "id" integer DEFAULT nextval('filter_group_id_seq'::text) NOT NULL,
+  "name" character varying(255),
+  "priority" integer
+);
+
+
diff --git a/dbscripts/updates/update20050109.sql b/dbscripts/updates/update20050109.sql
new file mode 100755 (executable)
index 0000000..ce20f61
--- /dev/null
@@ -0,0 +1,39 @@
+-- update script 2003-12-12 by rk
+--
+-- * adds filter and filtergroups to the database
+--
+-- This script will terminate with an error the second time it's run,
+--   so running this script when it isn't needed can't do any harm.
+--
+
+BEGIN TRANSACTION;
+
+CREATE SEQUENCE "filter_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+
+CREATE TABLE "filter" (
+  "id" integer DEFAULT nextval('filter_id_seq'::text) NOT NULL,
+  "priority" integer,
+  "filter_group_id" integer,
+  "type" character varying(255) NOT NULL,
+  "expression" character varying(255) NOT NULL,
+  "tag" character varying(255) NOT NULL,
+       "comment" text,
+  "articleaction" character varying(255) NOT NULL,
+  "commentaction" character varying(255) NOT NULL,
+       "last_hit" timestamp with time zone
+);
+
+--
+-- filter_group
+--
+
+CREATE SEQUENCE "filter_group_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+
+CREATE TABLE "filter_group" (
+  "id" integer DEFAULT nextval('filter_group_id_seq'::text) NOT NULL,
+  "name" character varying(255),
+  "priority" integer
+);
+  
+COMMIT TRANSACTION;
+
diff --git a/etc/objectstore.properties b/etc/objectstore.properties
deleted file mode 100755 (executable)
index 2bded21..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-StoreContainer.EntityDefaultSize 45
-StoreContainer.EntityListDefaultSize 15
-StorableObjectEntity.Entity.DefaultSize 300
-StorableObjectEntity.EntityList.DefaultSize 100
-EntityTopics.Entity.DefaultSize              200
-EntityTopics.EntityList.DefaultSize          20
index 91be32d..515d1ee 100755 (executable)
@@ -45,6 +45,8 @@ import javax.servlet.UnavailableException;
 import javax.servlet.http.*;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.util.*;
 
@@ -319,6 +321,9 @@ public class Mir extends AbstractServlet {
       Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()});
 
       responseData.put("errorstring", anException.toString());
+      StringWriter writer = new StringWriter();
+      anException.printStackTrace(new PrintWriter(writer));
+      responseData.put("stacktrace", writer.toString());
       responseData.put("date", new GregorianCalendar().getTime());
 
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"));
index 5b6d841..187f383 100755 (executable)
@@ -520,6 +520,7 @@ ServletModule.MediaType.DeleteConfirmationTemplate=confirm.template
 ServletModule.MediaType.EditTemplate=mediatype.template
 ServletModule.MediaType.ListTemplate=mediatypelist.template
 
+
 #
 # Object store configuration
 #
@@ -528,8 +529,8 @@ StoreContainer.EntityDefaultSize= 45
 StoreContainer.EntityListDefaultSize= 15
 StorableObjectEntity.Entity.DefaultSize= 300
 StorableObjectEntity.EntityList.DefaultSize= 100
-EntityTopics.Entity.DefaultSize=              200
-EntityTopics.EntityList.DefaultSize=          20
+EntityTopics.Entity.DefaultSize=200
+EntityTopics.EntityList.DefaultSize=20
 
 
 
@@ -538,8 +539,10 @@ EntityTopics.EntityList.DefaultSize=          20
 
 #
 # config for abuse
-ServletModule.Abuse.EditFilter.Template = abuse.filter.template
-ServletModule.Abuse.ListFilters.Template = abuse.filters.template
+ServletModule.Abuse.EditFilter.Template = filter.template
+ServletModule.Abuse.ListFilters.Template = filterlist.template
+ServletModule.Abuse.EditFilterGroup.Template = filtergroup.template
+ServletModule.Abuse.ListFilterGroups.Template = filtergrouplist.template
 ServletModule.Abuse.ViewLog.Template = abuse.log.template
 ServletModule.Abuse.Main.Template = abuse.template
 
index a4e6585..5cfd829 100755 (executable)
@@ -35,7 +35,6 @@ import java.util.List;
 import java.util.Map;
 
 import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
 import mir.log.LoggerWrapper;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectExc;
@@ -45,7 +44,7 @@ import mir.storage.StorageObjectFailure;
  * Base class the entities are derived from. Provides base functionality of
  * an entity.
  *
- * @version $Id: AbstractEntity.java,v 1.8.2.3 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: AbstractEntity.java,v 1.8.2.4 2005/01/09 20:37:07 zapata Exp $
  */
 
 public class AbstractEntity implements Entity {
@@ -61,18 +60,8 @@ public class AbstractEntity implements Entity {
     values = new HashMap();
   }
 
-  /**
-   * Constructor
-   * @param StorageObject The StorageObject of the Entity.
-   */
-  public AbstractEntity(StorageObject StorageObject) {
-    this();
-
-    setStorage(StorageObject);
-  }
-
-  public void setStorage(StorageObject storage) {
-    this.storageObject = storage;
+  public void setStorage(StorageObject aStorageObject) {
+    storageObject = aStorageObject;
   }
 
   /** {@inheritDoc} */
index a0e6e7a..7aa6574 100755 (executable)
  */
 package  mir.entity;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * An <code>Entity</code> represents a persistent data object, typically
  *   stored in a database.<p>
  *
- * @version $Id: Entity.java,v 1.21.2.8 2004/02/08 21:05:01 zapata Exp $
+ * @version $Id: Entity.java,v 1.21.2.9 2005/01/09 20:37:07 zapata Exp $
  */
 
-public interface Entity
-{
-  public void setStorage(StorageObject storage);
-
+public interface Entity {
   /**
    * Sets the values of the Entity. (Only to be called by the Storage Object)
    *
index 2ef7c69..f1ba030 100755 (executable)
@@ -50,7 +50,7 @@ public class EntityAdapterEngine {
 
   /**
    *
-   * @param aStorage
+   * @param aModel
    * @param aDefinition
    * @param aQualifier
    * @param anOrder
index 8620a93..025379e 100755 (executable)
@@ -32,8 +32,8 @@ package mir.entity.adapter;
 import multex.Failure;
 
 public class EntityAdapterFailure extends Failure {
-  public EntityAdapterFailure(String msg,Throwable cause) {
-    super(msg,cause);
+  public EntityAdapterFailure(String msg, Throwable cause) {
+    super(msg, cause);
   }
 
   public EntityAdapterFailure(Throwable aCause) {
index 0d4ea50..598596b 100755 (executable)
@@ -42,7 +42,7 @@ public class EntityAdapterModel {
     entityAdapterMappings = new HashMap();
   }
 
-  public EntityAdapter makeEntityAdapter( String aName, Entity anEntity ) throws EntityAdapterExc {
+  public EntityAdapter makeEntityAdapter( String aName, Entity anEntity ) {
     Mapping mapping = getMappingForName( aName );
 
     return mapping.getDefinition().makeEntityAdapter( anEntity, this );
@@ -51,9 +51,7 @@ public class EntityAdapterModel {
   public EntityAdapter createNewEntity( String aName ) throws EntityAdapterExc {
     try {
       Mapping mapping = getMappingForName(aName);
-      StorageObject storage = mapping.storage;
-      Entity entity = (Entity) storage.getEntityClass().newInstance();
-      entity.setStorage(storage);
+      Entity entity = mapping.storage.createNewEntity();
 
       return mapping.getDefinition().makeEntityAdapter(entity, this);
     }
@@ -66,9 +64,9 @@ public class EntityAdapterModel {
     entityAdapterMappings.put( aName, new Mapping( aStorage, aDefinition ) );
   }
 
-  public Mapping getMappingForName( String aName ) throws EntityAdapterExc {
+  public Mapping getMappingForName( String aName ) {
     if (!entityAdapterMappings.containsKey(aName))
-      throw new EntityAdapterExc( "'" + aName + "' not present in model" );
+      throw new EntityAdapterFailure("'" + aName + "' not present in model", null);
 
     return (Mapping) entityAdapterMappings.get( aName );
   }
index dfa9ae7..bdcb42d 100755 (executable)
@@ -49,20 +49,20 @@ public class EntityIteratorAdapter implements RewindableIterator {
 
   public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName )
-          throws StorageObjectFailure, EntityAdapterExc {
+          throws StorageObjectFailure {
     this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize), aModel, aDefinitionName);
   }
 
   public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
-          int aLimit, int aSkip) throws StorageObjectFailure, EntityAdapterExc {
+          int aLimit, int aSkip) throws StorageObjectFailure {
     this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
   }
 
   public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables,
           String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
-          int aLimit, int aSkip) throws StorageObjectFailure, EntityAdapterExc {
+          int aLimit, int aSkip) throws StorageObjectFailure {
     this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aMainTablePrefix, someExtraTables, aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
   }
 
@@ -72,12 +72,7 @@ public class EntityIteratorAdapter implements RewindableIterator {
   }
 
   public Object next() {
-    try {
-      return model.makeEntityAdapter(definitionName, (Entity) iterator.next());
-    }
-    catch (EntityAdapterExc e) {
-      return null;
-    }
+    return model.makeEntityAdapter(definitionName, (Entity) iterator.next());
   }
 
   public void remove() {
diff --git a/source/mir/entity/adapter/ToManyRelationField.java b/source/mir/entity/adapter/ToManyRelationField.java
new file mode 100755 (executable)
index 0000000..5c9c889
--- /dev/null
@@ -0,0 +1,56 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.entity.adapter;\r
+\r
+public class ToManyRelationField implements EntityAdapterDefinition.CalculatedField{\r
+  private String fromField;\r
+  private String toField;\r
+  private String toEntity;\r
+  private String orderByField;\r
+\r
+  public ToManyRelationField(String aFromField, String aToEntity, String aToField, String anOrderByField) {\r
+    fromField = aFromField;\r
+    toField = aToField;\r
+    toEntity = aToEntity;\r
+    orderByField = anOrderByField;\r
+  }\r
+\r
+  public Object getValue(EntityAdapter anEntityAdapter) {\r
+    try {\r
+      return anEntityAdapter.getRelation(\r
+                  toField + "=" + anEntityAdapter.get(fromField),\r
+                  orderByField,\r
+                  toEntity);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException(t.getMessage());\r
+    }\r
+  }\r
+}\r
diff --git a/source/mir/entity/adapter/ToOneRelationField.java b/source/mir/entity/adapter/ToOneRelationField.java
new file mode 100755 (executable)
index 0000000..d99ab9b
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.entity.adapter;\r
+\r
+public class ToOneRelationField implements EntityAdapterDefinition.CalculatedField{\r
+  private String fromField;\r
+  private String toField;\r
+  private String toEntity;\r
+\r
+  public ToOneRelationField(String aFromField, String aToEntity, String aToField) {\r
+    fromField = aFromField;\r
+    toField = aToField;\r
+    toEntity = aToEntity;\r
+  }\r
+\r
+  public Object getValue(EntityAdapter anEntityAdapter) {\r
+    try {\r
+      return anEntityAdapter.getToOneRelation(\r
+                  toField + "=" + anEntityAdapter.get(fromField),\r
+                  toField,\r
+                  toEntity);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException(t.getMessage());\r
+    }\r
+  }\r
+}\r
index d4a4ee7..b774a1d 100755 (executable)
@@ -363,7 +363,8 @@ public class FreemarkerGenerator implements Generator {
       Template template = (Template) templateCache.getItem(anIdentifier, "template");
 
       if (template==null) {
-        throw new GeneratorExc("FreemarkerGeneratorLibrary: Can't find template "+templateCache.getDirectory()+"/"+anIdentifier);
+        throw new GeneratorExc("FreemarkerGeneratorLibrary: Can't find template " +
+            templateCache.getDirectory() + File.separatorChar + anIdentifier);
       }
 
       return new FreemarkerGenerator(template);
index 1735701..31a671b 100755 (executable)
  */
 package mir.generator;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.File;
-import java.util.AbstractList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
+import mir.log.LoggerWrapper;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.RewindableIterator;
 import org.apache.commons.beanutils.MethodUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.velocity.Template;
@@ -49,9 +41,11 @@ import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.log.LogSystem;
-import mir.log.LoggerWrapper;
-import mir.util.GeneratorFormatAdapters;
-import mir.util.RewindableIterator;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.*;
 
 public class VelocityGenerator implements Generator {
   private String templateIdentifier;
@@ -229,7 +223,7 @@ public class VelocityGenerator implements Generator {
     }
 
     public Object call(Object aParameters[]) throws GeneratorExc {
-      List parameters = new Vector();
+      List parameters = new ArrayList();
 
       for (int i = 0; i<aParameters.length; i++) {
         parameters.add(unmakeAdapter(aParameters[i]));
@@ -239,7 +233,7 @@ public class VelocityGenerator implements Generator {
     }
 
     public Object call() throws GeneratorExc {
-      return makeAdapter(function.perform(new Vector()));
+      return makeAdapter(function.perform(new ArrayList()));
     }
 
     public Object call(Object anObject) throws GeneratorExc {
@@ -337,7 +331,7 @@ public class VelocityGenerator implements Generator {
     private IteratorAdapter(Iterator anIterator) {
       iterator = anIterator;
 
-      valuesCache = new Vector();
+      valuesCache = new ArrayList();
 
       if (iterator instanceof RewindableIterator) {
         ((RewindableIterator) iterator).rewind();
@@ -393,7 +387,7 @@ public class VelocityGenerator implements Generator {
     private ListAdapter(List aList) {
       list = aList;
 
-      valuesCache = new Vector();
+      valuesCache = new ArrayList();
     }
 
     private void getUntil(int anIndex) {
index 46d052a..1f959be 100755 (executable)
@@ -33,11 +33,12 @@ package mir.log;
 
 
 public interface Logger {
-  public void debug( Object o, String s);
-  public void info( Object o, String s);
-  public void warn( Object o, String s);
-  public void error( Object o, String s);
-  public void fatal( Object o, String s);
+  public void debug(Object o, String s);
+  public void info(Object o, String s);
+  public void warn(Object o, String s);
+  public void error(Object o, String s);
+  public void error(Object o, String s, Throwable anException);
+  public void fatal(Object o, String s);
 
   public void reload() throws LoggerExc, LoggerFailure;
 }
index 9073595..2b66599 100755 (executable)
@@ -71,6 +71,10 @@ public class LoggerEngine {
     loggerInstance.error(o, s);
   }
 
+  public static void error(Object o, String s, Throwable anException) {
+    loggerInstance.error(o, s, anException);
+  }
+
   public static void fatal(Object o, String s) {
     loggerInstance.fatal(o, s);
   }
index eb8db65..9f4deba 100755 (executable)
@@ -60,6 +60,10 @@ public class LoggerWrapper {
     LoggerEngine.error(object, aMessage);
   };
 
+  public void error(String aMessage, Throwable anException) {
+    LoggerEngine.error(object, aMessage, anException);
+  };
+
   public void fatal( String aMessage ) {
     LoggerEngine.fatal(object, aMessage);
   };
index cd80fd8..c6af2db 100755 (executable)
@@ -67,6 +67,11 @@ public class LoggerImpl implements mir.log.Logger {
   }
 
   /** {@inheritDoc} */
+  public void error(Object o, String s, Throwable anException) {
+    this.getLogger(o).error(s, anException);
+  }
+
+  /** {@inheritDoc} */
   public void fatal(Object o, String s) {
     this.getLogger(o).fatal(s);
   }
index a77ab2e..36d9fa1 100755 (executable)
@@ -29,9 +29,8 @@
  */
 package  mir.media;
 
-import java.io.InputStream;
 import java.io.File;
-import java.util.List;
+import java.io.InputStream;
 
 import mir.entity.Entity;
 import mir.session.UploadedFile;
@@ -81,7 +80,7 @@ import mir.session.UploadedFile;
  * ) and just override the things that need to be specific. see MediaHandlerAudio
  *
  * @author <mh@nadir.org>, the Mir-coders group
- * @version $Id: MediaHandler.java,v 1.1.2.3 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: MediaHandler.java,v 1.1.2.4 2005/01/09 20:37:08 zapata Exp $
  */
 
 public interface MediaHandler {
index aea424b..94fbffb 100755 (executable)
@@ -98,27 +98,12 @@ public class AbstractModule {
    * @exception ModuleExc
    * @exception ModuleFailure
    */
-  public String add (Map theValues) throws ModuleExc, ModuleFailure {
+  public String add(Map theValues) throws ModuleExc, ModuleFailure {
     try {
-      Entity theEntity = (Entity)storage.getEntityClass().newInstance();
-      theEntity.setStorage(storage);
-      theEntity.setFieldValues(theValues);
-      return theEntity.insert();
-    }
-    catch (Throwable e) {
-      throw new ModuleFailure(e);
-    }
-  }
-
-  /**
-   * This function creates an Entity without yet storing it in the database
-   */
-  public Entity createNew() throws ModuleExc, ModuleFailure {
-    try {
-      Entity result = (Entity)storage.getEntityClass().newInstance();
-      result.setStorage(storage);
+      Entity entity = storage.createNewEntity();
+      entity.setFieldValues(theValues);
 
-      return result;
+      return entity.insert();
     }
     catch (Throwable e) {
       throw new ModuleFailure(e);
@@ -134,7 +119,7 @@ public class AbstractModule {
    */
   public String set (Map theValues) throws ModuleExc, ModuleFailure {
     try {
-      Entity theEntity = storage.selectById((String)theValues.get("id"));
+      Entity theEntity = storage.selectById((String) theValues.get("id"));
       if (theEntity == null)
         throw new ModuleExc("No object found with id " + theValues.get("id"));
       theEntity.setFieldValues(theValues);
index 1964b3c..5825ae9 100755 (executable)
@@ -29,7 +29,6 @@
  */
 package mir.producer.reader;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
index a6556b7..3a01811 100755 (executable)
  */
 package mir.rss;
 
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
 import mir.util.HTTPClientHelper;
-import mir.util.xml.*;
 import mir.util.xml.XMLParserEngine;
+import mir.util.xml.XMLParserExc;
+import mir.util.xml.XMLParserFailure;
+
+import java.io.InputStream;
+import java.util.*;
 
 /**
  *
@@ -205,7 +201,7 @@ public class RSS091Reader {
 
     public RSS091ChannelSectionHandler(RSSData aData) {
       data = aData;
-      items = new Vector();
+      items = new ArrayList();
       channel = new RDFResource("rss:channel");
       attributes = new HashMap();
     }
@@ -326,7 +322,7 @@ public class RSS091Reader {
     private List items;
 
     public RDFSequenceSectionHandler() {
-      items = new Vector();
+      items = new ArrayList();
     }
 
     public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
index 6d89d49..ad2958a 100755 (executable)
@@ -41,16 +41,6 @@ import mir.util.xml.XMLParserEngine;
 import mir.util.xml.XMLParserExc;
 import mir.util.xml.XMLParserFailure;
 
-/**
- *
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
-
 public class RSSReader {
   public static final String RDF_NAMESPACE_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
   public static final String RSS_1_0_NAMESPACE_URI = "http://purl.org/rss/1.0/";
@@ -141,7 +131,7 @@ public class RSSReader {
 
   public RSSData parseUrl(String anUrl) throws RSSExc, RSSFailure {
     try {
-      HTTPClientHelper httpClientHelper = new HTTPClientHelper();      
+      HTTPClientHelper httpClientHelper = new HTTPClientHelper();
       InputStream inputStream = httpClientHelper.getUrl(anUrl);
       if (inputStream==null)
         throw new RSSExc("RSSChannel.parseUrl: Can't get url content");
index d2d89e8..02d4761 100755 (executable)
  */
 package mir.servlet;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -48,18 +45,11 @@ import mir.storage.StorageObject;
 import mir.util.HTTPRequestParser;
 import mir.util.URLBuilder;
 import mircoders.global.MirGlobal;
-import mircoders.servlet.ServletHelper;
 import mircoders.localizer.MirLocalizerExc;
-import multex.Failure;
+import mircoders.servlet.ServletHelper;
 
 /**
  *
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
  */
 
 public abstract class ServletModule {
@@ -77,8 +67,16 @@ public abstract class ServletModule {
   protected String deleteConfirmationGenerator;
   protected int nrEntitiesPerListPage;
 
+  /** the list of parameters that need to be propagated in the list */
+  protected List propagatedParameters = new ArrayList();
 
   public ServletModule(){
+    propagatedParameters.add("searchfield");
+    propagatedParameters.add("searchtext");
+    propagatedParameters.add("searchispublished");
+    propagatedParameters.add("searchstatus");
+    propagatedParameters.add("searchorder");
+
     definition = null;
     try {
       model = MirGlobal.localizer().dataModel().adapterModel();
@@ -88,8 +86,6 @@ public abstract class ServletModule {
       throw new ServletModuleFailure("Can't retrieve model", e);
     }
 
-
-
     listGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".ListTemplate");
     editGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".EditTemplate");
     deleteConfirmationGenerator = configuration.getString("ServletModule."+getOperationModuleName()+".DeleteConfirmationTemplate");
@@ -129,17 +125,17 @@ public abstract class ServletModule {
    * this supersedes getLanguage for the new i18n
    */
   public static Locale getLocale(HttpServletRequest aRequest) {
-    Locale loc = null;
+    Locale locale = null;
     HttpSession session = aRequest.getSession(false);
     if (session != null) {
       // session can be null in case of logout
-      loc = (Locale) session.getAttribute("locale");
+      locale = (Locale) session.getAttribute("locale");
     }
     // if there is nothing in the session get it fron the accept-language
-    if (loc == null) {
-      loc = aRequest.getLocale();
+    if (locale == null) {
+      locale = aRequest.getLocale();
     }
-    return loc;
+    return locale;
   }
 
   /**
@@ -158,7 +154,7 @@ public abstract class ServletModule {
    */
   public String getDefaultListOrdering() {
 
-    if (mainModule!=null && mainModule.getStorageObject()!=null){
+    if (mainModule!=null && mainModule.getStorageObject()!=null) {
       if (mainModule.getStorageObject().getFieldNames().contains("webdb_create"))
         return "webdb_create desc";
     }
@@ -170,8 +166,7 @@ public abstract class ServletModule {
    * Generic list servlet method
    */
 
-  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
 
     String where = requestParser.getParameter("where");
@@ -184,10 +179,13 @@ public abstract class ServletModule {
 
   public void returnList(HttpServletRequest aRequest, HttpServletResponse aResponse,
      String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {
+    returnList(aRequest, aResponse, aWhereClause, anOrderByClause, anOffset, Collections.EMPTY_MAP);
+  }
 
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+  public void returnList(HttpServletRequest aRequest, HttpServletResponse aResponse,
+     String aWhereClause, String anOrderByClause, int anOffset, Map anOverridingRequestParameters) throws ServletModuleExc {
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest, anOverridingRequestParameters);
     URLBuilder urlBuilder = new URLBuilder();
-    int count;
 
     try {
       Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, getLocales(aRequest));
@@ -199,30 +197,19 @@ public abstract class ServletModule {
       responseData.put("prevurl", null);
       responseData.put("module", getOperationModuleName());
 
-      count=mainModule.getSize(aWhereClause);
-
       urlBuilder.setValue("module", getOperationModuleName());
       urlBuilder.setValue("do", "list");
       urlBuilder.setValue("where", aWhereClause);
       urlBuilder.setValue("order", anOrderByClause);
 
-      urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));
-      urlBuilder.setValue("searchtext", requestParser.getParameter("searchtext"));
-      urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));
-      urlBuilder.setValue("searchstatus", requestParser.getParameter("searchstatus"));
-      urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));
-
-      responseData.put("searchfield", requestParser.getParameter("searchfield"));
-      responseData.put("searchtext", requestParser.getParameter("searchtext"));
-      responseData.put("searchispublished", requestParser.getParameter("searchispublished"));
-      responseData.put("searchstatus", requestParser.getParameter("searchstatus"));
-      responseData.put("searchorder", requestParser.getParameter("searchorder"));
 
       urlBuilder.setValue("offset", anOffset);
       responseData.put("offset" , new Integer(anOffset).toString());
       responseData.put("thisurl" , urlBuilder.getQuery());
 
-      if (count>anOffset+nrEntitiesPerListPage) {
+      propagateFields(requestParser, urlBuilder, responseData);
+
+      if (list.size()>=nrEntitiesPerListPage) {
         urlBuilder.setValue("offset", anOffset + nrEntitiesPerListPage);
         responseData.put("nexturl" , urlBuilder.getQuery());
       }
@@ -234,8 +221,8 @@ public abstract class ServletModule {
 
       responseData.put("entities", list);
       responseData.put("from" , Integer.toString(anOffset+1));
-      responseData.put("count", Integer.toString(count));
-      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));
+      responseData.put("count", "?");
+      responseData.put("to", Integer.toString(anOffset+list.size()-1));
 
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);
     }
@@ -471,4 +458,14 @@ public abstract class ServletModule {
     }
     return withValues;
   }
+
+  private void propagateFields(HTTPRequestParser aRequest, URLBuilder aUrlBuilder, Map aResponseData) {
+    Iterator i = propagatedParameters.iterator();
+    while (i.hasNext()) {
+      String parameter = (String) i.next();
+      String value = aRequest.getParameter(parameter);
+      aUrlBuilder.setValue(parameter, value);
+      aResponseData.put(parameter, value);
+    }
+  }
 }
\ No newline at end of file
index 9876791..f41f505 100755 (executable)
@@ -33,6 +33,7 @@ import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
 import mir.entity.EntityList;
 import mir.entity.StorableObjectEntity;
+import mir.entity.AbstractEntity;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.storage.store.*;
@@ -51,7 +52,7 @@ import java.util.*;
 /**
  * Implements database access.
  *
- * @version $Id: Database.java,v 1.44.2.23 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: Database.java,v 1.44.2.24 2005/01/09 20:37:09 zapata Exp $
  * @author rk
  *
  */
@@ -70,8 +71,7 @@ public class Database implements StorageObject {
   protected List fieldNames;
   protected int[] fieldTypes;
 
-  protected Class theEntityClass;
-  protected boolean hasTimestamp = true;
+  protected Class entityClass;
   private int defaultLimit;
 
   TimeZone timezone;
@@ -100,7 +100,7 @@ public class Database implements StorageObject {
     defaultLimit = Integer.parseInt(configuration.getString("Database.Limit"));
 
     try {
-      theEntityClass = GENERIC_ENTITY_CLASS;
+      entityClass = GENERIC_ENTITY_CLASS;
     }
     catch (Throwable e) {
       logger.error("Error in Database() constructor with " + theAdaptorName + " -- " + e.getMessage());
@@ -116,7 +116,19 @@ public class Database implements StorageObject {
    * @return Class-Objekt der Entity
    */
   public java.lang.Class getEntityClass() {
-    return theEntityClass;
+    return entityClass;
+  }
+
+  public Entity createNewEntity() throws StorageObjectFailure {
+    try {
+      AbstractEntity result = (AbstractEntity) entityClass.newInstance();
+      result.setStorage(this);
+
+      return result;
+    }
+    catch (Throwable t) {
+      throw new StorageObjectFailure(t);
+    }
   }
 
   /**
@@ -315,14 +327,14 @@ public class Database implements StorageObject {
     }
 
     // ask object store for object
-    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(entityClass)) {
       String uniqueId = id;
 
-      if (theEntityClass.equals(StorableObjectEntity.class)) {
+      if (entityClass.equals(StorableObjectEntity.class)) {
         uniqueId += ("@" + mainTable);
       }
 
-      StoreIdentifier search_sid = new StoreIdentifier(theEntityClass, uniqueId);
+      StoreIdentifier search_sid = new StoreIdentifier(entityClass, uniqueId);
       logger.debug("CACHE: (dbg) looking for sid " + search_sid.toString());
 
       Entity hit = (Entity) o_store.use(search_sid);
@@ -503,8 +515,8 @@ public class Database implements StorageObject {
     // check o_store for entitylist
     // only if no relational select
     if (anExtraTables==null) {
-      if (StoreUtil.extendsStorableEntity(theEntityClass)) {
-         StoreIdentifier searchSid = new StoreIdentifier(theEntityClass,
+      if (StoreUtil.extendsStorableEntity(entityClass)) {
+         StoreIdentifier searchSid = new StoreIdentifier(entityClass,
                StoreContainerType.STOC_TYPE_ENTITYLIST,
                StoreUtil.getEntityListUniqueIdentifierFor(mainTable,
                 aWhereClause, anOrderByClause, anOffset, aLimit));
@@ -617,7 +629,7 @@ public class Database implements StorageObject {
           theReturnList.setNextBatch(anOffset + aLimit);
         }
 
-        if (anExtraTables==null && StoreUtil.extendsStorableEntity(theEntityClass)) {
+        if (anExtraTables==null && StoreUtil.extendsStorableEntity(entityClass)) {
           StoreIdentifier sid = theReturnList.getStoreIdentifier();
           logger.debug("CACHE (add): " + sid.toString());
           o_store.add(sid);
@@ -639,12 +651,6 @@ public class Database implements StorageObject {
     return theReturnList;
   }
 
-  /**
-   *  Bastelt aus einer Zeile der Datenbank ein EntityObjekt.
-   *
-   *  @param rs Das ResultSetObjekt.
-   *  @return Entity Die Entity.
-   */
   private Entity makeEntityFromResultSet(ResultSet rs)
     throws StorageObjectFailure {
     Map theResultHash = new HashMap();
@@ -653,9 +659,9 @@ public class Database implements StorageObject {
     Entity returnEntity = null;
 
     try {
-      if (StoreUtil.extendsStorableEntity(theEntityClass)) {
+      if (StoreUtil.extendsStorableEntity(entityClass)) {
          StoreIdentifier searchSid = StorableObjectEntity.getStoreIdentifier(this,
-               theEntityClass, rs);
+               entityClass, rs);
          Entity hit = (Entity) o_store.use(searchSid);
          if (hit != null) return hit;
       }
@@ -693,9 +699,8 @@ public class Database implements StorageObject {
         }
       }
 
-      if (theEntityClass != null) {
-        returnEntity = (Entity) theEntityClass.newInstance();
-        returnEntity.setStorage(this);
+      if (entityClass != null) {
+        returnEntity = createNewEntity();
         returnEntity.setFieldValues(theResultHash);
 
         if (returnEntity instanceof StorableObject) {
@@ -703,18 +708,12 @@ public class Database implements StorageObject {
           o_store.add(((StorableObject) returnEntity).getStoreIdentifier());
         }
       } else {
-        throwStorageObjectException("Internal Error: theEntityClass not set!");
+        throwStorageObjectException("Internal Error: entityClass not set!");
       }
     }
-    catch (IllegalAccessException e) {
-      throwStorageObjectException("No access! -- " + e.getMessage());
-    }
     catch (IOException e) {
       throwStorageObjectException("IOException! -- " + e.getMessage());
     }
-    catch (InstantiationException e) {
-      throwStorageObjectException("No Instatiation! -- " + e.getMessage());
-    }
     catch (SQLException sqe) {
       throwSQLException(sqe, "makeEntityFromResultSet");
 
@@ -727,10 +726,10 @@ public class Database implements StorageObject {
   /**
    * Inserts an entity into the database.
    *
-   * @param theEntity
+   * @param anEntity
    * @return der Wert des Primary-keys der eingef?gten Entity
    */
-  public String insert(Entity theEntity) throws StorageObjectFailure {
+  public String insert(Entity anEntity) throws StorageObjectFailure {
     invalidateStore();
 
     String returnId = null;
@@ -752,16 +751,16 @@ public class Database implements StorageObject {
           aValue = null;
 
           // exceptions
-          if (!theEntity.hasFieldValue(aField) && (
+          if (!anEntity.hasFieldValue(aField) && (
               aField.equals("webdb_create") ||
               aField.equals("webdb_lastchange"))) {
             aValue = "NOW()";
           }
           else {
-              if (theEntity.hasFieldValue(aField)) {
+              if (anEntity.hasFieldValue(aField)) {
                 aValue =
                   "'" +
-                   JDBCStringRoutines.escapeStringLiteral(theEntity.getFieldValue(aField)) + "'";
+                   JDBCStringRoutines.escapeStringLiteral(anEntity.getFieldValue(aField)) + "'";
               }
           }
 
@@ -803,7 +802,7 @@ public class Database implements StorageObject {
 //      pstmt = con.prepareStatement("select currval('" +  + "_id_seq')");
 
       returnId = getLatestInsertedId(con);
-      theEntity.setId(returnId);
+      anEntity.setId(returnId);
     }
     catch (SQLException sqe) {
       throwSQLException(sqe, "insert");
@@ -938,17 +937,17 @@ public class Database implements StorageObject {
    */
   public boolean delete(String id) throws StorageObjectFailure {
     // ostore send notification
-    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(entityClass)) {
       String uniqueId = id;
 
-      if (theEntityClass.equals(StorableObjectEntity.class)) {
+      if (entityClass.equals(StorableObjectEntity.class)) {
         uniqueId += ("@" + mainTable);
       }
 
       logger.debug("CACHE: (del) " + id);
 
       StoreIdentifier search_sid =
-        new StoreIdentifier(theEntityClass,
+        new StoreIdentifier(entityClass,
           StoreContainerType.STOC_TYPE_ENTITY, uniqueId);
       o_store.invalidate(search_sid);
     }
@@ -1337,10 +1336,10 @@ public class Database implements StorageObject {
    * Invalidates any cached entity list
    */
   private void invalidateStore() {
-    // invalidating all EntityLists corresponding with theEntityClass
-    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
+    // invalidating all EntityLists corresponding with entityClass
+    if (StoreUtil.extendsStorableEntity(entityClass)) {
       StoreContainerType stoc_type =
-        StoreContainerType.valueOf(theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST);
+        StoreContainerType.valueOf(entityClass, StoreContainerType.STOC_TYPE_ENTITYLIST);
       o_store.invalidate(stoc_type);
     }
   }
index 5f4ecc9..483fde5 100755 (executable)
@@ -77,6 +77,8 @@ public interface StorageObject {
 
   public Class getEntityClass();
 
+  public Entity createNewEntity() throws StorageObjectFailure; 
+
   public String getIdName();
 
   public String getTableName();
index 358a5c5..fab5a7d 100755 (executable)
@@ -62,8 +62,6 @@ public class StoreIdentifier {
 
   protected LoggerWrapper logger = new LoggerWrapper("Database.ObjectStore");
 
-  /** @todo initialize logfile  */
-
   private StoreIdentifier() {}
 
   public StoreIdentifier(StorableObject reference, int storeType,
@@ -91,12 +89,6 @@ public class StoreIdentifier {
     this.stocType = StoreContainerType.valueOf(theClass, storeType);
   }
 
-  /**
-   *  Method:       ivalidate
-   *  Description:
-   *
-   *  @return
-   */
   public void invalidate() {
     logger.info("Invalidating: " + toString());
     // avoid deadlock due to propagation.
index 5b6b2a3..1bbfc0a 100755 (executable)
  */
 package mir.util;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Vector;
-import java.util.ArrayList;
 
 public class CachingRewindableIterator implements RewindableIterator {
   private Iterator master;
index d831028..916692c 100755 (executable)
  */
 package mir.util;
 
-import java.lang.reflect.InvocationTargetException;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
 
 import multex.Failure;
 
index 666f4cf..be02f67 100755 (executable)
 package mir.util;
 
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 
-import mir.util.UtilExc;
-
 public class HTTPClientHelper {
   private HttpClient client;
   private HttpMethod method;
index 9b50247..4695468 100755 (executable)
@@ -32,23 +32,25 @@ package mir.util;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Collections;
+import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 public class HTTPRequestParser {
   private HttpServletRequest request;
-  private String encoding;
+  private Map overridingParameters;
 
   public HTTPRequestParser(HttpServletRequest aRequest) {
-    this(aRequest, aRequest.getCharacterEncoding());
+    this(aRequest, Collections.EMPTY_MAP);
   }
 
-  public HTTPRequestParser(HttpServletRequest aRequest, String anEncoding) {
+  public HTTPRequestParser(HttpServletRequest aRequest, Map anOverridingParameters) {
     request = aRequest;
-    encoding = anEncoding;
+    overridingParameters = anOverridingParameters;
   }
 
   public boolean hasParameter(String aName) {
-    return request.getParameter(aName)!=null;
+    return (request.getParameter(aName)!=null) || overridingParameters.containsKey(aName);
   }
 
   public String getParameterWithDefault(String aName, String aDefault) {
@@ -61,13 +63,10 @@ public class HTTPRequestParser {
   public String getParameter(String aName) {
     try {
       String result = request.getParameter(aName);
-//      String requestEncoding = request.getCharacterEncoding();
-//      if (requestEncoding==null)
-//        requestEncoding = "ISO-8859-1";
 
-//      if (result != null && encoding!=null && !encoding.equals(requestEncoding)) {
-//        result = new String(result.getBytes(requestEncoding), encoding);
-//      }
+      if (result==null) {
+        result = (String) overridingParameters.get(aName);
+      }
 
       return result;
     }
index 734bec9..e397f6f 100755 (executable)
  */
 package mir.util;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
 import mir.generator.Generator;
 import mir.generator.GeneratorExc;
 import multex.Exc;
-
 import org.apache.commons.beanutils.MethodUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 
+import java.util.*;
+
 /**
  * Class to work with expressions. Will be gradually phased out and replaced
  * with {@link mir.util.expressions.ExpressionParser}
@@ -576,7 +571,7 @@ public class ParameterExpander {
     private List parseList() {
       Token token;
       Object expression;
-      List result = new Vector();
+      List result = new ArrayList();
 
       token = scanner.scan();
       if (!(token instanceof LeftParenthesisToken)) {
index 25d3e55..0044577 100755 (executable)
@@ -35,11 +35,7 @@ import java.io.LineNumberReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import multex.Exc;
 import multex.Failure;
@@ -49,7 +45,7 @@ public class PropertiesManipulator {
   private Map values;
 
   public PropertiesManipulator() {
-    entries = new Vector();
+    entries = new ArrayList();
     values = new HashMap();
   }
 
index 412ecad..7f3f354 100755 (executable)
@@ -33,7 +33,7 @@ package mir.util;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
+import java.util.ArrayList;
 
 
 /**
@@ -138,7 +138,7 @@ public class StructuredContentParser {
   }
 
   public static List parseList(Scanner aScanner) {
-    List result = new Vector();
+    List result = new ArrayList();
     aScanner.skipSpace();
     if (aScanner.peek() == '[')
       aScanner.scan();
index 1e98f7c..3478665 100755 (executable)
  */\r
 package mir.util.generator;\r
 \r
+import java.lang.reflect.InvocationTargetException;\r
+import java.util.List;\r
+\r
 import mir.generator.Generator;\r
 import mir.generator.GeneratorExc;\r
 import mir.generator.GeneratorFailure;\r
 import mir.util.ReflectionRoutines;\r
 \r
-import java.util.List;\r
-import java.lang.reflect.InvocationTargetException;\r
-\r
-import org.apache.commons.beanutils.MethodUtils;\r
-\r
 /**\r
  * Class to adapt methods with some name to a\r
  * {@link Generator.Function}\r
diff --git a/source/mircoders/abuse/AbstractFilterType.java b/source/mircoders/abuse/AbstractFilterType.java
new file mode 100755 (executable)
index 0000000..85b197e
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+\r
+public abstract class AbstractFilterType implements FilterType {\r
+  private String name;\r
+\r
+  public AbstractFilterType(String aName) {\r
+    name = aName;\r
+  }\r
+\r
+  public String getName() {\r
+    return name;\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/AbuseExc.java b/source/mircoders/abuse/AbuseExc.java
new file mode 100755 (executable)
index 0000000..903f121
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License, \r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library \r
+ * (or with modified versions of the above that use the same license as the above), \r
+ * and distribute linked combinations including the two.  You must obey the \r
+ * GNU General Public License in all respects for all of the code used other than \r
+ * the above mentioned libraries.  If you modify this file, you may extend this \r
+ * exception to your version of the file, but you are not obligated to do so.  \r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.abuse;\r
+\r
+import multex.Exc;\r
+\r
+public class AbuseExc extends Exc {\r
+  public AbuseExc(String aMessage) {\r
+    super(aMessage);\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/AbuseFailure.java b/source/mircoders/abuse/AbuseFailure.java
new file mode 100755 (executable)
index 0000000..429154c
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License, \r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library \r
+ * (or with modified versions of the above that use the same license as the above), \r
+ * and distribute linked combinations including the two.  You must obey the \r
+ * GNU General Public License in all respects for all of the code used other than \r
+ * the above mentioned libraries.  If you modify this file, you may extend this \r
+ * exception to your version of the file, but you are not obligated to do so.  \r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+import multex.Failure;\r
+\r
+public class AbuseFailure extends Failure {\r
+\r
+  public AbuseFailure(String msg,Throwable cause) {\r
+    super(msg,cause);\r
+  }\r
+\r
+  public AbuseFailure(Throwable aCause) {\r
+    this (aCause.getMessage(), aCause);\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/FilterEngine.java b/source/mircoders/abuse/FilterEngine.java
new file mode 100755 (executable)
index 0000000..79f63d8
--- /dev/null
@@ -0,0 +1,449 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.abuse;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.adapter.EntityAdapter;\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.entity.adapter.EntityIteratorAdapter;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.StorageObjectExc;\r
+import mir.session.Request;\r
+import mir.config.MirPropertiesConfiguration;\r
+import mircoders.storage.DatabaseFilter;\r
+import mircoders.storage.DatabaseFilterGroup;\r
+import mircoders.global.MirGlobal;\r
+\r
+import java.util.*;\r
+import java.text.SimpleDateFormat;\r
+\r
+public class FilterEngine {\r
+  private Map filterTypes;\r
+  private List filterTypeIds;\r
+\r
+  private List filterGroups;\r
+  private Map idToFilterGroup;\r
+  private LoggerWrapper logger;\r
+  private EntityAdapterModel model;\r
+  private SimpleDateFormat dateFormat;\r
+  private MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();\r
+\r
+  public FilterEngine(EntityAdapterModel aModel) {\r
+    logger = new LoggerWrapper("Global.Abuse.FilterEngine");\r
+    filterGroups = new ArrayList();\r
+    idToFilterGroup = new HashMap();\r
+\r
+    filterTypes = new HashMap();\r
+    filterTypeIds = new ArrayList();\r
+    try {\r
+      Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator();\r
+      while (i.hasNext()) {\r
+        FilterType filterType = (FilterType) i.next();\r
+\r
+        filterTypes.put(filterType.getName(), filterType);\r
+        filterTypeIds.add(filterType.getName());\r
+      }\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException(t.getMessage());\r
+    }\r
+\r
+    model = aModel;\r
+\r
+    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");\r
+    dateFormat.setTimeZone(TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone")));\r
+    reload();\r
+  }\r
+\r
+  public Filter testPosting(Entity anEntity, Request aRequest) {\r
+    Iterator i = filterGroups.iterator();\r
+    while (i.hasNext()) {\r
+      FilterGroup group = (FilterGroup) i.next();\r
+      Iterator j = group.getFilters().iterator();\r
+      while (j.hasNext()) {\r
+        Filter filter = (Filter) j.next();\r
+        try {\r
+          if (filter.test(anEntity, aRequest)) {\r
+            return filter;\r
+          }\r
+        }\r
+        catch (Throwable t) {\r
+          logger.warn("Exception thrown while testing filter " + filter.getType() + " ( " + filter.getExpression() + ") " + t.toString());\r
+        }\r
+      }\r
+    }\r
+\r
+    return null;\r
+  }\r
+\r
+  public List getFilterTypes() {\r
+    try {\r
+      List result = new ArrayList();\r
+\r
+      Iterator i = filterTypeIds.iterator();\r
+      while (i.hasNext()) {\r
+        String id = (String) i.next();\r
+\r
+        Map action = new HashMap();\r
+        action.put("resource", id);\r
+        action.put("identifier", id);\r
+\r
+        result.add(action);\r
+      }\r
+\r
+      return result;\r
+    }\r
+    catch (Throwable t) {\r
+      throw new RuntimeException("can't get article actions");\r
+    }\r
+  }\r
+\r
+  public class FilterGroup {\r
+    private List filters;\r
+    private Entity entity;\r
+    private Map idToFilter;\r
+\r
+    public FilterGroup(Entity anEntity) {\r
+      this (anEntity, Collections.EMPTY_LIST);\r
+    }\r
+\r
+    public FilterGroup(Entity anEntity, List aFilters) {\r
+      entity = anEntity;\r
+      filters = new ArrayList();\r
+      idToFilter = new HashMap();\r
+      Iterator i = aFilters.iterator();\r
+\r
+      while (i.hasNext()) {\r
+        Entity entity = (Entity) i.next();\r
+        try {\r
+          Filter filter = new Filter(entity);\r
+          introduceFilter(filter);\r
+        }\r
+        catch (AbuseExc e) {\r
+        }\r
+      }\r
+    }\r
+\r
+    public Entity getEntity() {\r
+      return entity;\r
+    }\r
+\r
+    public EntityAdapter getEntityAdapter() {\r
+      return model.makeEntityAdapter("filterGroup",  entity);\r
+    }\r
+\r
+    public List getFilterEntityAdapterList() {\r
+      List result = new ArrayList();\r
+\r
+      Iterator i = filters.iterator();\r
+      while (i.hasNext()) {\r
+        Filter filter = (Filter) i.next();\r
+        result.add(filter.getEntityAdapter());\r
+      }\r
+\r
+      return result;\r
+    }\r
+\r
+    public List getFilters() {\r
+      return filters;\r
+    }\r
+\r
+    public Filter getFilterForId(String anId) {\r
+      Filter result = (Filter) idToFilter.get(anId);\r
+      if (result==null) {\r
+        throw new NullPointerException("No such filter");\r
+      }\r
+\r
+      return result;\r
+    }\r
+\r
+    private void introduceFilter(Filter aFilter) {\r
+      filters.add(aFilter);\r
+      idToFilter.put(aFilter.getEntity().getId(), aFilter);\r
+    }\r
+\r
+    private void removeFilter(Filter aFilter) {\r
+      filters.remove(aFilter);\r
+      idToFilter.remove(aFilter.getEntity().getId());\r
+    }\r
+\r
+    private void deleteFilter(String anId) {\r
+      Filter filter = getFilterForId(anId);\r
+      removeFilter(filter);\r
+      DatabaseFilter.getInstance().delete(anId);\r
+    }\r
+\r
+    public void populateFilterEntity(Entity anEntity, String aType, String anExpression,\r
+                             String aComments, String aTag, String anArticleAction,\r
+                             String aCommentAction) {\r
+\r
+      anEntity.setFieldValue("type", aType);\r
+      anEntity.setFieldValue("expression", anExpression);\r
+      anEntity.setFieldValue("comment", aComments);\r
+      anEntity.setFieldValue("tag", aTag);\r
+      anEntity.setFieldValue("articleaction", anArticleAction);\r
+      anEntity.setFieldValue("commentaction", aCommentAction);\r
+    }\r
+\r
+    public String updateFilter(String anId, String aType, String anExpression,\r
+                             String aComments, String aTag, String anArticleAction,\r
+                             String aCommentAction) {\r
+\r
+      try {\r
+        getFilterTypeForId(aType).constructFilterInstance(anExpression);\r
+      }\r
+      catch (AbuseExc e) {\r
+        return e.getMessage();\r
+      }\r
+\r
+      Entity entity = getFilterForId(anId).getEntity();\r
+      populateFilterEntity(entity, aType, anExpression, aComments, aTag,\r
+          anArticleAction, aCommentAction);\r
+      entity.update();\r
+\r
+      return "";\r
+    }\r
+\r
+    public String createFilter(String aType, String anExpression,\r
+                             String aComments, String aTag, String anArticleAction,\r
+                             String aCommentAction) throws StorageObjectExc {\r
+      FilterInstance instance;\r
+\r
+      try {\r
+        instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);\r
+      }\r
+      catch (AbuseExc e) {\r
+        return e.getMessage();\r
+      }\r
+\r
+      Entity entity = DatabaseFilter.getInstance().createNewEntity();\r
+      populateFilterEntity(entity, aType, anExpression, aComments, aTag,\r
+          anArticleAction, aCommentAction);\r
+      entity.setFieldValue("priority", "1");\r
+      entity.setFieldValue("filter_group_id", getEntity().getId());\r
+      entity.insert();\r
+\r
+      Filter filter = new Filter(entity, instance);\r
+      introduceFilter(filter);\r
+\r
+      return "";\r
+    }\r
+\r
+    public String getName() {\r
+      return entity.getFieldValue("name");\r
+    }\r
+  }\r
+\r
+  public class Filter {\r
+    private Entity entity;\r
+    private FilterInstance instance;\r
+\r
+    public Filter(Entity anEntity) throws AbuseExc {\r
+      this(anEntity, getFilterTypeForId(anEntity.getFieldValue("type")).constructFilterInstance(anEntity.getFieldValue("expression")));\r
+    }\r
+\r
+    public Filter(Entity anEntity, FilterInstance anInstance) {\r
+      entity = anEntity;\r
+      instance = anInstance;\r
+    }\r
+\r
+    public Entity getEntity() {\r
+      return entity;\r
+    }\r
+\r
+    public EntityAdapter getEntityAdapter() {\r
+      return model.makeEntityAdapter("filter", entity);\r
+    }\r
+\r
+    public void update(String aType, String anExpression, String aComments, String aTag,\r
+                       String anArticleAction, String aCommentAction) throws AbuseExc {\r
+\r
+      instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);\r
+\r
+      entity.setFieldValue("type", aType);\r
+      entity.setFieldValue("expression", anExpression);\r
+      entity.setFieldValue("tag", aType);\r
+      entity.setFieldValue("comment", aComments);\r
+      entity.setFieldValue("articleaction", anArticleAction);\r
+      entity.setFieldValue("commentaction", aCommentAction);\r
+      entity.setFieldValue("last_hit", null);\r
+      entity.update();\r
+   }\r
+\r
+    public void updateLastHit(Date aDate) {\r
+      entity.setFieldValue("last_hit", dateFormat.format(aDate));\r
+      entity.update();\r
+    }\r
+\r
+    public String getType() {\r
+      return entity.getFieldValue("type");\r
+    }\r
+\r
+    public String getExpression() {\r
+      return entity.getFieldValue("expression");\r
+    }\r
+\r
+    public String getTag() {\r
+      return entity.getFieldValue("tag");\r
+    }\r
+\r
+    public String getComment() {\r
+      return entity.getFieldValue("comment");\r
+    }\r
+\r
+    public String getArticleAction() {\r
+      return entity.getFieldValue("articleaction");\r
+    }\r
+\r
+    public String getCommentAction() {\r
+      return entity.getFieldValue("commentaction");\r
+    }\r
+\r
+    public FilterInstance getInstance() {\r
+      return instance;\r
+    }\r
+\r
+    public boolean test(Entity anEntity, Request aRequest) {\r
+      return instance.test(anEntity, aRequest);\r
+    }\r
+  }\r
+\r
+  public synchronized void reload() {\r
+    filterGroups.clear();\r
+    idToFilterGroup.clear();\r
+\r
+    Iterator i = new EntityIteratorAdapter("", "priority asc", 100, model, "filterGroup");\r
+\r
+    while (i.hasNext()) {\r
+      EntityAdapter entityAdapter = (EntityAdapter) i.next();\r
+      List filters = new ArrayList();\r
+      Iterator j = (Iterator) entityAdapter.get("to_filters");\r
+      while (j.hasNext()) {\r
+        filters.add(((EntityAdapter) j.next()).getEntity());\r
+      }\r
+\r
+      FilterGroup filterGroup = new FilterGroup(entityAdapter.getEntity(), filters);\r
+      introduceFilterGroup(filterGroup);\r
+    }\r
+  }\r
+\r
+  public synchronized List getFilterGroups() {\r
+    List result = new ArrayList();\r
+    Iterator i = filterGroups.iterator();\r
+    while (i.hasNext()) {\r
+      result.add(((FilterGroup) i.next()).getEntityAdapter());\r
+    }\r
+\r
+    return result;\r
+  }\r
+\r
+  public synchronized void updateFilterGroup(String anId, String aName) {\r
+    FilterGroup filterGroup = getFilterGroupForId(anId);\r
+    filterGroup.getEntity().setFieldValue("name", aName);\r
+    filterGroup.getEntity().update();\r
+  }\r
+\r
+  public synchronized void addFilterGroup(String aName) throws StorageObjectExc {\r
+    Entity entity = DatabaseFilterGroup.getInstance().createNewEntity();\r
+    entity.setFieldValue("name", aName);\r
+    entity.setFieldValue("priority", "1");\r
+    entity.insert();\r
+\r
+    FilterGroup filterGroup = new FilterGroup(entity);\r
+    introduceFilterGroup(filterGroup);\r
+  }\r
+\r
+  public synchronized void deleteFilterGroup(String anId) {\r
+\r
+    FilterGroup filterGroup = getFilterGroupForId(anId);\r
+    removeFilterGroup(filterGroup);\r
+    DatabaseFilter.getInstance().deleteByWhereClause("filter_group_id = " + anId);\r
+    DatabaseFilterGroup.getInstance().delete(anId);\r
+  }\r
+\r
+  public synchronized void deleteFilter(String aGroupId, String anId) {\r
+    getFilterGroupForId(aGroupId).deleteFilter(anId);\r
+  }\r
+\r
+\r
+  public synchronized String updateFilter(String aGroupId, String anId,\r
+                                        String aType, String anExpression,\r
+                                        String aComments,\r
+                                        String aTag,\r
+                                        String anArticleAction,\r
+                                        String aCommentAction) {\r
+    return getFilterGroupForId(aGroupId).updateFilter(anId, aType,\r
+        anExpression, aComments, aTag, anArticleAction, aCommentAction);\r
+  }\r
+\r
+  public synchronized String addFilter(String aGroupId,\r
+                                       String aType, String anExpression,\r
+                                       String aComments,\r
+                                       String aTag,\r
+                                       String anArticleAction,\r
+                                       String aCommentAction) throws StorageObjectExc {\r
+    return getFilterGroupForId(aGroupId).createFilter(aType, anExpression,\r
+        aComments, aTag, anArticleAction, aCommentAction);\r
+  }\r
+\r
+\r
+  public FilterGroup getFilterGroupForId(String anId) {\r
+    FilterGroup result = (FilterGroup) idToFilterGroup.get(anId);\r
+    if (result == null) {\r
+      throw new NullPointerException("No such filter group");\r
+    }\r
+\r
+    return result;\r
+  }\r
+\r
+  public Filter getFilterForId(String aGroupId, String anId) {\r
+    return getFilterGroupForId(aGroupId).getFilterForId(anId);\r
+  }\r
+\r
+\r
+  public List getFilters(String aFilterGroupId) {\r
+    return getFilterGroupForId(aFilterGroupId).getFilterEntityAdapterList();\r
+  }\r
+\r
+  private void introduceFilterGroup(FilterGroup aFilterGroup) {\r
+    filterGroups.add(aFilterGroup);\r
+    idToFilterGroup.put(aFilterGroup.getEntity().getId(), aFilterGroup);\r
+  }\r
+\r
+  private void removeFilterGroup(FilterGroup aFilterGroup) {\r
+    filterGroups.remove(aFilterGroup);\r
+    idToFilterGroup.remove(aFilterGroup.getEntity().getId());\r
+  }\r
+\r
+  private FilterType getFilterTypeForId(String anId) {\r
+    return (FilterType) filterTypes.get(anId);\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/FilterInstance.java b/source/mircoders/abuse/FilterInstance.java
new file mode 100755 (executable)
index 0000000..dd20409
--- /dev/null
@@ -0,0 +1,46 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+import mir.entity.Entity;\r
+import mir.session.Request;\r
+\r
+public interface FilterInstance {\r
+  /**\r
+   * Must return <code>true</code> if the posting matches the filter.\r
+   */\r
+  public boolean test(Entity anEntity, Request aRequest);\r
+\r
+  /**\r
+   * May return a desription of the "status" of this filter. (E.g. the number\r
+   * of hits)\r
+   */\r
+  public String status();\r
+}\r
diff --git a/source/mircoders/abuse/FilterParseExc.java b/source/mircoders/abuse/FilterParseExc.java
new file mode 100755 (executable)
index 0000000..aeb43c1
--- /dev/null
@@ -0,0 +1,36 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+public class FilterParseExc extends AbuseExc {\r
+  public FilterParseExc(String aMessage) {\r
+    super(aMessage);\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/FilterType.java b/source/mircoders/abuse/FilterType.java
new file mode 100755 (executable)
index 0000000..acf3726
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mircoders.abuse;
+
+
+
+/**
+ * Interface to define filter types for the anti-abuse system
+ */
+
+public interface FilterType {
+  /**
+   * The identifying name of the filter type. Must be unique.
+   *
+   * @return
+   */
+  public String getName();
+
+  /**
+   * Must construct a filter instance or throw an exception if
+   *    <code>anExpression</code> is not a valid expression.
+   */
+  public FilterInstance constructFilterInstance(String anExpression) throws AbuseExc;
+}
\ No newline at end of file
diff --git a/source/mircoders/abuse/IPFilterType.java b/source/mircoders/abuse/IPFilterType.java
new file mode 100755 (executable)
index 0000000..e601831
--- /dev/null
@@ -0,0 +1,80 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+import mir.util.InternetFunctions;\r
+import mir.entity.Entity;\r
+import mir.session.Request;\r
+\r
+/**\r
+ * A basic ip filter type. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.\r
+ */\r
+public class IPFilterType extends AbstractFilterType {\r
+  public IPFilterType(String aName) {\r
+    super(aName);\r
+  }\r
+\r
+  /**\r
+   *\r
+   */\r
+  public boolean validate(String anExpression) {\r
+    try {\r
+      InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);\r
+      return true;\r
+    }\r
+    catch (Throwable t) {\r
+      return false;\r
+    }\r
+  }\r
+\r
+  public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc {\r
+    try {\r
+      InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new AbuseExc("Invalid expression: " + anExpression);\r
+    }\r
+\r
+    return new FilterInstance() {\r
+      public boolean test(Entity anEntity, Request aRequest) {\r
+        try {\r
+          return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);\r
+        }\r
+        catch (Exception e) {\r
+          return false;\r
+        }\r
+      }\r
+\r
+      public String status() {\r
+        return "";\r
+      }\r
+    };\r
+  }\r
+}\r
diff --git a/source/mircoders/abuse/RegularExpressionFilterType.java b/source/mircoders/abuse/RegularExpressionFilterType.java
new file mode 100755 (executable)
index 0000000..13d1db5
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mircoders.abuse;
+
+import gnu.regexp.RE;
+import mir.entity.Entity;
+import mir.session.Request;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+  * A regular expression filter.
+  */
+ public class RegularExpressionFilterType extends AbstractFilterType {
+    private boolean exactMatch;
+    private boolean caseSensitive;
+    private int fieldKind;
+    private List selectedFields;
+
+    public static final int ENTITY_FIELDS = 0;
+    public static final int REQUEST_HEADERS = 2;
+
+    public RegularExpressionFilterType(String aName) {
+      this(aName, false, false, null);
+    }
+
+    public RegularExpressionFilterType(String aName, boolean aCaseSensitive, boolean anExactMatch, String[] aSelectedFields) {
+      this (aName, aCaseSensitive, anExactMatch, ENTITY_FIELDS, aSelectedFields);
+    }
+
+    public RegularExpressionFilterType(String aName, boolean aCaseSensitive, boolean anExactMatch, int aFieldKind, String[] aSelectedFields) {
+      super(aName);
+
+      fieldKind = aFieldKind;
+
+      caseSensitive = aCaseSensitive;
+      exactMatch = anExactMatch;
+      if (aSelectedFields==null)
+        selectedFields = null;
+      else
+        selectedFields = Arrays.asList(aSelectedFields);
+    }
+
+
+  public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc {
+    try {
+      new RE(anExpression);
+
+      return new FilterInstance() {
+
+        public boolean test(Entity anEntity, Request aRequest) {
+
+          try {
+            Iterator j;
+            int flags = 0;
+
+            if (!caseSensitive) {
+              flags |= RE.REG_ICASE;
+            }
+
+            RE regularExpression = new RE(anExpression, flags);
+
+            switch (fieldKind) {
+              case REQUEST_HEADERS:
+                if (selectedFields != null) {
+                  j = selectedFields.iterator();
+
+                  while (j.hasNext()) {
+                    String fieldName = (String) j.next();
+                    String field = aRequest.getHeader(fieldName);
+
+                    if (exactMatch) {
+                      if (field != null && regularExpression.isMatch(field)) {
+                        return true;
+                      }
+                    }
+                    else {
+                      if (field != null && regularExpression.getMatch(field) != null) {
+                        return true;
+                      }
+                    }
+                  }
+                }
+                break;
+              case ENTITY_FIELDS:
+                if (selectedFields != null)
+                  j = selectedFields.iterator();
+                else
+                  j = anEntity.getFieldNames().iterator();
+
+                while (j.hasNext()) {
+                  String field = anEntity.getFieldValue( (String) j.next());
+
+                  if (exactMatch) {
+                    if (field != null && regularExpression.isMatch(field)) {
+                      return true;
+                    }
+                  }
+                  else {
+                    if (field != null && regularExpression.getMatch(field) != null) {
+                      return true;
+                    }
+                  }
+                }
+            }
+          }
+          catch (Throwable t) {
+          }
+          return false;
+        }
+
+        public String status() {
+          return null;
+        }
+      };
+    }
+    catch (Throwable t) {
+      throw new AbuseExc("Invalid expression: " + t.getMessage());
+    }
+  }
+}
\ No newline at end of file
diff --git a/source/mircoders/abuse/ThrottleFilter.java b/source/mircoders/abuse/ThrottleFilter.java
new file mode 100755 (executable)
index 0000000..714f205
--- /dev/null
@@ -0,0 +1,151 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.abuse;\r
+\r
+import mir.entity.Entity;\r
+import mir.session.Request;\r
+import mir.util.StringRoutines;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+/**\r
+ * A ip-based throttling filter.\r
+ *\r
+ * <p>\r
+ * Expressions have the form <time in minutes>:<posting limit>\r
+ */\r
+public class ThrottleFilter extends AbstractFilterType {\r
+\r
+  public ThrottleFilter(String aName) {\r
+    super(aName);\r
+  }\r
+\r
+  public FilterInstance constructFilterInstance(String anExpression) throws AbuseExc {\r
+    List parts = StringRoutines.splitString(anExpression.trim(), ":");\r
+\r
+    if (parts.size()==2) {\r
+      try {\r
+        final int interval = Integer.parseInt((String) parts.get(0));\r
+        final int limit = Integer.parseInt((String) parts.get(1));\r
+\r
+        if (interval<1) {\r
+          throw new AbuseExc("Interval should be larger than 0");\r
+        }\r
+        if (limit<1) {\r
+          throw new AbuseExc("Limit should be larger than 0");\r
+        }\r
+        final ThrottleManager manager = new ThrottleManager(interval*1000*60);\r
+\r
+        return new FilterInstance() {\r
+          public boolean test(Entity anEntity, Request aRequest) {\r
+            manager.addMessage(aRequest.getHeader("ip"));\r
+            if (manager.count(aRequest.getHeader("ip")) > limit) {\r
+              return true;\r
+            }\r
+\r
+            return false;\r
+          }\r
+\r
+          public String status() {\r
+            return Integer.toString(manager.messages.size()) + " messages";\r
+          }\r
+        };\r
+      }\r
+      catch (AbuseExc e) {\r
+        throw e;\r
+      }\r
+      catch (Throwable t) {\r
+        throw new AbuseExc("Invalid expression: <interval>:<limit> expected");\r
+      }\r
+    }\r
+    else {\r
+      throw new AbuseExc("Invalid expression: <interval>:<limit> expected");\r
+    }\r
+  }\r
+\r
+  private class ThrottleManager {\r
+    private long horizon;\r
+    private List messages;\r
+\r
+    public ThrottleManager(long aHorizon) {\r
+      horizon = aHorizon;\r
+\r
+      messages = new ArrayList();\r
+    }\r
+\r
+    public void flush() {\r
+      long limit = System.currentTimeMillis() - horizon;\r
+\r
+      while (messages.size()>0 && ((Message) messages.get(0)).getTime()<=limit) {\r
+        messages.remove(0);\r
+      }\r
+    }\r
+\r
+    public void addMessage(String anIp) {\r
+      Message newMessage = new Message(anIp, System.currentTimeMillis());\r
+      messages.add(newMessage);\r
+    }\r
+\r
+    public int count(String anIp) {\r
+      flush();\r
+\r
+      int result = 0;\r
+      Iterator i = messages.iterator();\r
+      while (i.hasNext()) {\r
+        Message message = (Message) i.next();\r
+        if (message.getIp().equals(anIp)) {\r
+          result = result + 1;\r
+        }\r
+      }\r
+\r
+      return result;\r
+    }\r
+\r
+    private class Message {\r
+      private String ip;\r
+      private long time;\r
+\r
+      public Message(String anIp, long aTime) {\r
+        ip = anIp;\r
+        time = aTime;\r
+      }\r
+\r
+      public String getIp() {\r
+        return ip;\r
+      }\r
+\r
+      public long getTime() {\r
+        return time;\r
+      }\r
+    }\r
+  }\r
+}\r
index 8ec7dc2..f06443b 100755 (executable)
@@ -32,13 +32,11 @@ package mircoders.entity;
 
 import java.util.Map;
 
-import mir.storage.StorageObject;
-
 /**
  * This class handles storage of audio data and meta data
  *
  * @author mh
- * @version $Id: EntityAudio.java,v 1.11.2.1 2004/02/08 21:05:02 zapata Exp $
+ * @version $Id: EntityAudio.java,v 1.11.2.2 2005/01/09 20:37:10 zapata Exp $
  */
 
 
@@ -48,11 +46,6 @@ public class EntityAudio extends EntityUploadedMedia
     super();
   }
 
-  public EntityAudio(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
   public void setFieldValues(Map theStringValues) {
     if (theStringValues != null) {
       if (!theStringValues.containsKey("is_published"))
index a40c0e0..b5fc55a 100755 (executable)
 
 package mircoders.entity;
 
-import java.util.Map;
-
 import mir.entity.AbstractEntity;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseCommentToMedia;
 import mircoders.storage.DatabaseContent;
 
+import java.util.Map;
+
 /**
  * This class maps one line of the comment-table to a java-object.
  *
  * @author $Author: zapata $
- * @version $Revision: 1.16.2.3 $ $Date: 2004/02/08 21:05:02 $
+ * @version $Revision: 1.16.2.4 $ $Date: 2005/01/09 20:37:10 $
  */
 
 
@@ -53,12 +52,6 @@ public class EntityComment extends AbstractEntity {
     super();
   }
 
-  public EntityComment(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
-
   /**
    * overridden method setFieldValues to patch creator_main_url
    */
index 144eddc..09fc32e 100755 (executable)
 
 package mircoders.entity;
 
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Map;
-
 import mir.entity.AbstractEntity;
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseContentToMedia;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Map;
+
 /**
  * this class implements mapping of one line of the database table content
  * to a java object
  *
- * @version $Id: EntityContent.java,v 1.19.2.7 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.8 2005/01/09 20:37:10 zapata Exp $
  * @author mir-coders group
  *
  */
@@ -61,12 +60,6 @@ public class EntityContent extends AbstractEntity {
     logger = new LoggerWrapper("Entity.Content");
   }
 
-  public EntityContent(StorageObject theStorage) {
-    this();
-
-    setStorage(theStorage);
-  }
-
   /**
    * set is_produced flag for the article
    */
index 1cff969..8abaf44 100755 (executable)
 
 package mircoders.entity;
 
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.sql.SQLException;
-
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 import mir.util.StreamCopier;
 import mircoders.media.ImageProcessor;
 
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.sql.SQLException;
+
 /**
  *
  * @author RK, mh, mir-coders
- * @version $Id: EntityImages.java,v 1.21.2.5 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: EntityImages.java,v 1.21.2.6 2005/01/09 20:37:10 zapata Exp $
  */
 
 
@@ -62,11 +61,6 @@ public class EntityImages extends EntityUploadedMedia
     logger = new LoggerWrapper("Entity.UploadedMedia.Images");
   }
 
-  public EntityImages(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
   /**
    * Retrieves the image data
    */
index d05c5fd..53be655 100755 (executable)
@@ -32,8 +32,6 @@ package mircoders.entity;
 
 import java.util.Map;
 
-import mir.storage.StorageObject;
-
 /**
  * This class handles storage of other data and meta data
  *
@@ -48,11 +46,6 @@ public class EntityOther extends EntityUploadedMedia
     super();
   }
 
-  public EntityOther(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
   public void setFieldValues(Map theStringValues) {
     if (theStringValues != null) {
       if (!theStringValues.containsKey("is_published"))
index 38ad755..c606e5b 100755 (executable)
 package mircoders.entity;
 
 import mir.entity.StorableObjectEntity;
-import mir.storage.StorageObject;
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK
- * @version 29.6.1999
- */
-
 
 public class EntityTopics extends StorableObjectEntity {
   public EntityTopics(){
          super();
   }
-
-  public EntityTopics(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
-
 }
index 110f694..a6a1fcb 100755 (executable)
  */
 package mircoders.entity;
 
-import java.sql.SQLException;
-import java.util.Map;
-
 import mir.entity.AbstractEntity;
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseUploadedMedia;
 
+import java.sql.SQLException;
+import java.util.Map;
+
 /**
  *
  * @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.8 2004/11/21 22:07:13 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.9 2005/01/09 20:37:10 zapata Exp $
  */
 
 public class EntityUploadedMedia extends AbstractEntity {
@@ -52,12 +51,6 @@ public class EntityUploadedMedia extends AbstractEntity {
     logger = new LoggerWrapper("Entity.UploadedMedia");
   }
 
-  public EntityUploadedMedia(StorageObject theStorage) {
-    this();
-
-    setStorage(theStorage);
-  }
-
   public void update() throws StorageObjectFailure {
     super.update();
 
index ceedeee..edd7818 100755 (executable)
@@ -29,9 +29,7 @@
  */
 package mircoders.entity;
 
-import mir.entity.Entity;
 import mir.entity.AbstractEntity;
-import mir.storage.StorageObject;
 
 /**
  * This class is objectmapping of database webdb_users
@@ -48,12 +46,7 @@ public class EntityUsers extends AbstractEntity {
                        super();
                }
 
-               public EntityUsers(StorageObject theStorage) {
-                       this();
-                       setStorage(theStorage);
-               }
-
-       // Methods
+  // Methods
 
        public boolean isAdmin()
        {
index ed4aaee..19d0d44 100755 (executable)
  */
 package mircoders.entity;
 
-import java.util.Map;
-
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
-
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK
- * @version 11.11.2000
- */
 
+import java.util.Map;
 
-public class EntityVideo extends EntityUploadedMedia
-{
+public class EntityVideo extends EntityUploadedMedia {
   public EntityVideo() {
     super();
 
     logger = new LoggerWrapper("Entity.UploadedMedia.Video");
   }
 
-  public EntityVideo(StorageObject theStorage) {
-    this();
-    setStorage(theStorage);
-  }
-
   public void setFieldValues(Map theStringValues) {
     if (theStringValues != null) {
       if (!theStringValues.containsKey("is_published"))
index 0009749..02a111c 100755 (executable)
 
 package mircoders.global;
 
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Vector;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
+import mir.entity.adapter.EntityAdapterModel;
 import mir.log.LoggerWrapper;
 import mir.session.Request;
 import mir.util.DateTimeFunctions;
+import mir.util.EntityUtility;
 import mir.util.GeneratorFormatAdapters;
 import mir.util.StringRoutines;
-import mir.util.EntityUtility;
+import mircoders.abuse.FilterEngine;
 import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.localizer.MirAdminInterfaceLocalizer;
-import mircoders.localizer.MirAntiAbuseFilterType;
-
 import org.apache.commons.collections.ExtendedProperties;
 
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.*;
+
 
 public class Abuse {
-  private List filterRules;
-  private Map filterTypes;
-  private List filterTypeIds;
-  private int maxIdentifier;
   private LoggerWrapper logger;
   private int logSize;
   private boolean logEnabled;
@@ -78,17 +65,18 @@ public class Abuse {
   private String commentBlockAction;
   private List log;
   private File configFile = MirGlobal.config().getFile("Abuse.Config");
+  private FilterEngine filterEngine;
 
   private MirPropertiesConfiguration configuration;
 
   private static String cookieName = MirGlobal.config().getString("Abuse.CookieName");
   private static int cookieMaxAge = 60 * 60 * MirGlobal.config().getInt("Abuse.CookieMaxAge");
 
-  public Abuse() {
+  public Abuse(EntityAdapterModel aModel) {
     logger = new LoggerWrapper("Global.Abuse");
-    filterRules = new Vector();
-    maxIdentifier = 0;
-    log = new Vector();
+    filterEngine = new FilterEngine(aModel);
+
+    log = new ArrayList();
 
     try {
       configuration = MirPropertiesConfiguration.instance();
@@ -105,25 +93,13 @@ public class Abuse {
     openPostingDisabled = false;
     cookieOnBlock = false;
 
-    try {
-      filterTypes = new HashMap();
-      filterTypeIds = new Vector();
-
-      Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator();
-
-      while (i.hasNext()) {
-        MirAntiAbuseFilterType filterType = (MirAntiAbuseFilterType) i.next();
-        filterTypes.put(filterType.getName(), filterType);
-        filterTypeIds.add(filterType.getName());
-      }
-    }
-    catch (Throwable t) {
-      throw new RuntimeException("Can't get filter types: " + t.getMessage());
-    }
-
     load();
   }
 
+  public FilterEngine getFilterEngine() {
+    return filterEngine;
+  }
+
   private void setCookie(HttpServletResponse aResponse) {
     Random random = new Random();
 
@@ -152,28 +128,15 @@ public class Abuse {
     return false;
   }
 
-  FilterRule findMatchingFilter(Entity anEntity, Request aRequest) {
-    Iterator iterator = filterRules.iterator();
-
-    while (iterator.hasNext()) {
-      FilterRule rule = (FilterRule) iterator.next();
-
-      if (rule.test(anEntity, aRequest))
-        return rule;
-    }
-
-    return null;
-  }
-
   public void checkComment(EntityComment aComment, Request aRequest, HttpServletResponse aResponse) {
     try {
       long time = System.currentTimeMillis();
 
-      FilterRule filterRule = findMatchingFilter(aComment, aRequest);
+      FilterEngine.Filter matchingFilter = filterEngine.testPosting(aComment, aRequest);
 
-      if (filterRule != null) {
-        logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression() + "'");
-        filterRule.setLastHit(new GregorianCalendar().getTime());
+      if (matchingFilter != null) {
+        logger.debug("Match for " + matchingFilter.getTag());
+        matchingFilter.updateLastHit(new GregorianCalendar().getTime());
 
         StringBuffer line = new StringBuffer();
 
@@ -182,26 +145,22 @@ public class Abuse {
             (new GregorianCalendar()).getTime(), configuration.getString("Mir.DefaultTimezone")));
 
         line.append(" ");
-        line.append("filter");
-
-        line.append(" ");
-        line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
+        line.append(matchingFilter.getTag());
         EntityUtility.appendLineToField(aComment, "comment", line.toString());
 
-        MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction());
+        MirGlobal.performCommentOperation(null, aComment, matchingFilter.getCommentAction());
         setCookie(aResponse);
         save();
-        logComment(aComment, aRequest, filterRule.getType(), filterRule.getExpression());
+        logComment(aComment, aRequest, matchingFilter.getTag());
       }
-      else
+      else {
         logComment(aComment, aRequest);
+      }
 
-
-      logger.info("checkComment: " + (System.currentTimeMillis() - time) + "ms");
+      logger.debug("checkComment: " + (System.currentTimeMillis() - time) + "ms");
     }
     catch (Throwable t) {
-      t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-      logger.error("Abuse.checkComment: " + t.toString());
+      logger.error("Exception thrown while checking comment", t);
     }
   }
 
@@ -209,11 +168,11 @@ public class Abuse {
     try {
       long time = System.currentTimeMillis();
 
-      FilterRule filterRule = findMatchingFilter(anArticle, aRequest);
+      FilterEngine.Filter matchingFilter = filterEngine.testPosting(anArticle, aRequest);
 
-      if (filterRule != null) {
-        logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression() + "'");
-        filterRule.setLastHit(new GregorianCalendar().getTime());
+      if (matchingFilter != null) {
+        logger.debug("Match for " + matchingFilter.getTag());
+//        matchingFilter.updateLastHit(new GregorianCalendar().getTime());
 
         StringBuffer line = new StringBuffer();
 
@@ -222,25 +181,22 @@ public class Abuse {
             (new GregorianCalendar()).getTime(), configuration.getString("Mir.DefaultTimezone")));
 
         line.append(" ");
-        line.append("filter");
-
-        line.append(" ");
-        line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
+        line.append(matchingFilter.getTag());
         EntityUtility.appendLineToField(anArticle, "comment", line.toString());
 
-        MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction());
+        MirGlobal.performArticleOperation(null, anArticle, matchingFilter.getArticleAction());
         setCookie(aResponse);
         save();
-        logArticle(anArticle, aRequest, filterRule.getType(), filterRule.getExpression());
+        logArticle(anArticle, aRequest, matchingFilter.getTag());
       }
-      else
+      else {
         logArticle(anArticle, aRequest);
+      }
 
       logger.info("checkArticle: " + (System.currentTimeMillis() - time) + "ms");
     }
     catch (Throwable t) {
-      t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-      logger.error("Abuse.checkArticle: " + t.toString());
+      logger.error("Exception thrown while checking article", t);
     }
   }
 
@@ -306,7 +262,7 @@ public class Abuse {
   public List getLog() {
     synchronized (log) {
       try {
-        List result = new Vector();
+        List result = new ArrayList();
 
         Iterator i = log.iterator();
         while (i.hasNext()) {
@@ -321,8 +277,7 @@ public class Abuse {
           else
             entry.put("type", "comment");
           entry.put("browser", logEntry.getBrowserString());
-          entry.put("hitfiltertype", logEntry.getHitFilterType());
-          entry.put("hitfilterexpression", logEntry.getHitFilterExpression());
+          entry.put("filtertag", logEntry.getMatchingFilterTag());
 
           result.add(entry);
         }
@@ -336,112 +291,82 @@ public class Abuse {
   }
 
   public void logComment(Entity aComment, Request aRequest) {
-    logComment(aComment, aRequest, null, null);
+    logComment(aComment, aRequest, null);
   }
 
-  public void logComment(Entity aComment, Request aRequest, String aHitFilterType, String aHitFilterExpression) {
+  public void logComment(Entity aComment, Request aRequest, String aMatchingFilterTag) {
     String ipAddress = aRequest.getHeader("ip");
     String id = aComment.getId();
     String browser = aRequest.getHeader("User-Agent");
 
-    logComment(ipAddress, id, new Date(), browser, aHitFilterType, aHitFilterExpression);
+    logComment(ipAddress, id, new Date(), browser, aMatchingFilterTag);
   }
 
   public void logArticle(Entity anArticle, Request aRequest) {
-    logArticle(anArticle, aRequest, null, null);
+    logArticle(anArticle, aRequest, null);
   }
 
-  public void logArticle(Entity anArticle, Request aRequest, String aHitFilterType, String aHitFilterExpression) {
+  public void logArticle(Entity anArticle, Request aRequest, String aMatchingFilterTag) {
     String ipAddress = aRequest.getHeader("ip");
     String id = anArticle.getId();
     String browser = aRequest.getHeader("User-Agent");
 
-    logArticle(ipAddress, id, new Date(), browser, aHitFilterType, aHitFilterExpression);
+    logArticle(ipAddress, id, new Date(), browser, aMatchingFilterTag);
   }
 
-  public void logComment(String anIp, String anId, Date aTimeStamp, String aBrowser, String aHitFilterType, String aHitFilterExpression) {
-    appendLog(new LogEntry(aTimeStamp, anIp, aBrowser, anId, false, aHitFilterType, aHitFilterExpression));
+  public void logComment(String anIp, String anId, Date aTimeStamp, String aBrowser, String aMatchingFilterTag) {
+    appendLog(new LogEntry(aTimeStamp, anIp, aBrowser, anId, false, aMatchingFilterTag));
   }
 
-  public void logArticle(String anIp, String anId, Date aTimeStamp, String aBrowser, String aHitFilterType, String aHitFilterExpression) {
-    appendLog(new LogEntry(aTimeStamp, anIp, aBrowser, anId, true, aHitFilterType, aHitFilterExpression));
+  public void logArticle(String anIp, String anId, Date aTimeStamp, String aBrowser, String aMatchingFilterTag) {
+    appendLog(new LogEntry(aTimeStamp, anIp, aBrowser, anId, true, aMatchingFilterTag));
   }
 
-  public void load() {
-    synchronized (filterRules) {
-      try {
-        ExtendedProperties configuration = new ExtendedProperties();
-
-        try {
-          configuration = new ExtendedProperties(configFile.getAbsolutePath());
-        }
-        catch (FileNotFoundException e) {
-        }
-
-        getFilterConfig(filterRules, "abuse.filter", configuration);
-
-        setOpenPostingDisabled(configuration.getString("abuse.openPostingDisabled", "0").equals("1"));
-        setOpenPostingPassword(configuration.getString("abuse.openPostingPassword", "0").equals("1"));
-        setCookieOnBlock(configuration.getString("abuse.cookieOnBlock", "0").equals("1"));
-        setLogEnabled(configuration.getString("abuse.logEnabled", "0").equals("1"));
-        setLogSize(configuration.getInt("abuse.logSize", 10));
-        setArticleBlockAction(configuration.getString("abuse.articleBlockAction", ""));
-        setCommentBlockAction(configuration.getString("abuse.commentBlockAction", ""));
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.toString());
-      }
-    }
-  }
+  public synchronized void load() {
+    try {
+      ExtendedProperties configuration = new ExtendedProperties();
 
-  public void save() {
-    synchronized (filterRules) {
       try {
-        ExtendedProperties configuration = new ExtendedProperties();
-
-        setFilterConfig(filterRules, "abuse.filter", configuration);
-
-        configuration.addProperty("abuse.openPostingDisabled", getOpenPostingDisabled() ? "1" : "0");
-        configuration.addProperty("abuse.openPostingPassword", getOpenPostingPassword() ? "1" : "0");
-        configuration.addProperty("abuse.cookieOnBlock", getCookieOnBlock() ? "1" : "0");
-        configuration.addProperty("abuse.logEnabled", getLogEnabled() ? "1" : "0");
-        configuration.addProperty("abuse.logSize", Integer.toString(getLogSize()));
-        configuration.addProperty("abuse.articleBlockAction", getArticleBlockAction());
-        configuration.addProperty("abuse.commentBlockAction", getCommentBlockAction());
-
-        configuration.save(new BufferedOutputStream(new FileOutputStream(configFile),8192), "Anti abuse configuration");
+        configuration = new ExtendedProperties(configFile.getAbsolutePath());
       }
-      catch (Throwable t) {
-        throw new RuntimeException(t.toString());
+      catch (FileNotFoundException e) {
       }
+
+      setOpenPostingDisabled(configuration.getString("abuse.openPostingDisabled", "0").equals("1"));
+      setOpenPostingPassword(configuration.getString("abuse.openPostingPassword", "0").equals("1"));
+      setCookieOnBlock(configuration.getString("abuse.cookieOnBlock", "0").equals("1"));
+      setLogEnabled(configuration.getString("abuse.logEnabled", "0").equals("1"));
+      setLogSize(configuration.getInt("abuse.logSize", 10));
+      setArticleBlockAction(configuration.getString("abuse.articleBlockAction", ""));
+      setCommentBlockAction(configuration.getString("abuse.commentBlockAction", ""));
+    }
+    catch (Throwable t) {
+      throw new RuntimeException(t.toString());
     }
   }
 
-  public List getFilterTypes() {
+  public synchronized void save() {
     try {
-      List result = new Vector();
+      ExtendedProperties configuration = new ExtendedProperties();
 
-      Iterator i = filterTypeIds.iterator();
-      while (i.hasNext()) {
-        String id = (String) i.next();
+      configuration.addProperty("abuse.openPostingDisabled", getOpenPostingDisabled() ? "1" : "0");
+      configuration.addProperty("abuse.openPostingPassword", getOpenPostingPassword() ? "1" : "0");
+      configuration.addProperty("abuse.cookieOnBlock", getCookieOnBlock() ? "1" : "0");
+      configuration.addProperty("abuse.logEnabled", getLogEnabled() ? "1" : "0");
+      configuration.addProperty("abuse.logSize", Integer.toString(getLogSize()));
+      configuration.addProperty("abuse.articleBlockAction", getArticleBlockAction());
+      configuration.addProperty("abuse.commentBlockAction", getCommentBlockAction());
 
-        Map action = new HashMap();
-        action.put("resource", id);
-        action.put("identifier", id);
-
-        result.add(action);
-      }
-
-      return result;
+      configuration.save(new BufferedOutputStream(new FileOutputStream(configFile),8192), "Anti abuse configuration");
     }
     catch (Throwable t) {
-      throw new RuntimeException("can't get article actions");
+      throw new RuntimeException(t.toString());
     }
   }
 
   public List getArticleActions() {
     try {
-      List result = new Vector();
+      List result = new ArrayList();
 
       Iterator i = MirGlobal.localizer().adminInterface().simpleArticleOperations().iterator();
       while (i.hasNext()) {
@@ -464,7 +389,7 @@ public class Abuse {
 
   public List getCommentActions() {
     try {
-      List result = new Vector();
+      List result = new ArrayList();
 
       Iterator i = MirGlobal.localizer().adminInterface().simpleCommentOperations().iterator();
       while (i.hasNext()) {
@@ -485,283 +410,6 @@ public class Abuse {
     }
   }
 
-  public List getFilters() {
-    List result = new Vector();
-
-    synchronized (filterRules) {
-      Iterator i = filterRules.iterator();
-      while (i.hasNext()) {
-        FilterRule filter = (FilterRule) i.next();
-        result.add(filter.clone());
-      }
-      return result;
-    }
-  }
-
-  public String addFilter(String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction) {
-    return addFilter(aType, anExpression, aComments, aCommentAction, anArticleAction, null);
-  }
-
-  public String addFilter(String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aListHit) {
-    return addFilter(filterRules, aType, anExpression, aComments, aCommentAction, anArticleAction, aListHit);
-  }
-
-  public FilterRule getFilter(String anId) {
-    synchronized (filterRules) {
-      FilterRule result = findFilter(filterRules, anId);
-      if (result == null)
-        return result;
-      else
-        return (FilterRule) result.clone();
-    }
-  }
-
-  public String setFilter(String anIdentifier, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction) {
-    return setFilter(filterRules, anIdentifier, aType, anExpression, aComments, aCommentAction, anArticleAction);
-  }
-
-  public void deleteFilter(String anIdentifier) {
-    deleteFilter(filterRules, anIdentifier);
-  }
-
-  public void moveFilterUp(String anIdentifier) {
-    moveFilter(filterRules, anIdentifier, -1);
-  }
-
-  public void moveFilterDown(String anIdentifier) {
-    moveFilter(filterRules, anIdentifier, 1);
-  }
-
-  public void moveFilterToTop(String anIdentifier) {
-    setFilterPosition(filterRules, anIdentifier, 0);
-  }
-
-  public void moveFilterToBottom(String anIdentifier) {
-    setFilterPosition(filterRules, anIdentifier, Integer.MAX_VALUE);
-  }
-
-  private String addFilter(List aFilters, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aLastHit) {
-    MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);
-
-    if (type == null)
-      return "invalidtype";
-
-    if (!type.validate(anExpression)) {
-      return "invalidexpression";
-    }
-
-    FilterRule filter = new FilterRule();
-
-    filter.setId(generateId());
-    filter.setExpression(anExpression);
-    filter.setType(aType);
-    filter.setComments(aComments);
-    filter.setArticleAction(anArticleAction);
-    filter.setCommentAction(aCommentAction);
-    filter.setLastHit(aLastHit);
-
-    synchronized (aFilters) {
-      aFilters.add(filter);
-    }
-
-    return null;
-  }
-
-  private String setFilter(List aFilters, String anIdentifier, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction) {
-    MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);
-
-    if (type == null)
-      return "invalidtype";
-
-    if (!type.validate(anExpression)) {
-      return "invalidexpression";
-    }
-
-    synchronized (aFilters) {
-      FilterRule filter = findFilter(aFilters, anIdentifier);
-
-      if (filter != null) {
-        filter.setExpression(anExpression);
-        filter.setType(aType);
-        filter.setCommentAction(aCommentAction);
-        filter.setArticleAction(anArticleAction);
-        filter.setComments(aComments);
-      }
-
-      return null;
-    }
-  }
-
-  private FilterRule findFilter(List aFilters, String anIdentifier) {
-    synchronized (aFilters) {
-      Iterator i = aFilters.iterator();
-      while (i.hasNext()) {
-        FilterRule filter = (FilterRule) i.next();
-
-        if (filter.getId().equals(anIdentifier)) {
-          return filter;
-        }
-      }
-    }
-
-    return null;
-  }
-
-  private void setFilterPosition(List aFilters, String anIdentifier, int aPosition) {
-    synchronized (aFilters) {
-      if (aPosition<0)
-        aPosition=0;
-
-      for (int i = 0; i < aFilters.size(); i++) {
-        FilterRule rule = (FilterRule) aFilters.get(i);
-
-        if (rule.getId().equals(anIdentifier)) {
-          aFilters.remove(rule);
-
-          if (aPosition<aFilters.size())
-            aFilters.add(aPosition, rule);
-          else
-            aFilters.add(rule);
-          break;
-        }
-      }
-    }
-  }
-
-  private void moveFilter(List aFilters, String anIdentifier, int aDirection) {
-    synchronized (aFilters) {
-      for (int i = 0; i < aFilters.size(); i++) {
-        FilterRule rule = (FilterRule) aFilters.get(i);
-
-        if (rule.getId().equals(anIdentifier) && (i + aDirection >= 0) && (i + aDirection < aFilters.size())) {
-          aFilters.remove(rule);
-          aFilters.add(i + aDirection, rule);
-          break;
-        }
-      }
-    }
-  }
-
-  private void deleteFilter(List aFilters, String anIdentifier) {
-    synchronized (aFilters) {
-      FilterRule filter = findFilter(aFilters, anIdentifier);
-
-      if (filter != null) {
-        aFilters.remove(filter);
-      }
-    }
-  }
-
-  private String generateId() {
-    synchronized (this) {
-      maxIdentifier = maxIdentifier + 1;
-
-      return Integer.toString(maxIdentifier);
-    }
-  }
-
-  public class FilterRule {
-    private String identifier;
-    private String expression;
-    private String type;
-    private String comments;
-    private String articleAction;
-    private String commentAction;
-    private Date lastHit;
-
-    public FilterRule() {
-      expression = "";
-      type = "";
-      identifier = "";
-      comments = "";
-      articleAction = articleBlockAction;
-      commentAction = commentBlockAction;
-      lastHit = null;
-    }
-
-    public Date getLastHit() {
-      return lastHit;
-    }
-
-    public void setLastHit(Date aDate) {
-      lastHit = aDate;
-    }
-
-    public String getId() {
-      return identifier;
-    }
-
-    public void setId(String anId) {
-      identifier = anId;
-    }
-
-    public String getExpression() {
-      return expression;
-    }
-
-    public void setExpression(String anExpression) {
-      expression = anExpression;
-    }
-
-    public String getType() {
-      return type;
-    }
-
-    public void setType(String aType) {
-      type = aType;
-    }
-
-    public void setComments(String aComments) {
-      comments = aComments;
-    }
-
-    public String getComments() {
-      return comments;
-    }
-
-    public String getArticleAction() {
-      return articleAction;
-    }
-
-    public void setArticleAction(String anArticleAction) {
-      articleAction = anArticleAction;
-    }
-
-    public String getCommentAction() {
-      return commentAction;
-    }
-
-    public void setCommentAction(String aCommentAction) {
-      commentAction = aCommentAction;
-    }
-
-    public boolean test(Entity anEntity, Request aRequest) {
-      MirAntiAbuseFilterType filterType = (MirAntiAbuseFilterType) filterTypes.get(type);
-      try {
-        if (filterType != null)
-          return filterType.test(expression, anEntity, aRequest);
-      }
-      catch (Throwable t) {
-        logger.error("error while testing " + type + "-filter '" + expression + "'");
-      }
-
-      return false;
-    };
-
-    public Object clone() {
-      FilterRule result = new FilterRule();
-      result.setComments(getComments());
-      result.setExpression(getExpression());
-      result.setId(getId());
-      result.setType(getType());
-      result.setArticleAction(getArticleAction());
-      result.setCommentAction(getCommentAction());
-      result.setLastHit(getLastHit());
-
-      return result;
-    }
-  }
-
   private String escapeConfigListEntry(String aFilterPart) {
     return StringRoutines.replaceStringCharacters(aFilterPart,
         new char[] {'\\', ':'},
@@ -781,92 +429,25 @@ public class Abuse {
         new String[] {"\\", ":", "\n", "\r", "\t", " "});
   }
 
-  private void setFilterConfig(List aFilters, String aConfigKey, ExtendedProperties aConfiguration) {
-    synchronized (aFilters) {
-      Iterator i = aFilters.iterator();
-
-      while (i.hasNext()) {
-        FilterRule filter = (FilterRule) i.next();
-
-        String filterconfig =
-            escapeConfigListEntry(escapeFilterPart(filter.getType())) + ":" +
-            escapeConfigListEntry(escapeFilterPart(filter.getExpression())) + ":" +
-            escapeConfigListEntry(escapeFilterPart(filter.getArticleAction())) + ":" +
-            escapeConfigListEntry(escapeFilterPart(filter.getCommentAction())) + ":" +
-            escapeConfigListEntry(escapeFilterPart(filter.getComments())) + ":";
-
-        if (filter.getLastHit() != null)
-          filterconfig = filterconfig + filter.getLastHit().getTime();
-
-        aConfiguration.addProperty(aConfigKey, filterconfig);
-      }
-    }
-  }
-
-  private void getFilterConfig(List aFilters, String aConfigKey, ExtendedProperties aConfiguration) {
-    synchronized (aFilters) {
-      aFilters.clear();
-
-      if (aConfiguration.getStringArray(aConfigKey) != null) {
-
-        Iterator i = Arrays.asList(aConfiguration.getStringArray(aConfigKey)).
-            iterator();
-
-        while (i.hasNext()) {
-          String filter = (String) i.next();
-          List parts = StringRoutines.splitStringWithEscape(filter, ':', '\\');
-          if (parts.size() == 2) {
-            parts.add(articleBlockAction);
-            parts.add(commentBlockAction);
-            parts.add("");
-            parts.add("");
-          }
-
-          if (parts.size() >= 5) {
-            Date lastHit = null;
-
-            if (parts.size() >= 6) {
-              String lastHitString = (String) parts.get(5);
-
-              try {
-                lastHit = new Date(Long.parseLong(lastHitString));
-              }
-              catch (Throwable t) {
-              }
-            }
-
-            addFilter(deescapeFilterPart( (String) parts.get(0)),
-                      deescapeFilterPart( (String) parts.get(1)),
-                      deescapeFilterPart( (String) parts.get(4)),
-                      deescapeFilterPart( (String) parts.get(3)),
-                      deescapeFilterPart( (String) parts.get(2)), lastHit);
-          }
-        }
-      }
-    }
-  }
-
   private static class LogEntry {
     private String ipNumber;
     private String browserString;
     private String id;
     private Date timeStamp;
     private boolean isArticle;
-    private String hitFilterType;
-    private String hitFilterExpression;
+    private String matchingFilterTag;
 
-    public LogEntry(Date aTimeStamp, String anIpNumber, String aBrowserString, String anId, boolean anIsArticle, String aHitFilterType, String aHitFilterExpression) {
+    public LogEntry(Date aTimeStamp, String anIpNumber, String aBrowserString, String anId, boolean anIsArticle, String aMatchingFilterTag) {
       ipNumber = anIpNumber;
       browserString = aBrowserString;
       id = anId;
       isArticle = anIsArticle;
       timeStamp = aTimeStamp;
-      hitFilterType = aHitFilterType;
-      hitFilterExpression = aHitFilterExpression;
+      matchingFilterTag = aMatchingFilterTag;
     }
 
     public LogEntry(Date aTimeStamp, String anIpNumber, String aBrowserString, String anId, boolean anIsArticle) {
-      this(aTimeStamp, anIpNumber, aBrowserString, anId, anIsArticle, null, null);
+      this(aTimeStamp, anIpNumber, aBrowserString, anId, anIsArticle, null);
     }
 
     public String getIpNumber() {
@@ -881,12 +462,8 @@ public class Abuse {
       return id;
     }
 
-    public String getHitFilterType() {
-      return hitFilterType;
-    }
-
-    public String getHitFilterExpression() {
-      return hitFilterExpression;
+    public String getMatchingFilterTag() {
+      return matchingFilterTag;
     }
 
     public Date getTimeStamp() {
index f3722eb..d006205 100755 (executable)
@@ -35,7 +35,6 @@ import java.util.LinkedList;
 import java.util.Map;
 
 import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
 import mir.log.LoggerWrapper;
 
 public class MRUCache {
index 2306d96..e1ea9d4 100755 (executable)
 \r
 package mircoders.global;\r
 \r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
 import mir.bundle.BasicBundleFactory;\r
 import mir.bundle.BundleFactory;\r
 import mir.bundle.CascadingBundleFactory;\r
@@ -52,6 +46,9 @@ import mircoders.entity.EntityUsers;
 import mircoders.localizer.MirAdminInterfaceLocalizer;\r
 import mircoders.localizer.MirCachingLocalizerDecorator;\r
 import mircoders.localizer.MirLocalizer;\r
+import mircoders.localizer.MirLocalizerExc;\r
+\r
+import java.util.*;\r
 \r
 public class MirGlobal {\r
   static private MirLocalizer localizer;\r
@@ -113,15 +110,21 @@ public class MirGlobal {
 \r
     result.append((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/(1024*1024));\r
     result.append("M in use, ");\r
-    result.append(Thread.currentThread().activeCount()).append(" threads, ");\r
+    result.append(Thread.activeCount()).append(" threads, ");\r
     result.append(getDatabaseEngine().getStatus());\r
 \r
     return result.toString();\r
   }\r
 \r
   public synchronized static Abuse abuse() {\r
-    if (abuse==null)\r
-      abuse = new Abuse();\r
+    if (abuse==null) {\r
+      try {\r
+        abuse = new Abuse(localizer().dataModel().adapterModel());\r
+      }\r
+      catch (MirLocalizerExc e) {\r
+        throw new RuntimeException(e.getMessage());\r
+      }\r
+    }\r
 \r
     return abuse;\r
   }\r
@@ -254,7 +257,7 @@ public class MirGlobal {
   }\r
 \r
   public static List getLoggedInUsers() {\r
-    List result = new Vector();\r
+    List result = new ArrayList();\r
 \r
     synchronized (loggedInUsers) {\r
       Iterator i = loggedInUsers.entrySet().iterator();\r
index 33a6267..2c42426 100755 (executable)
@@ -178,7 +178,7 @@ public class ProducerEngine {
   }
 
   private List convertJobInfoList(List aJobInfoList) {
-    List result = new Vector();
+    List result = new ArrayList();
 
     Iterator i = aJobInfoList.iterator();
 
@@ -280,7 +280,7 @@ public class ProducerEngine {
 
     public static List parseProducerTaskList(String aList) throws MirGlobalExc {
       Iterator i;
-      List result = new Vector();
+      List result = new ArrayList();
 
       i = StringRoutines.splitString(aList, ";").iterator();
       while (i.hasNext()) {
diff --git a/source/mircoders/localizer/MirAntiAbuseFilterType.java b/source/mircoders/localizer/MirAntiAbuseFilterType.java
deleted file mode 100755 (executable)
index a9cf39d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two.  You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries.  If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.localizer;
-
-import mir.entity.Entity;
-import mir.session.Request;
-
-/**
- * Interface to define filter types for the anti-abuse system
- */
-
-public interface MirAntiAbuseFilterType {
-  /**
-   * The identifying name of the filter type. Must be unique.
-   *
-   * @return
-   */
-  public String getName();
-
-  /**
-   * Must return <code>true</code> if the expression is valid for this filter. <code>false</code> if not.
-   * @param anExpression
-   * @return
-   */
-  public boolean validate(String anExpression);
-
-  /**
-   * Must return <code>true</code> if the posting matches the filter.
-   * @param anExpression
-   * @return
-   */
-  public boolean test(String anExpression, Entity anEntity, Request aRequest);
-}
\ No newline at end of file
index b4a50df..fba4761 100755 (executable)
@@ -34,7 +34,7 @@ import mir.bundle.Bundle;
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
 import mir.entity.adapter.EntityAdapter;
-import mir.entity.adapter.EntityAdapterExc;
+import mir.entity.adapter.EntityAdapterFailure;
 import mir.generator.Generator;
 import mir.generator.GeneratorExc;
 import mir.log.LoggerWrapper;
@@ -117,14 +117,13 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(aContext);
     aContext.put("article", anArticle);
 
-
     try {
       aContext.put(
           "language",
           MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("language",
               new ModuleLanguage().languageForCode(configuration.getString("Mir.Localizer.Admin.ArticlePreviewLanguage"))));
     }
-    catch (EntityAdapterExc e) {
+    catch (EntityAdapterFailure e) {
       throw new MirLocalizerFailure("Can't create entity adapter", e);
     }
     catch (ModuleExc e) {
diff --git a/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java b/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java
deleted file mode 100755 (executable)
index 3fae846..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two.  You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries.  If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-
-package mircoders.localizer.basic;
-
-import gnu.regexp.RE;
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.session.Request;
-import mir.util.InternetFunctions;
-import mircoders.localizer.MirAntiAbuseFilterType;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-
-/**
- * Wrapper around a collection of common filter classes for Mir's
- * anti-abuse filtering system.
- */
-public class MirBasicAntiAbuseFilterTypes {
-  protected static final LoggerWrapper logger = new LoggerWrapper("Localizer.ProducerAssistant");
-
-  private MirBasicAntiAbuseFilterTypes() {
-  }
-
-  public static abstract class BasicFilterType implements MirAntiAbuseFilterType {
-    private String name;
-
-    public BasicFilterType(String aName) {
-      name = aName;
-    }
-
-    public String getName() {
-      return name;
-    }
-  }
-
-  /**
-   * A basic ip filter. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.
-   */
-  public static class IPFilter extends BasicFilterType {
-    /**
-     *
-     */
-    public IPFilter(String aName) {
-      super(aName);
-    }
-
-    /**
-     *
-     */
-    public boolean validate(String anExpression) {
-      try {
-        InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
-        return true;
-      }
-      catch (Throwable t) {
-        return false;
-      }
-    };
-
-    /**
-     *
-     */
-    public boolean test(String anExpression, Entity anEntity, Request aRequest) {
-      try {
-        return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);
-      }
-      catch (Throwable t) {
-        return false;
-      }
-    };
-  }
-
-  /**
-   * A regular expression filter.
-   */
-  public static class RegularExpressionFilter extends BasicFilterType {
-    private boolean exactMatch;
-    private boolean caseSensitive;
-    private int fieldKind;
-    private List selectedFields;
-
-    public static final int ENTITY_FIELDS = 0;
-    public static final int REQUEST_HEADERS = 2;
-
-    public RegularExpressionFilter(String aName) {
-      this(aName, false, false, null);
-    }
-
-    public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, String[] aSelectedFields) {
-      this (aName, aCaseSensitive, anExactMatch, ENTITY_FIELDS, aSelectedFields);
-    }
-
-    public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, int aFieldKind, String[] aSelectedFields) {
-      super(aName);
-
-      fieldKind = aFieldKind;
-
-      caseSensitive = aCaseSensitive;
-      exactMatch = anExactMatch;
-      if (aSelectedFields==null)
-        selectedFields = null;
-      else
-        selectedFields = Arrays.asList(aSelectedFields);
-    }
-
-    public boolean validate(String anExpression) {
-      try {
-        new RE(anExpression);
-        return true;
-      }
-      catch (Throwable t) {
-        return false;
-      }
-    };
-
-    public boolean test(String anExpression, Entity anEntity, Request aRequest) {
-      try {
-        Iterator j;
-        int flags = 0;
-
-        if (!caseSensitive) {
-          flags |= RE.REG_ICASE;
-        }
-
-        RE regularExpression = new RE(anExpression, flags);
-
-        switch (fieldKind) {
-          case REQUEST_HEADERS:
-            if (selectedFields != null) {
-              j = selectedFields.iterator();
-
-              while (j.hasNext()) {
-                String fieldName = (String) j.next();
-                String field = aRequest.getHeader(fieldName);
-
-                if (exactMatch) {
-                  if (field != null && regularExpression.isMatch(field)) {
-                    return true;
-                  }
-                }
-                else {
-                  if (field != null && regularExpression.getMatch(field) != null) {
-                    return true;
-                  }
-                }
-              }
-            }
-            break;
-          case ENTITY_FIELDS:
-            if (selectedFields != null)
-              j = selectedFields.iterator();
-            else
-              j = anEntity.getFieldNames().iterator();
-
-            while (j.hasNext()) {
-              String field = anEntity.getFieldValue( (String) j.next());
-
-              if (exactMatch) {
-                if (field != null && regularExpression.isMatch(field)) {
-                  return true;
-                }
-              }
-              else {
-                if (field != null && regularExpression.getMatch(field) != null) {
-                  return true;
-                }
-              }
-            }
-        }
-      }
-      catch (Throwable t) {
-      }
-      return false;
-    }
-  }
-
-}
\ No newline at end of file
index 8f5ac49..8c26f8d 100755 (executable)
@@ -38,9 +38,10 @@ import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
 import mircoders.media.MediaUploadProcessor;
 import mircoders.module.ModuleArticleType;
-import mircoders.module.ModuleContent;
 import mircoders.module.ModuleMediafolder;
-import mircoders.storage.*;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseContentToMedia;
+import mircoders.storage.DatabaseContentToTopics;
 
 import java.util.*;
 
@@ -49,7 +50,6 @@ import java.util.*;
  */
 
 public class MirBasicArticlePostingHandler extends MirBasicPostingSessionHandler {
-  protected ModuleContent contentModule = new ModuleContent();
   protected DatabaseContentToMedia contentToMedia = DatabaseContentToMedia.getInstance();
   protected DatabaseContent contentDatabase = DatabaseContent.getInstance();
 
@@ -136,7 +136,7 @@ public class MirBasicArticlePostingHandler extends MirBasicPostingSessionHandler
       String id;
       Map values = getIntersectingValues(aRequest, DatabaseContent.getInstance());
 
-      EntityContent article = (EntityContent) contentModule.createNew();
+      EntityContent article = (EntityContent) contentDatabase.createNewEntity();
       article.setFieldValues(values);
 
       finalizeArticle(aRequest, aSession, article);
index 3661b97..199fba4 100755 (executable)
  */
 package mircoders.localizer.basic;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import mir.entity.Entity;
-import mir.session.*;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.ValidationHelper;
 import mir.util.EntityUtility;
 import mircoders.entity.EntityComment;
-import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
 import mircoders.media.MediaUploadProcessor;
 import mircoders.module.ModuleComment;
 import mircoders.module.ModuleCommentStatus;
 import mircoders.module.ModuleMediafolder;
-import mircoders.storage.*;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseCommentToMedia;
+import mircoders.storage.DatabaseContent;
 
 /**
- *
- * <p>Title: Experimental session handler for comment postings </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
+ * Session handler for comment postings
+ * 
  * @author Zapata
- * @version 1.0
  */
 
 public class MirBasicCommentPostingHandler extends MirBasicPostingSessionHandler {
-  protected ModuleComment commentModule = new ModuleComment();
+  protected DatabaseComment commentDatabase = DatabaseComment.getInstance();
   protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();
 
 
@@ -122,7 +124,7 @@ public class MirBasicCommentPostingHandler extends MirBasicPostingSessionHandler
       String id;
       Map values = getIntersectingValues(aRequest, DatabaseComment.getInstance());
 
-      EntityComment comment = (EntityComment) commentModule.createNew();
+      EntityComment comment = (EntityComment) commentDatabase.createNewEntity();
       comment.setFieldValues(values);
       finalizeComment(aRequest, aSession, comment);
       id = comment.insert();
index 4a41049..89e1914 100755 (executable)
@@ -31,9 +31,7 @@ package mircoders.localizer.basic;
 \r
 import mir.config.MirPropertiesConfiguration;\r
 import mir.entity.Entity;\r
-import mir.entity.adapter.EntityAdapter;\r
-import mir.entity.adapter.EntityAdapterDefinition;\r
-import mir.entity.adapter.EntityAdapterModel;\r
+import mir.entity.adapter.*;\r
 import mir.generator.Generator;\r
 import mir.generator.GeneratorExc;\r
 import mir.generator.GeneratorFailure;\r
@@ -69,13 +67,12 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
       anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));\r
       anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));\r
 \r
-      anEntityAdapterDefinition.addCalculatedField("lockinguser", new ContentToUserField("to_locking_user"));\r
+      anEntityAdapterDefinition.addCalculatedField("lockinguser", new ToOneRelationField("to_locking_user", "id", "user"));\r
       anEntityAdapterDefinition.addCalculatedField("is_locked", new ContentToIsLockedField());\r
 \r
       anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());\r
       anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());\r
-      anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());\r
-\r
+      anEntityAdapterDefinition.addCalculatedField("language", new ToOneRelationField("to_language", "language", "id"));\r
       anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));\r
       anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField(""));\r
 \r
@@ -101,13 +98,13 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
       anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new ContentToMediaField( "otherMedia", false));\r
       anEntityAdapterDefinition.addCalculatedField("to_media_icon", new ContentToIconField());\r
 \r
-      anEntityAdapterDefinition.addCalculatedField("article_type", new ContentToArticleTypeField());\r
+      anEntityAdapterDefinition.addCalculatedField("article_type", new ToOneRelationField("to_article_type", "articleType", "id"));\r
 \r
       anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
       anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));\r
 \r
       anEntityAdapterDefinition.addCalculatedField("children", new ContentToChildrenField());\r
-      anEntityAdapterDefinition.addCalculatedField("parent", new ContentToParentField());\r
+      anEntityAdapterDefinition.addCalculatedField("parent", new ToOneRelationField("to_content", "content", "id"));\r
 \r
       anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Article.PublicUrl")));\r
 \r
@@ -142,7 +139,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
   protected void constructCommentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure {\r
     try {\r
       anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
-      anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());\r
+      anEntityAdapterDefinition.addCalculatedField("to_content", new ToOneRelationField("to_media", "content", "id"));\r
       anEntityAdapterDefinition.addCalculatedField("status", new CommentToStatusField());\r
 \r
       anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new CommentToMediaField( "uploadedMedia" ));\r
@@ -196,27 +193,27 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
       result.addMapping( "internalMessage", DatabaseMessages.getInstance(), definition);\r
 \r
       definition = new EntityAdapterDefinition();\r
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      definition.addCalculatedField("mediafolder", new ToOneRelationField("to_media_folder", "mediaFolder", "id"));\r
       definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
       definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
       definition.addCalculatedField("info", new MediaToMediaInfoField());\r
       result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition);\r
       definition = new EntityAdapterDefinition();\r
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      definition.addCalculatedField("mediafolder", new ToOneRelationField("to_media_folder", "mediaFolder", "id"));\r
       definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
       definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
       definition.addCalculatedField("info", new MediaToMediaInfoField());\r
       definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
       result.addMapping( "image", DatabaseImages.getInstance(), definition);\r
       definition = new EntityAdapterDefinition();\r
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      definition.addCalculatedField("mediafolder", new ToOneRelationField("to_media_folder", "mediaFolder", "id"));\r
       definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
       definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
       definition.addCalculatedField("info", new MediaToMediaInfoField());\r
       definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
       result.addMapping( "audio", DatabaseAudio.getInstance(), definition);\r
       definition = new EntityAdapterDefinition();\r
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      definition.addCalculatedField("mediafolder", new ToOneRelationField("to_media_folder", "mediaFolder", "id"));\r
       definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
       definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
       definition.addCalculatedField("info", new MediaToMediaInfoField());\r
@@ -224,7 +221,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
       result.addMapping( "video", DatabaseVideo.getInstance(), definition);\r
 \r
       definition = new EntityAdapterDefinition();\r
-      definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+      definition.addCalculatedField("mediafolder", new ToOneRelationField("to_media_folder", "mediaFolder", "id"));\r
       definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
       definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
       definition.addCalculatedField("info", new MediaToMediaInfoField());\r
@@ -246,6 +243,15 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
 \r
       result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());\r
 \r
+      definition = new EntityAdapterDefinition();\r
+      definition.addCalculatedField("to_filters",\r
+          new ToManyRelationField("id", "filter", "filter_group_id", "priority asc"));\r
+      result.addMapping("filterGroup", DatabaseFilterGroup.getInstance(), definition);\r
+      definition = new EntityAdapterDefinition();\r
+      definition.addDBDateField("lasthit", "last_hit", configuration.getString("Mir.DefaultTimezone"));\r
+      definition.addCalculatedField("to_filter_group",\r
+          new ToOneRelationField("filter_group_id", "filter_group", "id"));\r
+      result.addMapping("filter", DatabaseFilter.getInstance(), definition);\r
     }\r
     catch (Throwable t) {\r
       throw new MirLocalizerFailure(t.getMessage(), t);\r
@@ -254,20 +260,6 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     return result;\r
   }\r
 \r
-  protected class CommentToContentField implements EntityAdapterDefinition.CalculatedField {\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        return anEntityAdapter.getToOneRelation(\r
-                    "id="+anEntityAdapter.get("to_media"),\r
-                    "id",\r
-                    "content" );\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
   protected class CommentToStatusField implements EntityAdapterDefinition.CalculatedField {\r
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
@@ -292,7 +284,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
         Iterator i = operations.iterator();\r
-        List availableOperations = new Vector();\r
+        List availableOperations = new ArrayList();\r
 \r
         while (i.hasNext()) {\r
           MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =\r
@@ -384,21 +376,6 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     }\r
   }\r
 \r
-  protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        logger.debug("ContentToParentField.getFieldValue");\r
-        return anEntityAdapter.getToOneRelation(\r
-                    "id="+anEntityAdapter.get("to_content"),\r
-                    "id",\r
-                    "content" );\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
   protected class ContentToChildrenField implements EntityAdapterDefinition.CalculatedField {\r
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
@@ -412,49 +389,6 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
       }\r
     }\r
   }\r
-\r
-  protected class ContentToLanguageField implements EntityAdapterDefinition.CalculatedField {\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        return anEntityAdapter.getToOneRelation(\r
-                    "id="+anEntityAdapter.get("to_language"),\r
-                    "id",\r
-                    "language" );\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
-  protected class ContentToArticleTypeField implements EntityAdapterDefinition.CalculatedField {\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        return anEntityAdapter.getToOneRelation(\r
-                    "id="+anEntityAdapter.get("to_article_type"),\r
-                    "id",\r
-                    "articleType" );\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
-  protected class MediaToMediaFolderField implements EntityAdapterDefinition.CalculatedField {\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        return anEntityAdapter.getToOneRelation(\r
-                    "id="+anEntityAdapter.get("to_media_folder"),\r
-                    "id",\r
-                    "mediaFolder" );\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
   public static class MediaInfo {\r
     private MediaHandler mediaHandler;\r
 \r
@@ -550,7 +484,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
 \r
-        Vector extraTable = new Vector();\r
+        ArrayList extraTable = new ArrayList();\r
         extraTable.add("content_x_topic cxt");\r
         String condition = "cxt.content_id="+anEntityAdapter.get("id")+\r
           " and cxt.topic_id=t.id";\r
@@ -587,7 +521,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
         if (published)\r
           condition = "is_published='t' and " + condition;\r
 \r
-        List extraTables = new Vector();\r
+        List extraTables = new ArrayList();\r
         extraTables.add("content_x_media cxm");\r
 \r
         return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);\r
@@ -618,7 +552,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
         if (published)\r
           condition = "is_published='t' and " + condition;\r
 \r
-        List extraTables = new Vector();\r
+        List extraTables = new ArrayList();\r
         extraTables.add("content_x_media cxm");\r
 \r
         return anEntityAdapter.getComplexToOneRelation("m", extraTables, condition, "id", definition);\r
@@ -650,7 +584,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
         if (published)\r
            condition = "is_published='t' and " + condition;\r
 \r
-        List extraTables = new Vector();\r
+        List extraTables = new ArrayList();\r
         extraTables.add("comment_x_media cxm");\r
         return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);\r
 \r
@@ -759,7 +693,7 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
 \r
     public Object getValue(EntityAdapter anEntityAdapter) {\r
       try {\r
-        Vector extraTable = new Vector();\r
+        ArrayList extraTable = new ArrayList();\r
         extraTable.add(table+" m");\r
         String selectSql = "cxm.media_id=m.id and cxm.content_id="+\r
           anEntityAdapter.get("id");\r
@@ -776,26 +710,6 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
     }\r
   }\r
 \r
-  protected class ContentToUserField implements EntityAdapterDefinition.CalculatedField {\r
-    private String fieldName;\r
-\r
-    public ContentToUserField(String aFieldName) {\r
-      fieldName = aFieldName;\r
-    }\r
-\r
-    public Object getValue(EntityAdapter anEntityAdapter) {\r
-      try {\r
-        return anEntityAdapter.getToOneRelation(\r
-            "id=" + anEntityAdapter.get(fieldName),\r
-            "id",\r
-            "user");\r
-      }\r
-      catch (Throwable t) {\r
-        throw new RuntimeException(t.getMessage());\r
-      }\r
-    }\r
-  }\r
-\r
   protected class ContentToIsLockedField implements EntityAdapterDefinition.CalculatedField {\r
     private ModuleContent contentModule;\r
 \r
index 39d0908..1df0a86 100755 (executable)
@@ -32,12 +32,12 @@ package mircoders.localizer.basic;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Vector;
-import java.util.Collections;
+import java.util.ArrayList;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.generator.Generator;
@@ -56,7 +56,6 @@ import mircoders.entity.EntityContent;
 import mircoders.global.CacheKey;
 import mircoders.global.MirGlobal;
 import mircoders.module.ModuleContent;
-import mircoders.storage.DatabaseContent;
 
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.commons.net.smtp.SMTPReply;
@@ -292,7 +291,7 @@ public class MirBasicEmailArticleHandler implements SessionHandler {
 
 
   protected void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    List validationErrors = new Vector();
+    List validationErrors = new ArrayList();
     if (shouldSendMail(aRequest,aSession,aResponse,validationErrors)){
 
       sendMail(aRequest,aSession,aResponse);
index d5a898c..5501e7a 100755 (executable)
@@ -34,15 +34,17 @@ import mir.log.LoggerWrapper;
 import mir.session.Request;
 import mir.session.Session;
 import mir.session.SessionHandler;
+import mircoders.abuse.FilterType;
+import mircoders.abuse.ThrottleFilter;
+import mircoders.abuse.IPFilterType;
+import mircoders.abuse.RegularExpressionFilterType;
 import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
 import mircoders.global.ProducerEngine;
-import mircoders.localizer.MirAntiAbuseFilterType;
 import mircoders.localizer.MirLocalizerExc;
 import mircoders.localizer.MirLocalizerFailure;
 import mircoders.localizer.MirOpenPostingLocalizer;
-import mircoders.localizer.basic.filters.ThrottleFilter;
 
 import java.util.*;
 
@@ -77,26 +79,26 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
       throw new MirLocalizerFailure(t);
     }
 
-    filterTypes = new Vector();
+    filterTypes = new ArrayList();
     filterTypesMap = new HashMap();
 
-    addSimpleAntiAbuseFilterType(new MirBasicAntiAbuseFilterTypes.RegularExpressionFilter("regexp"));
-    addSimpleAntiAbuseFilterType(new MirBasicAntiAbuseFilterTypes.RegularExpressionFilter("useragent", false, false,
-        MirBasicAntiAbuseFilterTypes.RegularExpressionFilter.REQUEST_HEADERS, new String[] {"User-Agent"}));
-    addSimpleAntiAbuseFilterType(new MirBasicAntiAbuseFilterTypes.IPFilter("ip"));
-    addSimpleAntiAbuseFilterType(new MirBasicAntiAbuseFilterTypes.RegularExpressionFilter("hostname", false, false,
-        MirBasicAntiAbuseFilterTypes.RegularExpressionFilter.REQUEST_HEADERS, new String[] {"hostname"}));
+    addSimpleAntiAbuseFilterType(new RegularExpressionFilterType("regexp"));
+    addSimpleAntiAbuseFilterType(new RegularExpressionFilterType("useragent", false, false,
+        RegularExpressionFilterType.REQUEST_HEADERS, new String[] {"User-Agent"}));
+    addSimpleAntiAbuseFilterType(new IPFilterType("ip"));
+    addSimpleAntiAbuseFilterType(new RegularExpressionFilterType("hostname", false, false,
+        RegularExpressionFilterType.REQUEST_HEADERS, new String[] {"hostname"}));
     addSimpleAntiAbuseFilterType(new ThrottleFilter("throttle", 60*60*1000));
   }
 
   public SessionHandler getOpenSessionHandler(String aSessionType) throws MirLocalizerExc, MirLocalizerFailure  {
-    if (aSessionType!=null && aSessionType.equals("email"))
+    if ("email".equals(aSessionType))
       return new MirBasicEmailArticleHandler();
 
-    if (aSessionType!=null && aSessionType.equals("comment"))
+    if ("comment".equals(aSessionType))
       return new MirBasicCommentPostingHandler(configuration.getBoolean("Localizer.OpenSession.PersistentUploadedFiles"));
 
-    if (aSessionType.equals("translation"))
+    if ("translation".equals(aSessionType))
       return new MirBasicTranslationPostingHandler();
 
     return new MirBasicArticlePostingHandler(configuration.getBoolean("Localizer.OpenSession.PersistentUploadedFiles"));
@@ -173,7 +175,7 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
     filterTypesMap.remove(aName);
   }
 
-  public void addSimpleAntiAbuseFilterType(MirAntiAbuseFilterType aFilterType) {
+  public void addSimpleAntiAbuseFilterType(FilterType aFilterType) {
     removeSimpleAntiAbuseFilterType(aFilterType.getName());
     filterTypesMap.put(aFilterType.getName(), aFilterType);
     filterTypes.add(aFilterType);
index d762c0d..4839f72 100755 (executable)
  */
 package mircoders.localizer.basic;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
 import mir.config.MirPropertiesConfiguration;
 import mir.log.LoggerWrapper;
-import mir.session.*;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.SessionHandler;
+import mir.session.UploadedFile;
+import mir.session.ValidationError;
 import mir.storage.StorageObject;
 import mir.util.ExceptionFunctions;
 import mir.util.FileFunctions;
 import mircoders.global.MirGlobal;
-import mircoders.module.ModuleMediaType;
 import mircoders.media.UnsupportedMediaTypeExc;
 
-import java.io.*;
-import java.util.*;
-
 /**
  * Extensible handler for open postings.
  * Behaviour can be altered by overriding methods.
index 66d5596..a1a0982 100755 (executable)
 package mircoders.localizer.basic;
 
 import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import mir.entity.adapter.EntityAdapterModel;
 import mir.generator.Generator;
@@ -66,7 +62,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
       logger = new LoggerWrapper("Localizer.Basic.Producer");
 
       producerRecipes = new HashMap();
-      producerRecipeNames = new Vector();
+      producerRecipeNames = new ArrayList();
 
       String[] recipes = MirGlobal.config().getStringArray("Mir.Localizer.Producer.ProducerRecipes");
       for (int i = 0; i<recipes.length; i++) {
@@ -136,7 +132,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
    */
   public List loadFactories() throws MirLocalizerExc {
       try {
-        List producers = new Vector();
+        List producers = new ArrayList();
         ProducerConfigReader reader;
         ProducerNodeBuilderLibrary library = new ProducerNodeBuilderLibrary();
         setupProducerNodeBuilderLibrary(library);
index d7f8eba..6c5a405 100755 (executable)
@@ -37,22 +37,9 @@ import mir.session.SessionExc;
 import mir.session.SessionFailure;
 import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
-import mircoders.localizer.basic.MirBasicChildArticlePostingHandler;
 import mircoders.module.ModuleArticleType;
-import mircoders.storage.DatabaseArticleType;
 import mircoders.storage.DatabaseContent;
 
-
-/**
- *
- * <p>Title: Session handler for translation postings </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author Zapata
- * @version 1.0
- */
-
 public class MirBasicTranslationPostingHandler extends MirBasicChildArticlePostingHandler {
   public MirBasicTranslationPostingHandler() {
     super();
index 363b997..1e6b304 100755 (executable)
  */\r
 package mircoders.localizer.basic;\r
 \r
-import mir.util.*;\r
-import mir.config.MirPropertiesConfiguration;\r
-\r
 import java.util.Collections;\r
 import java.util.List;\r
 \r
+import mir.util.HTMLRoutines;\r
+import mir.util.JDBCStringRoutines;\r
+import mir.util.ParameterExpander;\r
+import mir.util.RewindableIterator;\r
+import mir.util.StringRoutines;\r
+import mir.util.StructuredContentParser;\r
+import mir.util.SubsetIterator;\r
+\r
 public class MirBasicUtilityFunctions {\r
   public String encodeXML(Object anObject) throws Exception {\r
     return HTMLRoutines.encodeXML(StringRoutines.interpretAsString(anObject));\r
diff --git a/source/mircoders/localizer/basic/filters/ThrottleFilter.java b/source/mircoders/localizer/basic/filters/ThrottleFilter.java
deleted file mode 100755 (executable)
index 65b4732..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with  any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two.  You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries.  If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer.basic.filters;\r
-\r
-import mircoders.localizer.basic.MirBasicAntiAbuseFilterTypes;\r
-import mircoders.entity.EntityComment;\r
-\r
-import java.util.*;\r
-\r
-import mir.util.StringRoutines;\r
-import mir.entity.Entity;\r
-import mir.session.Request;\r
-\r
-/**\r
- * A ip-based throttling filter.\r
- *\r
- * <p>\r
- * Expressions have the form <time in minutes>:<posting limit>\r
- */\r
-public class ThrottleFilter extends MirBasicAntiAbuseFilterTypes.BasicFilterType {\r
-  private long overallHorizon;\r
-\r
-  private ThrottleManager throttleManager;\r
-\r
-  public ThrottleFilter(String aName, long anOverallHorizon) {\r
-    super(aName);\r
-\r
-    overallHorizon = anOverallHorizon;\r
-    throttleManager = new ThrottleManager(overallHorizon);\r
-  }\r
-\r
-  /** * {@inheritDoc} */\r
-  public boolean validate(String anExpression) {\r
-    List parts = StringRoutines.splitString(anExpression.trim(), ":");\r
-\r
-    try {\r
-      if (parts.size()==2) {\r
-        Integer.parseInt((String) parts.get(0));\r
-        Integer.parseInt((String) parts.get(1));\r
-\r
-        return true;\r
-      }\r
-    }\r
-    catch (Throwable t) {\r
-    }\r
-\r
-    return false;\r
-  }\r
-\r
-  /**\r
-   *\r
-   */\r
-  public boolean test(String anExpression, Entity anEntity, Request aRequest) {\r
-    String ip = aRequest.getHeader("ip");\r
-    int limit;\r
-    long period;\r
-\r
-    List parts = StringRoutines.splitString(anExpression, ":");\r
-\r
-    try {\r
-      period = Integer.parseInt((String) parts.get(0))*1000*60;\r
-      limit = Integer.parseInt((String) parts.get(1));\r
-    }\r
-    catch (Throwable t) {\r
-      return false;\r
-    }\r
-\r
-    return throttleManager.addMessage(ip, anEntity, limit, period);\r
-  };\r
-\r
-  private class ThrottleManager {\r
-    private Map throttles;\r
-    private long overallHorizon;\r
-    private Thread cleanUpThread;\r
-\r
-    public ThrottleManager(long anOverallHorizon) {\r
-      throttles = new HashMap();\r
-      overallHorizon = anOverallHorizon;\r
-\r
-      cleanUpThread = new Thread() {\r
-        public void run() {\r
-          while (true) {\r
-            synchronized(throttles) {\r
-              List toDelete = new ArrayList();\r
-              Iterator i = throttles.entrySet().iterator();\r
-\r
-              while (i.hasNext()) {\r
-                Map.Entry entry = (Map.Entry) i.next();\r
-                try {\r
-                  if (((Throttle) entry.getValue()).flush()) {\r
-                    toDelete.add(entry.getKey());\r
-                  }\r
-                }\r
-                catch (Throwable t) {\r
-                  toDelete.add(entry.getKey());\r
-                }\r
-              }\r
-\r
-              i = toDelete.iterator();\r
-              while (i.hasNext()) {\r
-                throttles.remove(i.next());\r
-              }\r
-            }\r
-            try {\r
-              Thread.sleep(60*10*1000);\r
-            }\r
-            catch (InterruptedException e) {\r
-              break;\r
-            }\r
-          }\r
-        }\r
-      };\r
-\r
-      cleanUpThread.setDaemon(true);\r
-      cleanUpThread.start();\r
-    }\r
-\r
-    public boolean addMessage(String anIP, Entity anEntity, int aLimit, long aPeriod) {\r
-      synchronized (throttles) {\r
-        Throttle throttle = (Throttle) throttles.get(anIP);\r
-\r
-        if (throttle==null) {\r
-          throttle = new Throttle(overallHorizon);\r
-          throttles.put(anIP, throttle);\r
-        }\r
-        return throttle.addMessage(anEntity, aLimit, aPeriod);\r
-      }\r
-    }\r
-\r
-    private class Throttle {\r
-      private List messages;\r
-      private long horizon;\r
-\r
-      public Throttle(long aHorizon) {\r
-        messages = new ArrayList();\r
-        horizon = aHorizon;\r
-      }\r
-\r
-      public boolean flush() {\r
-        long limit = System.currentTimeMillis() - horizon;\r
-\r
-        while (messages.size()>0 && ((Message) messages.get(0)).getTime()<=limit) {\r
-          messages.remove(0);\r
-        }\r
-\r
-        return messages.size()==0;\r
-      }\r
-\r
-      public boolean addMessage(Entity anEntity, int aLimit, long aPeriod) {\r
-        Message lastMessage=null;\r
-        if (messages.size()>0) {\r
-          lastMessage = (Message) messages.get(messages.size()-1);\r
-        }\r
-\r
-        Message newMessage = new Message(anEntity.getId(),\r
-                anEntity instanceof EntityComment, System.currentTimeMillis());\r
-\r
-        if (!newMessage.equals(lastMessage))\r
-          messages.add(newMessage);\r
-\r
-        if (messages.size()>=aLimit) {\r
-          Message message = (Message) messages.get(messages.size()-aLimit);\r
-          return (System.currentTimeMillis()-message.getTime())<aPeriod;\r
-        }\r
-\r
-        return false;\r
-      }\r
-\r
-      private class Message {\r
-        private String id;\r
-        private boolean isComment;\r
-        private long time;\r
-\r
-        public Message(String anId, boolean anIsComment, long aTime) {\r
-          id = anId;\r
-          isComment = anIsComment;\r
-          time = aTime;\r
-        }\r
-\r
-        public String getId() {\r
-          return id;\r
-        }\r
-\r
-        public boolean getIsComment() {\r
-          return isComment;\r
-        }\r
-\r
-        public long getTime() {\r
-          return time;\r
-        }\r
-\r
-        public int hashCode() {\r
-          return getId().hashCode();\r
-        }\r
-\r
-        public boolean equals(Object anObject) {\r
-          if (anObject instanceof Message) {\r
-            Message that = (Message) anObject;\r
-\r
-            if (that.getId().equals(getId()) && that.getIsComment() == getIsComment()) {\r
-              return true;\r
-            }\r
-          }\r
-\r
-          return false;\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
index 9479315..d563200 100755 (executable)
 package mircoders.media;
 
 import java.io.File;
-import java.io.InputStream;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.util.List;
-import java.util.Vector;
-import java.util.ArrayList;
+import java.io.InputStream;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
@@ -45,8 +42,8 @@ import mir.media.MediaFailure;
 import mir.media.MediaHandler;
 import mir.misc.FileUtil;
 import mir.misc.StringUtil;
-import mir.session.UploadedFile;
 import mir.session.SessionExc;
+import mir.session.UploadedFile;
 import mircoders.entity.EntityImages;
 
 /**
@@ -63,7 +60,7 @@ import mircoders.entity.EntityImages;
  *
  * @see mir.media.MediaHandler
  * @author mh
- * @version $Id: MediaHandlerImages.java,v 1.23.2.5 2004/11/21 22:07:14 zapata Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.23.2.6 2005/01/09 20:37:12 zapata Exp $
  */
 
 
index 0e0a457..d6f8454 100755 (executable)
 package  mircoders.media;
 
 import java.io.StringReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
 
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
index 3cbeb21..54aa624 100755 (executable)
 package  mircoders.media;
 
 import java.io.StringReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
 
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
@@ -53,7 +49,7 @@ import mir.misc.StringUtil;
  * @see mir.media.MediaHandlerGeneric
  * @see mir.media.MediaHandler
  * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.5 2004/11/21 22:07:14 zapata Exp $
+ * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.6 2005/01/09 20:37:12 zapata Exp $
  */
 
 
index 8825e89..beb7795 100755 (executable)
@@ -90,15 +90,8 @@ public class MediaUploadProcessor {
     values.put("to_media_type", mediaType.getId());
 
     try {
-      mediaEntity = (Entity) mediaStorage.getEntityClass().newInstance();
-      mediaEntity.setStorage(mediaStorage);
-    }
-    catch (Throwable e) {
-      throw new MediaFailure(e);
-    }
-
-    mediaEntity.setFieldValues(values);
-    try {
+      mediaEntity = mediaStorage.createNewEntity();
+      mediaEntity.setFieldValues(values);
       mediaEntity.insert();
       mediaHandler.store(aFile, mediaEntity, mediaType);
     }
index 7c0e6d2..7be662b 100755 (executable)
@@ -33,17 +33,7 @@ import mir.log.LoggerWrapper;
 import mir.module.AbstractModule;
 import mircoders.storage.DatabaseBreaking;
 
-
-
-/*
- *
- *
- *
- * @author RK
- */
-
-public class ModuleBreaking extends AbstractModule
-{
+public class ModuleBreaking extends AbstractModule {
   static LoggerWrapper logger = new LoggerWrapper("Module.Breaking");
 
   public ModuleBreaking ()
index 565d3d9..069dc99 100755 (executable)
@@ -66,6 +66,7 @@ public class ModuleLanguage extends AbstractModule {
   public Entity languageForCode(String aCode) throws ModuleExc, ModuleFailure {
     try {
       EntityList list = storage.selectByFieldValue("code", aCode);
+      
       if (list.size()>0) {
         return list.elementAt(0);
       }
index 0dfb7de..aedb191 100755 (executable)
@@ -42,7 +42,6 @@ import mir.log.LoggerWrapper;
 import mir.module.AbstractModule;
 import mir.module.ModuleExc;
 import mir.module.ModuleFailure;
-import mir.storage.StorageObject;
 import mir.util.JDBCStringRoutines;
 import mircoders.storage.DatabaseMediafolder;
 
index 4cc74c2..049f8b3 100755 (executable)
  */
 package mircoders.pdf;
 
+import com.lowagie.text.*;
+import com.lowagie.text.pdf.*;
 import gnu.regexp.RE;
 import gnu.regexp.REException;
 import gnu.regexp.REMatch;
 import gnu.regexp.REMatchEnumeration;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Iterator;
-import java.util.Vector;
-
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.EntityBrowser;
 import mir.log.LoggerWrapper;
@@ -49,20 +44,12 @@ import mircoders.entity.EntityContent;
 import mircoders.entity.EntityImages;
 import mircoders.storage.DatabaseImages;
 
-import com.lowagie.text.BadElementException;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Element;
-import com.lowagie.text.Font;
-import com.lowagie.text.Image;
-import com.lowagie.text.PageSize;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.pdf.BaseFont;
-import com.lowagie.text.pdf.ColumnText;
-import com.lowagie.text.pdf.PdfContentByte;
-import com.lowagie.text.pdf.PdfTemplate;
-import com.lowagie.text.pdf.PdfWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 public class PDFGenerator{
 
@@ -267,7 +254,7 @@ public class PDFGenerator{
       ict.setColumns(leftIndexCols,rightIndexCols);
       ict.setYLine(currentYPosition);
       ict.setAlignment(Element.ALIGN_LEFT);
-      int status=ict.go();
+      ict.go();
       currentYPosition = toYPosition;
     }
     catch(DocumentException de) {
@@ -325,12 +312,12 @@ public class PDFGenerator{
     fct.setColumns(leftFooterCols,rightFooterCols);
     fct.setYLine(bottomEdge+footerHeight-1);
     fct.setAlignment(Element.ALIGN_JUSTIFIED);
-    int status=fct.go();
+    fct.go();
 
     Paragraph numberP=new Paragraph((new Integer(currentPage)).toString(),new Font(footerFontFamily,footerFontSize,Font.BOLD));
     fct.addText(numberP);
     fct.setAlignment(Element.ALIGN_RIGHT);
-    status=fct.go();
+    fct.go();
 
     }
     catch (DocumentException de){
@@ -633,7 +620,7 @@ public class PDFGenerator{
      * source
     */
 
-    Vector extraTables = new Vector();
+    List extraTables = new ArrayList();
     extraTables.add("content_x_media cxm");
     Iterator images = new EntityBrowser(
       DatabaseImages.getInstance(), "i", extraTables,
index e7c8034..4427b67 100755 (executable)
 package mircoders.producer;
 
 import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
@@ -105,7 +101,7 @@ public class PDFPreFormattingProducerNode implements ProducerNode {
       ArrayList brokenUpContent = new ArrayList();
 
 
-      Vector extraTables = new Vector();
+      List extraTables = new ArrayList();
       extraTables.add("content_x_media cxm");
       Iterator images = new EntityBrowser(
         DatabaseImages.getInstance(), "i", extraTables,
index c01fab3..9dc4abf 100755 (executable)
  */
 package mircoders.producer;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import mir.log.LoggerWrapper;
 import mir.producer.ProducerFailure;
@@ -45,7 +38,6 @@ import mir.util.ExceptionFunctions;
 import mir.util.ParameterExpander;
 
 import org.apache.xmlrpc.XmlRpcClient;
-import org.apache.xmlrpc.XmlRpcException;
 
 
 public class RadicalendarProducerNode implements ProducerNode {
@@ -66,11 +58,9 @@ public class RadicalendarProducerNode implements ProducerNode {
       String expandedGroupName = ParameterExpander.expandExpression( aValueMap, groupname);
       String expandedGMTOffset = ParameterExpander.expandExpression( aValueMap, gmtoffset);
       
-      HashMap events=new HashMap();
-
       XmlRpcClient xmlrpc = new XmlRpcClient ("http://radicalendar.org:80/xmlresponderweek.php");
-      Vector params = new Vector ();
-      params.addElement(expandedGroupName+":"+expandedGMTOffset); //(shortname from calendar.getGroups)+gmtoffset in minutes
+      Vector params = new Vector();
+      params.add(expandedGroupName+":"+expandedGMTOffset); //(shortname from calendar.getGroups)+gmtoffset in minutes
       Hashtable result = (Hashtable) xmlrpc.execute ("calendar.getWeek", params);
     
 
index 3468419..e4aefc6 100755 (executable)
 
 package mircoders.search;
 
-import java.util.Iterator;
-import java.util.Map; 
-import java.util.Vector;
+import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
-import mircoders.storage.DatabaseContentToMedia;
 import mircoders.storage.DatabaseAudio;
 
 import org.apache.lucene.document.Document;
@@ -53,7 +49,7 @@ public class AudioSearchTerm extends SearchTerm{
 
   public void index(Document doc, Entity entity) throws StorageObjectFailure{
       //    EntityList audio = DatabaseContentToMedia.getInstance().getAudio((EntityContent) entity);
-    Vector extraTables = new Vector();
+    List extraTables = new ArrayList();
     extraTables.add("content_x_media cxm");
     Iterator audios = new EntityBrowser(
                                        DatabaseAudio.getInstance(), "i", extraTables,
index 275cb44..10673d8 100755 (executable)
@@ -36,12 +36,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.Vector;
+
 import javax.servlet.http.HttpServletRequest;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
 import mircoders.entity.EntityImages;
 import mircoders.storage.DatabaseImages;
 
@@ -55,7 +55,7 @@ public class ImagesSearchTerm extends SearchTerm{
   }
 
   public void index(Document doc, Entity entity) throws StorageObjectFailure{
-    Vector extraTables = new Vector();
+    List extraTables = new ArrayList();
     extraTables.add("content_x_media cxm");
 
     Iterator images = new EntityBrowser(
index 60137ce..40c1934 100755 (executable)
  */
 package mircoders.search;
 
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityContent;
 import mircoders.storage.DatabaseVideo;
 
 import org.apache.lucene.document.Document;
@@ -53,7 +50,7 @@ public class VideoSearchTerm extends SearchTerm {
   }
 
   public void index(Document doc, Entity entity) throws StorageObjectFailure {
-    Vector extraTables = new Vector();
+    List extraTables = new ArrayList();
     extraTables.add("content_x_media cxm");
 
     Iterator videos = new EntityBrowser(
index e026be6..9d017b1 100755 (executable)
 
 package mircoders.servlet;
 
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
+import mir.storage.StorageObjectExc;
 import mir.util.HTTPRequestParser;
 import mir.util.URLBuilder;
-import mircoders.global.Abuse;
+import mircoders.abuse.FilterEngine;
 import mircoders.global.MirGlobal;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
 public class ServletModuleAbuse extends ServletModule {
   private static ServletModuleAbuse instance = new ServletModuleAbuse();
   private String editFilterTemplate;
   private String listFiltersTemplate;
+  private String editFilterGroupTemplate;
+  private String listFilterGroupsTemplate;
   private String mainTemplate;
   private String viewLogTemplate;
 
@@ -60,43 +61,52 @@ public class ServletModuleAbuse extends ServletModule {
 
     editFilterTemplate = configuration.getString("ServletModule.Abuse.EditFilter.Template");
     listFiltersTemplate = configuration.getString("ServletModule.Abuse.ListFilters.Template");
+    editFilterGroupTemplate = configuration.getString("ServletModule.Abuse.EditFilterGroup.Template");
+    listFilterGroupsTemplate = configuration.getString("ServletModule.Abuse.ListFilterGroups.Template");
     viewLogTemplate = configuration.getString("ServletModule.Abuse.ViewLog.Template");
     mainTemplate = configuration.getString("ServletModule.Abuse.Main.Template");
   }
 
-  public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+  public void editfilter(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
     String id=requestParser.getParameterWithDefault("id", "");
+    String groupid=requestParser.getParameterWithDefault("groupid", "");
 
-    if (id.equals("")) {
-      editfilter(aRequest, aResponse, "", "", "", "", "", "", "");
-    }
-    else {
-      Abuse.FilterRule filter = MirGlobal.abuse().getFilter(id);
-      if (filter==null)
-        throw new ServletModuleExc("Filter not found");
+    FilterEngine.Filter filter = MirGlobal.abuse().getFilterEngine().getFilterForId(groupid, id);
 
-      editfilter(aRequest, aResponse, filter.getId(), filter.getType(), filter.getExpression(), filter.getComments(), filter.getCommentAction(), filter.getArticleAction(), "");
-    }
+    editfilter(aRequest, aResponse,
+        groupid,
+        id, filter.getType(), filter.getExpression(),
+        filter.getComment(), filter.getTag(), filter.getCommentAction(), filter.getArticleAction(), "");
+  }
+
+  public void addfilter(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+    String groupid=requestParser.getParameterWithDefault("groupid", "");
+
+    editfilter(aRequest, aResponse, groupid, "", "", "", "", "", "", "", "");
   }
 
   public void editfilter(HttpServletRequest aRequest, HttpServletResponse aResponse,
-        String anId, String aType, String anExpression, String aComments,
+        String aGroupId, String anId, String aType, String anExpression, String aComments,
+        String aTag,
         String aCommentAction, String anArticleAction, String anErrorMessage) throws ServletModuleExc {
     try {
       Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, getLocales(aRequest));
 
       responseData.put("id", anId);
+      responseData.put("groupid", aGroupId);
       responseData.put("type", aType);
       responseData.put("expression", anExpression);
       responseData.put("comments", aComments);
+      responseData.put("tag", aTag);
       responseData.put("articleaction", anArticleAction);
       responseData.put("commentaction", aCommentAction);
       responseData.put("errormessage", anErrorMessage);
 
       responseData.put("articleactions", MirGlobal.abuse().getArticleActions());
       responseData.put("commentactions", MirGlobal.abuse().getCommentActions());
-      responseData.put("filtertypes", MirGlobal.abuse().getFilterTypes());
+      responseData.put("filtertypes", MirGlobal.abuse().getFilterEngine().getFilterTypes());
 
       ServletHelper.generateResponse(aResponse.getWriter(), responseData, editFilterTemplate);
     }
@@ -110,108 +120,150 @@ public class ServletModuleAbuse extends ServletModule {
 
     String type=requestParser.getParameterWithDefault("type", "");
     String id=requestParser.getParameterWithDefault("id", "");
+    String groupid=requestParser.getParameter("groupid");
     String expression=requestParser.getParameterWithDefault("expression", "");
     String commentaction=requestParser.getParameterWithDefault("commentaction", "");
     String articleaction=requestParser.getParameterWithDefault("articleaction", "");
     String comments=requestParser.getParameterWithDefault("comments", "");
+    String tag=requestParser.getParameterWithDefault("tag", "");
 
     String errorMessage;
 
-    if (id.equals("")) {
-      errorMessage = MirGlobal.abuse().addFilter(type, expression,comments, commentaction, articleaction);
-      logAdminUsage(aRequest, "?", "object added");
+    try {
+      if (id.equals("")) {
+        errorMessage = MirGlobal.abuse().getFilterEngine().addFilter(
+            groupid, type, expression, comments, tag,
+            articleaction, commentaction);
+        logAdminUsage(aRequest, id, "filter added");
+      }
+      else {
+        errorMessage = MirGlobal.abuse().getFilterEngine().updateFilter(
+            groupid, id, type, expression, comments, tag,
+            articleaction, commentaction);
+        logAdminUsage(aRequest, id, "filter modified");
+      }
     }
-    else {
-      errorMessage = MirGlobal.abuse().setFilter(id, type, expression, comments, commentaction, articleaction);
-      logAdminUsage(aRequest, id, "object modified");
+    catch (StorageObjectExc e) {
+      throw new ServletModuleFailure(e);
     }
 
     if (errorMessage!=null) {
-      editfilter(aRequest, aResponse, id, type, expression, comments, commentaction, articleaction, errorMessage);
+      editfilter(aRequest, aResponse, groupid, id, type,
+          expression, comments, tag, commentaction, articleaction, errorMessage);
     }
     else {
       MirGlobal.abuse().save();
-      showfilters(aRequest, aResponse);
+      listfilters(aRequest, aResponse);
     }
   }
 
-  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+  public void deletefilter(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
 
-    String id=requestParser.getParameterWithDefault("id", "");
-    MirGlobal.abuse().deleteFilter(id);
-    logAdminUsage(aRequest, id, "object deleted");
-
-    MirGlobal.abuse().save();
+    String id=requestParser.getParameter("id");
+    String groupid=requestParser.getParameter("groupid");
+    MirGlobal.abuse().getFilterEngine().deleteFilter(groupid, id);
+    MirGlobal.logAdminUsage(ServletHelper.getUser(aRequest), getOperationModuleName() + ":" + "filter:"+groupid+":"+id, "filter deleted");
 
-    showfilters(aRequest, aResponse);
+    listfilters(aRequest, aResponse);
   }
 
-  public void moveup(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+  public void deletefiltergroup(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
 
-    String id=requestParser.getParameterWithDefault("id", "");
-    MirGlobal.abuse().moveFilterUp(id);
+    String groupid=requestParser.getParameter("groupid");
+    MirGlobal.abuse().getFilterEngine().deleteFilterGroup(groupid);
 
-    MirGlobal.abuse().save();
-    logAdminUsage(aRequest, id, "object moved upwards");
+    MirGlobal.logAdminUsage(ServletHelper.getUser(aRequest), getOperationModuleName() + ":" + "filtergroup:"+groupid, "filter group deleted");
 
-    showfilters(aRequest, aResponse);
+    showfiltergroups(aRequest, aResponse);
   }
 
-  public void movedown(HttpServletRequest aRequest, HttpServletResponse aResponse) {
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+  public void addfiltergroup(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+    editfiltergroup(aRequest, aResponse, "", "");
+  }
 
+  public void editgroup(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
     String id=requestParser.getParameterWithDefault("id", "");
-    MirGlobal.abuse().moveFilterDown(id);
-    logAdminUsage(aRequest, id, "object moved downwards");
 
-    MirGlobal.abuse().save();
+    FilterEngine.FilterGroup group = MirGlobal.abuse().getFilterEngine().getFilterGroupForId(id);
 
-    showfilters(aRequest, aResponse);
+    editfiltergroup(aRequest, aResponse, id, group.getName());
   }
 
-  public void movetop(HttpServletRequest aRequest, HttpServletResponse aResponse) {
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
-    String id=requestParser.getParameterWithDefault("id", "");
-    MirGlobal.abuse().moveFilterToTop(id);
+  public void editfiltergroup(HttpServletRequest aRequest, HttpServletResponse aResponse,
+        String anId, String aName) throws ServletModuleExc {
+    try {
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, getLocales(aRequest));
 
-    MirGlobal.abuse().save();
-    logAdminUsage(aRequest, id, "object moved to the top");
+      responseData.put("id", anId);
+      responseData.put("name", aName);
 
-    showfilters(aRequest, aResponse);
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editFilterGroupTemplate);
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 
-  public void movebottom(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+  public void listfilters(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+    URLBuilder urlBuilder = new URLBuilder();
     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+    String groupid=requestParser.getParameterWithDefault("groupid", "");
 
-    String id=requestParser.getParameterWithDefault("id", "");
-    MirGlobal.abuse().moveFilterToBottom(id);
+    try {
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, getLocales(aRequest));
+
+      urlBuilder.setValue("module", "Abuse");
+      urlBuilder.setValue("do", "listfilters");
+      urlBuilder.setValue("groupid", groupid);
+      responseData.put("thisurl", urlBuilder.getQuery());
+      responseData.put("groupid", groupid);
 
-    MirGlobal.abuse().save();
-    logAdminUsage(aRequest, id, "object moved to the bottom");
+      responseData.put("filters", MirGlobal.abuse().getFilterEngine().getFilters(groupid));
 
-    showfilters(aRequest, aResponse);
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listFiltersTemplate);
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
   }
 
-  public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
-    editfilter(aRequest, aResponse, "", "", "", "", "", "", "");
+  public void updatefiltergroup(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+    String name = requestParser.getParameterWithDefault("name", "");
+    String id = requestParser.getParameterWithDefault("id", "");
+
+    try {
+        if (id.equals("")) {
+          MirGlobal.abuse().getFilterEngine().addFilterGroup(name);
+        }
+        else {
+          MirGlobal.abuse().getFilterEngine().updateFilterGroup(id, name);
+        }
+    }
+    catch (StorageObjectExc e) {
+      throw new ServletModuleFailure(e);
+    }
+
+    showfiltergroups(aRequest, aResponse);
   }
 
-  public void showfilters(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+  public void showfiltergroups(HttpServletRequest aRequest, HttpServletResponse aResponse) {
     URLBuilder urlBuilder = new URLBuilder();
 
     try {
       Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, getLocales(aRequest));
 
       urlBuilder.setValue("module", "Abuse");
-      urlBuilder.setValue("do", "showfilters");
+      urlBuilder.setValue("do", "showfiltergroups");
       responseData.put("thisurl", urlBuilder.getQuery());
 
-      responseData.put("filters", MirGlobal.abuse().getFilters());
+      responseData.put("filtergroups", MirGlobal.abuse().getFilterEngine().getFilterGroups());
 
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listFiltersTemplate);
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listFilterGroupsTemplate);
     }
     catch (Throwable e) {
       throw new ServletModuleFailure(e);
index e57cbe7..4ef89ed 100755 (executable)
@@ -31,7 +31,6 @@ package mircoders.servlet;
 
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
-import mircoders.global.MirGlobal;
 import mircoders.module.ModuleUploadedMedia;
 import mircoders.storage.DatabaseAudio;
 
index dd4ea8d..c18ffc7 100755 (executable)
@@ -32,9 +32,7 @@ package mircoders.servlet;
 
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
-import mircoders.global.MirGlobal;
 import mircoders.module.ModuleBreaking;
-import mircoders.storage.DatabaseBreaking;
 
 /**
  *
index 5feb152..e2a7042 100755 (executable)
 
 package mircoders.servlet;
 
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import mir.entity.adapter.EntityAdapter;
 import mir.entity.adapter.EntityAdapterModel;
 import mir.entity.adapter.EntityIteratorAdapter;
-import mir.entity.adapter.EntityAdapter;
+import mir.generator.Generator;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
-import mir.util.CachingRewindableIterator;
-import mir.util.HTTPRequestParser;
-import mir.util.JDBCStringRoutines;
-import mir.util.SQLQueryBuilder;
-import mir.util.StringRoutines;
-import mir.util.URLBuilder;
-import mir.generator.Generator;
-import mircoders.entity.*;
+import mir.util.*;
+import mircoders.entity.EntityContent;
+import mircoders.entity.EntityUsers;
 import mircoders.global.MirGlobal;
 import mircoders.module.ModuleContent;
 import mircoders.storage.DatabaseContent;
 import mircoders.storage.DatabaseContentToTopics;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
 /**
  * Article admin interface code
  */
@@ -74,10 +63,12 @@ public class ServletModuleContent extends ServletModule
 
   private ServletModuleContent() {
     super();
+    propagatedParameters.add("selectarticleurl");
 
     logger = new LoggerWrapper("ServletModule.Content");
 
     try {
+      definition = "content";
       contentModule = new ModuleContent();
       mainModule = contentModule;
     }
@@ -86,18 +77,6 @@ public class ServletModuleContent extends ServletModule
     }
   }
 
-  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-
-    String where = requestParser.getParameter("where");
-    String order = requestParser.getParameterWithDefault("order", "webdb_create desc");
-    int offset = requestParser.getIntegerWithDefault("offset", 0);
-    String selectArticleUrl = requestParser.getParameter("selectarticleurl");
-
-    returnList(aRequest, aResponse, where, order, offset, selectArticleUrl);
-  }
-
   public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleFailure {
     try {
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
@@ -107,7 +86,6 @@ public class ServletModuleContent extends ServletModule
       String searchOrder = requestParser.getParameterWithDefault("searchorder", "");
       String searchispublished = requestParser.getParameterWithDefault("searchispublished", "");
       String searchArticleType = requestParser.getParameterWithDefault("searcharticletype", "");
-      String selectArticleUrl = requestParser.getParameter("selectarticleurl");
 
       if (searchValue.length()>0) {
         if (searchField.equals("id"))
@@ -145,7 +123,7 @@ public class ServletModuleContent extends ServletModule
           queryBuilder.appendAscendingOrder("creator");
       }
 
-      returnList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0, selectArticleUrl);
+      returnList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);
     }
     catch (Throwable e) {
       throw new ServletModuleFailure(e);
@@ -408,7 +386,7 @@ public class ServletModuleContent extends ServletModule
       }
       responseData.put("article", article);
 
-      List topicsList = new Vector();
+      List topicsList = new ArrayList();
 
       String[] topicCategories = configuration.getStringArray("Mir.Localizer.Admin.TopicLists");
 
@@ -422,9 +400,7 @@ public class ServletModuleContent extends ServletModule
             20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
         topicsList.add(categoryMap);
       }
-      else
-      {
-
+      else {
         for (int i = 0; i < topicCategories.length; i++) {
           try {
             Map categoryMap = new HashMap();
@@ -474,88 +450,7 @@ public class ServletModuleContent extends ServletModule
     }
   }
 
-  public void returnList(HttpServletRequest aRequest, HttpServletResponse aResponse,
-     String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {
-    this.returnList(aRequest, aResponse, aWhereClause, anOrderByClause, anOffset, null);
-  }
-
-  public void returnList(
-       HttpServletRequest aRequest,
-       HttpServletResponse aResponse,
-       String aWhereClause,
-       String anOrderByClause,
-       int anOffset,
-       String aSelectArticleUrl) throws ServletModuleExc {
-
-    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
-    URLBuilder urlBuilder = new URLBuilder();
-    int count;
-
-    try {
-      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
-      Object articleList =
-          new CachingRewindableIterator(
-            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrEntitiesPerListPage,
-               MirGlobal.localizer().dataModel().adapterModel(), "content", nrEntitiesPerListPage, anOffset)
-      );
-
-      responseData.put("nexturl", null);
-      responseData.put("prevurl", null);
-
-      count=mainModule.getSize(aWhereClause);
-
-      urlBuilder.setValue("module", "Content");
-      urlBuilder.setValue("do", "list");
-      urlBuilder.setValue("where", aWhereClause);
-      urlBuilder.setValue("order", anOrderByClause);
-
-
-      urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));
-      urlBuilder.setValue("searchvalue", requestParser.getParameter("searchvalue"));
-      urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));
-      urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));
-      urlBuilder.setValue("searcharticletype", requestParser.getParameter("searcharticletype"));
-      urlBuilder.setValue("selectarticleurl", aSelectArticleUrl);
-
-      responseData.put("searchfield", requestParser.getParameter("searchfield"));
-      responseData.put("searchvalue", requestParser.getParameter("searchvalue"));
-      responseData.put("searchispublished", requestParser.getParameter("searchispublished"));
-      responseData.put("searchorder", requestParser.getParameter("searchorder"));
-      responseData.put("searcharticletype", requestParser.getParameter("searcharticletype"));
-      responseData.put("selectarticleurl", aSelectArticleUrl);
-
-      urlBuilder.setValue("offset", anOffset);
-      responseData.put("offset" , new Integer(anOffset).toString());
-      responseData.put("thisurl" , urlBuilder.getQuery());
-
-      if (count>=anOffset+nrEntitiesPerListPage) {
-        urlBuilder.setValue("offset", (anOffset + nrEntitiesPerListPage));
-        responseData.put("nexturl" , urlBuilder.getQuery());
-      }
-
-      if (anOffset>0) {
-        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));
-        responseData.put("prevurl" , urlBuilder.getQuery());
-      }
-
-      responseData.put("articles", articleList);
-
-      responseData.put("from" , Integer.toString(anOffset+1));
-      responseData.put("count", Integer.toString(count));
-      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));
-      responseData.put("offset" , Integer.toString(anOffset));
-      responseData.put("order", anOrderByClause);
-      responseData.put("where" , aWhereClause);
-
-      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);
-    }
-    catch (Throwable e) {
-      throw new ServletModuleFailure(e);
-    }
-  }
-
-  public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
-  {
+  public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
     try {
       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
       URLBuilder urlBuilder = new URLBuilder();
@@ -565,7 +460,8 @@ public class ServletModuleContent extends ServletModule
       urlBuilder.setValue("childid", requestParser.getParameter("id"));
       urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
 
-      returnList(aRequest, aResponse, "", "", 0, urlBuilder.getQuery());
+      returnList(aRequest, aResponse, "", "", 0,
+          Collections.singletonMap("selectarticleurl", urlBuilder.getQuery()));
     }
     catch (Throwable e) {
       throw new ServletModuleFailure(e);
index 8354040..c8e0c2e 100755 (executable)
@@ -37,11 +37,7 @@ import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.FilenameFilter;
 import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -60,7 +56,7 @@ import mir.util.URLBuilder;
  *  in the config file.
  *
  * @author $Author: zapata $
- * @version $Revision: 1.13.2.7 $ $Date: 2004/11/21 22:07:14 $
+ * @version $Revision: 1.13.2.8 $ $Date: 2005/01/09 20:37:13 $
  *
  */
 
@@ -110,7 +106,7 @@ public class ServletModuleFileEdit extends ServletModule
     logger = new LoggerWrapper("ServletModule.FileEdit");
 
     directories = new HashMap();
-    directoryNames = new Vector();
+    directoryNames = new ArrayList();
 
     String settings[] = configuration.getStringArray("ServletModule.FileEdit.Configuration");
 
@@ -246,7 +242,7 @@ public class ServletModuleFileEdit extends ServletModule
       responseData.put("filelist", FileFunctions.getDirectoryContentsAsList(dir, aDirectory.getFilter()));
 
       if (aDirectory.getRecursive()) {
-        List dirs = new Vector();
+        List dirs = new ArrayList();
         if (!dir.getCanonicalPath().equals(aDirectory.getRootDirectory().getCanonicalPath()))
           responseData.put("updir", new File(aSubDirectory).getParent());
 
index 39370af..582334f 100755 (executable)
@@ -41,10 +41,7 @@ import mircoders.module.ModuleContent;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 public class ServletModuleLocalizer extends ServletModule {
   private static ServletModuleLocalizer instance = new ServletModuleLocalizer();
@@ -61,7 +58,7 @@ public class ServletModuleLocalizer extends ServletModule {
       contentModule = new ModuleContent();
       commentModule = new ModuleComment();
 
-      administerOperations = new Vector();
+      administerOperations = new ArrayList();
 
       String settings[] = configuration.getStringArray("Mir.Localizer.Admin.AdministerOperations");
 
index 4ca4ae6..0054cd9 100755 (executable)
  */
 package mircoders.servlet;
 
+import java.util.GregorianCalendar;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.servlet.ServletModule;
 import mircoders.module.ModuleMediafolder;
-import mircoders.storage.DatabaseMediafolder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.GregorianCalendar;
-import java.util.Map;
 
 /**
  *
index 4850e52..6b76231 100755 (executable)
  */
 package mircoders.servlet;
 
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleFailure;
 import mircoders.module.ModuleMessage;
-import mircoders.storage.DatabaseMessages;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
 
 /**
  * Title:       ServletModuleMessage
index bdb0f2e..2e37241 100755 (executable)
@@ -32,6 +32,30 @@ package mircoders.servlet;
 
 import gnu.regexp.RE;
 import gnu.regexp.REMatch;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
 import mir.bundle.Bundle;
 import mir.entity.Entity;
 import mir.generator.Generator;
@@ -41,9 +65,18 @@ import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
 import mir.servlet.ServletModuleUserExc;
-import mir.session.*;
+import mir.session.HTTPAdapters;
+import mir.session.Request;
+import mir.session.Session;
+import mir.session.SessionHandler;
+import mir.session.SimpleResponse;
+import mir.session.UploadedFile;
 import mir.storage.StorageObjectFailure;
-import mir.util.*;
+import mir.util.ExceptionFunctions;
+import mir.util.FileFunctions;
+import mir.util.HTTPParsedRequest;
+import mir.util.HTTPRequestParser;
+import mir.util.StringRoutines;
 import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.global.CacheKey;
@@ -52,11 +85,23 @@ import mircoders.media.MediaUploadProcessor;
 import mircoders.media.UnsupportedMediaTypeExc;
 import mircoders.module.ModuleComment;
 import mircoders.module.ModuleContent;
-import mircoders.module.ModuleMediaType;
-import mircoders.media.UnsupportedMediaTypeExc;
 import mircoders.pdf.PDFGenerator;
-import mircoders.search.*;
-import mircoders.storage.*;
+import mircoders.search.AudioSearchTerm;
+import mircoders.search.ContentSearchTerm;
+import mircoders.search.ImagesSearchTerm;
+import mircoders.search.KeywordSearchTerm;
+import mircoders.search.TextSearchTerm;
+import mircoders.search.TopicMatrixSearchTerm;
+import mircoders.search.TopicSearchTerm;
+import mircoders.search.UnIndexedSearchTerm;
+import mircoders.search.VideoSearchTerm;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseContentToMedia;
+import mircoders.storage.DatabaseContentToTopics;
+import mircoders.storage.DatabaseLanguage;
+import mircoders.storage.DatabaseTopics;
+
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.commons.net.smtp.SMTPReply;
@@ -69,12 +114,6 @@ import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Searcher;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.io.*;
-import java.util.*;
-
 /*
  *  ServletModuleOpenIndy -
  *   is the open-access-servlet, which is responsible for
@@ -82,7 +121,7 @@ import java.util.*;
  *    open-postings to the newswire
  *
  * @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.12 2004/11/21 22:07:14 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.13 2005/01/09 20:37:14 zapata Exp $
  *
  */
 
@@ -307,7 +346,7 @@ public class ServletModuleOpenIndy extends ServletModule
       }
 
       int mediaNum = Integer.parseInt(numOfMedia);
-      List mediaFields = new Vector();
+      List mediaFields = new ArrayList();
       for (int i = 0; i < mediaNum; i++) {
         Integer mNum = new Integer(i + 1);
         mediaFields.add(mNum.toString());
@@ -368,7 +407,7 @@ public class ServletModuleOpenIndy extends ServletModule
           ((parsedRequest.getParameter("content_data")).length() == 0))
         throw new ServletModuleUserExc("posting.error.missingfield", new String[] {});
 
-      List mediaList = new Vector();
+      List mediaList = new ArrayList();
       Iterator i = parsedRequest.getFiles().iterator();
 
       while (i.hasNext()) {
@@ -916,7 +955,7 @@ public class ServletModuleOpenIndy extends ServletModule
         if (theDocs != null) {
 
           mergeData.put("numberOfHits", (session.getAttribute("numberOfHits")).toString());
-          List theHits = new Vector();
+          List theHits = new ArrayList();
           int pIR = ( (Integer) session.getAttribute("positionInResults")).intValue();
           int terminus;
           int numHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
index f6e3b67..03b4556 100755 (executable)
  */
 package mircoders.servlet;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import mir.generator.Generator;
 import mir.log.LoggerWrapper;
 import mir.producer.ProducerFactory;
@@ -49,6 +37,12 @@ import mir.servlet.ServletModuleFailure;
 import mir.util.HTTPRequestParser;
 import mircoders.global.MirGlobal;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
 public class ServletModuleProducer extends ServletModule
 {
   private static ServletModuleProducer instance = new ServletModuleProducer();
@@ -81,12 +75,12 @@ public class ServletModuleProducer extends ServletModule
       generationData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
       generationData.put( "thisurl", "module=Producer&do=showProducerQueueStatus");
 
-      producersData = new Vector();
+      producersData = new ArrayList();
       Iterator i = MirGlobal.getProducerEngine().getFactories().iterator();
       while (i.hasNext()) {
         ProducerFactory factory = (ProducerFactory) i.next();
 
-        List producerVerbs = new Vector();
+        List producerVerbs = new ArrayList();
         Iterator j = factory.verbs().iterator();
         while (j.hasNext()) {
           Map verbData = new HashMap();
index 58067ea..b924244 100755 (executable)
 package mircoders.servlet;
 
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.ArrayList;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletOutputStream;
@@ -49,7 +49,6 @@ import mir.entity.adapter.EntityAdapter;
 import mir.entity.adapter.EntityAdapterModel;
 import mir.entity.adapter.EntityIteratorAdapter;
 import mir.log.LoggerWrapper;
-import mircoders.media.MediaHelper;
 import mir.media.MediaHandler;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleExc;
@@ -67,10 +66,9 @@ import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityUploadedMedia;
 import mircoders.global.MirGlobal;
+import mircoders.media.MediaHelper;
 import mircoders.media.MediaUploadProcessor;
 import mircoders.media.UnsupportedMediaTypeExc;
-import mircoders.module.ModuleMediaType;
-import mircoders.media.UnsupportedMediaTypeExc;
 import mircoders.storage.DatabaseComment;
 import mircoders.storage.DatabaseContent;
 
index 4bfaadc..367ab53 100755 (executable)
@@ -243,7 +243,6 @@ public class ServletModuleUsers extends ServletModule
        HttpServletResponse aResponse,
        int anOffset) throws ServletModuleExc {
 
-// ML: to be deleted, support for 3 extra vars to be added
     URLBuilder urlBuilder = new URLBuilder();
     int count;
 
index 20ea23d..7d14141 100755 (executable)
@@ -59,8 +59,7 @@ public class DatabaseArticleType extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.ArticleType");
-    this.hasTimestamp = false;
-    this.mainTable = "article_type";
+    mainTable = "article_type";
   }
 
 }
index c8c316a..6b8126c 100755 (executable)
@@ -56,10 +56,9 @@ public class DatabaseAudio extends Database implements StorageObject{
     super();
     logger = new LoggerWrapper("Database.Audio");
 
-    hasTimestamp = true;
     mainTable = "audio";
     primaryKeySequence = "media_id_seq";
-    theEntityClass = mircoders.entity.EntityAudio.class;
+    entityClass = mircoders.entity.EntityAudio.class;
   }
 
   public void update(Entity theEntity) throws StorageObjectFailure {
index a0a6849..fe12761 100755 (executable)
@@ -42,12 +42,8 @@ import mir.storage.StorageObjectFailure;
  */
 
 public class DatabaseBreaking extends Database implements StorageObject{
-
   private static DatabaseBreaking instance;
 
-  // the following *has* to be sychronized cause this static method
-  // could get preemted and we could end up with 2 instances of DatabaseFoo..
-  // see the "Singletons with needles and thread" article at JavaWorld -mh
   public synchronized static DatabaseBreaking getInstance() throws StorageObjectFailure {
     if (instance == null) {
       instance = new DatabaseBreaking();
@@ -55,12 +51,10 @@ public class DatabaseBreaking extends Database implements StorageObject{
     return instance;
   }
 
-  private DatabaseBreaking() throws StorageObjectFailure
-  {
+  private DatabaseBreaking() throws StorageObjectFailure {
     super();
+
     logger = new LoggerWrapper("Database.Breaking");
-    this.mainTable="breaking";
+    mainTable="breaking";
   }
-
-
 }
index 400b3fa..edbe653 100755 (executable)
@@ -59,11 +59,10 @@ public class DatabaseComment extends Database implements StorageObject{
 
   private DatabaseComment() {
     super();
-    hasTimestamp = false;
     mainTable = "comment";
     logger = new LoggerWrapper("Database.Comment");
 
-    this.theEntityClass = mircoders.entity.EntityComment.class;
+    entityClass = mircoders.entity.EntityComment.class;
   }
 
   public boolean deleteByContentId(String id) throws StorageObjectFailure {
index 40c3937..46dd251 100755 (executable)
 
 package mircoders.storage;
 
-/**
- * Title:
- * Description:
- * Copyright:    Copyright (c) 2001
- * Company:
- * @author:
- * @version 1.0
- */
-
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 
-
 public class DatabaseCommentStatus extends Database implements StorageObject{
 
   private static DatabaseCommentStatus instance;
@@ -59,7 +49,7 @@ public class DatabaseCommentStatus extends Database implements StorageObject{
 
   private DatabaseCommentStatus() throws StorageObjectFailure {
     super();
-    hasTimestamp = false;
+
     mainTable = "comment_status";
     logger = new LoggerWrapper("Database.CommentStatus");
   }
index 07adcd2..1105a7d 100755 (executable)
@@ -33,7 +33,7 @@ package mircoders.storage;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
@@ -48,7 +48,7 @@ import mircoders.entity.EntityUploadedMedia;
  * <b>implements abstract DB connection to the comment_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.7 2004/11/21 22:07:14 zapata Exp $
+ * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.8 2005/01/09 20:37:15 zapata Exp $
  *
  */
 
@@ -65,137 +65,10 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{
 
   private DatabaseCommentToMedia() {
     super();
+
     logger = new LoggerWrapper("Database.CommentToMedia");
-    hasTimestamp = false;
     mainTable = "comment_x_media";
-    theEntityClass = mir.entity.GenericEntity.class;
-  }
-
-  public boolean hasMedia(EntityComment comment) throws StorageObjectFailure,
-      StorageObjectExc {
-    if (comment != null) {
-      try {
-        return (getSize("comment_id=" + comment.getId()) == 0) ? false:true;
-      }
-      catch (Exception e) {
-        logger.error("DatabaseCommentToMedia.hasMedia: " + e.toString());
-        throw new StorageObjectFailure("DatabaseCommentToMedia.hasMedia: " +
-                                       e.toString(), e);
-      }
-    }
-    else {
-      logger.error("DatabaseCommentToMedia.hasMedia: comment == null");
-      throw new StorageObjectExc(
-          "DatabaseCommentToMedia.hasMedia: comment == null");
-    }
-  }
-
-  private EntityList getMultiMediaForComment(StorageObject store, EntityComment comment)
-      throws StorageObjectFailure {
-
-      EntityList returnList = null;
-      if (comment != null) {
-        String id = comment.getId();
-        try {
-          Vector extraTable = new Vector();
-          extraTable.add(mainTable+" cxm");
-          // media should stay in uploaded order. this is especially important
-          // for photo stories which require a specific chronologic order.
-          // this is why we have the the second parameter "id"
-          store.selectByWhereClause("m", extraTable,
-            "m.id=cxm.media_id and cxm.comment_id="+id, "id", -1, -1);
-
-        } catch (Exception e) {
-          logger.error("DatabaseCommenttToMedia.getMultiMediaForComment: " + e.toString());
-          throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForComment: " +
-                                       e.toString(), e);
-        }
-      }
-      return returnList;
-    }
-
-  /**
-   * get all the audio belonging to a comment entity
-   */
-  public EntityList getAudio(EntityComment comment) throws StorageObjectFailure {
-    return getMultiMediaForComment(DatabaseAudio.getInstance(), comment);
-  }
-
-  /**
-   * get all the video belonging to a comment entity
-   *
-   */
-  public EntityList getVideo(EntityComment comment) throws StorageObjectFailure {
-    return getMultiMediaForComment(DatabaseVideo.getInstance(), comment);
-  }
-
-  /**
-   * get all the images belonging to a comment entity
-   */
-  public EntityList getImages(EntityComment comment) throws StorageObjectFailure {
-    return getMultiMediaForComment(DatabaseImages.getInstance(), comment);
-  }
-
-  /**
-   * get all the uploaded/other Media belonging to a comment entity
-   */
-  public EntityList getOther(EntityComment comment) throws StorageObjectFailure {
-    return getMultiMediaForComment(DatabaseOther.getInstance(), comment);
-  }
-
-  /**
-   * get all the uploaded/other Media belonging to a comment entity
-   */
-  public EntityList getUploadedMedia(EntityComment comment) throws StorageObjectFailure {
-    return getMultiMediaForComment(DatabaseUploadedMedia.getInstance(), comment);
-  }
-
-  public void setMedia(String commentId, String[] mediaId) throws
-      StorageObjectFailure {
-    if (commentId == null) {
-      return;
-    }
-    if (mediaId == null || mediaId[0] == null) {
-      return;
-    }
-    //first delete all row with comment_id=commentId
-    String sql = "delete from " + mainTable + " where comment_id=" + commentId;
-
-    Connection con = null;
-    Statement stmt = null;
-    try {
-      con = obtainConnection();
-      // should be a preparedStatement because is faster
-      stmt = con.createStatement();
-      ResultSet rs = executeSql(stmt, sql);
-    }
-    catch (Exception e) {
-      logger.error("-- set media failed -- delete");
-      throw new StorageObjectFailure("-- set media failed -- delete", e);
-    }
-    finally {
-      freeConnection(con, stmt);
-    }
-
-    //now insert
-    //first delete all row with comment_id=commentId
-    for (int i = 0; i < mediaId.length; i++) {
-      sql = "insert into " + mainTable + " (comment_id,media_id) values ("
-          + commentId + "," + mediaId[i] + ")";
-      try {
-        con = obtainConnection();
-        // should be a preparedStatement because is faster
-        stmt = con.createStatement();
-        int rs = executeUpdate(stmt, sql);
-      }
-      catch (Exception e) {
-        logger.error("-- set topics failed -- insert");
-        throw new StorageObjectFailure("-- set topics failed -- insert ", e);
-      }
-      finally {
-        freeConnection(con, stmt);
-      }
-    }
+    entityClass = mir.entity.GenericEntity.class;
   }
 
   public void addMedia(String commentId, String mediaId) throws
@@ -356,7 +229,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{
     if (media != null) {
 
       String id = media.getId();
-      Vector extraTables = new Vector();
+      ArrayList extraTables = new ArrayList();
       extraTables.add(mainTable + " cxm");
 
       String mediaSelect = "cxm.comment_id=c.id and cxm.media_id="+id;
@@ -381,7 +254,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{
   public EntityList getComment() throws StorageObjectFailure {
     EntityList returnList = null;
 
-    Vector extraTables = new Vector();
+    ArrayList extraTables = new ArrayList();
     extraTables.add(mainTable + " cxm");
 
     String mediaSelect = "cxm.comment_id=c.id";
index 53c00f7..dbe4e01 100755 (executable)
@@ -68,7 +68,7 @@ public class DatabaseContent extends Database implements StorageObject {
     primaryKeySequence="media_id_seq";
     logger = new LoggerWrapper("Database.Content");
 
-    theEntityClass = mircoders.entity.EntityContent.class;
+    entityClass = mircoders.entity.EntityContent.class;
   }
 
   // methods
index 14a4a53..6dd5098 100755 (executable)
@@ -33,7 +33,7 @@ package mircoders.storage;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
@@ -48,7 +48,7 @@ import mircoders.entity.EntityUploadedMedia;
  * <b>implements abstract DB connection to the content_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseContentToMedia.java,v 1.19.2.6 2004/11/21 22:07:14 zapata Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.7 2005/01/09 20:37:15 zapata Exp $
  *
  */
 
@@ -67,132 +67,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.ContentToMedia");
-    hasTimestamp = false;
     mainTable = "content_x_media";
-    theEntityClass = mir.entity.GenericEntity.class;
-  }
-
-  public boolean hasMedia(EntityContent content) throws StorageObjectFailure,
-      StorageObjectExc {
-    if (content != null) {
-      try {
-        return (getSize("content_id=" + content.getId()) == 0) ? false:true;
-      }
-      catch (Exception e) {
-        logger.error("DatabaseContentToMedia.hasMedia: " + e.toString());
-        throw new StorageObjectFailure("DatabaseContentToMedia.hasMedia: " +
-                                       e.toString(), e);
-      }
-    }
-    else {
-      logger.error("DatabaseContentToMedia.hasMedia: content == null");
-      throw new StorageObjectExc(
-          "DatabaseContentToMedia.hasMedia: content == null");
-    }
-  }
-
-  private EntityList getMultiMediaForContent(StorageObject store, EntityContent content)
-    throws StorageObjectFailure {
-
-    EntityList returnList = null;
-    if (content != null) {
-      String id = content.getId();
-      try {
-        Vector extraTable = new Vector();
-        extraTable.add(mainTable+" cxm");
-        // media should stay in uploaded order. this is especially important
-        // for photo stories which require a specific chronologic order.
-        // this is why we have the the second parameter "id"
-        store.selectByWhereClause("m", extraTable,
-          "m.id=cxm.media_id and cxm.content_id="+id, "id", -1, -1);
-
-                       } catch (Exception e) {
-        logger.error("DatabaseContentToMedia.getMultiMediaForContent: " + e.toString());
-        throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForContent: " +
-                                     e.toString(), e);
-      }
-    }
-    return returnList;
-  }
-
-  /**
-   * get all the audio belonging to a content entity
-   */
-  public EntityList getAudio(EntityContent content) throws StorageObjectFailure {
-    return getMultiMediaForContent(DatabaseAudio.getInstance(), content);
-  }
-
-  /**
-   * get all the video belonging to a content entity
-   */
-  public EntityList getVideo(EntityContent content) throws StorageObjectFailure {
-    return getMultiMediaForContent(DatabaseVideo.getInstance(), content);
-  }
-
-  /**
-   * get all the images belonging to a content entity
-   */
-  public EntityList getImages(EntityContent content) throws StorageObjectFailure {
-    return getMultiMediaForContent(DatabaseImages.getInstance(), content);
-  }
-
-  /**
-   * get all the uploaded/other Media belonging to a content entity
-   */
-  public EntityList getOther(EntityContent content) throws StorageObjectFailure {
-    return getMultiMediaForContent(DatabaseOther.getInstance(), content);
-  }
-
-  /**
-   * get all the uploaded/other Media belonging to a content entity
-   */
-  public EntityList getUploadedMedia(EntityContent content) throws StorageObjectFailure {
-    return getMultiMediaForContent(DatabaseUploadedMedia.getInstance(), content);
-  }
-
-
-  public void setMedia(String contentId, String[] mediaId) throws StorageObjectFailure {
-    if (contentId == null || mediaId == null || mediaId[0] == null) {
-      return;
-    }
-    //first delete all row with content_id=contentId
-    String sql = "delete from " + mainTable + " where content_id=" + contentId;
-
-    Connection con = null;
-    Statement stmt = null;
-    try {
-      con = obtainConnection();
-      // should be a preparedStatement because is faster
-      stmt = con.createStatement();
-      ResultSet rs = executeSql(stmt, sql);
-    }
-    catch (Exception e) {
-      logger.error("-- set media failed -- delete");
-      throw new StorageObjectFailure("-- set media failed -- delete", e);
-    }
-    finally {
-      freeConnection(con, stmt);
-    }
-
-    //now insert
-    //first delete all row with content_id=contentId
-    for (int i = 0; i < mediaId.length; i++) {
-      sql = "insert into " + mainTable + " (content_id,media_id) values ("
-          + contentId + "," + mediaId[i] + ")";
-      try {
-        con = obtainConnection();
-        // should be a preparedStatement because is faster
-        stmt = con.createStatement();
-        int rs = executeUpdate(stmt, sql);
-      }
-      catch (Exception e) {
-        logger.error("-- set topics failed -- insert");
-        throw new StorageObjectFailure("-- set topics failed -- insert ", e);
-      }
-      finally {
-        freeConnection(con, stmt);
-      }
-    }
+    entityClass = mir.entity.GenericEntity.class;
   }
 
   public void addMedia(String contentId, String mediaId) throws
@@ -354,7 +230,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     if (media != null) {
 
       String id = media.getId();
-      Vector extraTables = new Vector();
+      ArrayList extraTables = new ArrayList();
       extraTables.add(mainTable + " cxm");
 
       String mediaSelect = "cxm.content_id=c.id and cxm.media_id="+id;
@@ -379,7 +255,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
 
     EntityList returnList = null;
 
-    Vector extraTables = new Vector();
+    ArrayList extraTables = new ArrayList();
     extraTables.add(mainTable + " cxm");
 
     String mediaSelect = "cxm.content_id=c.id";
index 2186c5e..cddbe9e 100755 (executable)
 
 package mircoders.storage;
 
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
@@ -47,6 +38,14 @@ import mir.storage.StorageObjectFailure;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityTopics;
 
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * <b>This class implements the 1-n-relation between
  * content and topic
@@ -68,10 +67,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.ContentToTopics");
-
-    hasTimestamp = false;
     mainTable="content_x_topic";
-    theEntityClass = mir.entity.GenericEntity.class;
+    entityClass = mir.entity.GenericEntity.class;
   }
 
   /**
@@ -83,7 +80,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
 
       String id = content.getId();
       try {
-        Vector extraTables = new Vector();
+        ArrayList extraTables = new ArrayList();
         extraTables.add(mainTable+" cxt");
         returnList = DatabaseTopics.getInstance()
                       .selectByWhereClauseWithExtraTables("t",extraTables,
@@ -149,7 +146,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
   }
 
   public void setTopics(String anArticleId, List aTopics) throws StorageObjectFailure {
-    List newTopics = new Vector();
+    List newTopics = new ArrayList();
     if (aTopics!=null) {
       Iterator i = aTopics.iterator();
 
@@ -279,7 +276,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
     if (topic != null) {
       String id = topic.getId();
       try {
-        Vector extraTables = new Vector();
+        ArrayList extraTables = new ArrayList();
         extraTables.add(mainTable+" cxt");
         returnList = DatabaseContent.getInstance()
                       .selectByWhereClauseWithExtraTables("c",extraTables,
diff --git a/source/mircoders/storage/DatabaseFilter.java b/source/mircoders/storage/DatabaseFilter.java
new file mode 100755 (executable)
index 0000000..2c86e5e
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+/**\r
+ *\r
+ */\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+\r
+public class DatabaseFilter extends Database implements StorageObject{\r
+  private static DatabaseFilter instance;\r
+\r
+  public synchronized static DatabaseFilter getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseFilter();\r
+    }\r
+    \r
+    return instance;\r
+  }\r
+\r
+  private DatabaseFilter() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.Filter");\r
+    mainTable = "filter";\r
+  }\r
+}\r
diff --git a/source/mircoders/storage/DatabaseFilterGroup.java b/source/mircoders/storage/DatabaseFilterGroup.java
new file mode 100755 (executable)
index 0000000..de15925
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+/**\r
+ *\r
+ */\r
+\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+\r
+public class DatabaseFilterGroup extends Database implements StorageObject {\r
+  private static DatabaseFilterGroup instance;\r
+\r
+  public synchronized static DatabaseFilterGroup getInstance() {\r
+    if (instance == null) {\r
+      instance = new DatabaseFilterGroup();\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  private DatabaseFilterGroup() {\r
+    super();\r
+\r
+    logger = new LoggerWrapper("Database.FilterGroup");\r
+    mainTable="filter_group";\r
+  }\r
+}\r
index 6881eba..ab66401 100755 (executable)
@@ -56,8 +56,8 @@ public class DatabaseImageColor extends Database implements StorageObject{
 
   private DatabaseImageColor() {
     super();
+
     logger = new LoggerWrapper("Database.ImageColor");
-    hasTimestamp = false;
     mainTable = "img_color";
   }
 
index 210dfb2..cd02567 100755 (executable)
@@ -56,8 +56,8 @@ public class DatabaseImageFormat extends Database implements StorageObject{
 
   private DatabaseImageFormat() {
     super();
+
     logger = new LoggerWrapper("Database.ImageFormat");
-    hasTimestamp = false;
     mainTable = "img_format";
   }
 }
index 8e48eb3..ec10643 100755 (executable)
@@ -58,7 +58,6 @@ public class DatabaseImageLayout extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.ImageLayout");
-    hasTimestamp = false;
     mainTable = "img_layout";
   }
 }
index 8bf91f4..1ae36c5 100755 (executable)
@@ -55,9 +55,8 @@ public class DatabaseImageType extends Database implements StorageObject{
 
   private DatabaseImageType() {
     super();
-    logger = new LoggerWrapper("Database.ImageType");
 
-    hasTimestamp = false;
+    logger = new LoggerWrapper("Database.ImageType");
     mainTable = "img_type";
   }
 }
index 33a0769..69a24bf 100755 (executable)
@@ -61,10 +61,9 @@ public class DatabaseImages extends Database implements StorageObject{
 
     logger = new LoggerWrapper("Database.Images");
 
-    hasTimestamp = true;
     mainTable = "images";
     primaryKeySequence = "media_id_seq";
-    theEntityClass = mircoders.entity.EntityImages.class;
+    entityClass = mircoders.entity.EntityImages.class;
   }
 
   public void update(Entity theEntity) throws StorageObjectFailure {
index 61f9958..9439f47 100755 (executable)
@@ -39,11 +39,7 @@ package mircoders.storage;
  * @version 1.0
  */
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
@@ -69,14 +65,13 @@ public class DatabaseLanguage extends Database implements StorageObject{
 
   private DatabaseLanguage() throws StorageObjectFailure {
     super();
-    logger = new LoggerWrapper("Database.Language");
 
-    this.hasTimestamp = false;
-    this.mainTable = "language";
+    logger = new LoggerWrapper("Database.Language");
+    mainTable = "language";
   }
 
   public List getPopupData() throws StorageObjectFailure {
-    List result = new Vector();
+    List result = new ArrayList();
     Iterator i = new EntityBrowser(this, "", "name", 100, -1, 0);
 
     while (i.hasNext()) {
index fd900f9..da70771 100755 (executable)
@@ -56,10 +56,8 @@ public class DatabaseMediaType extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.MediaType");
-
-    hasTimestamp = false;
     mainTable="media_type";
-    theEntityClass = mir.entity.GenericEntity.class;
+    entityClass = mir.entity.GenericEntity.class;
   }
 
 }
index a9d3dd4..9204112 100755 (executable)
@@ -45,6 +45,7 @@ public class DatabaseMediafolder extends Database implements StorageObject{
     if (instance == null) {
       instance = new DatabaseMediafolder();
     }
+
     return instance;
   }
 
@@ -52,8 +53,6 @@ public class DatabaseMediafolder extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.Mediafolder");
-
-    hasTimestamp = false;
     mainTable="media_folder";
   }
 }
index c4c422b..a7df77b 100755 (executable)
@@ -66,11 +66,9 @@ public class DatabaseOther extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.OtherMedia");
-
-    hasTimestamp = true;
     mainTable = "other_media";
     primaryKeySequence = "media_id_seq";
-    theEntityClass = mircoders.entity.EntityOther.class;
+    entityClass = mircoders.entity.EntityOther.class;
   }
 
   public void update(Entity theEntity) throws StorageObjectFailure {
index d2a5c63..e6adf8d 100755 (executable)
@@ -59,8 +59,6 @@ public class DatabaseRights extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.Rights");
-
-    hasTimestamp = false;
     mainTable = "rights";
   }
 }
index 252ae0b..cc2d4b3 100755 (executable)
 
 package mircoders.storage;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
 
 import mir.entity.Entity;
 import mir.entity.EntityBrowser;
@@ -68,13 +64,12 @@ public class DatabaseTopics extends Database implements StorageObject{
 
     logger = new LoggerWrapper("Database.Topics");
 
-    hasTimestamp = false;
     mainTable = "topic";
-    theEntityClass = mircoders.entity.EntityTopics.class;
+    entityClass = mircoders.entity.EntityTopics.class;
   }
 
   public List getPopupData() throws StorageObjectFailure {
-    List result = new Vector();
+    List result = new ArrayList();
     Iterator i = new EntityBrowser(this, "", "title", 100, -1, 0);
 
     while (i.hasNext()) {
index ce42e11..fc3849d 100755 (executable)
@@ -57,7 +57,7 @@ public class DatabaseUploadedMedia extends Database implements StorageObject {
 
     mainTable="uploaded_media";
     primaryKeySequence="media_id_seq";
-    theEntityClass = mircoders.entity.EntityUploadedMedia.class;
+    entityClass = mircoders.entity.EntityUploadedMedia.class;
   }
 
 
index 3e2c4b3..cd1ad60 100755 (executable)
@@ -63,9 +63,7 @@ public class DatabaseUsers extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.Users");
-
-    hasTimestamp = false;
     mainTable = "webdb_users";
-    theEntityClass = mircoders.entity.EntityUsers.class;
+    entityClass = mircoders.entity.EntityUsers.class;
   }
 }
index 4595bef..e2c1c9c 100755 (executable)
@@ -67,11 +67,9 @@ public class DatabaseVideo extends Database implements StorageObject{
     super();
 
     logger = new LoggerWrapper("Database.Video");
-
-    hasTimestamp = true;
     mainTable = "video";
     primaryKeySequence = "media_id_seq";
-    theEntityClass = mircoders.entity.EntityVideo.class;
+    entityClass = mircoders.entity.EntityVideo.class;
   }
 
   public void update(Entity theEntity) throws StorageObjectFailure {
diff --git a/templates/admin/abuse.filter.template b/templates/admin/abuse.filter.template
deleted file mode 100755 (executable)
index 2597360..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<html>
-<head>
-  <title>${lang("abuse.filter.htmltitle")}</title>
-  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css"
-</head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "FUNCTIONS.template">
-<include "EDITFUNCTIONS.template">
-
-<include "head.template">
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-  <if errormessage>
-     <p class="text-alert"> ${lang("abuse.filtererror."+errormessage)}
-     </p>
-  </if>
-
-
-  <call EditStart( 
-        ["module", "id", "do"], 
-        ["Abuse", id, "updatefilter"])>
-
-        <call EditPullDownNormal(lang("abuse.filter.type"), "type", filtertypes, "identifier", "resource", type, "abuse.filtertype.")>\r
-        <call EditTextNormal (lang("abuse.filter.expression"), 40, 255, "expression", expression)>
-        <call EditPullDownNormal(lang("abuse.filter.articleaction"), "articleaction", articleactions, "identifier", "resource", articleaction, "content.operation.")>\r
-        <call EditPullDownNormal(lang("abuse.filter.commentaction"), "commentaction", commentactions, "identifier", "resource", commentaction, "comment.operation.")>\r
-        <call EditTextAreaNormal (lang("abuse.filter.comments"), "", 40, 3, "comments", comments)>
-        
-        <tr>
-          <td class="table-foot" colspan="2" align="right"> 
-          <if id>
-            <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
-          <else>
-            <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
-          </if> 
-          </td>
-        </tr>
-        
-  <call EditEnd()>
-  <p><a class="link-box" href="${config.actionRoot}?module=Abuse&do=showfilters">[&lt;] ${lang("back")} </a> &nbsp;</p>
-    <include "foot.template">
-  </body>
-</html>
diff --git a/templates/admin/abuse.filters.template b/templates/admin/abuse.filters.template
deleted file mode 100755 (executable)
index 5c9db62..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<html>
-<head>
-  <title>${config["Mir.Name"]} | ${lang("abuse.filters.htmltitle")}</title>
-  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-</head>
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-<include "LISTFUNCTIONS.template">
-<include "FUNCTIONS.template">
-<include "head.template">
-
-    <p>
-      <a class="link-box" href="${config.actionRoot}?module=Abuse">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
-      <a class="link-box" href="${config.actionRoot}?module=Abuse&do=add">[+] ${lang("add")}</a> &nbsp;
-      <if config["Abuse.DisallowIPLogging"]!="1">
-        <a class="link-box" href="${config.actionRoot}?module=Abuse&do=showlog">${lang("abuse.showlog")}</a>
-      </if>
-      <br><br>
-    </p>
-    <call ListStart()>\r
-    <call SpannedListHead([
-          lang("abuse.filter.type"), 
-          lang("abuse.filter.expression")], ["1","3"])>
-    <call ListHead([
-          lang("abuse.filter.articleaction"),
-          lang("abuse.filter.commentaction"),
-          lang("abuse.filter.comments"),
-          lang("abuse.filter.lasthit")])>
-    <list filters as f>    
-        <call SpannedListEntry([
-          lang("abuse.filtertype."+f.type),
-          utility.encodeHTML(f.expression)],
-          ["1","3"],
-          "module=Abuse&id="+f.id, 
-           ["&do=edit", "&do=delete"], 
-           [lang("edit"), lang("delete")])>
-          <if f.lastHit>\r
-              <call ListEntry([
-                lang("content.operation."+f.articleAction),
-                lang("comment.operation."+f.commentAction),
-                utility.prettyEncodeHTML(f.comments),
-                f.lastHit.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"])
-                ], 
-                "module=Abuse&id="+f.id, 
-                ["&do=moveup", "&do=movedown", "&do=movetop", "&do=movebottom"], 
-                [lang("abuse.filters.moveup"), lang("abuse.filters.movedown"),
-                 lang("abuse.filters.movetop"), lang("abuse.filters.movebottom")])
-              >
-          <else>
-              <call ListEntry([
-                lang("content.operation."+f.articleAction),
-                lang("comment.operation."+f.commentAction),
-                utility.prettyEncodeHTML(f.comments),
-                "-"
-                ], 
-                "module=Abuse&id="+f.id, 
-                ["&do=moveup", "&do=movedown", "&do=movetop", "&do=movebottom"], 
-                [lang("abuse.filters.moveup"), lang("abuse.filters.movedown"),
-                 lang("abuse.filters.movetop"), lang("abuse.filters.movebottom")])
-              >
-          </if>
-        <tr height="2" class="${TABLE_HEAD_CLASS}"><td colspan="6"> </td></tr>
-    </list>\r
-    <call ListEnd()>\r
-    
-    <p>
-      <a class="link-box" href="${config.actionRoot}?module=Abuse">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
-      <a class="link-box" href="${config.actionRoot}?module=Abuse&do=add">[+] ${lang("add")}</a> &nbsp;
-      <if config["Abuse.DisallowIPLogging"]!="1">
-        <a class="link-box" href="${config.actionRoot}?module=Abuse&do=showlog">${lang("abuse.showlog")}</a>
-      </if>
-      <br><br>
-    </p>
-
-  <include "foot.template">
-</body>
-</html>
-
-
-
-
index 53e27cd..185b5d5 100755 (executable)
@@ -60,7 +60,7 @@
   <if config["Abuse.DisallowIPLogging"]!="1">
     &gt; <a href="${config.actionRoot}?module=Abuse&do=showlog">${lang("abuse.showlog")}</a><br>
   </if>  
-  &gt; <a href="${config.actionRoot}?module=Abuse&do=showfilters">${lang("abuse.showfilters")}</a>
+  &gt; <a href="${config.actionRoot}?module=Abuse&do=showfiltergroups">${lang("abuse.showfiltergroups")}</a>
 </p>
 
 </td>
index b89e0aa..8aaaf74 100755 (executable)
@@ -24,7 +24,7 @@
   <call ContentSearch ("layouted")>
 </if>
 
-<if articles>
+<if entities>
 
 <if showactions=="1">
   <if config["Mir.Localizer.Admin.ListOperationsFlavor"]!="0">
@@ -60,7 +60,7 @@
   </tr>
 
 <assign grey="0">
-  <list articles as entry>
+  <list entities as entry>
     <tr <if grey=="1"><assign grey="0">class="listrow1"<else>class="listrow2"<assign grey="1"></if>>
       <td class="x-small">
           ${entry.creationdate.format(config["Mir.DefaultDateTimeFormat"])}<br>
index 65f7d00..402dbb8 100755 (executable)
@@ -11,6 +11,7 @@
       <p class="box-head" align="center"><font size="+2"><b>${lang("error.title")}</b></font></p>
       <p align="center">${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
       <p align="center" class="bg-neutral"><br><font color="red">${date.format(config["Mir.DefaultDateTimeFormat"])} -- ${errorstring}</font><br><br></p>
+      <p align="center" class="bg-neutral"><br><font color="red">${utility.prettyEncodeHTML(stacktrace)}</font><br><br></p>
       <p align="center">${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}</p>
 
     </td></tr></table>
diff --git a/templates/admin/filter.template b/templates/admin/filter.template
new file mode 100755 (executable)
index 0000000..285aa10
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<head>
+  <title>${lang("filter.htmltitle")}</title>
+  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css"
+</head>
+
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+
+<include "FUNCTIONS.template">
+<include "EDITFUNCTIONS.template">
+
+<include "head.template">
+
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+
+  <if errormessage>
+     <p class="text-alert"> ${utility.prettyEncodeHTML(errormessage)}
+     </p>
+  </if>
+
+
+  <call EditStart( 
+        ["module", "groupid", "id", "do"], 
+        ["Abuse", groupid, id, "updatefilter"])>
+
+        <call EditPullDownNormal(lang("filter.type"), "type", filtertypes, "identifier", "resource", type, "filtertype.")>\r
+        <call EditTextNormal (lang("filter.expression"), 40, 255, "expression", expression)>
+        <call EditTextNormal (lang("filter.tag"), 40, 255, "tag", tag)>
+        <call EditPullDownNormal(lang("filter.articleaction"), "articleaction", articleactions, "identifier", "resource", articleaction, "content.operation.")>\r
+        <call EditPullDownNormal(lang("filter.commentaction"), "commentaction", commentactions, "identifier", "resource", commentaction, "comment.operation.")>\r
+        <call EditTextAreaNormal (lang("filter.comment"), "", 40, 3, "comments", comments)>
+        
+        <tr>
+          <td class="table-foot" colspan="2" align="right"> 
+          <if id>
+            <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
+          <else>
+            <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
+          </if> 
+          </td>
+        </tr>
+        
+  <call EditEnd()>
+  <p><a class="link-box" href="${config.actionRoot}?module=Abuse&amp;do=listfilters&amp;groupid=${groupid}">[&lt;] ${lang("back")} </a> &nbsp;</p>
+    <include "foot.template">
+  </body>
+</html>
diff --git a/templates/admin/filtergroup.template b/templates/admin/filtergroup.template
new file mode 100755 (executable)
index 0000000..4c8388d
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<head>
+  <title>${lang("abuse.filtergroup.htmltitle")}</title>
+  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css"
+</head>
+
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+
+<include "FUNCTIONS.template">
+<include "EDITFUNCTIONS.template">
+
+<include "head.template">
+
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+
+  <call EditStart( 
+        ["module", "id", "do"], 
+        ["Abuse", id, "updatefiltergroup"])>
+
+        <call EditTextNormal (lang("filtergroup.name"), 40, 255, "name", name)>
+        
+        <tr>
+          <td class="table-foot" colspan="2" align="right"> 
+          <if id>
+            <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
+          <else>
+            <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
+          </if> 
+          </td>
+        </tr>
+        
+  <call EditEnd()>
+  <p><a class="link-box" href="${config.actionRoot}?module=Abuse&do=showfiltergroups">[&lt;] ${lang("back")} </a> &nbsp;</p>
+    <include "foot.template">
+  </body>
+</html>
diff --git a/templates/admin/filtergrouplist.template b/templates/admin/filtergrouplist.template
new file mode 100755 (executable)
index 0000000..a4a7892
--- /dev/null
@@ -0,0 +1,42 @@
+<html>
+<head>
+  <title>${config["Mir.Name"]} | ${lang("filtergrouplist.htmltitle")}</title>
+  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+</head>
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+<include "LISTFUNCTIONS.template">
+<include "FUNCTIONS.template">
+<include "head.template">
+
+    <p>
+      <a class="link-box" href="${config.actionRoot}?module=Abuse">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&do=addfiltergroup">[+] ${lang("add")}</a> &nbsp;
+      <if config["Abuse.DisallowIPLogging"]!="1">
+        <a class="link-box" href="${config.actionRoot}?module=Abuse&do=showlog">${lang("abuse.showlog")}</a>
+      </if>
+      <br><br>
+    </p>
+    <call ListStart()>\r
+    <call ListHead([
+          lang("filtergroup.name")])>
+
+    <list filtergroups as f>    
+          <call ListEntry([
+            utility.encodeHTML(f.name)],
+            "module=Abuse&groupid="+f.id, 
+            ["&do=movefiltergroupup", "&do=movefiltergroupdown", "&do=listfilters", "&do=deletefiltergroup"], 
+            [lang("filtergroup.moveup"), lang("filtergroup.movedown"), lang("filtergroup.listfilters"), lang("delete")])
+          >
+    </list>\r
+
+    <call ListEnd()>\r
+    
+    <p>
+      <a class="link-box" href="${config.actionRoot}?module=Abuse">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&do=addfiltergroup">[+] ${lang("add")}</a> &nbsp;
+      <br><br>
+    </p>
+
+  <include "foot.template">
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/admin/filterlist.template b/templates/admin/filterlist.template
new file mode 100755 (executable)
index 0000000..c708b52
--- /dev/null
@@ -0,0 +1,86 @@
+<html>
+<head>
+  <title>${config["Mir.Name"]} | ${lang("filterlist.htmltitle")}</title>
+  <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+</head>
+<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
+<include "LISTFUNCTIONS.template">
+<include "FUNCTIONS.template">
+<include "head.template">
+
+    <p>
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&amp;do=showfiltergroups">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&amp;groupid=${groupid}&amp;do=addfilter">[+] ${lang("add")}</a> &nbsp;
+      <if config["Abuse.DisallowIPLogging"]!="1">
+        <a class="link-box" href="${config.actionRoot}?module=Abuse&do=showlog">${lang("showlog")}</a>
+      </if>
+      <br><br>
+    </p>
+    <call ListStart()>\r
+    <call SpannedListHead([
+          lang("filter.type"), 
+          lang("filter.expression")], ["1","3"])>
+    <call ListHead([
+          lang("filter.articleaction"),
+          lang("filter.commentaction"),
+          lang("filter.tag"),
+          lang("filter.last_hit")])>
+    <call SpannedListHead([
+          lang("filter.comment")], ["4"])>
+    <list filters as f>    
+        <call SpannedListEntry([
+          lang("filtertype."+f.type),
+          utility.encodeHTML(f.expression)],
+          ["1","3"],
+          "module=Abuse&id="+f.id+"&groupid="+groupid, 
+           ["&do=editfilter", "&do=deletefilter"], 
+           [lang("edit"), lang("delete")])>
+          <if f.last_hit>\r
+              <call ListEntry([
+                lang("content.operation."+f.articleaction),
+                lang("comment.operation."+f.commentaction),
+                utility.encodeHTML(f.tag),
+                f.last_hit.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"])
+                ], 
+                "module=Abuse&id="+f.id+"&groupid="+groupid, 
+                ["&do=movefilterup", "&do=movefilterdown"], 
+                [lang("filters.moveup"), lang("filters.movedown")])
+              >
+          <else>
+              <call ListEntry([
+                lang("content.operation."+f.articleaction),
+                lang("comment.operation."+f.commentaction),
+                utility.encodeHTML(f.tag),
+                "-"
+                ], 
+                "module=Abuse&id="+f.id+"&groupid="+groupid, 
+                ["&do=movefilterup", "&do=movefilterdown"], 
+                [lang("filters.moveup"), lang("filters.movedown")])
+              >
+          </if>
+          <call SpannedListEntry([
+            utility.prettyEncodeHTML(f.comment)],
+            ["4"],
+            "module=Abuse&id="+f.id+"&groupid="+groupid, 
+             ["&do=movefiltertop", "&do=movefilterbottom"], 
+             [lang("filters.movetop"), lang("filters.movebottom")])>
+        <tr height="2" class="${TABLE_HEAD_CLASS}"><td colspan="6"> </td></tr>
+    </list>\r
+    <call ListEnd()>\r
+    
+    <p>
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&amp;do=showfiltergroups">[ &lt; ] ${lang("back")}</a>&nbsp;&nbsp;
+      <a class="link-box" href="${config.actionRoot}?module=Abuse&amp;groupid=${groupid}&amp;do=addfilter">[+] ${lang("add")}</a> &nbsp;
+      <if config["Abuse.DisallowIPLogging"]!="1">
+        <a class="link-box" href="${config.actionRoot}?module=Abuse&amp;do=showlog">${lang("showlog")}</a>
+      </if>
+      <br><br>
+    </p>
+
+  <include "foot.template">
+</body>
+</html>
+
+
+
+