update of the open session system: articles can now also be posted
authorzapata <zapata>
Sat, 26 Apr 2003 00:42:21 +0000 (00:42 +0000)
committerzapata <zapata>
Sat, 26 Apr 2003 00:42:21 +0000 (00:42 +0000)
25 files changed:
bundles/admin_en.properties
etc/open/donearticle.template [new file with mode: 0755]
etc/open/donecomment.template
etc/open/dupearticle.template [new file with mode: 0755]
etc/open/editarticle.template [new file with mode: 0755]
etc/open/editcomment.template
etc/open/sessionerror.template [new file with mode: 0755]
etc/open/unsupportedmediatype.template [new file with mode: 0755]
source/default.properties
source/mir/servlet/AbstractServlet.java
source/mir/session/HTTPAdapters.java
source/mir/session/Request.java
source/mir/util/HTTPParsedRequest.java
source/mircoders/global/Abuse.java
source/mircoders/global/ProducerEngine.java
source/mircoders/localizer/basic/MirBasicArticlePostingHandler.java [new file with mode: 0755]
source/mircoders/localizer/basic/MirBasicCommentPostingHandler.java [new file with mode: 0755]
source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java [deleted file]
source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
source/mircoders/media/UnsupportedMediaFormatExc.java [deleted file]
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
templates/admin/superusermenu.template

index 80af4ea..f32e3e3 100755 (executable)
@@ -1,6 +1,6 @@
 ########## admin ##########
 # language: english
-# $Id: admin_en.properties,v 1.43 2003/04/09 17:05:18 zapata Exp $
+# $Id: admin_en.properties,v 1.44 2003/04/26 00:42:21 zapata Exp $
 
 languagename=English
 
@@ -248,21 +248,6 @@ language.code=Language code
 
 languagelist.htmltitle=Languages
 
-
-# imcs
-linkimcs.htmltitle=LinksImcs
-linkimcs.name=Name
-linkimcs.continent=Continent
-linkimcs.new_parent=New Parent
-linkimcs.url=URL
-linkimcs.sort_by=Sortcriteria
-linkimcs.language=Language
-linkimcs.parent=parent
-
-linkimcslist.htmltitle=LinksImcsList
-linkimcslist.search_in=Search text in
-
-
 # login
 login.htmltitle=login
 login.info=This area is only accessible to authorized groups. If you want to join as an editorial group, please contact us at the {0}.
diff --git a/etc/open/donearticle.template b/etc/open/donearticle.template
new file mode 100755 (executable)
index 0000000..1920ddd
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+       <title>${lang("postingdone.htmltitle")}</title> \r
+       <style type="text/css" media="all">@import "forms.css";</style>\r
+</head>\r
+\r
+<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#dddddd">\r
+\r
+       <table cellspacing="0" cellpadding="0" width="100%">\r
+               <tr>\r
+                       <td colspan="3" width="100%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td width="20%" bgcolor="#ff9966">\r
+                               &nbsp;&nbsp;<a href="${config["Producer.ProductionHost"]}/index.shtml" class="startlink">start &gt;&gt;</a>\r
+                       </td>\r
+                       <td width="60%" bgcolor="#ff9966" class="pad4x">\r
+                               <span id="title"><b>${lang("postingdone.title")}</b></span>\r
+                       </td>\r
+                       <td width="20%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               <br>\r
+                ${lang("postingdone.info")}<br>\r
+                               <br>\r
+                               <em>${lang("commentdone.stay_calm")}</em><br>\r
+                               <br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               \r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5Lx" bgcolor="#eecc99">\r
+                         <if referer>\r
+          <a href="${referer}"><b>${lang("postingdone.back")} &gt;&gt;</b></a>\r
+                               </if>\r
+                       </td>\r
+                       <td bgcolor="#eecc99">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x">&nbsp;<br><br></td>\r
+               </tr>\r
+       </table>\r
+\r
+\r
+</body>\r
+</html>\r
index bf9d1ed..dac560b 100755 (executable)
@@ -28,7 +28,7 @@
        </tr>
        <tr>
                <td valign="top" align="center" bgcolor="#663399">
-                       <a href="javascript:history.go(-2)"><font color="White"><b>&gt;&gt; ${lang("commentdone.back")}</b></font></a>
+                       <a href="${referer}"><font color="White"><b>&gt;&gt; ${lang("commentdone.back")}</b></font></a>
                </td>
        </tr>
 </table>
diff --git a/etc/open/dupearticle.template b/etc/open/dupearticle.template
new file mode 100755 (executable)
index 0000000..500d893
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+       <title>${lang("postingdupe.htmltitle")}</title> \r
+       <style type="text/css" media="all">@import "forms.css";</style>\r
+</head>\r
+\r
+<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#dddddd">\r
+\r
+       <table cellspacing="0" cellpadding="0" width="100%">\r
+               <tr>\r
+                       <td colspan="3" width="100%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td width="20%" bgcolor="#cc3333">\r
+                               &nbsp;&nbsp;<a href="${config["Producer.ProductionHost]}/index.shtml" class="startlink">start &gt;&gt;</a>\r
+                       </td>\r
+                       <td width="60%" bgcolor="#cc3333" class="pad4x">\r
+                               <span id="title"><b>${lang("postingdupe.title")}</b></span>\r
+                       </td>\r
+                       <td width="20%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               <br>\r
+                ${lang("postingdupe.explanation")}<br>\r
+                               <br>\r
+                               <em><font color="#cc3333">${lang("postingdupe.no_panic")}</font></em><br>\r
+                               <br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               \r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5Lx" bgcolor="#eecc99">\r
+                               <a href="javascript:history.go(-2)"><b>${lang("postingdupe.back")} &gt;&gt;</b></a>\r
+                       </td>\r
+                       <td bgcolor="#eecc99">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x">&nbsp;<br><br></td>\r
+               </tr>\r
+       </table>\r
+\r
+\r
+</body>\r
+</html>\r
diff --git a/etc/open/editarticle.template b/etc/open/editarticle.template
new file mode 100755 (executable)
index 0000000..4fc94a8
--- /dev/null
@@ -0,0 +1,328 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+       <title>${lang("posting.htmltitle")}</title>     \r
+       <meta name="description" content="${lang("posting.meta.description")}>\r
+       <meta name="author" content="${lang("posting.meta.author")}>\r
+       <meta name="keywords" content="${lang("posting.meta.keywords")}>\r
+       <meta http-equiv="Content-Type" content="text/html; charset=${lang("htmlcharset")}>\r
+       <meta name="robots" content="index">\r
+       <meta name="robots" content="follow">\r
+       <style type="text/css" media="all">@import "forms.css";</style>\r
+</head>\r
+\r
+<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#dddddd">\r
+\r
+       <table cellspacing="0" cellpadding="0" width="100%">\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+    <if errors>
+      <tr>
+        <td colspan="3">
+          Your input had the following errors:<br><br>
+          <list errors as e>
+            <font color="red">
+              <if e.field>
+                ${lang("content."+e.field)}:
+              </if>
+              ${lang(e.message)} <br>
+            </font>
+          </list>
+        </td>
+      </tr>
+    </if>\r
+\r
+               <form enctype="multipart/form-data" action="${actionURL}&do=opensession&sessiontype=article" method="post">\r
+    <if password>
+      <tr>
+        <td align="right">&nbsp;</td>
+        <td>
+          ${lang("comment.note")}
+          <br>\r
+          ${password}<br>
+          <br>
+        </td>
+        <td>&nbsp;</td>
+      </tr>
+      <tr>
+        <td></td>
+        <td valign="top">
+           ${lang("comment.password")}: <input type="text" name="password" size="10">
+        </td>
+        <td>&nbsp;</td>
+      </tr>
+    </if>
+               <tr>\r
+                       <td colspan="3" width="100%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td width="20%" bgcolor="#cc0033">\r
+                               &nbsp;\r
+                       </td>\r
+                       <td width="60%" bgcolor="#cc0033" class="pad4x">\r
+                               <span id="title"><b>${lang("posting.form.title")}</b></span>\r
+                       </td>\r
+                       <td width="20%">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               <b>Please follow this form step by step. \r
+                               Especially if this is the first time you post something on indymedia, \r
+                               be sure to read the introductory remarks. \r
+                               Then come back to this form!<br>\r
+                               <a href="#intro">intro &gt;&gt;</a><br><br></b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>&nbsp;</td>\r
+                       <td bgcolor="#cc6666" class="pad4x">\r
+                               <span class="subtitle"><b><a name="form" id="form">Number of media files</a></b></span>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               <font color="#FF0000">First of all</font> if you want to upload more than one media files \r
+                               please change the following number accordingly! Than press the button to reload this page. <br><br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               <b>${lang("posting.nr_of_media")}</b><br><br>\r
+                       </td>\r
+                       <td class="pad5L" >\r
+                               <input type="text" name="nrmediaitems" value="${utility.encodeHTML(nrmediaitems)}" size="2" class="r">&nbsp;<input type="submit" value="${lang("posting.nr_of_media.submit")}"><br><br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right" valign="top">&nbsp;</td>\r
+                       <td valign="top" bgcolor="#cc9999" class="pad4x">\r
+                               <b><font color="#cc0033">R E Q U I R E D</font> information</b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.title")}:\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="title" class="w95r" maxlength="45" value="${utility.encodeHTML(title)}">\r
+                       </td>\r
+                       <td valign="top"><font size="1">${lang("posting.title.info")}</font></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right" valign="top">\r
+                               ${lang("posting.abstract")}:\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <textarea name="description" rows="6" wrap="virtual" class="w95rs">${utility.encodeHTML(description)}</textarea>\r
+                       </td>\r
+                       <td valign="top"><font size="1">${lang("posting.abstract.info")}</font></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right" valign="top">\r
+                               ${lang("posting.text")}:\r
+                       </td>\r
+                       <td class="pad5L"> \r
+                               <textarea name="content_data" rows="20" wrap="soft" class="w95rf">${utility.encodeHTML(content_data)}</textarea>\r
+                       </td>\r
+                       <td valign="top"><font size="1">${lang("posting.text.info")}</font></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.author")}:<br><br>\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="creator" value="${utility.encodeHTML(creator)}" class="w95r" maxlength="45">\r
+                               <br><br>\r
+                       </td>\r
+                       <td valign="top"></td>\r
+               </tr>\r
+               \r
+               <tr>\r
+                       <td align="right" valign="top">&nbsp;</td>\r
+                       <td valign="top" bgcolor="#cc9999" class="pad4x">\r
+                               <b>Additional information</b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.language")}:<br><br>\r
+                       </td>\r
+                       <td class="pad5L">                      \r
+                               <select name="to_language" class="w60" size="1">\r
+                                       <list languages as l>\r
+              <option <if to_language==l.id>selected</if> value="${l.id}">${l.name}</option>\r
+                                       </list>\r
+                               </select>\r
+                               <br><br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right" valign="top">\r
+                               ${lang("posting.topic")}:<br><br>\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <list topics as t>\r
+                                       <input type="checkbox" name="to_topic" value="${t.id}" <list to_topic as to><if (t.id == to)>checked</if></list>>&nbsp;${t.title}<br>\r
+                               </list>\r
+                               <br>\r
+                       </td>\r
+                       <td valign="top"><font size="1">${lang("posting.topic.info")}</font></td>\r
+               </tr>\r
+               \r
+               <tr>\r
+                       <td align="right" valign="top">&nbsp;</td>\r
+                       <td valign="top" bgcolor="#cc9999" class="pad4x">\r
+                               <b>Contact information</b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                                ${lang("posting.contact.info")}\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.email")}:\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="creator_email" maxlength="80" value="${utility.encodeHTML(creator_email)}" class="w60">\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.url")}:\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="creator_main_url" maxlength="160" value="${utility.encodeHTML(creator_main_url)}" class="w60">\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.address")}:\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="creator_address" maxlength="160" value="${utility.encodeHTML(creator_address)}" class="w60">\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">\r
+                               ${lang("posting.phone")}<br><br>\r
+                       </td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="creator_phone" maxlength="20" value="${utility.encodeHTML(creator_phone)}" class="w60"><br><br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               \r
+               <tr>\r
+                       <td align="right" valign="top">&nbsp;</td>\r
+                       <td valign="top" bgcolor="#cc9999" class="pad4x">\r
+                               <b>${lang("posting.media")}</b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right"></td>\r
+                       <td class="pad5L">\r
+                                ${lang("posting.media.howto")}\r
+                       </td>\r
+                       <td valign="top"><font size="-2">${lang("posting.media.info")}</font></td>\r
+               </tr>\r
+  \r
+       <list mediaitems as m>\r
+               <tr>\r
+                       <td align="right">${lang("posting.media.title")} ${m}:</td>\r
+                       <td class="pad5L">\r
+                               <input type="text" name="media${m}_title" maxlength="80" value="" class="w60">\r
+                       </td>\r
+                       <td valign="top"></font></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">${lang("posting.media.media")} ${m}:</td>\r
+                       <td class="pad5L">\r
+                               <input type="file" name="media${m}" maxlength="80" value="" class="w60"><br><br>\r
+                       </td>\r
+                       <td valign="top"></font></td>\r
+               </tr>\r
+       </list>\r
+               \r
+               <tr>\r
+                       <td align="right" valign="top">&nbsp;</td>\r
+                       <td valign="top" bgcolor="#cc9999" class="pad4x">\r
+                               <b>Publish this!</b>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad4x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               ${lang("posting.submit.info")}<br><br>\r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5Lx" bgcolor="#cc0033">\r
+                               <input id="button" type="submit" name="post" value="${lang("posting.submit")}">\r
+                       </td>\r
+                       <td bgcolor="#cc0033">&nbsp;</td>\r
+               </tr>\r
+               <tr>\r
+                       <td colspan="3" class="pad2x"><span class="size2px">&nbsp;</span></td>\r
+               </tr>\r
+    </form>\r
+               <tr>\r
+                       <td align="right">&nbsp;</td>\r
+                       <td class="pad5L">\r
+                               ${lang("posting.criteria")}\r
+                               <br><br><br><br><br>\r
+                               <b><font size="+1"><a name="intro" id="intro">${lang("posting.title")}</a></font></b><br><br>\r
+                               \r
+                               <include "open/disclaimer.inc.de"><br><br>\r
+                               \r
+                               <a href="#form"><b>${lang("posting.jump_to_form")}</b></a>\r
+                               \r
+                       </td>\r
+                       <td>&nbsp;</td>\r
+               </tr>\r
+       </table>\r
+</body>\r
+</html>\r
index 5414017..b5eff3f 100755 (executable)
@@ -1,20 +1,20 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
-<html>\r
-  <head>\r
-    <title>${lang("comment.htmltitle")}</title> \r
-  </head>\r
-  \r
-  <body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#dddddd">\r
-    <form enctype="multipart/form-data" action="${actionURL}&do=opensession" method="post">\r
-      <input type="hidden" name="do" value="processcomment">\r
-      <input type="hidden" name="to_media" value="${to_media}">\r
-    \r
-      <table cellspacing="0" cellpadding="0" width="100%">\r
-        <tr>\r
-          <td colspan="3"><span>&nbsp;</span></td>\r
-        </tr>
-        <if errors>\r
-        <tr>\r
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <title>${lang("comment.htmltitle")}</title> 
+  </head>
+  
+  <body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#dddddd">
+    <form enctype="multipart/form-data" action="${actionURL}&do=opensession&sessiontype=comment" method="post">
+      <input type="hidden" name="do" value="processcomment">
+      <input type="hidden" name="to_media" value="${to_media}">
+    
+      <table cellspacing="0" cellpadding="0" width="100%">
+        <tr>
+          <td colspan="3"><span>&nbsp;</span></td>
+        </tr>
+        <if errors>
+        <tr>
           <td colspan="3">
             Your input had the following errors:<br><br>
             <list errors as e>
               ${lang(e.message)} <br>
               </font>
             </list>
-          </td>\r
-        </tr>
-        </if>\r
-        <if password>\r
-          <tr>\r
-            <td align="right">&nbsp;</td>\r
-            <td>\r
-              ${lang("comment.note")}\r
-                     <br>${data.passwd}<br>\r
-               <br>\r
-            </td>\r
-            <td>&nbsp;</td>\r
-          </tr>\r
-          <tr>\r
-            <td></td>\r
-            <td  valign="top">\r
-                  ${lang("comment.password")}: <input type="text" name="passwd" size="10">\r
-            </td>\r
-            <td>&nbsp;</td>\r
-          </tr>\r
-        </if>\r
-        <tr>\r
-          <td width="20%" bgcolor="#cc0033">\r
-          </td>\r
-          <td width="60%" bgcolor="#cc0033">\r
-            <span id="title"><b>${lang("comment.formtitle")}</b></span>\r
-          </td>\r
-          <td width="20%">&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td colspan="3"><span>&nbsp;</span></td>\r
-        </tr>\r
-\r
-        <tr>\r
-          <td align="right" valign="top">&nbsp;</td>\r
-          <td valign="top" bgcolor="#cc9999" cellpadding="8" >\r
-            <b><font color="#cc0033">R E Q U I R E D</font> information</b>\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td colspan="3"><span>&nbsp;</span></td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.title")}:\r
-          </td>\r
-          <td>\r
-            <input type="text" name="title"  maxlength="45" value="${utility.encodeHTML(title)}">\r
-          </td>\r
-          <td></td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right" valign="top">\r
-            ${lang("comment.text")}:\r
-          </td>\r
-          <td> \r
-            <textarea name="description" rows="10" wrap="virtual">${utility.encodeHTML(description)}</textarea>\r
-          </td>\r
-          <td></td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.name")}:<br><br>\r
-          </td>\r
-          <td>\r
-            <input type="text" name="creator"  maxlength="45" value="${utility.encodeHTML(creator)}">\r
-            <br><br>\r
-          </td>\r
-          <td></td>\r
-        </tr>\r
-        \r
-        <tr>\r
-          <td align="right" valign="top">&nbsp;</td>\r
-          <td valign="top" bgcolor="#cc9999">\r
-            <b>Additional information</b>\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td colspan="3"><span>&nbsp;</span></td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.language")}:<br><br>\r
-          </td>\r
-          <td>      \r
-            <select name="to_language"  size="1">\r
-              <list languages as l>\r
-                <option value="${l.id}" <if to_language==l.id>selected="1"</if>>${l.name}</option>\r
-              </list>\r
-            </select>\r
-            <br><br>\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        \r
-        <tr>\r
-          <td align="right" valign="top">&nbsp;</td>\r
-          <td valign="top" bgcolor="#cc9999">\r
-            <b>Contact information</b>\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td colspan="3"><span>&nbsp;</span></td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">&nbsp;</td>\r
-          <td>\r
-             ${lang("comment.contact.info")}\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.email")}:\r
-          </td>\r
-          <td>\r
-            <input type="text" name="email" maxlength="80" value="">\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.url")}:\r
-          </td>\r
-          <td>\r
-            <input type="text" name="main_url" maxlength="160" value="http://">\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.address")}:\r
-          </td>\r
-          <td>\r
-            <input type="text" name="address" maxlength="160" value="">\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td align="right">\r
-            ${lang("comment.phone")}<br><br>\r
-          </td>\r
-          <td>\r
-            <input type="text" name="phone" maxlength="20" value=""><br><br>\r
-          </td>\r
-          <td>&nbsp;</td>\r
-        </tr>\r
-        \r
+          </td>
+        </tr>
+        </if>
+        <if password>
+          <tr>
+            <td align="right">&nbsp;</td>
+            <td>
+              ${lang("comment.note")}<br>
+              ${password}<br>
+              <br>
+            </td>
+            <td>&nbsp;</td>
+          </tr>
+          <tr>
+            <td></td>
+            <td valign="top">
+              ${lang("comment.password")}: <input type="text" name="password" size="10">
+            </td>
+            <td>&nbsp;</td>
+          </tr>
+        </if>
+        <tr>
+          <td width="20%" bgcolor="#cc0033">
+          </td>
+          <td width="60%" bgcolor="#cc0033">
+            <span id="title"><b>${lang("comment.formtitle")}</b></span>
+          </td>
+          <td width="20%">&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="3"><span>&nbsp;</span></td>
+        </tr>
+
+        <tr>
+          <td align="right" valign="top">&nbsp;</td>
+          <td valign="top" bgcolor="#cc9999" cellpadding="8" >
+            <b><font color="#cc0033">R E Q U I R E D</font> information</b>
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="3"><span>&nbsp;</span></td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.title")}:
+          </td>
+          <td>
+            <input type="text" name="title"  maxlength="45" value="${utility.encodeHTML(title)}">
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top">
+            ${lang("comment.text")}:
+          </td>
+          <td> 
+            <textarea name="description" rows="10" wrap="virtual">${utility.encodeHTML(description)}</textarea>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.name")}:<br><br>
+          </td>
+          <td>
+            <input type="text" name="creator"  maxlength="45" value="${utility.encodeHTML(creator)}">
+            <br><br>
+          </td>
+          <td></td>
+        </tr>
+        
+        <tr>
+          <td align="right" valign="top">&nbsp;</td>
+          <td valign="top" bgcolor="#cc9999">
+            <b>Additional information</b>
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="3"><span>&nbsp;</span></td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.language")}:<br><br>
+          </td>
+          <td>      
+            <select name="to_language"  size="1">
+              <list languages as l>
+                <option value="${l.id}" <if to_language==l.id>selected="1"</if>>${l.name}</option>
+              </list>
+            </select>
+            <br><br>
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        
+        <tr>
+          <td align="right" valign="top">&nbsp;</td>
+          <td valign="top" bgcolor="#cc9999">
+            <b>Contact information</b>
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="3"><span>&nbsp;</span></td>
+        </tr>
+        <tr>
+          <td align="right">&nbsp;</td>
+          <td>
+             ${lang("comment.contact.info")}
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.email")}:
+          </td>
+          <td>
+            <input type="text" name="email" maxlength="80" value="${utility.encodeHTML(email)}">
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.url")}:
+          </td>
+          <td>
+            <input type="text" name="main_url" maxlength="160" value="${utility.encodeHTML(main_url)}">
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.address")}:
+          </td>
+          <td>
+            <input type="text" name="address" maxlength="160" value="${utility.encodeHTML(address)}">
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td align="right">
+            ${lang("comment.phone")}<br><br>
+          </td>
+          <td>
+            <input type="text" name="phone" maxlength="20" value="${utility.encodeHTML(phone)}"><br><br>
+          </td>
+          <td>&nbsp;</td>
+        </tr>
+        
        <tr>
                <td>
                ${lang("posting.media.title")} 1:
                </td>
                <td colspan="2">
