public class ServletModuleOpenIndy extends ServletModule
{
- private String commentFormTemplate, commentFormDoneTemplate;
+ private String commentFormTemplate, commentFormDoneTemplate, commentFormDupeTemplate;
private String postingFormTemplate, postingFormDoneTemplate;
private ModuleContent contentModule;
private ModuleImages imageModule;
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();
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());}