From: mj Date: Sun, 23 Sep 2001 11:28:19 +0000 (+0000) Subject: Added a dupe prevention mechanism for comments. X-Git-Tag: prexmlproducerconfig~455 X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=commitdiff_plain;h=c3d3b2446a16b79702fb7583e2232ee8037df56f Added a dupe prevention mechanism for comments. --- diff --git a/doc/makejavadoc.sh b/doc/makejavadoc.sh index 312ae4fb..53ba812a 100755 --- a/doc/makejavadoc.sh +++ b/doc/makejavadoc.sh @@ -15,12 +15,12 @@ umask 022 BASEDIR=$(pwd) SOURCES=$(find $BASEDIR/../source -name \*.java) PACKAGES=$(. classpath.sh $BASEDIR/../../Mir/WEB-INF/lib/*.jar) -#LINK=/usr/share/doc/libservlet2.2-java/api +LINK=/usr/share/doc/libservlet2.2-java/api/ #echo $BASEDIR #echo $SOURCES #echo $PACKAGES -javadoc -sourcepath $PACKAGES -d /pub/Dokumente/Indymedia/de-tech/Mir/javadoc/ $SOURCES +javadoc -sourcepath $PACKAGES -d /pub/Dokumente/Indymedia/de-tech/Mir/javadoc/ -link $LINK $SOURCES umask $OLDU \ No newline at end of file diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 7322c246..1c765e04 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -33,7 +33,7 @@ import mircoders.producer.*; public class ServletModuleOpenIndy extends ServletModule { - private String commentFormTemplate, commentFormDoneTemplate; + private String commentFormTemplate, commentFormDoneTemplate, commentFormDupeTemplate; private String postingFormTemplate, postingFormDoneTemplate; private ModuleContent contentModule; private ModuleImages imageModule; @@ -49,6 +49,7 @@ public class ServletModuleOpenIndy extends ServletModule theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.OpenIndy.Logfile")); commentFormTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentTemplate"); commentFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentDoneTemplate"); + commentFormDupeTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentDupeTemplate"); postingFormTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingTemplate"); postingFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDoneTemplate"); directOp = MirConfig.getProp("DirectOpenposting").toLowerCase(); @@ -96,20 +97,28 @@ public class ServletModuleOpenIndy extends ServletModule HashMap withValues = getIntersectingValues(req, DatabaseComment.getInstance()); withValues.put("is_published","1"); - // inserting into database - String id = mainModule.add(withValues); + // Dupe detection + EntityList com = mainModule.getByWhereClause("description='"+req.getParameter("description")+"' AND to_media='"+aid+"' AND creator='"+req.getParameter("creator")+"'", 0); + if (com.getCount() > 0) { + theLog.printDebugInfo("Comment dupe dropped for article "+aid); + deliver(req, res, (TemplateModelRoot) null, commentFormDupeTemplate); + } else { - // producing new page - new ProducerContent().handle(null, null, true, false, aid); - - // sync the server - int exitValue = Helper.rsync(); - theLog.printDebugInfo("rsync:"+exitValue); - - // redirecting to url - // should implement back to article - SimpleHash mergeData = new SimpleHash(); - deliver(req, res, mergeData, commentFormDoneTemplate); + // inserting into database + String id = mainModule.add(withValues); + + // producing new page + new ProducerContent().handle(null, null, true, false, aid); + + // sync the server + int exitValue = Helper.rsync(); + theLog.printDebugInfo("rsync:"+exitValue); + + // redirecting to url + // should implement back to article + SimpleHash mergeData = new SimpleHash(); + deliver(req, res, mergeData, commentFormDoneTemplate); + } } catch (StorageObjectException e) { throw new ServletModuleException(e.toString());} catch (ModuleException e) { throw new ServletModuleException(e.toString());}