-                       <input type="text" name="media_title1" size="40" maxlength="80" value=""><br>
+                       <input type="text" name="media1_title" size="40" maxlength="80" value=""><br>
                </td>
        </tr>
        <tr>
                ${lang("posting.media.title")} 2:
                </td>
                <td colspan="2">
-                       <input type="text" name="media_title2" size="40" maxlength="80" value=""><br>
+                       <input type="text" name="media2_title" size="40" maxlength="80" value=""><br>
                </td>
        </tr>
        <tr>
                ${lang("posting.media.title")} 3:
                </td>
                <td colspan="2">
-                       <input type="text" name="media_title3" size="40" maxlength="80" value=""><br>
+                       <input type="text" name="media3_title" size="40" maxlength="80" value=""><br>
                </td>
        </tr>
        <tr>
                        <INPUT TYPE="file" NAME="media3">
                </td>
        </tr>
-        <tr>\r
-          <td align="right">&nbsp;</td>\r
-          <td  bgcolor="#cc0033">\r
-            <input id="button" type="submit" value="${lang("comment.submit")}">\r
-          </td>\r
-          <td bgcolor="#cc0033">&nbsp;</td>\r
-        </tr>\r
-        <tr>\r
-          <td colspan="3">&nbsp;<br><br></td>\r
-        </tr>\r
-      </table>\r
-    </form>\r
-  </body>\r
-</html>\r
+        <tr>
+          <td align="right">&nbsp;</td>
+          <td  bgcolor="#cc0033">
+            <input id="button" type="submit" value="${lang("comment.submit")}">
+          </td>
+          <td bgcolor="#cc0033">&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="3">&nbsp;<br><br></td>
+        </tr>
+      </table>
+    </form>
+  </body>
+</html>
diff --git a/etc/open/sessionerror.template b/etc/open/sessionerror.template
new file mode 100755 (executable)
index 0000000..2a0395d
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+    <title>${config["Mir.Name"]} | ${lang("error.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+</head>
+<body>
+<include "head.template">
+<table width="100%" border="0" align="center">
+       <tr class="grey">
+               <td>
+                       <div align="center"><h2><font class="specialtext">${lang("error.title")}</font></h2>
+                       </div>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>
+                       <p align="center"><font color="red">${data.date} -- ${data.errorstring}</font>
+                       <p>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p align="center">
+            ${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+                       <p>
+               </td>
+       </tr>
+</table>
+<include "foot.template">
+</body>
+</html>
diff --git a/etc/open/unsupportedmediatype.template b/etc/open/unsupportedmediatype.template
new file mode 100755 (executable)
index 0000000..2a0395d
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+    <title>${config["Mir.Name"]} | ${lang("error.htmltitle")}</title>
+    <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+</head>
+<body>
+<include "head.template">
+<table width="100%" border="0" align="center">
+       <tr class="grey">
+               <td>
+                       <div align="center"><h2><font class="specialtext">${lang("error.title")}</font></h2>
+                       </div>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p>
+                       <p align="center"><font color="red">${data.date} -- ${data.errorstring}</font>
+                       <p>
+               </td>
+       </tr>
+       <tr>
+               <td>
+                       <p align="center">
+            ${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])}
+                       <p>
+               </td>
+       </tr>
+</table>
+<include "foot.template">
+</body>
+</html>
index 2785101..e4d232c 100755 (executable)
@@ -362,9 +362,17 @@ Mir.DefaultHTMLCharset=UTF-8
 
 
 
+Localizer.OpenSession.article.EditTemplate = editarticle.template
+Localizer.OpenSession.article.DupeTemplate = dupearticle.template
+Localizer.OpenSession.article.DoneTemplate = donearticle.template
+Localizer.OpenSession.article.UnsupportedMediaTemplate = unsupportedmediatype.template
 Localizer.OpenSession.comment.EditTemplate = editcomment.template
-Localizer.OpenSession.comment.DupeTemplate = donecomment.template
-Localizer.OpenSession.comment.DoneTemplate = dupecomment.template
+Localizer.OpenSession.comment.DupeTemplate = dupecomment.template
+Localizer.OpenSession.comment.DoneTemplate = donecomment.template
+Localizer.OpenSession.comment.UnsupportedMediaTemplate = unsupportedmediatype.template
+Localizer.OpenSession.ErrorTemplate = sessionerror.template
+
+
 
 
 #
index ef0d592..cc2463e 100755 (executable)
  * 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.  
+ * 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 mir.servlet;
@@ -56,7 +56,7 @@ import com.codestudio.util.SQLManager;
  * Copyright:    Copyright (c) 2001, 2002
  * Company:      Mir-coders group
  * @author       idfx, the Mir-coders group
- * @version      $Id: AbstractServlet.java,v 1.29 2003/04/21 12:42:50 idfx Exp $
+ * @version      $Id: AbstractServlet.java,v 1.30 2003/04/26 00:42:21 zapata Exp $
  */
 
 public abstract class AbstractServlet extends HttpServlet {
@@ -197,30 +197,29 @@ public abstract class AbstractServlet extends HttpServlet {
       pool = manager.createPool(meta);
     }
   }
-  
+
   private void setEncoding(HttpServletRequest request){
-       try {
-                       Class reqClass = request.getClass();
-                       Method method = reqClass.getMethod("setCharacterEncoding", new Class[]{String.class});
-                       String encoding = configuration.getString("Mir.DefaultHTMLCharset");
-                       method.invoke(request, new Object[]{encoding});                 
-               } catch (NoSuchMethodException e) {
-                       // TODO set the encoding in a zapata-way
-                       e.printStackTrace();
-                       logger.error("not yes implemented: " + e.getMessage());
-               } catch (SecurityException e) {
-                       logger.error(e.getMessage());
-                       e.printStackTrace();
-               } catch (IllegalArgumentException e) {
-                       logger.error(e.getMessage());
-                       e.printStackTrace();
-               } catch (IllegalAccessException e) {
-                       logger.error(e.getMessage());
-                       e.printStackTrace();
-               } catch (InvocationTargetException e) {
-                       logger.error(e.getMessage());
-                       e.printStackTrace();
-               }
+    try {
+      Class reqClass = request.getClass();
+      Method method = reqClass.getMethod("setCharacterEncoding", new Class[]{String.class});
+      String encoding = configuration.getString("Mir.DefaultHTMLCharset");
+      method.invoke(request, new Object[]{encoding});
+    } catch (NoSuchMethodException e) {
+      // TODO set the encoding in a zapata-way
+//      logger.warn("set encoding not yet implemented: " + e.getMessage());
+    } catch (SecurityException e) {
+      logger.error(e.getMessage());
+      e.printStackTrace();
+    } catch (IllegalArgumentException e) {
+      logger.error(e.getMessage());
+      e.printStackTrace();
+    } catch (IllegalAccessException e) {
+      logger.error(e.getMessage());
+      e.printStackTrace();
+    } catch (InvocationTargetException e) {
+      logger.error(e.getMessage());
+      e.printStackTrace();
+    }
   }
 
   protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
index 9ca728b..83ed63d 100755 (executable)
  * 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.  
+ * 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 mir.session;
@@ -48,6 +48,10 @@ public class HTTPAdapters {
       request = aRequest;
     }
 
+    public String getHeader(String aHeaderName) {
+      return request.getHeader(aHeaderName);
+    };
+
     public String getParameter(String aName) {
       return request.getParameter(aName);
     };
@@ -72,6 +76,10 @@ public class HTTPAdapters {
       request = aRequest;
     }
 
+    public String getHeader(String aHeaderName) {
+      return request.getHeader(aHeaderName);
+    };
+
     public String getParameter(String aName) {
       return request.getParameter(aName);
     };
@@ -111,7 +119,10 @@ public class HTTPAdapters {
     }
 
     public void setAttribute(String aName, Object aNewValue) {
-      session.setAttribute(aName, aNewValue);
+      if (aNewValue==null)
+        deleteAttribute(aName);
+      else
+        session.setAttribute(aName, aNewValue);
     }
 
     public void terminate() {
index 278e09f..3133000 100755 (executable)
  * 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.  
+ * 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 mir.session;
@@ -35,4 +35,5 @@ public interface Request {
   public String getParameter(String aName);
   public List getUploadedFiles();
   public List getParameters(String aName);
+  public String getHeader(String aHeaderName);
 }
\ No newline at end of file
index fb22d60..ba30796 100755 (executable)
  * 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.  
+ * 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 mir.util;
@@ -85,6 +85,10 @@ public class HTTPParsedRequest {
     return (String) stringValues.get(aName);
   }
 
+  public String getHeader(String aName) {
+    return request.getHeader(aName);
+  }
+
   public List getFiles() {
     return files;
   }
index 55eed8c..41b31f8 100755 (executable)
  * 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.  
+ * 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.
  */
 
@@ -218,15 +218,32 @@ public class Abuse {
     }
   }
 
-  public void checkArticle(EntityContent anArticle, HttpServletRequest aRequest, HttpServletResponse aResponse) {
+  public void checkArticle(EntityContent anArticle, Request aRequest, HttpServletResponse aResponse) {
     try {
       long time = System.currentTimeMillis();
+      String address = "0.0.0.0";
+      String browser = "unknown";
+      Cookie[] cookies = {};
+
+      HttpServletRequest request = null;
+
+      if (aRequest instanceof HTTPAdapters.HTTPParsedRequestAdapter) {
+        request = ((HTTPAdapters.HTTPParsedRequestAdapter) aRequest).getRequest();
+      }
+      else if (aRequest instanceof HTTPAdapters.HTTPRequestAdapter) {
+        request = ((HTTPAdapters.HTTPRequestAdapter) aRequest).getRequest();
+      }
+      if (request!=null) {
+        browser = (String) request.getHeader("User-Agent");
+        address = request.getRemoteAddr();
+        cookies = request.getCookies();
+      }
 
-      logArticle(aRequest.getRemoteAddr(), anArticle.getId(), new Date(), (String) aRequest.getHeader("User-Agent"));
+      logArticle(address, anArticle.getId(), new Date(), browser);
 
       MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation = MirGlobal.localizer().adminInterface().simpleCommentOperationForName(commentBlockAction);
 
-      if (checkCookie(Arrays.asList(aRequest.getCookies())) || checkIpFilter(aRequest.getRemoteAddr()) || checkRegExpFilter(anArticle)) {
+      if (checkCookie(Arrays.asList(cookies)) || checkIpFilter(address) || checkRegExpFilter(anArticle)) {
         operation.perform(null, MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", anArticle));
         setCookie(aResponse);
       }
index fff103d..518fac8 100755 (executable)
  * 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.  
+ * 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.global;
@@ -246,13 +246,16 @@ private class ProducerJob {
 
       i = StringRoutines.splitString(aList, ";").iterator();
       while (i.hasNext()) {
-        String taskExpression = (String) i.next();
-        List parts = StringRoutines.splitString(taskExpression, ".");
+        String taskExpression = ((String) i.next()).trim();
 
-        if (parts.size()!=2)
-          throw new ProducerEngineExc("Invalid producer expression: '" + taskExpression + "'");
-        else
-          result.add(new ProducerEngine.ProducerTask((String) parts.get(0), (String) parts.get(1)));
+        if (taskExpression.length()>0) {
+          List parts = StringRoutines.splitString(taskExpression, ".");
+
+          if (parts.size() != 2)
+            throw new ProducerEngineExc("Invalid producer expression: '" + taskExpression + "'");
+          else
+            result.add(new ProducerEngine.ProducerTask( (String) parts.get(0), (String) parts.get(1)));
+        }
       }
 
       return result;
diff --git a/source/mircoders/localizer/basic/MirBasicArticlePostingHandler.java b/source/mircoders/localizer/basic/MirBasicArticlePostingHandler.java
new file mode 100755 (executable)
index 0000000..6afb6f7
--- /dev/null
@@ -0,0 +1,409 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.UploadedFile;
+import mir.util.ExceptionFunctions;
+import mircoders.global.MirGlobal;
+import mir.misc.*;
+import mircoders.media.MediaUploadProcessor;
+import mircoders.module.*;
+import mircoders.entity.*;
+import mircoders.storage.*;
+import mircoders.storage.DatabaseContent;
+import mircoders.media.*;
+
+/**
+ *
+ * <p>Title: Experimental session handler for article postings </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author Zapata
+ * @version 1.0
+ */
+
+public class MirBasicArticlePostingHandler extends MirBasicPostingSessionHandler {
+  protected ModuleContent contentModule = new ModuleContent(DatabaseContent.getInstance());
+  protected DatabaseContentToMedia contentToMedia = DatabaseContentToMedia.getInstance();
+  protected DatabaseContent contentDatabase = DatabaseContent.getInstance();
+
+  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    super.initializeResponseData(aRequest, aSession, aResponse);
+
+    Iterator i = DatabaseContent.getInstance().getFields().iterator();
+    while (i.hasNext()) {
+      String field = (String) i.next();
+      aResponse.setResponseValue(field, aRequest.getParameter(field));
+    }
+    aResponse.setResponseValue("to_topic", aRequest.getParameter("to_topic"));
+  }
+
+  public void validate(List aResults, Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    testFieldEntered(aRequest, "title", "validationerror.missing", aResults);
+    testFieldEntered(aRequest, "description", "validationerror.missing", aResults);
+    testFieldEntered(aRequest, "creator", "validationerror.missing", aResults);
+    testFieldEntered(aRequest, "content_data", "validationerror.missing", aResults);
+  }
+
+  public void finalizeArticle(Request aRequest, Session aSession, EntityContent aContent) throws SessionExc, SessionFailure {
+    aContent.setValueForProperty("is_published", "1");
+    aContent.setValueForProperty("is_produced", "0");
+    aContent.setValueForProperty("date", StringUtil.date2webdbDate(new GregorianCalendar()));
+    aContent.setValueForProperty("is_html","0");
+    aContent.setValueForProperty("publish_path", StringUtil.webdbDate2path(aContent.getValue("date")));
+    aContent.setValueForProperty("to_article_type", "1");
+    aContent.setValueForProperty("to_publisher", "1");
+  }
+
+  public void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    try {
+      String id;
+      Map values = getIntersectingValues(aRequest, DatabaseContent.getInstance());
+
+      EntityContent article = (EntityContent) contentModule.createNew();
+      article.setValues(values);
+
+      finalizeArticle(aRequest, aSession, article);
+      id = article.insert();
+      if (id == null) {
+        logger.info("Duplicate article rejected");
+        throw new DuplicateArticleExc("Duplicate article rejected");
+      }
+      aSession.setAttribute("content", article);
+
+      // topics:
+      List topics = aRequest.getParameters("to_topic");
+      if (topics.size() > 0) {
+        try {
+          DatabaseContentToTopics.getInstance().setTopics(id, topics);
+        }
+        catch (Throwable e) {
+          logger.error("setting content_x_topic failed");
+          contentModule.deleteById(id);
+          throw new SessionFailure("MirBasicArticlePostingHandler: can't set topics: " + e.toString(), e);
+        }
+      }
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+  }
+
+  public void processUploadedFile(Request aRequest, Session aSession, UploadedFile aFile) throws SessionExc, SessionFailure {
+    try {
+      Map values = new HashMap();
+      values.put("title", aRequest.getParameter(aFile.getFieldName()+"_title"));
+      values.put("creator", aRequest.getParameter("creator"));
+      values.put("to_publisher", "0");
+      values.put("is_published", "1");
+      values.put("is_produced", "1");
+      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, values);
+      mediaItem.update();
+      contentToMedia.addMedia(((EntityContent) aSession.getAttribute("content")).getId(), mediaItem.getId());
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+  }
+
+  public void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    EntityContent article = (EntityContent) aSession.getAttribute("content");
+
+    MirGlobal.abuse().checkArticle(article, aRequest, null);
+    try {
+      MirGlobal.localizer().openPostings().afterContentPosting(article);
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+    logger.info("article posted");
+  };
+
+  protected void makeInitialResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));
+  };
+
+  protected void makeResponse(Request aRequest, Session aSession, Response aResponse, List anErrors) throws SessionExc, SessionFailure {
+    aResponse.setResponseValue("errors", anErrors);
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));
+  };
+
+  protected void makeFinalResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.article.DoneTemplate"));
+  };
+
+  protected void makeErrorResponse(Request aRequest, Session aSession, Response aResponse, Throwable anError) throws SessionExc, SessionFailure {
+    anError.printStackTrace();
+    Throwable rootCause = ExceptionFunctions.traceCauseException(anError);
+
+    if (rootCause instanceof DuplicateArticleExc)
+      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.article.DupeTemplate"));
+    if (rootCause instanceof ModuleMediaType.UnsupportedMimeTypeExc) {
+      aResponse.setResponseValue("mimetype", ((ModuleMediaType.UnsupportedMimeTypeExc) rootCause).getMimeType());
+      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.article.UnsupportedMediaTemplate"));
+    }
+    else
+      super.makeErrorResponse(aRequest, aSession, aResponse, anError);
+  };
+
+  protected static class DuplicateArticleExc extends SessionExc {
+    public DuplicateArticleExc(String aMessage) {
+      super(aMessage);
+    }
+  }
+}
+
+/*
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.UploadedFile;
+import mir.util.ExceptionFunctions;
+import mircoders.entity.EntityContent;
+import mircoders.global.MirGlobal;
+import mircoders.media.MediaUploadProcessor;
+import mircoders.module.ModuleContent;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseContentToMedia;
+import mircoders.storage.DatabaseContent;
+
+public abstract class MirBasicArticlePostingHandler extends MirBasicPostingSessionHandler {
+  protected ModuleContent contentModule;
+  protected DatabaseContentToMedia contentToMedia = DatabaseContentToMedia.getInstance();
+
+  public MirBasicArticlePostingHandler() {
+    super();
+
+    contentModule= new ModuleContent(DatabaseContent.getInstance());
+  }
+
+  public void processRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    if (aSession.getAttribute("initialRequest")==null) {
+      initialRequest(aRequest, aSession, aResponse);
+      aSession.setAttribute("initialRequest", "no");
+    }
+    else {
+      subsequentRequest(aRequest, aSession, aResponse);
+    }
+  };
+
+  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    super.initializeResponseData(aRequest, aSession, aResponse);
+
+    Iterator i = DatabaseContent.getInstance().getFields().iterator();
+    while (i.hasNext()) {
+      String field = (String) i.next();
+      aResponse.setResponseValue(field, aRequest.getParameter(field));
+    }
+
+  };
+
+  public void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure{
+    super.initialRequest(aRequest, aSession, aResponse);
+
+    String articleId = aRequest.getParameter("to_media");
+    if (articleId == null)
+      throw new SessionExc("MirBasicArticlePostingHandler.initialRequest: article id not set!");
+    aSession.setAttribute("to_media", articleId);
+
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.content.EditTemplate"));
+  }
+
+  public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    try {
+      initializeResponseData(aRequest, aSession, aResponse);
+
+      List validationErrors = validate(aRequest, aSession);
+
+      if (validationErrors != null && validationErrors.size()>0) {
+        returnValidationErrors(aRequest, aSession, aResponse, validationErrors);
+      }
+      else {
+        EntityContent content = (EntityContent) contentModule.createNew ();
+        Iterator i = DatabaseContent.getInstance().getFields().iterator();
+//        content.setValues(contentFields);
+
+        finishContent(aRequest, aSession, content);
+
+        String id = content.insert();
+        if(id==null){
+          afterDuplicateContentPosting(aRequest, aSession, aResponse, content);
+          logger.info("Dupe content rejected");
+          aSession.terminate();
+        }
+        else {
+          i = aRequest.getUploadedFiles().iterator();
+          while (i.hasNext()) {
+            UploadedFile file = (UploadedFile) i.next();
+            processMediaFile(aRequest, aSession, content, file);
+          }
+
+          afterContentPosting(aRequest, aSession, aResponse, content);
+          MirGlobal.abuse().checkArticle(content, aRequest, null);
+          MirGlobal.localizer().openPostings().afterContentPosting(content);
+          logger.info("Content posted");
+          aSession.terminate();
+        }
+      }
+    }
+    catch (Throwable t) {
+      ExceptionFunctions.traceCauseException(t).printStackTrace();
+
+      throw new SessionFailure("MirBasicArticlePostingHandler.subsequentRequest: " + t.getMessage(), t);
+    }
+  }
+
+  public void initializeContentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionFailure, SessionExc {
+    String articleId = aRequest.getParameter("to_media");
+    if (articleId==null)
+      articleId = aRequest.getParameter("aid");
+
+    if (articleId==null)
+      throw new SessionExc("initializeContentPosting: article id not set!");
+
+    aSession.setAttribute("to_media", articleId);
+    processContentPosting(aRequest, aSession, aResponse);
+  };
+
+  public void returnValidationErrors(Request aRequest, Session aSession, Response aResponse, List aValidationErrors) throws SessionFailure, SessionExc {
+    aResponse.setResponseValue("errors", aValidationErrors);
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.content.EditTemplate"));
+  };
+
+  public void processContentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    if (MirGlobal.abuse().getOpenPostingPassword()) {
+      String password = generateOnetimePassword();
+      aSession.setAttribute("password", password);
+      aResponse.setResponseValue("password", password);
+      aResponse.setResponseValue("passwd", password);
+    }
+    else {
+      aResponse.setResponseValue("password", null);
+    }
+
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.content.EditTemplate"));
+  };
+
+  public void processMediaFile(Request aRequest, Session aSession, EntityContent aContent, UploadedFile aFile) throws SessionExc, SessionFailure {
+    try {
+      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, new HashMap());
+      finishMedia(aRequest, aSession, aFile, mediaItem);
+      mediaItem.update();
+      contentToMedia.addMedia(aContent.getId(), mediaItem.getId());
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+  }
+
+  public void finishMedia(Request aRequest, Session aSession, UploadedFile aFile, Entity aMedia) throws SessionExc, SessionFailure {
+  }
+
+  public void finishContent(Request aRequest, Session aSession, EntityContent aContent) throws SessionExc, SessionFailure {
+    if (aSession.getAttribute("to_media") == null)
+      throw new SessionExc("missing to_media");
+
+    aContent.setValueForProperty("is_published", "1");
+    aContent.setValueForProperty("to_content_status", "1");
+    aContent.setValueForProperty("is_html","0");
+    aContent.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
+  };
+
+  public void addMedia(Request aRequest, Session aSession, EntityContent aContent)  throws SessionExc, SessionFailure {
+  }
+
+  public void afterContentPosting(Request aRequest, Session aSession, Response aResponse, EntityContent aContent) {
+    DatabaseContent.getInstance().setUnproduced("id=" + aContent.getValue("to_media"));
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.content.DoneTemplate"));
+  };
+
+  public void afterDuplicateContentPosting(Request aRequest, Session aSession, Response aResponse, EntityContent aContent) {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.content.DupeTemplate"));
+  };
+
+  public class ValidationError {
+    private String field;
+    private String message;
+    private List parameters;
+
+    public ValidationError(String aField, String aMessage) {
+      this (aField, aMessage, new String[] {});
+    }
+
+    public ValidationError(String aField, String aMessage, Object aParameter) {
+      this (aField, aMessage, new Object[] {aParameter});
+    }
+
+    public ValidationError(String aField, String aMessage, Object[] aParameters) {
+      field = aField;
+      message = aMessage;
+      parameters = Arrays.asList(aParameters);
+    }
+
+    public String getMessage() {
+      return message;
+    }
+
+    public String getField() {
+      return field;
+    }
+
+    public List getParameters() {
+      return parameters;
+    }
+  }
+
+
+
+}
+*/
\ No newline at end of file
diff --git a/source/mircoders/localizer/basic/MirBasicCommentPostingHandler.java b/source/mircoders/localizer/basic/MirBasicCommentPostingHandler.java
new file mode 100755 (executable)
index 0000000..76933bf
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.UploadedFile;
+import mir.util.ExceptionFunctions;
+import mircoders.entity.EntityComment;
+import mircoders.global.MirGlobal;
+import mircoders.media.MediaUploadProcessor;
+import mircoders.module.*;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseCommentToMedia;
+import mircoders.storage.DatabaseContent;
+import mircoders.media.*;
+
+/**
+ *
+ * <p>Title: Experimental session handler for comment postings </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author Zapata
+ * @version 1.0
+ */
+
+public class MirBasicCommentPostingHandler extends MirBasicPostingSessionHandler {
+  protected ModuleComment commentModule = new ModuleComment(DatabaseComment.getInstance());
+  protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();
+
+  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    super.initializeResponseData(aRequest, aSession, aResponse);
+
+    Iterator i = DatabaseComment.getInstance().getFields().iterator();
+    while (i.hasNext()) {
+      String field = (String) i.next();
+      aResponse.setResponseValue(field, aRequest.getParameter(field));
+    }
+  }
+
+  public void validate(List aResults, Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    testFieldEntered(aRequest, "title", "validationerror.missing", aResults);
+    testFieldEntered(aRequest, "description", "validationerror.missing", aResults);
+    testFieldEntered(aRequest, "creator", "validationerror.missing", aResults);
+  }
+
+  protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    super.initializeSession(aRequest, aSession);
+
+    String articleId = aRequest.getParameter("to_media");
+    if (articleId==null)
+      throw new SessionExc("initializeCommentPosting: article id not set!");
+
+    aSession.setAttribute("to_media", articleId);
+  };
+
+  public void finalizeComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {
+    aComment.setValueForProperty("is_published", "1");
+    aComment.setValueForProperty("to_comment_status", "1");
+    aComment.setValueForProperty("is_html","0");
+  }
+
+  public void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    try {
+      String id;
+      Map values = getIntersectingValues(aRequest, DatabaseComment.getInstance());
+
+      EntityComment comment = (EntityComment) commentModule.createNew();
+      comment.setValues(values);
+      comment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
+      finalizeComment(aRequest, aSession, comment);
+      id = comment.insert();
+      if (id == null) {
+        logger.info("Duplicate comment rejected");
+        throw new DuplicateCommentExc("Duplicate comment rejected");
+      }
+      aSession.setAttribute("comment", comment);
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+  }
+
+  public void processUploadedFile(Request aRequest, Session aSession, UploadedFile aFile) throws SessionExc, SessionFailure {
+    try {
+      Map values = new HashMap();
+      values.put("title", aRequest.getParameter(aFile.getFieldName()+"_title"));
+      values.put("creator", aRequest.getParameter("creator"));
+      values.put("to_publisher", "0");
+      values.put("is_published", "1");
+      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, values);
+      mediaItem.update();
+      commentToMedia.addMedia(((EntityComment) aSession.getAttribute("comment")).getId(), mediaItem.getId());
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+  }
+
+  public void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+    EntityComment comment = (EntityComment) aSession.getAttribute("comment");
+
+    MirGlobal.abuse().checkComment(comment, aRequest, null);
+    try {
+      MirGlobal.localizer().openPostings().afterCommentPosting(comment);
+    }
+    catch (Throwable t) {
+      throw new SessionFailure(t);
+    }
+    DatabaseContent.getInstance().setUnproduced("id=" + comment.getValue("to_media"));
+    logger.info("Comment posted");
+  };
+
+  protected void makeInitialResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
+  };
+
+  protected void makeResponse(Request aRequest, Session aSession, Response aResponse, List anErrors) throws SessionExc, SessionFailure {
+    aResponse.setResponseValue("errors", anErrors);
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
+  };
+
+  protected void makeFinalResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));
+  };
+
+  protected void makeErrorResponse(Request aRequest, Session aSession, Response aResponse, Throwable anError) throws SessionExc, SessionFailure {
+    anError.printStackTrace();
+    Throwable rootCause = ExceptionFunctions.traceCauseException(anError);
+
+    if (rootCause instanceof DuplicateCommentExc)
+      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DupeTemplate"));
+    if (rootCause instanceof ModuleMediaType.UnsupportedMimeTypeExc) {
+      aResponse.setResponseValue("mimetype", ((ModuleMediaType.UnsupportedMimeTypeExc) rootCause).getMimeType());
+      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.UnsupportedMediaTemplate"));
+    }
+    else
+      super.makeErrorResponse(aRequest, aSession, aResponse, anError);
+  };
+
+  protected static class DuplicateCommentExc extends SessionExc {
+    public DuplicateCommentExc(String aMessage) {
+      super(aMessage);
+    }
+  }
+}
\ No newline at end of file
diff --git a/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java
deleted file mode 100755 (executable)
index de797a2..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.localizer.basic;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import mir.entity.Entity;
-import mir.session.Request;
-import mir.session.Response;
-import mir.session.Session;
-import mir.session.SessionExc;
-import mir.session.SessionFailure;
-import mir.session.UploadedFile;
-import mir.util.ExceptionFunctions;
-import mircoders.entity.EntityComment;
-import mircoders.global.MirGlobal;
-import mircoders.media.MediaUploadProcessor;
-import mircoders.module.ModuleComment;
-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>
- * @author not attributable
- * @version 1.0
- */
-
-public class MirBasicCommentPostingSessionHandler extends MirBasicPostingSessionHandler {
-  protected ModuleComment commentModule;
-  protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();
-
-  public MirBasicCommentPostingSessionHandler() {
-    super();
-
-    commentModule= new ModuleComment(DatabaseComment.getInstance());
-  }
-
-  public void processRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    if (aSession.getAttribute("initialRequest")==null) {
-      initialRequest(aRequest, aSession, aResponse);
-      aSession.setAttribute("initialRequest", "no");
-    }
-    else {
-      subsequentRequest(aRequest, aSession, aResponse);
-    }
-  };
-
-  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    super.initializeResponseData(aRequest, aSession, aResponse);
-
-    Iterator i = DatabaseComment.getInstance().getFields().iterator();
-    while (i.hasNext()) {
-      String field = (String) i.next();
-      aResponse.setResponseValue(field, aRequest.getParameter(field));
-    }
-
-  };
-
-  public void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure{
-    super.initialRequest(aRequest, aSession, aResponse);
-
-    String articleId = aRequest.getParameter("to_media");
-    if (articleId == null)
-      throw new SessionExc("MirBasicCommentPostingSessionHandler.initialRequest: article id not set!");
-    aSession.setAttribute("to_media", articleId);
-
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
-  }
-
-  public List validate(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
-    List result = new Vector();
-
-    testFieldEntered(aRequest, "title", "validationerror.missing", result);
-    testFieldEntered(aRequest, "description", "validationerror.missing", result);
-    testFieldEntered(aRequest, "creator", "validationerror.missing", result);
-
-    return result;
-  }
-
-  public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    try {
-      initializeResponseData(aRequest, aSession, aResponse);
-
-      List validationErrors = validate(aRequest, aSession);
-
-      if (validationErrors != null && validationErrors.size()>0) {
-        returnValidationErrors(aRequest, aSession, aResponse, validationErrors);
-      }
-      else {
-        EntityComment comment = (EntityComment) commentModule.createNew ();
-        Iterator i = DatabaseComment.getInstance().getFields().iterator();
-//        comment.setValues(commentFields);
-
-        finishComment(aRequest, aSession, comment);
-
-        String id = comment.insert();
-        if(id==null){
-          afterDuplicateCommentPosting(aRequest, aSession, aResponse, comment);
-          logger.info("Dupe comment rejected");
-          aSession.terminate();
-        }
-        else {
-          i = aRequest.getUploadedFiles().iterator();
-          while (i.hasNext()) {
-            UploadedFile file = (UploadedFile) i.next();
-            processMediaFile(aRequest, aSession, comment, file);
-          }
-
-          afterCommentPosting(aRequest, aSession, aResponse, comment);
-          MirGlobal.abuse().checkComment(comment, aRequest, null);
-          MirGlobal.localizer().openPostings().afterCommentPosting(comment);
-          logger.info("Comment posted");
-          aSession.terminate();
-        }
-      }
-    }
-    catch (Throwable t) {
-      ExceptionFunctions.traceCauseException(t).printStackTrace();
-
-      throw new SessionFailure("MirBasicCommentPostingSessionHandler.subsequentRequest: " + t.getMessage(), t);
-    }
-  }
-
-  public void initializeCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionFailure, SessionExc {
-    String articleId = aRequest.getParameter("to_media");
-    if (articleId==null)
-      articleId = aRequest.getParameter("aid");
-
-    if (articleId==null)
-      throw new SessionExc("initializeCommentPosting: article id not set!");
-
-    aSession.setAttribute("to_media", articleId);
-    processCommentPosting(aRequest, aSession, aResponse);
-  };
-
-  public void returnValidationErrors(Request aRequest, Session aSession, Response aResponse, List aValidationErrors) throws SessionFailure, SessionExc {
-    aResponse.setResponseValue("errors", aValidationErrors);
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
-  };
-
-  public void processCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    if (MirGlobal.abuse().getOpenPostingPassword()) {
-      String password = generateOnetimePassword();
-      aSession.setAttribute("password", password);
-      aResponse.setResponseValue("password", password);
-      aResponse.setResponseValue("passwd", password);
-    }
-    else {
-      aResponse.setResponseValue("password", null);
-    }
-
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
-  };
-
-  public void processMediaFile(Request aRequest, Session aSession, EntityComment aComment, UploadedFile aFile) throws SessionExc, SessionFailure {
-    try {
-      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, new HashMap());
-      finishMedia(aRequest, aSession, aFile, mediaItem);
-      mediaItem.update();
-      commentToMedia.addMedia(aComment.getId(), mediaItem.getId());
-    }
-    catch (Throwable t) {
-      throw new SessionFailure(t);
-    }
-  }
-
-  public void finishMedia(Request aRequest, Session aSession, UploadedFile aFile, Entity aMedia) throws SessionExc, SessionFailure {
-  }
-
-  public void finishComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {
-    if (aSession.getAttribute("to_media") == null)
-      throw new SessionExc("missing to_media");
-
-    aComment.setValueForProperty("is_published", "1");
-    aComment.setValueForProperty("to_comment_status", "1");
-    aComment.setValueForProperty("is_html","0");
-    aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
-  };
-
-  public void addMedia(Request aRequest, Session aSession, EntityComment aComment)  throws SessionExc, SessionFailure {
-  }
-
-  public void afterCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {
-    DatabaseContent.getInstance().setUnproduced("id=" + aComment.getValue("to_media"));
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));
-  };
-
-  public void afterDuplicateCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DupeTemplate"));
-  };
-
-  public class ValidationError {
-    private String field;
-    private String message;
-    private List parameters;
-
-    public ValidationError(String aField, String aMessage) {
-      this (aField, aMessage, new String[] {});
-    }
-
-    public ValidationError(String aField, String aMessage, Object aParameter) {
-      this (aField, aMessage, new Object[] {aParameter});
-    }
-
-    public ValidationError(String aField, String aMessage, Object[] aParameters) {
-      field = aField;
-      message = aMessage;
-      parameters = Arrays.asList(aParameters);
-    }
-
-    public String getMessage() {
-      return message;
-    }
-
-    public String getField() {
-      return field;
-    }
-
-    public List getParameters() {
-      return parameters;
-    }
-  }
-
-
-
-}
\ No newline at end of file
index c0a9784..c6e4cbb 100755 (executable)
  * 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.  
