+
+
+
diff --git a/source/default.properties b/source/default.properties
index 27851017..e4d232ce 100755
--- a/source/default.properties
+++ b/source/default.properties
@@ -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
+
+
#
diff --git a/source/mir/servlet/AbstractServlet.java b/source/mir/servlet/AbstractServlet.java
index ef0d5923..cc2463e0 100755
--- a/source/mir/servlet/AbstractServlet.java
+++ b/source/mir/servlet/AbstractServlet.java
@@ -18,13 +18,13 @@
* 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 {
diff --git a/source/mir/session/HTTPAdapters.java b/source/mir/session/HTTPAdapters.java
index 9ca728b6..83ed63d3 100755
--- a/source/mir/session/HTTPAdapters.java
+++ b/source/mir/session/HTTPAdapters.java
@@ -18,13 +18,13 @@
* 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() {
diff --git a/source/mir/session/Request.java b/source/mir/session/Request.java
index 278e09fd..3133000e 100755
--- a/source/mir/session/Request.java
+++ b/source/mir/session/Request.java
@@ -18,13 +18,13 @@
* 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
diff --git a/source/mir/util/HTTPParsedRequest.java b/source/mir/util/HTTPParsedRequest.java
index fb22d60b..ba307968 100755
--- a/source/mir/util/HTTPParsedRequest.java
+++ b/source/mir/util/HTTPParsedRequest.java
@@ -18,13 +18,13 @@
* 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;
}
diff --git a/source/mircoders/global/Abuse.java b/source/mircoders/global/Abuse.java
index 55eed8cb..41b31f8c 100755
--- a/source/mircoders/global/Abuse.java
+++ b/source/mircoders/global/Abuse.java
@@ -18,13 +18,13 @@
* 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);
}
diff --git a/source/mircoders/global/ProducerEngine.java b/source/mircoders/global/ProducerEngine.java
index fff103d1..518fac87 100755
--- a/source/mircoders/global/ProducerEngine.java
+++ b/source/mircoders/global/ProducerEngine.java
@@ -18,13 +18,13 @@
* 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
index 00000000..6afb6f79
--- /dev/null
+++ b/source/mircoders/localizer/basic/MirBasicArticlePostingHandler.java
@@ -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.*;
+
+/**
+ *
+ *
Title: Experimental session handler for article postings
+ *
Description:
+ *
Copyright: Copyright (c) 2003
+ *
Company:
+ * @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
index 00000000..76933bf7
--- /dev/null
+++ b/source/mircoders/localizer/basic/MirBasicCommentPostingHandler.java
@@ -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.*;
+
+/**
+ *
+ *
Title: Experimental session handler for comment postings
+ *
Description:
+ *
Copyright: Copyright (c) 2003
+ *
Company:
+ * @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
index de797a27..00000000
--- a/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java
+++ /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;
-
-/**
- *
- *
Title: Experimental session handler for comment postings
- *
Description:
- *
Copyright: Copyright (c) 2003
- *
Company:
- * @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
diff --git a/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java b/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
index c0a9784b..c6e4cbb7 100755
--- a/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
+++ b/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
@@ -18,16 +18,15 @@
* 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;
diff --git a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
index 62e01b1b..637f4ac6 100755
--- a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
+++ b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
@@ -18,13 +18,13 @@
* 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");
}
diff --git a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
index 921eb099..df23dedc 100755
--- a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
+++ b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
@@ -18,13 +18,13 @@
* 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 (iTitle:
+ *
Description:
+ *
Copyright: Copyright (c) 2003
+ *
Company:
+ * @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
index 7efdfb28..00000000
--- a/source/mircoders/media/UnsupportedMediaFormatExc.java
+++ /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
diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java
index 0f0f47aa..a7c9fd58 100755
--- a/source/mircoders/servlet/ServletModuleOpenIndy.java
+++ b/source/mircoders/servlet/ServletModuleOpenIndy.java
@@ -18,13 +18,13 @@
* 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"));
diff --git a/source/mircoders/servlet/ServletModuleUploadedMedia.java b/source/mircoders/servlet/ServletModuleUploadedMedia.java
index d4047553..6349e424 100755
--- a/source/mircoders/servlet/ServletModuleUploadedMedia.java
+++ b/source/mircoders/servlet/ServletModuleUploadedMedia.java
@@ -18,13 +18,13 @@
* 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);
diff --git a/templates/admin/superusermenu.template b/templates/admin/superusermenu.template
index 3adb6b5c..36910cd8 100755
--- a/templates/admin/superusermenu.template
+++ b/templates/admin/superusermenu.template
@@ -20,7 +20,6 @@
> ${lang("superusermenu.users")}
> ${lang("superusermenu.languages")}
> ${lang("superusermenu.abuse")}
- > ${lang("superusermenu.imcs")}