- * Method for making a comment
- */
-
- public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- if (MirGlobal.abuse().getOpenPostingDisabled()) {
- openPostingDisabled(req, res);
-
- return;
- }
-
- String aid = req.getParameter("aid"); // the article id the comment will belong to
-
- if (aid != null && !aid.equals("")) {
- try {
- Map mergeData = new HashMap();
-
- // onetimepasswd
- if (MirGlobal.abuse().getOpenPostingPassword()) {
- String passwd = this.createOneTimePasswd();
- HttpSession session = req.getSession(false);
- session.setAttribute("passwd", passwd);
- mergeData.put("passwd", passwd);
- }
- else {
- mergeData.put("passwd", (String)null);
- }
- mergeData.put("aid", aid);
-
- Map extraInfo = new HashMap();
- extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData());
-
- deliver(req, res, mergeData, extraInfo, commentFormTemplate);
- }
- catch (Throwable t) {
- throw new ServletModuleFailure("ServletModuleOpenIndy.addcomment: " + t.getMessage(), t);
- }
- }
- else
- throw new ServletModuleExc("aid not set!");
- }
-
- /**
- * Method for inserting a comment into the Database and delivering
- * the commentDone Page
- */
-
- public void inscomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- if (MirGlobal.abuse().getOpenPostingDisabled()) {
- openPostingDisabled(req, res);
-
- return;
- }
-
- String aid = req.getParameter("to_media"); // the article id the comment will belong to
- if (aid != null && !aid.equals("")) {
- // ok, collecting data from form
- try {
- Map withValues = getIntersectingValues(req, DatabaseComment.getInstance());
-
- //no html in comments(for now)
- for (Iterator i = withValues.keySet().iterator(); i.hasNext(); ) {
- String k = (String) i.next();
- String v = (String) withValues.get(k);
-
- withValues.put(k, StringUtil.removeHTMLTags(v));
- }
- withValues.put("is_published", "1");
- withValues.put("to_comment_status", "1");
- withValues.put("is_html", "0");
-
- //checking the onetimepasswd
- HttpSession session = req.getSession(false);
- String sessionPasswd = (String) session.getAttribute("passwd");
- if (sessionPasswd != null) {
- String passwd = req.getParameter("passwd");
- if (passwd == null || passwd.length() == 0) {
- throw new ServletModuleUserExc("comment.error.missingpassword", new String[] {});
- }
- if (!sessionPasswd.equals(passwd)) {
- throw new ServletModuleUserExc("comment.error.invalidpassword", new String[] {});
- }
- session.invalidate();
- }
-
- String id = mainModule.add(withValues);
-
- SimpleResponse response = new SimpleResponse();
- response.setResponseGenerator(commentFormDoneTemplate);
-
- if (id == null) {
- deliver(req, res, (Map)null, null, commentFormDupeTemplate);
- }
- else {
- DatabaseContent.getInstance().setUnproduced("id=" + aid);
-
- try {
- EntityComment comment = (EntityComment) DatabaseComment.getInstance().selectById(id);
- MirGlobal.localizer().openPostings().afterCommentPosting(comment);
- MirGlobal.abuse().checkComment(
- comment, new HTTPAdapters.HTTPRequestAdapter(req), res);
- }
- catch (Throwable t) {
- throw new ServletModuleExc(t.getMessage());
- }
- }
-
- // redirecting to url
- // should implement back to article
- deliver(req, res, response.getResponseValues(), null, response.getResponseGenerator());
- }
- catch (Throwable e) {
- throw new ServletModuleFailure(e);
- }
- }
- else
- throw new ServletModuleExc("aid not set!");
-
- }
-
- /**
- * Method for delivering the form-Page for open posting