+ * 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 mir.generator.FreemarkerGenerator;
index 62e01b1..637f4ac 100755 (executable)
  * 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.  
+ * 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;
@@ -51,7 +51,6 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
   protected LoggerWrapper logger;
   protected MirPropertiesConfiguration configuration;
 
-
   public MirBasicOpenPostingLocalizer() throws MirLocalizerExc, MirLocalizerFailure {
     logger = new LoggerWrapper("Localizer.Basic.OpenPosting");
 
@@ -76,9 +75,18 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
     }
   }
 
+  public SessionHandler getOpenSessionHandler(String aSessionType) {
+    if (aSessionType!=null && aSessionType.equals("comment"))
+      return new MirBasicCommentPostingHandler();
+
+    return new MirBasicArticlePostingHandler();
+  }
+
   public SessionHandler getOpenSessionHandler(Request aRequest, Session aSession) throws MirLocalizerExc, MirLocalizerFailure {
     if (aSession.getAttribute("handler")==null)
-      aSession.setAttribute("handler", new MirBasicCommentPostingSessionHandler());
+    {
+      aSession.setAttribute("handler", getOpenSessionHandler(aRequest.getParameter("sessiontype")));
+    }
 
     return (SessionHandler) aSession.getAttribute("handler");
   }
index 921eb09..df23ded 100755 (executable)
  * 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.  
