+ public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ try {
+ MirGlobal.accessControl().general().assertMayDeleteComments(ServletHelper.getUser(aRequest));
+
+ super.delete(aRequest, aResponse);
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
+ }
+
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String idParam = aRequest.getParameter("id");
+
+ if (idParam == null)
+ throw new ServletModuleExc("Invalid call: id not supplied ");
+
+ editObject(aRequest, aResponse, idParam);
+ }
+
+ public void editObject(HttpServletRequest aRequest, HttpServletResponse aResponse, String anId) throws ServletModuleExc {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});
+ EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
+ Map comment;
+ URLBuilder urlBuilder = new URLBuilder();
+
+ urlBuilder.setValue("module", "Comment");
+ urlBuilder.setValue("do", "edit");
+ urlBuilder.setValue("id", anId);
+ urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
+
+ if (anId != null) {
+ responseData.put("new", Boolean.FALSE);
+ comment = model.makeEntityAdapter("comment", mainModule.getById(anId));
+ }
+ else {
+ List fields = DatabaseComment.getInstance().getFields();
+ responseData.put("new", Boolean.TRUE);
+ comment = new HashMap();
+ Iterator i = fields.iterator();
+ while (i.hasNext()) {
+ comment.put(i.next(), null);
+ }
+ }
+ responseData.put("comment", comment);
+
+ responseData.put("returnurl", requestParser.getParameter("returnurl"));
+ responseData.put("thisurl", urlBuilder.getQuery());
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String mediaIdParam = aRequest.getParameter("mid");
+ String commentId = aRequest.getParameter("commentid");
+
+ if (commentId == null || mediaIdParam==null) throw new ServletModuleExc("smod comment :: attach :: commentid/mid missing");
+
+ try {
+ EntityComment comment = (EntityComment) mainModule.getById(commentId);
+ comment.attach(mediaIdParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ logAdminUsage(aRequest, commentId, "media " + mediaIdParam + " attached");
+
+ editObject(aRequest, aResponse, commentId);
+ }
+
+ public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String commentId = aRequest.getParameter("commentid");
+ String midParam = aRequest.getParameter("mid");
+ if (commentId == null)
+ throw new ServletModuleExc("smod comment :: dettach :: commentid missing");
+ if (midParam == null)
+ throw new ServletModuleExc("smod comment :: dettach :: mid missing");
+
+ try {
+ EntityComment comment = (EntityComment)mainModule.getById(commentId);
+ comment.dettach(commentId, midParam);
+ }
+ catch(Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+
+ logAdminUsage(aRequest, commentId, "media " + midParam + " deattached");
+
+ editObject(aRequest, aResponse, commentId);
+ }
+
+
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc