- if ( passwd == null || passwd.length()==0) {
- throw new ServletModuleUserExc("posting.error.missingpassword", new String[] {});
- }
- if (!sessionPasswd.equals(passwd)) {
- throw new ServletModuleUserExc("posting.error.invalidpassword", new String[] {});
- }
- session.invalidate();
- }
-
- if ((((String)withValues.get("title")).length() == 0) ||
- (((String)withValues.get("description")).length() == 0) ||
- (((String)withValues.get("content_data")).length() == 0))
- throw new ServletModuleUserExc("posting.error.missingfield", new String[] {});
-
- // call the routines that escape html
-
- for (Iterator i=withValues.keySet().iterator(); i.hasNext(); ){
- String k=(String)i.next();
- String v=(String)withValues.get(k);
-
- if (k.equals("content_data")){
- //this doesn't quite work yet, so for now, all html goes
- //withValues.put(k,StringUtil.approveHTMLTags(v));
- withValues.put(k,StringUtil.deleteForbiddenTags(v));
- }
- else if (k.equals("description")) {
- String tmp = StringUtil.deleteForbiddenTags(v);
- withValues.put(k,StringUtil.deleteHTMLTableTags(tmp));
- }
- else {
- withValues.put(k,StringUtil.removeHTMLTags(v));
- }
-
- }
-
- withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
- withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));
- withValues.put("is_produced", "0");
- withValues.put("is_published","1");
- if (directOp.equals("yes"))
- withValues.put("to_article_type","1");
-
- withValues.put("to_publisher","1");
-
- // inserting content into database
- String cid = contentModule.add(withValues);
- logger.debug("id: "+cid);
- //insert was not successfull
- if(cid==null){
-
- //How do we know that it was not succesful cause of a
- //dupe, what if it failed cause of "No space left on device"?
- //Or is there something I am missing? Wouldn't it be better
- //to have an explicit dupe check and then insert? I have no
- //idea what I am talking about. this comment is in case
- //I forget to explicitely ask. -mh
- deliver(req, res, mergeData, null, postingFormDupeTemplate);
- return;
- }
-
- MirGlobal.abuse().logArticle(req.getRemoteAddr(), cid, new Date(), (String) req.getHeader("User-Agent"));
-
- String[] to_topicsArr = mp.getParameterValues("to_topic");
-
- if (to_topicsArr != null && to_topicsArr.length > 0) {
- try{
- DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
- setTopic = true;
- }
- catch (Throwable e) {
- logger.error("setting content_x_topic failed");
- contentModule.deleteById(cid);
- throw new ServletModuleFailure("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString(), e);
- } //end try
- } //end if
-
- //if we're here all is ok... associate the media to the article
- for(int i=0;i<mediaList.size();i++) {
- Entity mediaEnt = (Entity)mediaList.elementAt(i);
- DatabaseContentToMedia.getInstance().addMedia(cid,mediaEnt.getId());
- }
-
- EntityContent article = (EntityContent) contentModule.getById(cid);
-
- try {
- MirGlobal.abuse().checkArticle(article, req, res);
- MirGlobal.localizer().openPostings().afterContentPosting(article);
- }
- catch (Throwable t) {
- logger.error("Error while post-processing article: " + t.getMessage());
- }