+ * 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;
@@ -35,7 +35,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
-import java.util.Vector;
+import java.util.*;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
@@ -67,11 +67,9 @@ import mircoders.storage.DatabaseContent;
  * @version 1.0
  */
 
-public class MirBasicPostingSessionHandler implements SessionHandler {
+public abstract class MirBasicPostingSessionHandler implements SessionHandler {
   protected LoggerWrapper logger;
   protected MirPropertiesConfiguration configuration;
-  protected ModuleComment commentModule;
-  protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();
 
   public MirBasicPostingSessionHandler() {
     logger = new LoggerWrapper("Localizer.OpenPosting");
@@ -83,7 +81,6 @@ public class MirBasicPostingSessionHandler implements SessionHandler {
 
       throw new RuntimeException("Cannot load configuration: " + t.toString());
     }
-    commentModule= new ModuleComment(DatabaseComment.getInstance());
   }
 
   public void processRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
@@ -96,242 +93,129 @@ public class MirBasicPostingSessionHandler implements SessionHandler {
     }
   };
 
-  protected Map getIntersectingValues(Request aRequest, StorageObject aStorage) throws SessionExc, SessionFailure {
-    Map result = new HashMap();
-
-    Iterator i = aStorage.getFields().iterator();
-
-    while (i.hasNext()) {
-      String fieldName = (String) i.next();
-      Object value = aRequest.getParameter(fieldName);
-      if (value != null)
-        result.put(fieldName, value);
-    }
-
-    return result;
+  protected void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    initializeSession(aRequest, aSession);
+    initializeResponseData(aRequest, aSession, aResponse);
+    makeInitialResponse(aRequest, aSession, aResponse);
   }
 
+  public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    try {
 
-  protected String generateOnetimePassword() {
-    Random r = new Random();
-    int random = r.nextInt();
-
-    long l = System.currentTimeMillis();
-
-    l = (l*l*l*l)/random;
-    if (l<0)
-      l = l * -1;
+      try {
+        List validationErrors = new Vector();
 
-    String returnString = ""+l;
+        if (!shouldProcessRequest(aRequest, aSession, validationErrors)) {
+          initializeResponseData(aRequest, aSession, aResponse);
+          makeResponse(aRequest, aSession, aResponse, validationErrors);
+        }
+        else {
+          preProcessRequest(aRequest, aSession);
+          Iterator i = aRequest.getUploadedFiles().iterator();
+          while (i.hasNext()) {
+            processUploadedFile(aRequest, aSession, (UploadedFile) i.next());
+          }
+          postProcessRequest(aRequest, aSession);
+          initializeResponseData(aRequest, aSession, aResponse);
+          makeFinalResponse(aRequest, aSession, aResponse);
+          aSession.terminate();
+        }
+      }
+      catch (Throwable t) {
+        initializeResponseData(aRequest, aSession, aResponse);
+        makeErrorResponse(aRequest, aSession, aResponse, t);
+        aSession.terminate();
+      }
+    }
+    catch (Throwable t) {
+      aSession.terminate();
 
-    return returnString.substring(5);
+      throw new SessionFailure(t);
+    }
   }
 
-  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+  protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
     if (MirGlobal.abuse().getOpenPostingPassword()) {
       String password = (String) aSession.getAttribute("password");
       if (password==null) {
         password = generateOnetimePassword();
         aSession.setAttribute("password", password);
       }
-      aResponse.setResponseValue("password", password);
     }
     else {
-      aResponse.setResponseValue("password", null);
       aSession.deleteAttribute("password");
     }
 
-    aResponse.setResponseValue("errors", null);
-  };
-
-  protected void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure{
-    Iterator i = DatabaseComment.getInstance().getFields().iterator();
-    while (i.hasNext()) {
-      aResponse.setResponseValue( (String) i.next(), null);
-    }
-
-    String articleId = aRequest.getParameter("to_media");
+    logger.debug("referrer = " + aRequest.getHeader("Referer"));
 
-    if (articleId == null)
-      throw new SessionExc("MirBasicPostingSessionHandler.initialRequest: article id not set!");
-
-    aSession.setAttribute("to_media", articleId);
-
-    initializeResponseData(aRequest, aSession, aResponse);
-
-    try {
-      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
-    }
-    catch (Throwable e) {
-      throw new SessionFailure("Can't get configuration: " + e.getMessage(), e);
-    }
-
-  }
-
-  protected boolean testFieldEntered(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {
-    Object value = aRequest.getParameter(aFieldName);
-    if (value==null || !(value instanceof String) || ((String) value).trim().length()==0) {
-      logger.debug("  missing field " + aFieldName + " value = " + value);
-      aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));
-      return false;
-    }
-    else
-      return true;
-  }
-
-  protected boolean testFieldIsNumeric(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {
-    Object value = aRequest.getParameter(aFieldName);
-    if (value!=null) {
-      try {
-        Integer.parseInt((String) value);
-        return true;
-      }
-      catch (Throwable t) {
-        logger.debug("  field not numeric: " + aFieldName + " value = " + value);
-        aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));
-        return false;
-      }
-    }
-    return true;
+    aSession.setAttribute("referer", aRequest.getHeader("Referer"));
+    aSession.setAttribute("nrmediaitems",
+        new Integer(configuration.getInt("ServletModule.OpenIndy.DefaultMediaUploadItems")));
   }
 
