########## 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
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
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
"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
+);
+
+
--- /dev/null
+-- 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;
+
+++ /dev/null
-StoreContainer.EntityDefaultSize 45
-StoreContainer.EntityListDefaultSize 15
-StorableObjectEntity.Entity.DefaultSize 300
-StorableObjectEntity.EntityList.DefaultSize 100
-EntityTopics.Entity.DefaultSize 200
-EntityTopics.EntityList.DefaultSize 20
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.*;
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"));
ServletModule.MediaType.EditTemplate=mediatype.template
ServletModule.MediaType.ListTemplate=mediatypelist.template
+
#
# Object store configuration
#
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
#
# 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
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;
* 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 {
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} */
*/
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)
*
/**
*
- * @param aStorage
+ * @param aModel
* @param aDefinition
* @param aQualifier
* @param anOrder
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) {
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 );
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);
}
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 );
}
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);
}
}
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() {
--- /dev/null
+/*\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
--- /dev/null
+/*\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
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);
*/
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;
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;
}
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]));
}
public Object call() throws GeneratorExc {
- return makeAdapter(function.perform(new Vector()));
+ return makeAdapter(function.perform(new ArrayList()));
}
public Object call(Object anObject) throws GeneratorExc {
private IteratorAdapter(Iterator anIterator) {
iterator = anIterator;
- valuesCache = new Vector();
+ valuesCache = new ArrayList();
if (iterator instanceof RewindableIterator) {
((RewindableIterator) iterator).rewind();
private ListAdapter(List aList) {
list = aList;
- valuesCache = new Vector();
+ valuesCache = new ArrayList();
}
private void getUntil(int anIndex) {
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;
}
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);
}
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);
};
}
/** {@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);
}
*/
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;
* ) 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 {
* @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);
*/
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);
*/
package mir.producer.reader;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
*/
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.*;
/**
*
public RSS091ChannelSectionHandler(RSSData aData) {
data = aData;
- items = new Vector();
+ items = new ArrayList();
channel = new RDFResource("rss:channel");
attributes = new HashMap();
}
private List items;
public RDFSequenceSectionHandler() {
- items = new Vector();
+ items = new ArrayList();
}
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
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/";
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");
*/
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;
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 {
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();
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");
* 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;
}
/**
*/
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";
}
* 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");
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));
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());
}
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);
}
}
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
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.*;
/**
* 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
*
*/
protected List fieldNames;
protected int[] fieldTypes;
- protected Class theEntityClass;
- protected boolean hasTimestamp = true;
+ protected Class entityClass;
private int defaultLimit;
TimeZone timezone;
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());
* @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);
+ }
}
/**
}
// 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);
// 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));
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);
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();
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;
}
}
}
- if (theEntityClass != null) {
- returnEntity = (Entity) theEntityClass.newInstance();
- returnEntity.setStorage(this);
+ if (entityClass != null) {
+ returnEntity = createNewEntity();
returnEntity.setFieldValues(theResultHash);
if (returnEntity instanceof StorableObject) {
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");
/**
* 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;
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)) + "'";
}
}
// pstmt = con.prepareStatement("select currval('" + + "_id_seq')");
returnId = getLatestInsertedId(con);
- theEntity.setId(returnId);
+ anEntity.setId(returnId);
}
catch (SQLException sqe) {
throwSQLException(sqe, "insert");
*/
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);
}
* 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);
}
}
public Class getEntityClass();
+ public Entity createNewEntity() throws StorageObjectFailure;
+
public String getIdName();
public String getTableName();
protected LoggerWrapper logger = new LoggerWrapper("Database.ObjectStore");
- /** @todo initialize logfile */
-
private StoreIdentifier() {}
public StoreIdentifier(StorableObject reference, int storeType,
this.stocType = StoreContainerType.valueOf(theClass, storeType);
}
- /**
- * Method: ivalidate
- * Description:
- *
- * @return
- */
public void invalidate() {
logger.info("Invalidating: " + toString());
// avoid deadlock due to propagation.
*/
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;
*/
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;
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;
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) {
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;
}
*/
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}
private List parseList() {
Token token;
Object expression;
- List result = new Vector();
+ List result = new ArrayList();
token = scanner.scan();
if (!(token instanceof LeftParenthesisToken)) {
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;
private Map values;
public PropertiesManipulator() {
- entries = new Vector();
+ entries = new ArrayList();
values = new HashMap();
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
+import java.util.ArrayList;
/**
}
public static List parseList(Scanner aScanner) {
- List result = new Vector();
+ List result = new ArrayList();
aScanner.skipSpace();
if (aScanner.peek() == '[')
aScanner.scan();
*/\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
--- /dev/null
+/*\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
--- /dev/null
+/*\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
--- /dev/null
+/*\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
--- /dev/null
+/*\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
--- /dev/null
+/*\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
--- /dev/null
+/*\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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*\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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*\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
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 $
*/
super();
}
- public EntityAudio(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
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 $
*/
super();
}
- public EntityComment(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
-
/**
* overridden method setFieldValues to patch creator_main_url
*/
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
*
*/
logger = new LoggerWrapper("Entity.Content");
}
- public EntityContent(StorageObject theStorage) {
- this();
-
- setStorage(theStorage);
- }
-
/**
* set is_produced flag for the article
*/
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 $
*/
logger = new LoggerWrapper("Entity.UploadedMedia.Images");
}
- public EntityImages(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
/**
* Retrieves the image data
*/
import java.util.Map;
-import mir.storage.StorageObject;
-
/**
* This class handles storage of other data and meta data
*
super();
}
- public EntityOther(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
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);
- }
-
-
}
*/
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 {
logger = new LoggerWrapper("Entity.UploadedMedia");
}
- public EntityUploadedMedia(StorageObject theStorage) {
- this();
-
- setStorage(theStorage);
- }
-
public void update() throws StorageObjectFailure {
super.update();
*/
package mircoders.entity;
-import mir.entity.Entity;
import mir.entity.AbstractEntity;
-import mir.storage.StorageObject;
/**
* This class is objectmapping of database webdb_users
super();
}
- public EntityUsers(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- // Methods
+ // Methods
public boolean isAdmin()
{
*/
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"))
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;
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();
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();
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();
(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);
}
}
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();
(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);
}
}
public List getLog() {
synchronized (log) {
try {
- List result = new Vector();
+ List result = new ArrayList();
Iterator i = log.iterator();
while (i.hasNext()) {
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);
}
}
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()) {
public List getCommentActions() {
try {
- List result = new Vector();
+ List result = new ArrayList();
Iterator i = MirGlobal.localizer().adminInterface().simpleCommentOperations().iterator();
while (i.hasNext()) {
}
}
- 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[] {'\\', ':'},
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() {
return id;
}
- public String getHitFilterType() {
- return hitFilterType;
- }
-
- public String getHitFilterExpression() {
- return hitFilterExpression;
+ public String getMatchingFilterTag() {
+ return matchingFilterTag;
}
public Date getTimeStamp() {
import java.util.Map;
import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
import mir.log.LoggerWrapper;
public class MRUCache {
\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
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
\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
}\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
}
private List convertJobInfoList(List aJobInfoList) {
- List result = new Vector();
+ List result = new ArrayList();
Iterator i = aJobInfoList.iterator();
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()) {
+++ /dev/null
-/*
- * 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
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;
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) {
+++ /dev/null
-/*
- * 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
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.*;
*/
public class MirBasicArticlePostingHandler extends MirBasicPostingSessionHandler {
- protected ModuleContent contentModule = new ModuleContent();
protected DatabaseContentToMedia contentToMedia = DatabaseContentToMedia.getInstance();
protected DatabaseContent contentDatabase = DatabaseContent.getInstance();
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);
*/
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();
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();
\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
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
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
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
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
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
\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
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
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
}\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
}\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
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
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
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
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
\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
}\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
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;
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;
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);
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.*;
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"));
filterTypesMap.remove(aName);
}
- public void addSimpleAntiAbuseFilterType(MirAntiAbuseFilterType aFilterType) {
+ public void addSimpleAntiAbuseFilterType(FilterType aFilterType) {
removeSimpleAntiAbuseFilterType(aFilterType.getName());
filterTypesMap.put(aFilterType.getName(), aFilterType);
filterTypes.add(aFilterType);
*/
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.
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;
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++) {
*/
public List loadFactories() throws MirLocalizerExc {
try {
- List producers = new Vector();
+ List producers = new ArrayList();
ProducerConfigReader reader;
ProducerNodeBuilderLibrary library = new ProducerNodeBuilderLibrary();
setupProducerNodeBuilderLibrary(library);
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();
*/\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
+++ /dev/null
-/*\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
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;
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;
/**
*
* @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 $
*/
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;
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;
* @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 $
*/
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);
}
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 ()
public Entity languageForCode(String aCode) throws ModuleExc, ModuleFailure {
try {
EntityList list = storage.selectByFieldValue("code", aCode);
+
if (list.size()>0) {
return list.elementAt(0);
}
import mir.module.AbstractModule;
import mir.module.ModuleExc;
import mir.module.ModuleFailure;
-import mir.storage.StorageObject;
import mir.util.JDBCStringRoutines;
import mircoders.storage.DatabaseMediafolder;
*/
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;
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{
ict.setColumns(leftIndexCols,rightIndexCols);
ict.setYLine(currentYPosition);
ict.setAlignment(Element.ALIGN_LEFT);
- int status=ict.go();
+ ict.go();
currentYPosition = toYPosition;
}
catch(DocumentException de) {
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){
* source
*/
- Vector extraTables = new Vector();
+ List extraTables = new ArrayList();
extraTables.add("content_x_media cxm");
Iterator images = new EntityBrowser(
DatabaseImages.getInstance(), "i", extraTables,
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;
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,
*/
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;
import mir.util.ParameterExpander;
import org.apache.xmlrpc.XmlRpcClient;
-import org.apache.xmlrpc.XmlRpcException;
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);
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;
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,
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;
}
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(
*/
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;
}
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(
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;
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);
}
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);
import mir.log.LoggerWrapper;
import mir.servlet.ServletModule;
-import mircoders.global.MirGlobal;
import mircoders.module.ModuleUploadedMedia;
import mircoders.storage.DatabaseAudio;
import mir.log.LoggerWrapper;
import mir.servlet.ServletModule;
-import mircoders.global.MirGlobal;
import mircoders.module.ModuleBreaking;
-import mircoders.storage.DatabaseBreaking;
/**
*
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
*/
private ServletModuleContent() {
super();
+ propagatedParameters.add("selectarticleurl");
logger = new LoggerWrapper("ServletModule.Content");
try {
+ definition = "content";
contentModule = new ModuleContent();
mainModule = contentModule;
}
}
}
- 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);
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"))
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);
}
responseData.put("article", article);
- List topicsList = new Vector();
+ List topicsList = new ArrayList();
String[] topicCategories = configuration.getStringArray("Mir.Localizer.Admin.TopicLists");
20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
topicsList.add(categoryMap);
}
- else
- {
-
+ else {
for (int i = 0; i < topicCategories.length; i++) {
try {
Map categoryMap = new HashMap();
}
}
- 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();
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);
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;
* 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 $
*
*/
logger = new LoggerWrapper("ServletModule.FileEdit");
directories = new HashMap();
- directoryNames = new Vector();
+ directoryNames = new ArrayList();
String settings[] = configuration.getStringArray("ServletModule.FileEdit.Configuration");
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());
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();
contentModule = new ModuleContent();
commentModule = new ModuleComment();
- administerOperations = new Vector();
+ administerOperations = new ArrayList();
String settings[] = configuration.getStringArray("Mir.Localizer.Admin.AdministerOperations");
*/
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;
/**
*
*/
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
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;
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;
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;
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
* 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 $
*
*/
}
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());
((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()) {
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();
*/
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;
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();
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();
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;
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;
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;
HttpServletResponse aResponse,
int anOffset) throws ServletModuleExc {
-// ML: to be deleted, support for 3 extra vars to be added
URLBuilder urlBuilder = new URLBuilder();
int count;
super();
logger = new LoggerWrapper("Database.ArticleType");
- this.hasTimestamp = false;
- this.mainTable = "article_type";
+ mainTable = "article_type";
}
}
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 {
*/
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();
return instance;
}
- private DatabaseBreaking() throws StorageObjectFailure
- {
+ private DatabaseBreaking() throws StorageObjectFailure {
super();
+
logger = new LoggerWrapper("Database.Breaking");
- this.mainTable="breaking";
+ mainTable="breaking";
}
-
-
}
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 {
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;
private DatabaseCommentStatus() throws StorageObjectFailure {
super();
- hasTimestamp = false;
+
mainTable = "comment_status";
logger = new LoggerWrapper("Database.CommentStatus");
}
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;
* <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 $
*
*/
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
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;
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";
primaryKeySequence="media_id_seq";
logger = new LoggerWrapper("Database.Content");
- theEntityClass = mircoders.entity.EntityContent.class;
+ entityClass = mircoders.entity.EntityContent.class;
}
// methods
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;
* <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 $
*
*/
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
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;
EntityList returnList = null;
- Vector extraTables = new Vector();
+ ArrayList extraTables = new ArrayList();
extraTables.add(mainTable + " cxm");
String mediaSelect = "cxm.content_id=c.id";
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;
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
super();
logger = new LoggerWrapper("Database.ContentToTopics");
-
- hasTimestamp = false;
mainTable="content_x_topic";
- theEntityClass = mir.entity.GenericEntity.class;
+ entityClass = mir.entity.GenericEntity.class;
}
/**
String id = content.getId();
try {
- Vector extraTables = new Vector();
+ ArrayList extraTables = new ArrayList();
extraTables.add(mainTable+" cxt");
returnList = DatabaseTopics.getInstance()
.selectByWhereClauseWithExtraTables("t",extraTables,
}
public void setTopics(String anArticleId, List aTopics) throws StorageObjectFailure {
- List newTopics = new Vector();
+ List newTopics = new ArrayList();
if (aTopics!=null) {
Iterator i = aTopics.iterator();
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,
--- /dev/null
+/*\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
--- /dev/null
+/*\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
private DatabaseImageColor() {
super();
+
logger = new LoggerWrapper("Database.ImageColor");
- hasTimestamp = false;
mainTable = "img_color";
}
private DatabaseImageFormat() {
super();
+
logger = new LoggerWrapper("Database.ImageFormat");
- hasTimestamp = false;
mainTable = "img_format";
}
}
super();
logger = new LoggerWrapper("Database.ImageLayout");
- hasTimestamp = false;
mainTable = "img_layout";
}
}
private DatabaseImageType() {
super();
- logger = new LoggerWrapper("Database.ImageType");
- hasTimestamp = false;
+ logger = new LoggerWrapper("Database.ImageType");
mainTable = "img_type";
}
}
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 {
* @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;
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()) {
super();
logger = new LoggerWrapper("Database.MediaType");
-
- hasTimestamp = false;
mainTable="media_type";
- theEntityClass = mir.entity.GenericEntity.class;
+ entityClass = mir.entity.GenericEntity.class;
}
}
if (instance == null) {
instance = new DatabaseMediafolder();
}
+
return instance;
}
super();
logger = new LoggerWrapper("Database.Mediafolder");
-
- hasTimestamp = false;
mainTable="media_folder";
}
}
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 {
super();
logger = new LoggerWrapper("Database.Rights");
-
- hasTimestamp = false;
mainTable = "rights";
}
}
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;
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()) {
mainTable="uploaded_media";
primaryKeySequence="media_id_seq";
- theEntityClass = mircoders.entity.EntityUploadedMedia.class;
+ entityClass = mircoders.entity.EntityUploadedMedia.class;
}
super();
logger = new LoggerWrapper("Database.Users");
-
- hasTimestamp = false;
mainTable = "webdb_users";
- theEntityClass = mircoders.entity.EntityUsers.class;
+ entityClass = mircoders.entity.EntityUsers.class;
}
}
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 {
+++ /dev/null
-<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">[<] ${lang("back")} </a> </p>
- <include "foot.template">
- </body>
-</html>
+++ /dev/null
-<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">[ < ] ${lang("back")}</a>
- <a class="link-box" href="${config.actionRoot}?module=Abuse&do=add">[+] ${lang("add")}</a>
- <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">[ < ] ${lang("back")}</a>
- <a class="link-box" href="${config.actionRoot}?module=Abuse&do=add">[+] ${lang("add")}</a>
- <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>
-
-
-
-
<if config["Abuse.DisallowIPLogging"]!="1">
> <a href="${config.actionRoot}?module=Abuse&do=showlog">${lang("abuse.showlog")}</a><br>
</if>
- > <a href="${config.actionRoot}?module=Abuse&do=showfilters">${lang("abuse.showfilters")}</a>
+ > <a href="${config.actionRoot}?module=Abuse&do=showfiltergroups">${lang("abuse.showfiltergroups")}</a>
</p>
</td>
<call ContentSearch ("layouted")>
</if>
-<if articles>
+<if entities>
<if showactions=="1">
<if config["Mir.Localizer.Admin.ListOperationsFlavor"]!="0">
</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>
<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>
--- /dev/null
+<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&do=listfilters&groupid=${groupid}">[<] ${lang("back")} </a> </p>
+ <include "foot.template">
+ </body>
+</html>
--- /dev/null
+<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">[<] ${lang("back")} </a> </p>
+ <include "foot.template">
+ </body>
+</html>
--- /dev/null
+<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">[ < ] ${lang("back")}</a>
+ <a class="link-box" href="${config.actionRoot}?module=Abuse&do=addfiltergroup">[+] ${lang("add")}</a>
+ <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">[ < ] ${lang("back")}</a>
+ <a class="link-box" href="${config.actionRoot}?module=Abuse&do=addfiltergroup">[+] ${lang("add")}</a>
+ <br><br>
+ </p>
+
+ <include "foot.template">
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<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&do=showfiltergroups">[ < ] ${lang("back")}</a>
+ <a class="link-box" href="${config.actionRoot}?module=Abuse&groupid=${groupid}&do=addfilter">[+] ${lang("add")}</a>
+ <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&do=showfiltergroups">[ < ] ${lang("back")}</a>
+ <a class="link-box" href="${config.actionRoot}?module=Abuse&groupid=${groupid}&do=addfilter">[+] ${lang("add")}</a>
+ <if config["Abuse.DisallowIPLogging"]!="1">
+ <a class="link-box" href="${config.actionRoot}?module=Abuse&do=showlog">${lang("showlog")}</a>
+ </if>
+ <br><br>
+ </p>
+
+ <include "foot.template">
+</body>
+</html>
+
+
+
+