fixed comment/article search + configurable icon sizes
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
1 /*\r
2  * Copyright (C) 2001, 2002  The Mir-coders group\r
3  *\r
4  * This file is part of Mir.\r
5  *\r
6  * Mir is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 2 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Mir is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with Mir; if not, write to the Free Software\r
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19  *\r
20  * In addition, as a special exception, The Mir-coders gives permission to link\r
21  * the code of this program with the com.oreilly.servlet library, any library\r
22  * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
23  * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
24  * the above that use the same license as the above), and distribute linked\r
25  * combinations including the two.  You must obey the GNU General Public\r
26  * License in all respects for all of the code used other than the above\r
27  * mentioned libraries.  If you modify this file, you may extend this exception\r
28  * to your version of the file, but you are not obligated to do so.  If you do\r
29  * not wish to do so, delete this exception statement from your version.\r
30  */\r
31 \r
32 package mircoders.servlet;\r
33 \r
34 import java.io.PrintWriter;\r
35 import java.io.IOException;\r
36 import java.util.*;\r
37 \r
38 import javax.servlet.http.HttpServletRequest;\r
39 import javax.servlet.http.HttpServletResponse;\r
40 import javax.servlet.http.HttpSession;\r
41 \r
42 import mir.entity.EntityList;\r
43 import mir.entity.adapter.EntityAdapter;\r
44 import mir.entity.adapter.EntityAdapterModel;\r
45 import mir.entity.adapter.EntityIteratorAdapter;\r
46 import mir.log.LoggerWrapper;\r
47 import mir.misc.StringUtil;\r
48 import mir.module.ModuleException;\r
49 import mir.servlet.ServletModule;\r
50 import mir.servlet.ServletModuleException;\r
51 import mir.storage.StorageObjectFailure;\r
52 import mir.util.CachingRewindableIterator;\r
53 import mir.util.HTMLRoutines;\r
54 import mir.util.JDBCStringRoutines;\r
55 import mir.util.HTTPRequestParser;\r
56 import mir.util.URLBuilder;\r
57 import mir.util.SQLQueryBuilder;\r
58 import mir.log.*;\r
59 \r
60 import mircoders.entity.EntityContent;\r
61 import mircoders.entity.EntityUsers;\r
62 import mircoders.global.MirGlobal;\r
63 import mircoders.module.ModuleContent;\r
64 import mircoders.module.ModuleImages;\r
65 import mircoders.module.ModuleSchwerpunkt;\r
66 import mircoders.module.ModuleTopics;\r
67 import mircoders.search.IndexUtil;\r
68 import mircoders.storage.DatabaseArticleType;\r
69 import mircoders.storage.DatabaseComment;\r
70 import mircoders.storage.DatabaseContent;\r
71 import mircoders.storage.DatabaseContentToTopics;\r
72 import mircoders.storage.DatabaseFeature;\r
73 import mircoders.storage.DatabaseImages;\r
74 import mircoders.storage.DatabaseLanguage;\r
75 import mircoders.storage.DatabaseTopics;\r
76 \r
77 import org.apache.lucene.index.IndexReader;\r
78 \r
79 import freemarker.template.SimpleHash;\r
80 import freemarker.template.SimpleScalar;\r
81 import freemarker.template.TemplateModelRoot;\r
82 \r
83 /*\r
84  *  ServletModuleContent -\r
85  *  deliver html for the article admin form.\r
86  *\r
87  * @version $Id: ServletModuleContent.java,v 1.34 2003/02/21 05:37:59 zapata Exp $\r
88  * @author rk, mir-coders\r
89  *\r
90  */\r
91 \r
92 public class ServletModuleContent extends ServletModule\r
93 {\r
94   private String editTemplate = configuration.getString("ServletModule.Content.ObjektTemplate");;\r
95   private String listTemplate = configuration.getString("ServletModule.Content.ListTemplate");\r
96 \r
97   private static ServletModuleContent instance = new ServletModuleContent();\r
98   public static ServletModule getInstance() { return instance; }\r
99 \r
100   private ServletModuleContent() {\r
101     super();\r
102     logger = new LoggerWrapper("ServletModule.Content");\r
103     try {\r
104 \r
105       templateListString = configuration.getString("ServletModule.Content.ListTemplate");\r
106       templateObjektString = configuration.getString("ServletModule.Content.ObjektTemplate");\r
107       templateConfirmString = configuration.getString("ServletModule.Content.ConfirmTemplate");\r
108 \r
109       mainModule = new ModuleContent(DatabaseContent.getInstance());\r
110     }\r
111     catch (StorageObjectFailure e) {\r
112       logger.error("servletmodulecontent konnte nicht initialisiert werden");\r
113     }\r
114   }\r
115 \r
116   public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
117   {\r
118     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
119 \r
120     String where = requestParser.getParameter("where");\r
121     String order = requestParser.getParameterWithDefault("order", "webdb_create desc");\r
122     int offset = requestParser.getIntegerWithDefault("offset", 0);\r
123     String selectArticleUrl = requestParser.getParameter("selectarticleurl");\r
124 \r
125     returnArticleList(aRequest, aResponse, where, order, offset, selectArticleUrl);\r
126   }\r
127 \r
128   public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {\r
129     try {\r
130       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
131       SQLQueryBuilder queryBuilder = new SQLQueryBuilder();\r
132       String searchField = requestParser.getParameterWithDefault("searchfield", "");\r
133       String searchValue = requestParser.getParameterWithDefault("searchvalue", "").trim();\r
134       String searchOrder = requestParser.getParameterWithDefault("searchorder", "");\r
135       String searchispublished = requestParser.getParameterWithDefault("searchispublished", "");\r
136       String searchArticleType = requestParser.getParameterWithDefault("searcharticletype", "");\r
137       String selectArticleUrl = requestParser.getParameter("selectarticleurl");\r
138 \r
139       if (searchValue.length()>0) {\r
140         if (searchField.equals("contents"))\r
141           queryBuilder.appendAndCondition(\r
142             "(lower(content_data) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')"+\r
143             " or (lower(description) like " + "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%')");\r
144         else\r
145           queryBuilder.appendAndCondition(\r
146             "lower("+ searchField + ") like " +\r
147             "'%" + JDBCStringRoutines.escapeStringLiteral(searchValue.toLowerCase()) + "%'");\r
148       }\r
149 \r
150       if (searchispublished.length()>0) {\r
151         if (searchispublished.equals("0"))\r
152           queryBuilder.appendAndCondition("is_published='f'");\r
153         else\r
154           queryBuilder.appendAndCondition("is_published='t'");\r
155       }\r
156 \r
157       if (searchArticleType.length()>0) {\r
158         queryBuilder.appendAndCondition("to_article_type="+Integer.parseInt(searchArticleType));\r
159       }\r
160 \r
161       if (searchOrder.length()>0) {\r
162         if (searchOrder.equals("datedesc"))\r
163           queryBuilder.appendAscendingOrder("webdb_create");\r
164         else if (searchOrder.equals("dateasc"))\r
165           queryBuilder.appendDescendingOrder("webdb_create");\r
166         else if (searchOrder.equals("title"))\r
167           queryBuilder.appendDescendingOrder("title");\r
168         else if (searchOrder.equals("creator"))\r
169           queryBuilder.appendDescendingOrder("creator");\r
170       }\r
171 \r
172       returnArticleList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0, selectArticleUrl);\r
173     }\r
174     catch (Throwable e) {\r
175       throw new ServletModuleException(e.toString());\r
176     }\r
177   }\r
178 \r
179   public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {\r
180     _showObject(null, req, res);\r
181   }\r
182 \r
183 \r
184   public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
185   {\r
186 //theLog.printDebugInfo(":: content :: trying to insert");\r
187     try {\r
188       EntityUsers   user = _getUser(req);\r
189       HashMap withValues = getIntersectingValues(req, DatabaseContent.getInstance());\r
190 \r
191       String now = StringUtil.date2webdbDate(new GregorianCalendar());\r
192       withValues.put("date", now);\r
193       withValues.put("publish_path", StringUtil.webdbDate2path(now));\r
194       withValues.put("to_publisher", user.getId());\r
195       withValues.put("is_produced", "0");\r
196       if (!withValues.containsKey("is_published"))\r
197         withValues.put("is_published","0");\r
198       if (!withValues.containsKey("is_html"))\r
199         withValues.put("is_html","0");\r
200 \r
201       String id = mainModule.add(withValues);\r
202       DatabaseContentToTopics.getInstance().setTopics(id,req.getParameterValues("to_topic"));\r
203 \r
204       _showObject(id, req, res);\r
205     }\r
206     catch (StorageObjectFailure e) {\r
207       throw new ServletModuleException(e.toString());\r
208     }\r
209     catch (ModuleException e) {\r
210       throw new ServletModuleException(e.toString());\r
211     }\r
212   }\r
213 \r
214   public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
215   {\r
216     EntityUsers   user = _getUser(req);\r
217 \r
218     String idParam = req.getParameter("id");\r
219     if (idParam == null) throw new ServletModuleException("Invalid call: id missing");\r
220 \r
221     String confirmParam = req.getParameter("confirm");\r
222     String cancelParam = req.getParameter("cancel");\r
223 \r
224     logger.info("where = " + req.getParameter("where"));\r
225 \r
226     if (confirmParam == null && cancelParam == null) {\r
227 \r
228       SimpleHash mergeData = new SimpleHash();\r
229       mergeData.put("module", "Content");\r
230       mergeData.put("infoString", "Content: " + idParam);\r
231       mergeData.put("id", idParam);\r
232       mergeData.put("where", req.getParameter("where"));\r
233       mergeData.put("order", req.getParameter("order"));\r
234       mergeData.put("offset", req.getParameter("offset"));\r
235       deliver(req, res, mergeData, templateConfirmString);\r
236     }\r
237     else {\r
238       if (confirmParam!= null && !confirmParam.equals("")) {\r
239         try {\r
240           mainModule.deleteById(idParam);\r
241 \r
242           /** @todo the following two should be implied in\r
243            *  DatabaseContent */\r
244 \r
245           //delete rows in the content_x_topic-table\r
246           DatabaseContentToTopics.getInstance().deleteByContentId(idParam);\r
247           //delete rows in the comment-table\r
248           DatabaseComment.getInstance().deleteByContentId(idParam);\r
249           //delete from lucene index, if any\r
250           String index = configuration.getString("IndexPath");\r
251           if (IndexReader.indexExists(index)){\r
252             IndexUtil.unindexID(idParam,index);\r
253           }\r
254 \r
255         }\r
256         catch (ModuleException e) {\r
257           throw new ServletModuleException(e.toString());\r
258         }\r
259         catch (StorageObjectFailure e) {\r
260           throw new ServletModuleException(e.toString());\r
261         }\r
262         catch (IOException e) {\r
263           throw new ServletModuleException(e.toString());\r
264         }\r
265         list(req,res);\r
266       }\r
267       else {\r
268         // Datensatz anzeigen\r
269         _showObject(idParam, req, res);\r
270       }\r
271     }\r
272   }\r
273 \r
274   public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
275   {\r
276     String idParam = req.getParameter("id");\r
277     if (idParam == null)\r
278       throw new ServletModuleException("Invalid call: id not supplied ");\r
279     _showObject(idParam, req, res);\r
280   }\r
281 \r
282 // methods for attaching media file\r
283   public void attach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
284   {\r
285     String  mediaIdParam = req.getParameter("mid");\r
286     String  idParam = req.getParameter("cid");\r
287     if (idParam == null||mediaIdParam==null) throw new ServletModuleException("smod content :: attach :: cid/mid missing");\r
288 \r
289     try {\r
290       EntityContent entContent = (EntityContent)mainModule.getById(idParam);\r
291       entContent.attach(mediaIdParam);\r
292     }\r
293     catch(ModuleException e) {\r
294       logger.error("smod content :: attach :: could not get entityContent");\r
295     }\r
296     catch(StorageObjectFailure e) {\r
297       logger.error("smod content :: attach :: could not get entityContent");\r
298     }\r
299 \r
300     _showObject(idParam, req, res);\r
301   }\r
302 \r
303   public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException\r
304   {\r
305     String  cidParam = req.getParameter("cid");\r
306     String  midParam = req.getParameter("mid");\r
307     if (cidParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");\r
308     if (midParam == null) throw new ServletModuleException("smod content :: dettach :: mid missing");\r
309 \r
310     try {\r
311       EntityContent entContent = (EntityContent)mainModule.getById(cidParam);\r
312       entContent.dettach(cidParam,midParam);\r
313     }\r
314     catch(ModuleException e) {\r
315       logger.error("smod content :: dettach :: could not get entityContent");\r
316     }\r
317     catch(StorageObjectFailure e) {\r
318       logger.error("smod content :: dettach :: could not get entityContent");\r
319     }\r
320 \r
321     _showObject(cidParam, req, res);\r
322   }\r
323 \r
324   public void update(HttpServletRequest aRequest, HttpServletResponse aResponse)\r
325       throws ServletModuleException\r
326   {\r
327     try {\r
328       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
329 \r
330       String returnUrl = requestParser.getParameter("returnurl");\r
331 \r
332       String idParam = aRequest.getParameter("id");\r
333       if (idParam == null) throw new ServletModuleException("Wrong call: (id) is missing");\r
334 \r
335       HashMap withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());\r
336       String[] topic_id = aRequest.getParameterValues("to_topic");\r
337       String content_id = aRequest.getParameter("id");\r
338 \r
339       withValues.put("is_produced", "0");\r
340       if (!withValues.containsKey("is_published"))\r
341         withValues.put("is_published","0");\r
342       if (!withValues.containsKey("is_html"))\r
343         withValues.put("is_html","0");\r
344 \r
345       String id = mainModule.set(withValues);\r
346       DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"),topic_id);\r
347 \r
348       String whereParam = aRequest.getParameter("where");\r
349       String orderParam = aRequest.getParameter("order");\r
350 \r
351       if (returnUrl!=null){\r
352         redirect(aResponse, returnUrl);\r
353       }\r
354       else\r
355         _showObject(idParam, aRequest, aResponse);\r
356     }\r
357     catch (Throwable e) {\r
358       throw new ServletModuleException(e.toString());\r
359     }\r
360   }\r
361 \r
362 /*\r
363   * HelperMethod shows the basic article editing form.\r
364   *\r
365   * if the "id" parameter is null, it means show an empty form to add a new\r
366   * article.\r
367 */\r
368   private void _showObject(String id, HttpServletRequest aRequest, HttpServletResponse aResponse)\r
369       throws ServletModuleException {\r
370 \r
371     try {\r
372       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
373       Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest));\r
374       EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();\r
375       Map article;\r
376       URLBuilder urlBuilder = new URLBuilder();\r
377 \r
378       urlBuilder.setValue("module", "Content");\r
379       urlBuilder.setValue("do", "edit");\r
380       urlBuilder.setValue("id", id);\r
381       urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));\r
382 \r
383       if (id!=null) {\r
384         responseData.put("new", Boolean.FALSE);\r
385         article = model.makeEntityAdapter("content", mainModule.getById(id));\r
386       }\r
387       else {\r
388         List fields = DatabaseContent.getInstance().getFields();\r
389         responseData.put("new", Boolean.TRUE);\r
390         article = new HashMap();\r
391         Iterator i = fields.iterator();\r
392         while (i.hasNext()) {\r
393           article.put(i.next(), null);\r
394         }\r
395 \r
396         article.put("to_topics", null);\r
397 \r
398         MirGlobal.localizer().adminInterface().initializeArticle(article);\r
399       }\r
400       responseData.put("article", article);\r
401 \r
402       responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
403       responseData.put("thisurl", urlBuilder.getQuery());\r
404 \r
405       ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);\r
406     }\r
407     catch (Exception e) {\r
408       throw new ServletModuleException(e.toString());\r
409     }\r
410   }\r
411 \r
412   public void returnArticleList(\r
413        HttpServletRequest aRequest,\r
414        HttpServletResponse aResponse,\r
415        String aWhereClause,\r
416        String anOrderByClause,\r
417        int anOffset,\r
418        String aSelectArticleUrl) throws ServletModuleException {\r
419 \r
420     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
421     URLBuilder urlBuilder = new URLBuilder();\r
422     EntityAdapterModel model;\r
423     int nrArticlesPerPage = 20;\r
424     int count;\r
425 \r
426     try {\r
427       Map responseData = ServletHelper.makeGenerationData(getLocale(aRequest));\r
428       model = MirGlobal.localizer().dataModel().adapterModel();\r
429 \r
430       Object articleList =\r
431           new CachingRewindableIterator(\r
432             new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrArticlesPerPage,\r
433                MirGlobal.localizer().dataModel().adapterModel(), "content", nrArticlesPerPage, anOffset)\r
434       );\r
435 \r
436       responseData.put("nexturl", null);\r
437       responseData.put("prevurl", null);\r
438 \r
439       count=mainModule.getSize(aWhereClause);\r
440 \r
441       urlBuilder.setValue("module", "Content");\r
442       urlBuilder.setValue("do", "list");\r
443       urlBuilder.setValue("where", aWhereClause);\r
444       urlBuilder.setValue("order", anOrderByClause);\r
445 \r
446 \r
447       urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));\r
448       urlBuilder.setValue("searchvalue", requestParser.getParameter("searchvalue"));\r
449       urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));\r
450       urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));\r
451       urlBuilder.setValue("searcharticletype", requestParser.getParameter("searcharticletype"));\r
452       urlBuilder.setValue("selectarticleurl", aSelectArticleUrl);\r
453 \r
454       responseData.put("searchfield", requestParser.getParameter("searchfield"));\r
455       responseData.put("searchvalue", requestParser.getParameter("searchvalue"));\r
456       responseData.put("searchispublished", requestParser.getParameter("searchispublished"));\r
457       responseData.put("searchorder", requestParser.getParameter("searchorder"));\r
458       responseData.put("searcharticletype", requestParser.getParameter("searcharticletype"));\r
459       responseData.put("selectarticleurl", aSelectArticleUrl);\r
460 \r
461       urlBuilder.setValue("offset", anOffset);\r
462       responseData.put("offset" , new Integer(anOffset).toString());\r
463       responseData.put("thisurl" , urlBuilder.getQuery());\r
464 \r
465       if (count>=anOffset+nrArticlesPerPage) {\r
466         urlBuilder.setValue("offset", anOffset + nrArticlesPerPage);\r
467         responseData.put("nexturl" , urlBuilder.getQuery());\r
468       }\r
469 \r
470       if (anOffset>0) {\r
471         urlBuilder.setValue("offset", Math.max(anOffset - nrArticlesPerPage, 0));\r
472         responseData.put("prevurl" , urlBuilder.getQuery());\r
473       }\r
474 \r
475       responseData.put("articles", articleList);\r
476 \r
477       responseData.put("from" , Integer.toString(anOffset+1));\r
478       responseData.put("count", Integer.toString(count));\r
479       responseData.put("to", Integer.toString(Math.min(anOffset+nrArticlesPerPage, count)));\r
480       responseData.put("offset" , Integer.toString(anOffset));\r
481       responseData.put("order", anOrderByClause);\r
482       responseData.put("where" , aWhereClause);\r
483 \r
484       ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);\r
485     }\r
486     catch (Throwable e) {\r
487       throw new ServletModuleException(e.toString());\r
488     }\r
489   }\r
490 \r
491   public void selectparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
492   {\r
493     try {\r
494       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
495       URLBuilder urlBuilder = new URLBuilder();\r
496 \r
497       urlBuilder.setValue("module", "Content");\r
498       urlBuilder.setValue("do", "setparent");\r
499       urlBuilder.setValue("childid", requestParser.getParameter("id"));\r
500       urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));\r
501 \r
502       returnArticleList(aRequest, aResponse, "", "", 0, urlBuilder.getQuery());\r
503     }\r
504     catch (Throwable e) {\r
505       throw new ServletModuleException(e.getMessage());\r
506     }\r
507   }\r
508 \r
509   public void listchildren(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
510   {\r
511     try {\r
512       HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
513       String articleId = requestParser.getParameter("article_id");\r
514 \r
515       if (articleId == null)\r
516         throw new ServletModuleException("ServletModuleContent.listchildren: article_id not set!");\r
517 \r
518       returnArticleList(aRequest, aResponse, "to_content = " + articleId, "", 0, null);\r
519     }\r
520     catch (Throwable e) {\r
521       throw new ServletModuleException(e.getMessage());\r
522     }\r
523   }\r
524 \r
525   public void setparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
526   {\r
527     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
528     String articleId = aRequest.getParameter("childid");\r
529     String parentId  = aRequest.getParameter("id");\r
530     String returnUrl = aRequest.getParameter("returnurl");\r
531 \r
532     try {\r
533       EntityContent article = (EntityContent) mainModule.getById(articleId);\r
534       article.setValueForProperty("to_content", parentId);\r
535       article.setProduced(false);\r
536       article.update();\r
537     }\r
538     catch(Throwable e) {\r
539       logger.error("ServletModuleContent.setparent: " + e.getMessage());\r
540       throw new ServletModuleException("ServletModuleContent.setparent: " + e.getMessage());\r
541     }\r
542 \r
543     redirect(aResponse, returnUrl);\r
544   }\r
545 \r
546   public void clearparent(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException\r
547   {\r
548     HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
549     String articleId = requestParser.getParameter("id");\r
550     String returnUrl = requestParser.getParameter("returnurl");\r
551 \r
552     try {\r
553       EntityContent article = (EntityContent) mainModule.getById(articleId);\r
554       article.setValueForProperty("to_content", "");\r
555       article.setProduced(false);\r
556       article.update();\r
557     }\r
558     catch(Throwable e) {\r
559       e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
560       logger.error("ServletModuleContent.clearparent: " + e.getMessage());\r
561 \r
562       throw new ServletModuleException("ServletModuleContent.clearparent: " + e.getMessage());\r
563     }\r
564 \r
565     redirect(aResponse, returnUrl);\r
566   }\r
567 \r
568   private EntityUsers _getUser(HttpServletRequest req)\r
569   {\r
570     HttpSession session=req.getSession(false);\r
571 \r
572     return (EntityUsers)session.getAttribute("login.uid");\r
573   }\r
574 }\r