-  public void validate(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-
-  }
-
-  public List validate(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
-    List result = new Vector();
-
-    testFieldEntered(aRequest, "title", "validationerror.missing", result);
-    testFieldEntered(aRequest, "description", "validationerror.missing", result);
-    testFieldEntered(aRequest, "creator", "validationerror.missing", result);
-
-    return result;
-  }
-
-  public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    try {
-      Map commentFields = new HashMap();
-
-      Iterator i = DatabaseContent.getInstance().getFields().iterator();
-      while (i.hasNext()) {
-        String field = (String) i.next();
-        aResponse.setResponseValue(field, aRequest.getParameter(field));
-        if (aRequest.getParameter(field)!=null) {
-          commentFields.put(field, aRequest.getParameter(field));
-        }
-      }
-
-      initializeResponseData(aRequest, aSession, aResponse);
-
-      List validationErrors = validate(aRequest, aSession);
-
-      if (validationErrors != null && validationErrors.size()>0) {
-        returnValidationErrors(aRequest, aSession, aResponse, validationErrors);
-      }
-      else {
-//        finish(aRequest, aSession, aResponse);
-
-        EntityComment comment = (EntityComment) commentModule.createNew ();
-//        comment.setValues(getIntersectingValues(aRequest, ));
-
-        finishComment(aRequest, aSession, comment);
-
-        String id = comment.insert();
-        if(id==null){
-          afterDuplicateCommentPosting(aRequest, aSession, aResponse, comment);
-          logger.info("Dupe comment rejected");
-          aSession.terminate();
-        }
-        else {
-          i = aRequest.getUploadedFiles().iterator();
-          while (i.hasNext()) {
-            UploadedFile file = (UploadedFile) i.next();
-            processMediaFile(aRequest, aSession, comment, file);
-          }
+  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+    int nrMediaItems = ((Integer) aSession.getAttribute("nrmediaitems")).intValue();
+    List mediaItems = new Vector();
+    int i=0;
 
-          afterCommentPosting(aRequest, aSession, aResponse, comment);
-          MirGlobal.abuse().checkComment(comment, aRequest, null);
-          MirGlobal.localizer().openPostings().afterCommentPosting(comment);
-          logger.info("Comment posted");
-          aSession.terminate();
-        }
-      }
+    while (i<nrMediaItems) {
+      i++;
+      mediaItems.add(new Integer(i));
     }
-    catch (Throwable t) {
-      ExceptionFunctions.traceCauseException(t).printStackTrace();
 
-      throw new SessionFailure("MirBasicPostingSessionHandler.subsequentRequest: " + t.getMessage(), t);
-    }
+    aResponse.setResponseValue("nrmediaitems", new Integer(nrMediaItems));
+    aResponse.setResponseValue("mediaitems", mediaItems);
+    aResponse.setResponseValue("password", aSession.getAttribute("password"));
+    aResponse.setResponseValue("referer", aSession.getAttribute("referer"));
+    aResponse.setResponseValue("errors", null);
   }
 
-  public void initializeCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionFailure, SessionExc {
-    String articleId = aRequest.getParameter("to_media");
-    if (articleId==null)
-      articleId = aRequest.getParameter("aid");
+  protected abstract void makeInitialResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure;
+  protected abstract void makeResponse(Request aRequest, Session aSession, Response aResponse, List anErrors) throws SessionExc, SessionFailure;
+  protected abstract void makeFinalResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure;
 
-    if (articleId==null)
-      throw new SessionExc("initializeCommentPosting: article id not set!");
-
-    aSession.setAttribute("to_media", articleId);
-    processCommentPosting(aRequest, aSession, aResponse);
+  protected void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
   };
-
-  public void returnValidationErrors(Request aRequest, Session aSession, Response aResponse, List aValidationErrors) throws SessionFailure, SessionExc {
-    aResponse.setResponseValue("errors", aValidationErrors);
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
+  public void processUploadedFile(Request aRequest, Session aSession, UploadedFile aFile) throws SessionExc, SessionFailure {
   };
-
-  public void processCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
-    if (MirGlobal.abuse().getOpenPostingPassword()) {
-      String password = generateOnetimePassword();
-      aSession.setAttribute("password", password);
-      aResponse.setResponseValue("password", password);
-      aResponse.setResponseValue("passwd", password);
-    }
-    else {
-      aResponse.setResponseValue("password", null);
-    }
-
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));
+  protected void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
   };
 
-  public void processMediaFile(Request aRequest, Session aSession, EntityComment aComment, UploadedFile aFile) throws SessionExc, SessionFailure {
+  protected boolean shouldProcessRequest(Request aRequest, Session aSession, List aValidationErrors) throws SessionExc, SessionFailure {
+    int nrMediaItems = ((Integer) aSession.getAttribute("nrmediaitems")).intValue();
     try {
-      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, new HashMap());
-      finishMedia(aRequest, aSession, aFile, mediaItem);
-      mediaItem.update();
-      commentToMedia.addMedia(aComment.getId(), mediaItem.getId());
+      nrMediaItems = Math.min(configuration.getInt("ServletModule.OpenIndy.MaxMediaUploadItems"), Integer.parseInt(aRequest.getParameter("nrmediaitems")));
     }
     catch (Throwable t) {
-      throw new SessionFailure(t);
     }
-  }
-
-  public void finishMedia(Request aRequest, Session aSession, UploadedFile aFile, Entity aMedia) throws SessionExc, SessionFailure {
-  }
 
-  public void finishComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {
-    if (aSession.getAttribute("to_media") == null)
-      throw new SessionExc("missing to_media");
+    aSession.setAttribute("nrmediaitems", new Integer(nrMediaItems));
 
-    aComment.setValueForProperty("is_published", "1");
-    aComment.setValueForProperty("to_comment_status", "1");
-    aComment.setValueForProperty("is_html","0");
-    aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
-  };
+    if (aRequest.getParameter("post")==null)
+      return false;
+    else {
+      validate(aValidationErrors, aRequest, aSession);
+      return (aValidationErrors == null || aValidationErrors.size() == 0);
+    }
+  }
 
-  public void addMedia(Request aRequest, Session aSession, EntityComment aComment)  throws SessionExc, SessionFailure {
+  protected void validate(List aResults, Request aRequest, Session aSession) throws SessionExc, SessionFailure {
   }
 
-  public void afterCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {
-    DatabaseContent.getInstance().setUnproduced("id=" + aComment.getValue("to_media"));
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));
+  protected void makeErrorResponse(Request aRequest, Session aSession, Response aResponse, Throwable anError) throws SessionExc, SessionFailure {
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.ErrorTemplate"));
   };
 
-  public void afterDuplicateCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {
-    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DupeTemplate"));
-  };
+  /**
+   * Class that represents a validation error
+   *
+   * <p>Title: </p>
+   * <p>Description: </p>
+   * <p>Copyright: Copyright (c) 2003</p>
+   * <p>Company: </p>
+   * @author not attributable
+   * @version 1.0
+   */
 
   public class ValidationError {
     private String field;
@@ -365,6 +249,94 @@ public class MirBasicPostingSessionHandler implements SessionHandler {
     }
   }
 
+  /**
+   * Convenience validation method to test wether a field has been filled in
+   *
+   * @param aRequest
+   * @param aFieldName
+   * @param anErrorMessageResource
+   * @param aValidationResults
+   * @return
+   */
+
+  protected boolean testFieldEntered(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {
+    Object value = aRequest.getParameter(aFieldName);
+    if (value==null || !(value instanceof String) || ((String) value).trim().length()==0) {
+      aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));
+      return false;
+    }
+    else
+      return true;
+  }
+
+  /**
+   * Convenience validation method to test wether a field is numeric
 
+   * @param aRequest
+   * @param aFieldName
+   * @param anErrorMessageResource
+   * @param aValidationResults
+   * @return
+   */
+
+  protected boolean testFieldIsNumeric(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {
+    Object value = aRequest.getParameter(aFieldName);
+    if (value!=null) {
+      try {
+        Integer.parseInt((String) value);
+        return true;
+      }
+      catch (Throwable t) {
+        aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
+   * Method to generate a one-time password
+   *
+   * @return a password, to be used once
+   */
+  protected String generateOnetimePassword() {
+    Random r = new Random();
+    int random = r.nextInt();
+
+    long l = System.currentTimeMillis();
+
+    l = (l*l*l*l)/random;
+    if (l<0)
+      l = l * -1;
+
+    String returnString = ""+l;
+
+    return returnString.substring(5);
+  }
+
+
+  /**
+   *
+   * @param aRequest
+   * @param aStorage
+   * @return
+   * @throws SessionExc
+   * @throws SessionFailure
+   */
+
+  protected static final Map getIntersectingValues(Request aRequest, StorageObject aStorage) throws SessionExc, SessionFailure {
+    Map result = new HashMap();
+
+    Iterator i = aStorage.getFields().iterator();
+
+    while (i.hasNext()) {
+      String fieldName = (String) i.next();
+      Object value = aRequest.getParameter(fieldName);
+      if (value != null)
+        result.put(fieldName, value);
+    }
+
+    return result;
+  }
 
 }
diff --git a/source/mircoders/media/UnsupportedMediaFormatExc.java b/source/mircoders/media/UnsupportedMediaFormatExc.java
deleted file mode 100755 (executable)
index 7efdfb2..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.media;
-
-import mir.media.MediaExc;
-
-public class UnsupportedMediaFormatExc extends MediaExc {
-  public UnsupportedMediaFormatExc(String aMessage) {
-    super(aMessage);
-  }
-}
\ No newline at end of file
index 0f0f47a..a7c9fd5 100755 (executable)
  * 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.  
+ * 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.
  */
 
@@ -93,8 +93,7 @@ import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
 import mircoders.media.MediaUploadProcessor;
-import mircoders.media.UnsupportedMediaFormatExc;
-import mircoders.module.ModuleComment;
+import mircoders.module.*;
 import mircoders.module.ModuleContent;
 import mircoders.module.ModuleImages;
 import mircoders.module.ModuleTopics;
@@ -122,7 +121,7 @@ import mircoders.storage.DatabaseTopics;
  *    open-postings to the newswire
  *
  * @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.80 2003/04/21 12:42:51 idfx Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.81 2003/04/26 00:42:22 zapata Exp $
  *
  */
 
@@ -495,7 +494,8 @@ public class ServletModuleOpenIndy extends ServletModule
 
       EntityContent article = (EntityContent) contentModule.getById(cid);
       try {
-        MirGlobal.abuse().checkArticle(article, aRequest, aResponse);
+        MirGlobal.abuse().checkArticle(
+            article, new HTTPAdapters.HTTPRequestAdapter(aRequest), aResponse);
         MirGlobal.localizer().openPostings().afterContentPosting(article);
       }
       catch (Throwable t) {
@@ -507,7 +507,7 @@ public class ServletModuleOpenIndy extends ServletModule
       e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
       Throwable cause = ExceptionFunctions.traceCauseException(e);
 
-      if (cause instanceof UnsupportedMediaFormatExc) {
+      if (cause instanceof ModuleMediaType.UnsupportedMimeTypeExc) {
         throw new ServletModuleUserExc("media.unsupportedformat", new String[] {});
       }
       throw new ServletModuleFailure(e);
@@ -1108,9 +1108,7 @@ public class ServletModuleOpenIndy extends ServletModule
       Map data = new HashMap();
 
       MessageResources messages = MessageResources.getMessageResources("bundles.open");
-      data.put("errorstring",
-              messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters())
-          );
+      data.put("errorstring", messages.getMessage(getLocale(aRequest), anException.getMessage(), anException.getParameters()));
       data.put("date", StringUtil.date2readableDateTime(new GregorianCalendar()));
 
       deliver(out, aRequest, aResponse, data, null, configuration.getString("ServletModule.OpenIndy.UserErrorTemplate"));
index d404755..6349e42 100755 (executable)
  * 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.  
+ * 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.
  */
 
@@ -62,7 +62,7 @@ import mircoders.entity.EntityContent;
 import mircoders.entity.EntityUploadedMedia;
 import mircoders.entity.EntityUsers;
 import mircoders.media.MediaUploadProcessor;
-import mircoders.media.UnsupportedMediaFormatExc;
+import mircoders.module.*;
 import mircoders.storage.DatabaseComment;
 import mircoders.storage.DatabaseContent;
 import mircoders.storage.DatabaseMediafolder;
@@ -76,7 +76,7 @@ import freemarker.template.SimpleList;
  *  ServletModuleBilder -
  *  liefert HTML fuer Bilder
  *
- * @version $Id: ServletModuleUploadedMedia.java,v 1.26 2003/04/21 12:42:51 idfx Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.27 2003/04/26 00:42:22 zapata Exp $
  * @author RK, the mir-coders group
  */
 
@@ -174,7 +174,7 @@ public abstract class ServletModuleUploadedMedia
     catch (Throwable t) {
       Throwable cause = ExceptionFunctions.traceCauseException(t);
 
-      if (cause instanceof UnsupportedMediaFormatExc) {
+      if (cause instanceof ModuleMediaType.UnsupportedMimeTypeExc) {
         throw new ServletModuleUserExc("media.error.unsupportedformat", new String[] {});
       }
       throw new ServletModuleFailure("ServletModuleUploadedMedia.insert: " + t.toString(), t);
index 3adb6b5..36910cd 100755 (executable)
@@ -20,7 +20,6 @@
                &gt; <a href="${config.actionRoot}?module=Users&do=list">${lang("superusermenu.users")}</a><br>
                &gt; <a href="${config.actionRoot}?module=Language&do=list">${lang("superusermenu.languages")}</a><br>
                &gt; <a href="${config.actionRoot}?module=Abuse">${lang("superusermenu.abuse")}</a><br>
-               &gt; <a href="${config.actionRoot}?module=LinksImcs&do=list">${lang("superusermenu.imcs")}</a><br>
                </p>
                </td>
       <td>&nbsp;  </td>