cos is gone woohee
authorzapata <zapata>
Mon, 21 Apr 2003 02:58:29 +0000 (02:58 +0000)
committerzapata <zapata>
Mon, 21 Apr 2003 02:58:29 +0000 (02:58 +0000)
29 files changed:
lib/cos-05Nov2002.jar [deleted file]
source/Mir.java
source/mir/misc/FileExtFilter.java [deleted file]
source/mir/misc/FileHandler.java [deleted file]
source/mir/misc/HTMLTemplateProcessor.java
source/mir/misc/Helper.java [deleted file]
source/mir/misc/ListOfFiles.java [deleted file]
source/mir/misc/WebdbMultipartRequest.java [deleted file]
source/mir/session/CommonsUploadedFileAdapter.java
source/mir/session/Request.java
source/mir/session/SessionHandler.java
source/mir/session/SimpleResponse.java
source/mir/storage/store/test/TestStore.java
source/mir/util/PropertiesManipulator.java
source/mircoders/global/Abuse.java
source/mircoders/localizer/MirOpenPostingLocalizer.java
source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java
source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java [new file with mode: 0755]
source/mircoders/media/MediaRequest.java [deleted file]
source/mircoders/media/MediaUploadProcessor.java
source/mircoders/servlet/ServletHelper.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
source/tool/BundleTool.java
templates/admin/audio.template
templates/admin/image.template
templates/admin/media.template
templates/admin/video.template

diff --git a/lib/cos-05Nov2002.jar b/lib/cos-05Nov2002.jar
deleted file mode 100755 (executable)
index a0e34a7..0000000
Binary files a/lib/cos-05Nov2002.jar and /dev/null differ
index ea6a9f3..9a93a65 100755 (executable)
  * not wish to do so, delete this exception statement from your version.\r
  */\r
 \r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-import java.lang.reflect.Method;\r
-import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.UnavailableException;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import javax.servlet.http.HttpSession;\r
-\r
-import org.apache.struts.util.MessageResources;\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateModel;\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.generator.FreemarkerGenerator;\r
-import mir.log.LoggerWrapper;\r
-import mir.misc.HTMLTemplateProcessor;\r
-import mir.misc.StringUtil;\r
-import mir.servlet.AbstractServlet;\r
-import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleDispatch;\r
-import mir.servlet.ServletModuleExc;\r
-import mir.servlet.ServletModuleUserExc;\r
-import mir.util.ExceptionFunctions;\r
-import mir.util.StringRoutines;\r
-import mir.util.*;\r
-import mir.entity.*;\r
-import mir.entity.adapter.*;\r
-import mircoders.entity.EntityUsers;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.module.ModuleMessage;\r
-import mircoders.module.ModuleUsers;\r
-import mircoders.storage.DatabaseArticleType;\r
-import mircoders.storage.DatabaseMessages;\r
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.struts.util.MessageResources;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModel;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.generator.FreemarkerGenerator;
+import mir.log.LoggerWrapper;
+import mir.misc.HTMLTemplateProcessor;
+import mir.misc.StringUtil;
+import mir.servlet.AbstractServlet;
+import mir.servlet.ServletModule;
+import mir.servlet.ServletModuleDispatch;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleUserExc;
+import mir.util.CachingRewindableIterator;
+import mir.util.ExceptionFunctions;
+import mir.util.StringRoutines;
+import mircoders.entity.EntityUsers;
+import mircoders.global.MirGlobal;
+import mircoders.module.ModuleMessage;
+import mircoders.module.ModuleUsers;
+import mircoders.servlet.ServletHelper;
 import mircoders.storage.DatabaseUsers;\r
-import mircoders.servlet.*;\r
 \r
 \r
 \r
@@ -81,7 +79,7 @@ import mircoders.servlet.*;
  * Mir.java - main servlet, that dispatches to servletmodules\r
  *\r
  * @author $Author: zapata $\r
- * @version $Id: Mir.java,v 1.43 2003/04/12 15:29:43 zapata Exp $\r
+ * @version $Id: Mir.java,v 1.44 2003/04/21 02:58:29 zapata Exp $\r
  *\r
  */\r
 public class Mir extends AbstractServlet {\r
diff --git a/source/mir/misc/FileExtFilter.java b/source/mir/misc/FileExtFilter.java
deleted file mode 100755 (executable)
index 5a54ee1..0000000
+++ /dev/null
@@ -1,54 +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 the com.oreilly.servlet library, 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.misc;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-
-public class FileExtFilter implements FilenameFilter
-{
-
-  static String _SEP_EXT;
-
-  public FileExtFilter(String ext) {
-    _SEP_EXT = ext;
-  }
-
-  public boolean accept(File dir, String name) {
-    System.out.println("NAME: "+name+" "+_SEP_EXT);
-    return name.endsWith("."+_SEP_EXT);
-  }
-
-}
-
-
diff --git a/source/mir/misc/FileHandler.java b/source/mir/misc/FileHandler.java
deleted file mode 100755 (executable)
index a7a6ec8..0000000
+++ /dev/null
@@ -1,78 +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 the com.oreilly.servlet library, 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.misc;
-
-import java.util.Map;
-
-import multex.Exc;
-import multex.Failure;
-
-import com.oreilly.servlet.multipart.FilePart;
-
-
-/**
- * Interface that classes wishing to be used as a callback on FileParts for the
- * WebdbMultipartRequest class should implement this interface.
- *
- * @author mh <mh@nadir.org>
- * @version $Id: FileHandler.java,v 1.6 2003/03/09 19:14:21 idfx Exp $
- * @see mir.misc.WebdbMultipartRequest
- *
- */
-
-public interface  FileHandler {
-
-  public void setFile (FilePart filePart, int fileNum, Map Params) throws FileHandlerExc, FileHandlerFailure;
-
-  public static class FileHandlerExc extends Exc {
-    public FileHandlerExc(String aMessage) {
-
-      super(aMessage);
-    }
-  }
-
-  public static class FileHandlerFailure extends Failure {
-
-    public FileHandlerFailure(String msg, Throwable cause) {
-      super(msg, cause);
-    }
-
-    public FileHandlerFailure(Throwable aCause) {
-      this(aCause.getMessage(), aCause);
-    }
-  }
-
-}
-
-
-
-
index 5b842a2..1f40e51 100755 (executable)
 \r
 package mir.misc;\r
 \r
-import java.io.PrintWriter;\r
-import java.net.URLEncoder;\r
-import java.util.GregorianCalendar;\r
-import java.util.Iterator;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.apache.struts.util.MessageResources;\r
-\r
-import freemarker.template.FileTemplateCache;\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.Template;\r
-import freemarker.template.TemplateModelRoot;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
-import mir.entity.Entity;\r
-import mir.entity.EntityList;\r
-import mir.generator.FreemarkerGenerator;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.StorageObjectFailure;\r
-import mir.util.GeneratorHTMLFunctions;\r
-import mir.util.GeneratorIntegerFunctions;\r
-import mir.util.*;\r
+import java.io.PrintWriter;
+import java.net.URLEncoder;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.util.MessageResources;
+import freemarker.template.FileTemplateCache;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+import freemarker.template.SimpleScalar;
+import freemarker.template.Template;
+import freemarker.template.TemplateModelRoot;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration$PropertiesConfigExc;
+import mir.entity.Entity;
+import mir.entity.EntityList;
+import mir.generator.FreemarkerGenerator;
+import mir.log.LoggerWrapper;
+import mir.storage.StorageObjectFailure;
+import mir.util.GeneratorHTMLFunctions;
+import mir.util.GeneratorIntegerFunctions;
+import mir.util.ResourceBundleGeneratorFunction;\r
 \r
 /**\r
  * Hilfsklasse zum Mergen von Template und Daten\r
diff --git a/source/mir/misc/Helper.java b/source/mir/misc/Helper.java
deleted file mode 100755 (executable)
index 9dda35c..0000000
+++ /dev/null
@@ -1,82 +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 the com.oreilly.servlet library, 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.misc;
-
-import java.io.IOException;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-
-/**
- * Title:        Indy
- * Description:  This class provides some satic help methods
- * Copyright:    Copyright (c) 2001
- * Company:      indymedia.de
- * @author idfx
- * @version 1.0
- */
-
-public class Helper {
-
-  /**
-   * rsync the webrepository
-   * needs a rsyncscript
-   * returns the exit-code
-        * returns 255 if rsync should not be used
-   */
-  public static int rsync(){
-    MirPropertiesConfiguration configuration = null;
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    } catch (PropertiesConfigExc e) {
-      e.printStackTrace();
-      return 255;
-    }
-    
-               if(!configuration.getString("Rsync").toLowerCase().equals("yes")){
-                       return 255;
-               }
-               
-         Process p;
-    int returnValue = -1;
-    try {
-      Runtime run = Runtime.getRuntime();
-      p = run.exec(configuration.getString("Rsync.Script.Path"));
-      returnValue = p.waitFor();
-    } catch (IOException e) {
-      return returnValue;
-    } catch (InterruptedException e) {
-      return returnValue;
-    }
-    return returnValue;
-  }
-}
diff --git a/source/mir/misc/ListOfFiles.java b/source/mir/misc/ListOfFiles.java
deleted file mode 100755 (executable)
index 35403e9..0000000
+++ /dev/null
@@ -1,81 +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 the com.oreilly.servlet library, 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.
- */
-
-/* taken largely from the java tutorial --- pretty much wholesale, 
- * except modified to take a list rather than an array --jd
- */
-
-package mir.misc;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-public class ListOfFiles implements Enumeration {
-
-    private LinkedList listOfFiles;
-    private ListIterator listOfFilesIterator;
-    
-
-    public ListOfFiles(LinkedList listOfFiles) {
-        this.listOfFiles = listOfFiles;
-       this.listOfFilesIterator = listOfFiles.listIterator();
-    }
-    
-    public boolean hasMoreElements() {
-       return listOfFilesIterator.hasNext();
-    }
-
-    public Object nextElement() {
-        InputStream in = null;
-
-        if (!hasMoreElements())
-            throw new NoSuchElementException("No more files.");
-        else {
-            String nextElement = (String) listOfFilesIterator.next();
-            try {
-                in = new FileInputStream(nextElement);
-            } catch (FileNotFoundException e) {
-                System.err.println("ListOfFiles: Can't open " + nextElement);
-            }
-        }
-        return in;
-    }
-}
-
-
-
-
-
diff --git a/source/mir/misc/WebdbMultipartRequest.java b/source/mir/misc/WebdbMultipartRequest.java
deleted file mode 100755 (executable)
index 4be6c03..0000000
+++ /dev/null
@@ -1,179 +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 the com.oreilly.servlet library, 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.misc;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-
-import com.oreilly.servlet.multipart.FilePart;
-import com.oreilly.servlet.multipart.MultipartParser;
-import com.oreilly.servlet.multipart.ParamPart;
-import com.oreilly.servlet.multipart.Part;
-
-/**
- * Title:
- * Description:
- * Copyright:    Copyright (c) 2001
- * Company:      Indymedia
- * @author
- * @version 1.0
- */
-
-public class WebdbMultipartRequest
-{
-  HttpServletRequest    req=null;
-  Hashtable             parameters = new Hashtable();
-  MultipartParser       mp=null;
-  FileHandler           _fHandler;
-
-  public WebdbMultipartRequest(HttpServletRequest theReq, FileHandler handler)
-    throws FileHandler.FileHandlerExc, FileHandler.FileHandlerFailure, IOException, PropertiesConfigExc
-  {
-    req=theReq;
-    int maxSize;
-    try {
-      maxSize = MirPropertiesConfiguration.instance().getInt("MaxMediaUploadSize");
-    }
-    catch (PropertiesConfigExc e) {
-      maxSize = 1024;
-      throw e;
-    }
-    mp = new MultipartParser(req, 1024*maxSize);
-    _fHandler = handler;
-    _evaluateRequest();
-  }
-
-
-  /**
-   * The following comment and some code was adapted from the Oreilley cos.jar
-   * package. -mh 2001.09.20
-   *
-   * Returns all the parameters as a Map of Strings, any parameter
-   * that sent without a value will be null.  A value
-   * is guaranteed to be in its normal, decoded form.  If A parameter
-   * has multiple values, only the last one is returned (for backward
-   * compatibility).  For parameters with multiple values, it's possible
-   * the last "value" may be null.
-   *
-   * @return A Map of String representations of the  parameter values.
-   */
-  public Map getParameters(){
-    Map pHash = new HashMap();
-    String value = new String();
-
-    Enumeration Keys = parameters.keys();
-    while(Keys.hasMoreElements()) {
-      String KeyNm = (String)Keys.nextElement();
-      Vector values = (Vector)parameters.get(KeyNm);
-
-      if (values == null || values.size() == 0) {
-        value = null;
-      }
-      else {
-        value = (String)values.elementAt(values.size() - 1);
-      }
-
-      pHash.put(KeyNm, value);
-    }
-
-    return pHash;
-  }
-
-  /**
-   * The following code and comment stolen from oreilley cos.jar.
-   * -mh. 2001.09.20
-   *
-   * Returns the values of the named parameter as a String array, or null if
-   * the parameter was not sent.  The array has one entry for each parameter
-   * field sent.  If any field was sent without a value that entry is stored
-   * in the array as a null.  The values are guaranteed to be in their
-   * normal, decoded form.  A single value is returned as a one-element array.
-   *
-   * @param name the parameter name.
-   * @return the parameter values.
-   */
-  public String[] getParameterValues(String name) {
-    try {
-      Vector values = (Vector)parameters.get(name);
-      if (values == null || values.size() == 0) {
-        return null;
-      }
-      String[] valuesArray = new String[values.size()];
-      values.copyInto(valuesArray);
-      return valuesArray;
-    }
-    catch (Exception e) {
-      return null;
-    }
-  }
-
-  private void _evaluateRequest() throws FileHandler.FileHandlerExc,
-      FileHandler.FileHandlerFailure, IOException {
-
-    Part part;
-    int i = 1;
-    while ((part = mp.readNextPart()) != null) {
-      String name = part.getName();
-      if (part.isParam()) {
-        // It's a parameter part, add it to the vector of values
-        ParamPart paramPart = (ParamPart) part;
-        String value = paramPart.getStringValue();
-        Vector existingValues = (Vector)parameters.get(name);
-        if (existingValues == null) {
-          existingValues = new Vector();
-          parameters.put(name, existingValues);
-        }
-        existingValues.addElement(value);
-      }
-      else if (part.isFile()) {
-        // nur das erste uploadfile beruecksichtigen
-        FilePart filePart = (FilePart) part;
-        String fn = filePart.getFileName();
-        if (filePart.getFileName() != null) {
-          if (_fHandler != null)
-            _fHandler.setFile(filePart, i, getParameters());
-          i++;
-        }
-      }
-    } // while */
-  }
-
-}
index 869f7b3..925e2d8 100755 (executable)
@@ -31,8 +31,9 @@
 
 package mir.session;
 
-import org.apache.commons.fileupload.*;
-import java.io.*;
+import java.io.InputStream;
+
+import org.apache.commons.fileupload.FileItem;
 
 public class CommonsUploadedFileAdapter implements UploadedFile {
   private FileItem fileItem;
index e0709bd..16679f8 100755 (executable)
@@ -31,7 +31,7 @@
 
 package mir.session;
 
-import java.util.*;
+import java.util.List;
 
 public interface Request {
   public String getParameter(String aName);
index 87b3801..a7ee1f7 100755 (executable)
@@ -1,3 +1,34 @@
+/*
+ * 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 the com.oreilly.servlet library, 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;
 
 public interface SessionHandler {
index 3dcadf5..85613f9 100755 (executable)
@@ -1,32 +1,64 @@
-package mir.session;\r
-\r
-import java.util.*;\r
-\r
-public class SimpleResponse implements Response {\r
-  private String generator;\r
-  private Map values;\r
-\r
-  public SimpleResponse() {\r
-    values = new HashMap();\r
-  }\r
-\r
-  public SimpleResponse(Map aMap) {\r
-    values = aMap;\r
-  }\r
-\r
-  public void setResponseValue(String aName, Object aValue) {\r
-    values.put(aName, aValue);\r
-  }\r
-\r
-  public Map getResponseValues() {\r
-    return values;\r
-  }\r
-\r
-  public void setResponseGenerator(String aGenerator) {\r
-    generator = aGenerator;\r
-  }\r
-\r
-  public String getResponseGenerator() {\r
-    return generator;\r
-  }\r
+/*
+ * 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 the com.oreilly.servlet library, 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SimpleResponse implements Response {
+  private String generator;
+  private Map values;
+
+  public SimpleResponse() {
+    values = new HashMap();
+  }
+
+  public SimpleResponse(Map aMap) {
+    values = aMap;
+  }
+
+  public void setResponseValue(String aName, Object aValue) {
+    values.put(aName, aValue);
+  }
+
+  public Map getResponseValues() {
+    return values;
+  }
+
+  public void setResponseGenerator(String aGenerator) {
+    generator = aGenerator;
+  }
+
+  public String getResponseGenerator() {
+    return generator;
+  }
 }
\ No newline at end of file
index e9a1e4d..d10f06b 100755 (executable)
@@ -42,7 +42,7 @@ package mir.storage.store.test;
 
 import mir.storage.store.ObjectStore;
 import mir.storage.store.StorableObject;
-import mir.storage.store.*;
+import mir.storage.store.StoreIdentifier;
 
 public class TestStore {
 
index 194f31b..daf90ec 100755 (executable)
@@ -35,7 +35,8 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.OutputStream;
-import java.io.*;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
index b3e1855..f67524a 100755 (executable)
 \r
 package mircoders.global;\r
 \r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.util.Arrays;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Random;\r
-import java.util.Vector;\r
-import javax.servlet.http.Cookie;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.apache.commons.collections.ExtendedProperties;\r
-\r
-import gnu.regexp.RE;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.util.DateToMapAdapter;\r
-import mir.util.InternetFunctions;\r
-import mir.util.StringRoutines;\r
-import mir.session.*;\r
-import mircoders.entity.EntityComment;\r
-import mircoders.entity.EntityContent;\r
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Vector;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.ExtendedProperties;
+import gnu.regexp.RE;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.session.HTTPAdapters;
+import mir.session.Request;
+import mir.util.DateToMapAdapter;
+import mir.util.InternetFunctions;
+import mir.util.StringRoutines;
+import mircoders.entity.EntityComment;
+import mircoders.entity.EntityContent;
 import mircoders.localizer.MirAdminInterfaceLocalizer;\r
 \r
 \r
index b323275..6af0292 100755 (executable)
 \r
 package mircoders.localizer;\r
 \r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import mir.session.Request;\r
-import mir.session.Response;\r
-import mir.session.*;\r
-import mircoders.entity.EntityComment;\r
+import mir.session.Request;
+import mir.session.Session;
+import mir.session.SessionHandler;
+import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;\r
 \r
 public interface MirOpenPostingLocalizer {\r
index 522f116..0b68736 100755 (executable)
 \r
 package mircoders.localizer.basic;\r
 \r
-import java.util.*;\r
-import mir.log.LoggerWrapper;\r
-import mir.session.*;\r
-import mir.config.*;\r
-import mir.util.*;\r
-import mir.entity.*;\r
-import mircoders.storage.*;\r
-import mircoders.global.*;\r
-import mircoders.localizer.*;\r
-import mircoders.entity.*;\r
-import mircoders.module.*;\r
-import mircoders.media.*;\r
+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;\r
 \r
 /**\r
  *\r
index 67d5ca9..666bcf4 100755 (executable)
@@ -34,7 +34,7 @@ package mircoders.localizer.basic;
 import mir.generator.FreemarkerGenerator;
 import mir.generator.Generator;
 import mir.generator.GeneratorLibraryRepository;
-import mir.generator.*;
+import mir.generator.WriterEngine;
 import mir.log.LoggerWrapper;
 import mircoders.global.MirGlobal;
 import mircoders.localizer.MirGeneratorLocalizer;
diff --git a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
new file mode 100755 (executable)
index 0000000..245e6b3
--- /dev/null
@@ -0,0 +1,372 @@
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.localizer.basic;\r
+\r
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Vector;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.SessionHandler;
+import mir.session.UploadedFile;
+import mir.storage.StorageObject;
+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;\r
+\r
+/**\r
+ *\r
+ * <p>Title: Experimental session handler for comment postings </p>\r
+ * <p>Description: </p>\r
+ * <p>Copyright: Copyright (c) 2003</p>\r
+ * <p>Company: </p>\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+\r
+public class MirBasicPostingSessionHandler implements SessionHandler {\r
+  protected LoggerWrapper logger;\r
+  protected MirPropertiesConfiguration configuration;\r
+  protected ModuleComment commentModule;\r
+  protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();\r
+\r
+  public MirBasicPostingSessionHandler() {\r
+    logger = new LoggerWrapper("Localizer.OpenPosting");\r
+    try {\r
+      configuration = MirPropertiesConfiguration.instance();\r
+    }\r
+    catch (Throwable t) {\r
+      logger.fatal("Cannot load configuration: " + t.toString());\r
+\r
+      throw new RuntimeException("Cannot load configuration: " + t.toString());\r
+    }\r
+    commentModule= new ModuleComment(DatabaseComment.getInstance());\r
+  }\r
+\r
+  public void processRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
+    if (aSession.getAttribute("initialRequest")==null) {\r
+      initialRequest(aRequest, aSession, aResponse);\r
+      aSession.setAttribute("initialRequest", "no");\r
+    }\r
+    else {\r
+      subsequentRequest(aRequest, aSession, aResponse);\r
+    }\r
+  };\r
+\r
+  protected Map getIntersectingValues(Request aRequest, StorageObject aStorage) throws SessionExc, SessionFailure {\r
+    Map result = new HashMap();\r
+\r
+    Iterator i = aStorage.getFields().iterator();\r
+\r
+    while (i.hasNext()) {\r
+      String fieldName = (String) i.next();\r
+      Object value = aRequest.getParameter(fieldName);\r
+      if (value != null)\r
+        result.put(fieldName, value);\r
+    }\r
+\r
+    return result;\r
+  }\r
+\r
+\r
+  protected String generateOnetimePassword() {\r
+    Random r = new Random();\r
+    int random = r.nextInt();\r
+\r
+    long l = System.currentTimeMillis();\r
+\r
+    l = (l*l*l*l)/random;\r
+    if (l<0)\r
+      l = l * -1;\r
+\r
+    String returnString = ""+l;\r
+\r
+    return returnString.substring(5);\r
+  }\r
+\r
+  protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
+    if (MirGlobal.abuse().getOpenPostingPassword()) {\r
+      String password = (String) aSession.getAttribute("password");\r
+      if (password==null) {\r
+        password = generateOnetimePassword();\r
+        aSession.setAttribute("password", password);\r
+      }\r
+      aResponse.setResponseValue("password", password);\r
+    }\r
+    else {\r
+      aResponse.setResponseValue("password", null);\r
+      aSession.deleteAttribute("password");\r
+    }\r
+\r
+    aResponse.setResponseValue("errors", null);\r
+  };\r
+\r
+  protected void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure{\r
+    Iterator i = DatabaseComment.getInstance().getFields().iterator();\r
+    while (i.hasNext()) {\r
+      aResponse.setResponseValue( (String) i.next(), null);\r
+    }\r
+\r
+    String articleId = aRequest.getParameter("to_media");\r
+\r
+    if (articleId == null)\r
+      throw new SessionExc("MirBasicPostingSessionHandler.initialRequest: article id not set!");\r
+\r
+    aSession.setAttribute("to_media", articleId);\r
+\r
+    initializeResponseData(aRequest, aSession, aResponse);\r
+\r
+    try {\r
+      aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));\r
+    }\r
+    catch (Throwable e) {\r
+      throw new SessionFailure("Can't get configuration: " + e.getMessage(), e);\r
+    }\r
+\r
+  }\r
+\r
+  protected boolean testFieldEntered(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {\r
+    Object value = aRequest.getParameter(aFieldName);\r
+    if (value==null || !(value instanceof String) || ((String) value).trim().length()==0) {\r
+      logger.debug("  missing field " + aFieldName + " value = " + value);\r
+      aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));\r
+      return false;\r
+    }\r
+    else\r
+      return true;\r
+  }\r
+\r
+  protected boolean testFieldIsNumeric(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) {\r
+    Object value = aRequest.getParameter(aFieldName);\r
+    if (value!=null) {\r
+      try {\r
+        Integer.parseInt((String) value);\r
+        return true;\r
+      }\r
+      catch (Throwable t) {\r
+        logger.debug("  field not numeric: " + aFieldName + " value = " + value);\r
+        aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));\r
+        return false;\r
+      }\r
+    }\r
+    return true;\r
+  }\r
+\r
+  public void validate(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
+\r
+  }\r
+\r
+  public List validate(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
+    List result = new Vector();\r
+\r
+    testFieldEntered(aRequest, "title", "validationerror.missing", result);\r
+    testFieldEntered(aRequest, "description", "validationerror.missing", result);\r
+    testFieldEntered(aRequest, "creator", "validationerror.missing", result);\r
+\r
+    return result;\r
+  }\r
+\r
+  public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
+    try {\r
+      Map commentFields = new HashMap();\r
+\r
+      Iterator i = DatabaseContent.getInstance().getFields().iterator();\r
+      while (i.hasNext()) {\r
+        String field = (String) i.next();\r
+        aResponse.setResponseValue(field, aRequest.getParameter(field));\r
+        if (aRequest.getParameter(field)!=null) {\r
+          commentFields.put(field, aRequest.getParameter(field));\r
+        }\r
+      }\r
+\r
+      initializeResponseData(aRequest, aSession, aResponse);\r
+\r
+      List validationErrors = validate(aRequest, aSession);\r
+\r
+      if (validationErrors != null && validationErrors.size()>0) {\r
+        returnValidationErrors(aRequest, aSession, aResponse, validationErrors);\r
+      }\r
+      else {\r
+//        finish(aRequest, aSession, aResponse);\r
+\r
+        EntityComment comment = (EntityComment) commentModule.createNew ();\r
+//        comment.setValues(getIntersectingValues(aRequest, ));\r
+\r
+        finishComment(aRequest, aSession, comment);\r
+\r
+        String id = comment.insert();\r
+        if(id==null){\r
+          afterDuplicateCommentPosting(aRequest, aSession, aResponse, comment);\r
+          logger.info("Dupe comment rejected");\r
+          aSession.terminate();\r
+        }\r
+        else {\r
+          i = aRequest.getUploadedFiles().iterator();\r
+          while (i.hasNext()) {\r
+            UploadedFile file = (UploadedFile) i.next();\r
+            processMediaFile(aRequest, aSession, comment, file);\r
+          }\r
+\r
+          afterCommentPosting(aRequest, aSession, aResponse, comment);\r
+          MirGlobal.abuse().checkComment(comment, aRequest, null);\r
+          MirGlobal.localizer().openPostings().afterCommentPosting(comment);\r
+          logger.info("Comment posted");\r
+          aSession.terminate();\r
+        }\r
+      }\r
+    }\r
+    catch (Throwable t) {\r
+      ExceptionFunctions.traceCauseException(t).printStackTrace();\r
+\r
+      throw new SessionFailure("MirBasicPostingSessionHandler.subsequentRequest: " + t.getMessage(), t);\r
+    }\r
+  }\r
+\r
+  public void initializeCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionFailure, SessionExc {\r
+    String articleId = aRequest.getParameter("to_media");\r
+    if (articleId==null)\r
+      articleId = aRequest.getParameter("aid");\r
+\r
+    if (articleId==null)\r
+      throw new SessionExc("initializeCommentPosting: article id not set!");\r
+\r
+    aSession.setAttribute("to_media", articleId);\r
+    processCommentPosting(aRequest, aSession, aResponse);\r
+  };\r
+\r
+  public void returnValidationErrors(Request aRequest, Session aSession, Response aResponse, List aValidationErrors) throws SessionFailure, SessionExc {\r
+    aResponse.setResponseValue("errors", aValidationErrors);\r
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));\r
+  };\r
+\r
+  public void processCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
+    if (MirGlobal.abuse().getOpenPostingPassword()) {\r
+      String password = generateOnetimePassword();\r
+      aSession.setAttribute("password", password);\r
+      aResponse.setResponseValue("password", password);\r
+      aResponse.setResponseValue("passwd", password);\r
+    }\r
+    else {\r
+      aResponse.setResponseValue("password", null);\r
+    }\r
+\r
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate"));\r
+  };\r
+\r
+  public void processMediaFile(Request aRequest, Session aSession, EntityComment aComment, UploadedFile aFile) throws SessionExc, SessionFailure {\r
+    try {\r
+      Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, new HashMap());\r
+      finishMedia(aRequest, aSession, aFile, mediaItem);\r
+      mediaItem.update();\r
+      commentToMedia.addMedia(aComment.getId(), mediaItem.getId());\r
+    }\r
+    catch (Throwable t) {\r
+      throw new SessionFailure(t);\r
+    }\r
+  }\r
+\r
+  public void finishMedia(Request aRequest, Session aSession, UploadedFile aFile, Entity aMedia) throws SessionExc, SessionFailure {\r
+  }\r
+\r
+  public void finishComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {\r
+    if (aSession.getAttribute("to_media") == null)\r
+      throw new SessionExc("missing to_media");\r
+\r
+    aComment.setValueForProperty("is_published", "1");\r
+    aComment.setValueForProperty("to_comment_status", "1");\r
+    aComment.setValueForProperty("is_html","0");\r
+    aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));\r
+  };\r
+\r
+  public void addMedia(Request aRequest, Session aSession, EntityComment aComment)  throws SessionExc, SessionFailure {\r
+  }\r
+\r
+  public void afterCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {\r
+    DatabaseContent.getInstance().setUnproduced("id=" + aComment.getValue("to_media"));\r
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));\r
+  };\r
+\r
+  public void afterDuplicateCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) {\r
+    aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DupeTemplate"));\r
+  };\r
+\r
+  public class ValidationError {\r
+    private String field;\r
+    private String message;\r
+    private List parameters;\r
+\r
+    public ValidationError(String aField, String aMessage) {\r
+      this (aField, aMessage, new String[] {});\r
+    }\r
+\r
+    public ValidationError(String aField, String aMessage, Object aParameter) {\r
+      this (aField, aMessage, new Object[] {aParameter});\r
+    }\r
+\r
+    public ValidationError(String aField, String aMessage, Object[] aParameters) {\r
+      field = aField;\r
+      message = aMessage;\r
+      parameters = Arrays.asList(aParameters);\r
+    }\r
+\r
+    public String getMessage() {\r
+      return message;\r
+    }\r
+\r
+    public String getField() {\r
+      return field;\r
+    }\r
+\r
+    public List getParameters() {\r
+      return parameters;\r
+    }\r
+  }\r
+\r
+\r
+\r
+}\r
diff --git a/source/mircoders/media/MediaRequest.java b/source/mircoders/media/MediaRequest.java
deleted file mode 100755 (executable)
index 473051c..0000000
+++ /dev/null
@@ -1,290 +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 the com.oreilly.servlet library, 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 java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.Entity;
-import mir.entity.EntityList;
-import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.misc.FileHandler;
-import mir.misc.StringUtil;
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseMediaType;
-
-import com.oreilly.servlet.multipart.FilePart;
-
-
-/*
- *  MediaRequest.java -
- *    Takes an HTTPServletRequest from a mutltipart form and finds the files
- *    uploaded via the com.oreilly.servlet.multipart package. Finally the
- *    appropriate media objects are set.
- *
- * @author mh
- * @version $Id: MediaRequest.java,v 1.18 2003/03/09 19:14:21 idfx Exp $
- *
- */
-
-public class MediaRequest implements FileHandler
-{
-  private String _user;
-  private EntityList _returnList = new EntityList();
-  private boolean _publish;
-  private LoggerWrapper logger;
-
-  public MediaRequest(String user, boolean publish) {
-    _user = user;
-    _publish = publish;
-    logger = new LoggerWrapper("Media.Request");
-  }
-
-  public EntityList getEntityList() {
-    return _returnList;
-  }
-
-  /*
-   * parses the files in the uploaded media and creates media Entity's out of
-   * them.  Produces them if the "produce" argument is true. The "publish"
-   * parameter determines if it should publish per default in the case where no
-   * is_published parameter (from the upload form) is supplied. (for backwards
-   * compatibility.)
-   */
-  public void setFile(FilePart filePart, int fileNum, Map mediaValues) throws FileHandlerExc, FileHandlerFailure {
-
-    String mediaId=null;
-    MirMedia mediaHandler;
-    Database mediaStorage = null;
-
-    try {
-      String fileName = filePart.getFileName();
-
-      //get the content-type from what the client browser
-      //sends us. (the "Oreilly method")
-      String contentType = filePart.getContentType();
-
-      //theLog.printInfo("FROM BROWSER: "+contentType);
-
-      //if the client browser sent us unknown (text/plain is default)
-      //or if we got application/octet-stream, it's possible that
-      //the browser is in error, better check against the file extension
-      if (contentType.equals("text/plain") ||
-          contentType.equals("application/octet-stream")) {
-        /**
-         * Fallback to finding the mime-type through the standard ServletApi
-         * ServletContext getMimeType() method.
-         *
-         * This is a way to get the content-type via the .extension,
-         * we could maybe use a magic method as an additional method of
-         * figuring out the content-type, by looking at the header (first
-         * few bytes) of the file. (like the file(1) command). We could
-         * also call the "file" command through Runtime. This is an
-         * option that I almost prefer as it is already implemented and
-         * exists with an up-to-date map on most modern Unix like systems.
-         * I haven't found a really nice implementation of the magic method
-         * in pure java yet.
-         *
-         * The first method we try thought is the "Oreilly method". It
-         * relies on the content-type that the client browser sends and
-         * that sometimes is application-octet stream with
-         * broken/mis-configured browsers.
-         *
-         * The map file we use for the extensions is the standard web-app
-         * deployment descriptor file (web.xml). See Mir's web.xml or see
-         * your Servlet containers (most likely Tomcat) documentation.
-         * So if you support a new media type you have to make sure that
-         * it is in this file -mh
-         */
-        ServletContext ctx = MirPropertiesConfiguration.getContext();
-        contentType = ctx.getMimeType(fileName);
-        if (contentType==null)
-          contentType = "text/plain"; // rfc1867 says this is the default
-      }
-      //theLog.printInfo("CONTENT TYPE IS: "+contentType);
-
-      if (contentType.equals("text/plain") ||
-          contentType.equals("application/octet-stream")) {
-        _throwBadContentType(fileName, contentType);
-      }
-
-      // call the routines that escape html
-      for (Iterator i=mediaValues.keySet().iterator(); i.hasNext(); ){
-        String k=(String)i.next();
-        String v=(String)mediaValues.get(k);
-
-        if (k.equals("description")) {
-          String tmp = StringUtil.deleteForbiddenTags(v);
-          mediaValues.put(k,StringUtil.deleteHTMLTableTags(tmp));
-        } else {
-          //we don't want people fucking with the author/title, etc..
-          mediaValues.put(k,StringUtil.removeHTMLTags(v));
-        }
-
-      }
-
-      String mediaTitle = (String)mediaValues.get("media_title"+fileNum);
-      if ( (mediaTitle == null) || (mediaTitle.length() == 0)) {
-        //  uncomment the next line and comment out the exception throw
-        //  if you'd rather just assign missing media titles automatically
-        //  mediaTitle="media item "+fileNum;
-//        throw new FileHandlerUserException("Missing field: media title "+mediaTitle+fileNum);
-      }
-
-      // TODO: need to add all the extra fields that can be present in the
-      // admin upload form. -mh
-      mediaValues.put("title", mediaTitle);
-      mediaValues.put("date", StringUtil.date2webdbDate(
-                                                    new GregorianCalendar()));
-      mediaValues.put("to_publisher", _user);
-      //mediaValues.put("to_media_folder", "7"); // op media_folder
-      mediaValues.put("is_produced", "0");
-
-      // icky backwards compatibility code -mh
-      if (_publish == true) {
-        mediaValues.put("is_published", "1");
-      } else {
-        if (!mediaValues.containsKey("is_published"))
-          mediaValues.put("is_published", "0");
-      }
-
-      // @todo this should probably be moved to DatabaseMediaType -mh
-      String[] cTypeSplit = StringUtil.split(contentType, "/");
-      String wc = " mime_type LIKE '"+cTypeSplit[0]+"%'";
-
-      DatabaseMediaType mediaTypeStor = DatabaseMediaType.getInstance();
-      EntityList mediaTypesList = mediaTypeStor.selectByWhereClause(wc);
-
-      String mediaTypeId = null;
-
-      //if we didn't find an entry matching the
-      //content-type int the table.
-      if (mediaTypesList.size() == 0) {
-       _throwBadContentType(fileName, contentType);
-      }
-
-      Entity mediaType = null;
-      Entity mediaType2 = null;
-
-      // find out if we an exact content-type match if so take it.
-      // otherwise try to match majortype/*
-      // @todo this should probably be moved to DatabaseMediaType -mh
-      for(int j=0;j<mediaTypesList.size();j++) {
-        if(contentType.equals(
-              mediaTypesList.elementAt(j).getValue("mime_type")))
-          mediaType = mediaTypesList.elementAt(j);
-        else if ((mediaTypesList.elementAt(j).getValue("mime_type")).equals(
-                  cTypeSplit[0]+"/*") )
-          mediaType2= mediaTypesList.elementAt(j);
-      }
-
-      if ( (mediaType == null) && (mediaType2 == null) ) {
-        _throwBadContentType(fileName, contentType);
-      } else if( (mediaType == null) && (mediaType2 != null) ) {
-        mediaType = mediaType2;
-      }
-
-      //get the class names from the media_type table.
-      mediaTypeId = mediaType.getId();
-      // ############### @todo: merge these and the getURL call into one
-      // getURL helper call that just takes the Entity as a parameter
-      // along with media_type
-      try {
-        mediaHandler = MediaHelper.getHandler(mediaType);
-        mediaStorage = MediaHelper.getStorage(mediaType, "mircoders.storage.Database");
-      }
-      catch (Throwable e) {
-        throw new FileHandlerFailure(e);
-      }
-      mediaValues.put("to_media_type",mediaTypeId);
-
-      //load the classes via reflection
-      String MediaId;
-      Entity mediaEnt = null;
-
-      try {
-        mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance();
-      }
-      catch (Throwable e) {
-        throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);
-      }
-
-      mediaEnt.setStorage(mediaStorage);
-      mediaEnt.setValues(mediaValues);
-      mediaId = mediaEnt.insert();
-
-      //save and store the media data/metadata
-      try {
-        mediaHandler.set(filePart.getInputStream(), mediaEnt, mediaType);
-      }
-      catch (Throwable e) {
-        throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);
-      }
-
-      _returnList.add(mediaEnt);
-    }
-    catch (StorageObjectFailure e) {
-      // first try to delete it.. don't catch exception as we've already..
-      try {
-        mediaStorage.delete(mediaId);
-      }
-      catch (Exception e2) {
-      }
-      throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);
-    }
-    catch (Throwable e) {
-      throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);
-    } //end try/catch block
-
-  } // method setFile()
-
-  private void _throwBadContentType (String fileName, String contentType) throws FileHandlerExc, FileHandlerFailure {
-    try {
-      throw new UnsupportedMediaFormatExc(
-          "The file you uploaded is of the following mime-type: " + contentType +
-          ", we do not support this mime-type. "
-          + "Error One or more files of unrecognized type. Sorry");
-    }
-    catch (Throwable t) {
-      throw new FileHandlerFailure(t);
-    }
-  }
-
-}
-
index bfe1782..2f81916 100755 (executable)
-/*\r
- * Copyright (C) 2001, 2002  The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with the com.oreilly.servlet library, any library\r
- * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
- * the above that use the same license as the above), and distribute linked\r
- * combinations including the two.  You must obey the GNU General Public\r
- * License in all respects for all of the code used other than the above\r
- * mentioned libraries.  If you modify this file, you may extend this exception\r
- * to your version of the file, but you are not obligated to do so.  If you do\r
- * not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.media;\r
-\r
-import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.media.MediaExc;\r
-import mir.media.MediaFailure;\r
-import mir.media.MediaHelper;\r
-import mir.media.MirMedia;\r
-import mir.misc.StringUtil;\r
-import mir.session.UploadedFile;\r
-import mir.storage.Database;\r
-\r
-import mircoders.module.ModuleMediaType;\r
-\r
-public class MediaUploadProcessor {\r
-  public static Entity processMediaUpload(UploadedFile aFile, Map aValues) throws MediaExc, MediaFailure {\r
-    String mediaId;\r
-    MirMedia mediaHandler;\r
-    Entity mediaType;\r
-    ModuleMediaType mediaTypeModule;\r
-    Database mediaStorage;\r
-    Map values = new HashMap();\r
-    String MediaId;\r
-    Entity mediaEntity;\r
-\r
-\r
-    try {\r
-      String contentType = aFile.getContentType();\r
-\r
-      if (contentType.equals("text/plain") ||\r
-          contentType.equals("application/octet-stream") ||\r
-          contentType == null) {\r
-        throw new MediaExc("Invalid content-type: " + contentType);\r
-      }\r
-\r
-      values.putAll(aValues);\r
-      values.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));\r
-      values.put("is_produced", "0");\r
-      values.put("is_published", "1");\r
-      values.put("to_publisher", "0");\r
-      values.put("to_media_folder", "7");\r
-\r
-      mediaTypeModule = new ModuleMediaType();\r
-      mediaType = mediaTypeModule.findMediaTypeForMimeType(contentType);\r
-\r
-      try {\r
-        mediaHandler = MediaHelper.getHandler(mediaType);\r
-        mediaStorage = MediaHelper.getStorage(mediaType, "mircoders.storage.Database");\r
-      }\r
-      catch (Throwable e) {\r
-        throw new MediaFailure(e);\r
-      }\r
-\r
-      values.put("to_media_type", mediaType.getId());\r
-\r
-      try {\r
-        mediaEntity = (Entity) mediaStorage.getEntityClass().newInstance();\r
-        mediaEntity.setStorage(mediaStorage);\r
-      }\r
-      catch (Throwable e) {\r
-        throw new MediaFailure(e);\r
-      }\r
-\r
-      mediaEntity.setValues(values);\r
-      mediaId = mediaEntity.insert();\r
-\r
-      try {\r
-        mediaHandler.set(aFile.getInputStream(), mediaEntity, mediaType);\r
-      }\r
-      catch (Throwable e) {\r
-        throw new MediaFailure(e);\r
-      }\r
-\r
-      return mediaEntity;\r
-    }\r
-    catch (Throwable e) {\r
-      throw new MediaFailure(e);\r
-    }\r
-\r
-  }\r
+/*
+ * 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 the com.oreilly.servlet library, 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 java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.media.MediaExc;
+import mir.media.MediaFailure;
+import mir.media.MediaHelper;
+import mir.media.MirMedia;
+import mir.misc.StringUtil;
+import mir.session.UploadedFile;
+import mir.storage.Database;
+
+import mircoders.module.ModuleMediaType;
+
+public class MediaUploadProcessor {
+  public static Entity processMediaUpload(UploadedFile aFile, Map aValues) throws MediaExc, MediaFailure {
+    String mediaId;
+    MirMedia mediaHandler;
+    Entity mediaType;
+    ModuleMediaType mediaTypeModule;
+    Database mediaStorage;
+    Map values = new HashMap();
+    String MediaId;
+    Entity mediaEntity;
+
+
+    try {
+      String contentType = aFile.getContentType();
+
+      if (contentType.equals("text/plain") ||
+          contentType.equals("application/octet-stream") ||
+          contentType == null) {
+        throw new MediaExc("Invalid content-type: " + contentType);
+      }
+
+      values.putAll(aValues);
+      values.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
+      values.put("is_produced", "0");
+
+      mediaTypeModule = new ModuleMediaType();
+      mediaType = mediaTypeModule.findMediaTypeForMimeType(contentType);
+
+      try {
+        mediaHandler = MediaHelper.getHandler(mediaType);
+        mediaStorage = MediaHelper.getStorage(mediaType, "mircoders.storage.Database");
+      }
+      catch (Throwable e) {
+        throw new MediaFailure(e);
+      }
+
+      values.put("to_media_type", mediaType.getId());
+
+      try {
+        mediaEntity = (Entity) mediaStorage.getEntityClass().newInstance();
+        mediaEntity.setStorage(mediaStorage);
+      }
+      catch (Throwable e) {
+        throw new MediaFailure(e);
+      }
+
+      mediaEntity.setValues(values);
+      mediaId = mediaEntity.insert();
+
+      try {
+        mediaHandler.set(aFile.getInputStream(), mediaEntity, mediaType);
+      }
+      catch (Throwable e) {
+        throw new MediaFailure(e);
+      }
+
+      return mediaEntity;
+    }
+    catch (Throwable e) {
+      throw new MediaFailure(e);
+    }
+
+  }
 }
\ No newline at end of file
index dd58860..c6dfce4 100755 (executable)
 \r
 package mircoders.servlet;\r
 \r
-import java.io.PrintWriter;\r
-import java.util.HashMap;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-\r
-import org.apache.struts.util.MessageResources;\r
-import mir.entity.adapter.EntityIteratorAdapter;\r
-import mir.generator.Generator;\r
-import mir.servlet.ServletModuleExc;\r
-import mir.servlet.ServletModuleFailure;\r
-import mir.util.CachingRewindableIterator;\r
-import mir.util.NullWriter;\r
-import mir.util.ResourceBundleGeneratorFunction;\r
-import mir.log.*;\r
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.struts.util.MessageResources;
+
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.generator.Generator;
+import mir.log.LoggerWrapper;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
+import mir.util.CachingRewindableIterator;
+import mir.util.ResourceBundleGeneratorFunction;
 import mircoders.global.MirGlobal;\r
 \r
 \r
index b1747db..e68f9fd 100755 (executable)
@@ -57,6 +57,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpUtils;
 
+import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.commons.net.smtp.SMTPReply;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -67,34 +68,32 @@ import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Searcher;
 import org.apache.struts.util.MessageResources;
-import org.apache.commons.fileupload.FileItem;
 import gnu.regexp.RE;
 import gnu.regexp.REMatch;
+
 import mir.entity.Entity;
-import mir.entity.EntityList;
 import mir.generator.Generator;
 import mir.log.LoggerWrapper;
-import mir.misc.FileHandler;
 import mir.misc.StringUtil;
-import mir.misc.WebdbMultipartRequest;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleExc;
 import mir.servlet.ServletModuleFailure;
 import mir.servlet.ServletModuleUserExc;
-import mir.session.*;
+import mir.session.HTTPAdapters;
 import mir.session.Request;
 import mir.session.Session;
 import mir.session.SessionHandler;
 import mir.session.SimpleResponse;
+import mir.session.UploadedFile;
 import mir.storage.StorageObjectFailure;
 import mir.util.ExceptionFunctions;
 import mir.util.HTTPParsedRequest;
 import mir.util.HTTPRequestParser;
-import mir.util.*;
+import mir.util.StringRoutines;
 import mircoders.entity.EntityComment;
 import mircoders.entity.EntityContent;
 import mircoders.global.MirGlobal;
-import mircoders.media.*;
+import mircoders.media.MediaUploadProcessor;
 import mircoders.media.UnsupportedMediaFormatExc;
 import mircoders.module.ModuleComment;
 import mircoders.module.ModuleContent;
@@ -124,7 +123,7 @@ import mircoders.storage.DatabaseTopics;
  *    open-postings to the newswire
  *
  * @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.78 2003/04/21 00:24:06 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.79 2003/04/21 02:58:30 zapata Exp $
  *
  */
 
@@ -384,7 +383,7 @@ public class ServletModuleOpenIndy extends ServletModule
       HTTPParsedRequest parsedRequest = new HTTPParsedRequest(
           aRequest,
           configuration.getString("Mir.DefaultEncoding"),
-          configuration.getInt("MaxMediaUploadSize"),
+          configuration.getInt("MaxMediaUploadSize")*1024,
           configuration.getString("TempDir"));
 
       Map mergeData = new HashMap();
@@ -421,6 +420,9 @@ public class ServletModuleOpenIndy extends ServletModule
 
         mediaValues.put("title", StringUtil.removeHTMLTags(title));
         mediaValues.put("creator", StringUtil.removeHTMLTags(parsedRequest.getParameter("creator")));
+        mediaValues.put("to_publisher", "0");
+        mediaValues.put("is_published", "1");
+        mediaValues.put("to_media_folder", "7");
 
         mediaList.add(MediaUploadProcessor.processMediaUpload(file, mediaValues));
       }
index d790412..27bcf27 100755 (executable)
-/*\r
- * Copyright (C) 2001, 2002  The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with the com.oreilly.servlet library, any library\r
- * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
- * the above that use the same license as the above), and distribute linked\r
- * combinations including the two.  You must obey the GNU General Public\r
- * License in all respects for all of the code used other than the above\r
- * mentioned libraries.  If you modify this file, you may extend this exception\r
- * to your version of the file, but you are not obligated to do so.  If you do\r
- * not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.servlet;\r
-\r
-import java.io.InputStream;\r
-import java.net.URLEncoder;\r
-import java.util.Map;\r
-import javax.servlet.ServletContext;\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import javax.servlet.http.HttpSession;\r
-\r
-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.entity.Entity;\r
-import mir.entity.EntityList;\r
-import mir.log.LoggerWrapper;\r
-import mir.media.MediaHelper;\r
-import mir.media.MirMedia;\r
-import mir.misc.FileHandler;\r
-import mir.misc.WebdbMultipartRequest;\r
-import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleExc;\r
-import mir.servlet.ServletModuleFailure;\r
-import mir.servlet.ServletModuleUserExc;\r
-import mir.util.ExceptionFunctions;\r
-import mircoders.entity.EntityComment;\r
-import mircoders.entity.EntityContent;\r
-import mircoders.entity.EntityUploadedMedia;\r
-import mircoders.entity.EntityUsers;\r
-import mircoders.media.MediaRequest;\r
-import mircoders.media.UnsupportedMediaFormatExc;\r
-import mircoders.storage.DatabaseComment;\r
-import mircoders.storage.DatabaseContent;\r
-import mircoders.storage.DatabaseMediafolder;\r
-\r
-/*\r
- *  ServletModuleBilder -\r
- *  liefert HTML fuer Bilder\r
- *\r
- * @version $Id: ServletModuleUploadedMedia.java,v 1.24 2003/04/10 03:31:47 zapata Exp $\r
- * @author RK, the mir-coders group\r
- */\r
-\r
-public abstract class ServletModuleUploadedMedia\r
-        extends mir.servlet.ServletModule {\r
-\r
-  //private static DatabaseRights dbRights;\r
-\r
-  public static ServletModule getInstance() {\r
-    return null;\r
-  }\r
-\r
-  public ServletModuleUploadedMedia() {\r
-    super();\r
-    logger = new LoggerWrapper("ServletModule.UploadedMedia");\r
-  }\r
-\r
-  public void insert(HttpServletRequest req, HttpServletResponse res)\r
-          throws ServletModuleExc, ServletModuleUserExc {\r
-    try {\r
-      EntityUsers user = _getUser(req);\r
-      MediaRequest mediaReq =  new MediaRequest(user.getId(), false);\r
-      WebdbMultipartRequest mp = new WebdbMultipartRequest(req, (FileHandler)mediaReq);\r
-      EntityList mediaList = mediaReq.getEntityList();\r
-      String articleid = (String) mp.getParameters().get("articleid");\r
-      String commentid = (String) mp.getParameters().get("commentid");\r
-\r
-      if (articleid!=null) {\r
-        EntityContent entContent = (EntityContent) DatabaseContent.getInstance().selectById(articleid);\r
-\r
-        mediaList.rewind();\r
-\r
-        while (mediaList.hasNext()) {\r
-          entContent.attach( ( (EntityUploadedMedia) mediaList.next()).getId());\r
-        }\r
-        mediaList.rewind();\r
-\r
-        ((ServletModuleContent) ServletModuleContent.getInstance())._showObject(articleid, req, res);\r
-\r
-        return;\r
-      }\r
-\r
-      if (commentid!=null) {\r
-        EntityComment comment = (EntityComment) DatabaseComment.getInstance().selectById(commentid);\r
-\r
-        mediaList.rewind();\r
-\r
-        while (mediaList.hasNext()) {\r
-          comment.attach( ( (EntityUploadedMedia) mediaList.next()).getId());\r
-        }\r
-        mediaList.rewind();\r
-\r
-        ((ServletModuleComment) ServletModuleComment.getInstance()).showComment(commentid, req, res);\r
-\r
-        return;\r
-      }\r
-\r
-      SimpleHash mergeData = new SimpleHash();\r
-      SimpleHash popups = new SimpleHash();\r
-      mergeData.put("contentlist", mediaList);\r
-      if (mediaList.getOrder() != null) {\r
-        mergeData.put("order", mediaList.getOrder());\r
-        mergeData.put("order_encoded", URLEncoder.encode(mediaList.getOrder()));\r
-      }\r
-      mergeData.put("count", (new Integer(mediaList.getCount())).toString());\r
-      mergeData.put("from", (new Integer(mediaList.getFrom())).toString());\r
-      mergeData.put("to", (new Integer(mediaList.getTo())).toString());\r
-      if (mediaList.hasNextBatch())\r
-        mergeData.put("next", (new Integer(mediaList.getNextBatch())).toString());\r
-      if (mediaList.hasPrevBatch())\r
-        mergeData.put("prev", (new Integer(mediaList.getPrevBatch())).toString());\r
-      //fetch the popups\r
-      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());\r
-      // raus damit\r
-      deliver(req, res, mergeData, popups, templateListString);\r
-    }\r
-    catch (Throwable t) {\r
-      Throwable cause = ExceptionFunctions.traceCauseException(t);\r
-\r
-      if (cause instanceof UnsupportedMediaFormatExc) {\r
-        throw new ServletModuleUserExc("media.error.unsupportedformat", new String[] {});\r
-      }\r
-      throw new ServletModuleFailure("ServletModuleUploadedMedia.insert: " + t.toString(), t);\r
-    }\r
-  }\r
-\r
-  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-\r
-    try {\r
-      EntityUsers user = _getUser(req);\r
-      WebdbMultipartRequest mp = new WebdbMultipartRequest(req, null);\r
-      Map parameters = mp.getParameters();\r
-\r
-      parameters.put("to_publisher", user.getId());\r
-      parameters.put("is_produced", "0");\r
-      if (!parameters.containsKey("is_published"))\r
-        parameters.put("is_published", "0");\r
-\r
-      String id = mainModule.set(parameters);\r
-      logger.debug("update: media ID = " + id);\r
-      _edit(id, req, res);\r
-    }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure("upload -- exception " + e.toString(), e);\r
-    }\r
-\r
-  }\r
-\r
-\r
-  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-    // Parameter auswerten\r
-    SimpleHash mergeData = new SimpleHash();\r
-    SimpleHash popups = new SimpleHash();\r
-\r
-    String query_text = req.getParameter("query_text");\r
-    mergeData.put("query_text", query_text);\r
-    if (query_text != null) mergeData.put("query_text_encoded", URLEncoder.encode(query_text));\r
-    String query_field = req.getParameter("query_field");\r
-    mergeData.put("query_field", query_field);\r
-    String query_is_published = req.getParameter("query_is_published");\r
-    mergeData.put("query_is_published", query_is_published);\r
-    String query_media_folder = req.getParameter("query_media_folder");\r
-    mergeData.put("query_media_folder", query_media_folder);\r
-    String offset = req.getParameter("offset");\r
-    if (offset == null || offset.equals("")) offset = "0";\r
-    mergeData.put("offset", offset);\r
-\r
-    String order = req.getParameter("order");\r
-    if (order == null || order.equals("")) order = "webdb_lastchange desc";\r
-\r
-    // if in connection mode to content\r
-    mergeData.put("articleid", req.getParameter("articleid"));\r
-    mergeData.put("commentid", req.getParameter("commentid"));\r
-\r
-\r
-    // sql basteln\r
-    String whereClause = "";\r
-    boolean isFirst = true;\r
-    if (query_text != null && !query_text.equalsIgnoreCase("")) {\r
-      whereClause += "lower(" + query_field + ") like lower('%" + query_text + "%')";\r
-      isFirst = false;\r
-    }\r
-    if (query_is_published != null && !query_is_published.equals("")) {\r
-      if (isFirst == false) whereClause += " and ";\r
-      whereClause += "is_published='" + query_is_published + "'";\r
-      isFirst = false;\r
-    }\r
-    if (query_media_folder != null && !query_media_folder.equals("")) {\r
-      if (isFirst == false) whereClause += " and ";\r
-      whereClause += "to_media_folder='" + query_media_folder + "'";\r
-    }\r
-    //theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset);\r
-\r
-    // fetch and deliver\r
-    try {\r
-      if (query_text != null || query_is_published != null || query_media_folder != null) {\r
-        EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue(), 10);\r
-        if (theList != null) {\r
-          mergeData.put("contentlist", theList);\r
-          if (theList.getOrder() != null) {\r
-            mergeData.put("order", theList.getOrder());\r
-            mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));\r
-          }\r
-          mergeData.put("count", (new Integer(theList.getCount())).toString());\r
-          mergeData.put("from", (new Integer(theList.getFrom())).toString());\r
-          mergeData.put("to", (new Integer(theList.getTo())).toString());\r
-          if (theList.hasNextBatch())\r
-            mergeData.put("next", (new Integer(theList.getNextBatch())).toString());\r
-          if (theList.hasPrevBatch())\r
-            mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());\r
-        }\r
-      }\r
-      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());\r
-\r
-      deliver(req, res, mergeData, popups, templateListString);\r
-    }\r
-    catch (Throwable e) {\r
-      throw new ServletModuleFailure(e);\r
-    }\r
-  }\r
-\r
-\r
-  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-    try {\r
-      SimpleHash mergeData = new SimpleHash();\r
-      SimpleHash popups = new SimpleHash();\r
-      String maxMedia = MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.MaxMediaUploadItems");\r
-      String numOfMedia = req.getParameter("medianum");\r
-\r
-      mergeData.put("new", "1");\r
-      mergeData.put("articleid", req.getParameter("articleid"));\r
-      mergeData.put("commentid", req.getParameter("commentid"));\r
-\r
-      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());\r
-\r
-      if (numOfMedia==null || numOfMedia.equals("")) {\r
-        numOfMedia="1";\r
-      }\r
-      else if(Integer.parseInt(numOfMedia) > Integer.parseInt(maxMedia)) {\r
-        numOfMedia = maxMedia;\r
-      }\r
-\r
-      int mediaNum = Integer.parseInt(numOfMedia);\r
-      SimpleList mediaFields = new SimpleList();\r
-      for(int i =0; i<mediaNum;i++){\r
-        Integer mNum = new Integer(i+1);\r
-        mediaFields.add(mNum.toString());\r
-      }\r
-      mergeData.put("medianum",numOfMedia);\r
-      mergeData.put("mediafields",mediaFields);\r
-      deliver(req, res, mergeData, popups, templateObjektString);\r
-    }\r
-    catch (Exception e) {\r
-      throw new ServletModuleFailure(e);\r
-    }\r
-  }\r
-\r
-  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-    String idParam = req.getParameter("id");\r
-    _edit(idParam, req, res);\r
-  }\r
-\r
-  private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-    if (idParam != null && !idParam.equals("")) {\r
-      try {\r
-        SimpleHash popups = new SimpleHash();\r
-        popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());\r
-        deliver(req, res, mainModule.getById(idParam), popups,\r
-                templateObjektString);\r
-      }\r
-      catch (Throwable e) {\r
-        throw new ServletModuleFailure(e);\r
-      }\r
-    }\r
-    else {\r
-      throw new ServletModuleExc("ServletmoduleUploadedMedia :: _edit without id");\r
-    }\r
-  }\r
-\r
-\r
-  /** @todo should be in ServletModule.java */\r
-  private EntityUsers _getUser(HttpServletRequest req) {\r
-    HttpSession session = req.getSession(false);\r
-    return (EntityUsers) session.getAttribute("login.uid");\r
-  }\r
-\r
-  public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {\r
-    String idParam = req.getParameter("id");\r
-    if (idParam!=null && !idParam.equals("")) {\r
-      try {\r
-        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);\r
-        Entity mediaType = ent.getMediaType();\r
-        MirMedia mediaHandler;\r
-\r
-        ServletContext ctx = MirPropertiesConfiguration.getContext();\r
-        String fName = ent.getId()+"."+mediaType.getValue("name");\r
-\r
-        mediaHandler = MediaHelper.getHandler(mediaType);\r
-        InputStream in = mediaHandler.getMedia(ent, mediaType);\r
-\r
-        res.setContentType(ctx.getMimeType(fName));\r
-        //important that before calling this res.getWriter was not called first\r
-        ServletOutputStream out = res.getOutputStream();\r
-\r
-        int read ;\r
-        byte[] buf = new byte[8 * 1024];\r
-        while((read = in.read(buf)) != -1) {\r
-          out.write(buf, 0, read);\r
-        }\r
-        in.close();\r
-        out.close();\r
-      }\r
-      catch (Throwable e) {\r
-        throw new ServletModuleFailure(e);\r
-      }\r
-    }\r
-    else logger.error("id not specified.");\r
-    // no exception allowed\r
-  }\r
-\r
-  public void getIcon(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc\r
-  {\r
-    String idParam = req.getParameter("id");\r
-    if (idParam!=null && !idParam.equals("")) {\r
-      try {\r
-        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);\r
-        Entity mediaType = ent.getMediaType();\r
-        MirMedia mediaHandler;\r
-\r
-        ServletContext ctx = MirPropertiesConfiguration.getContext();\r
-        String fName = ent.getId()+"."+mediaType.getValue("name");\r
-\r
-        mediaHandler = MediaHelper.getHandler(mediaType);\r
-        InputStream in = mediaHandler.getIcon(ent);\r
-\r
-        res.setContentType(ctx.getMimeType(fName));\r
-        //important that before calling this res.getWriter was not called first\r
-        ServletOutputStream out = res.getOutputStream();\r
-\r
-        int read ;\r
-        byte[] buf = new byte[8 * 1024];\r
-        while((read = in.read(buf)) != -1) {\r
-          out.write(buf, 0, read);\r
-        }\r
-        in.close();\r
-        out.close();\r
-      }\r
-\r
-      catch (Throwable e) {\r
-        throw new ServletModuleFailure(e);\r
-      }\r
-    }\r
-    else logger.error("getIcon: id not specified.");\r
-    // no exception allowed\r
-  }\r
-\r
-}\r
-\r
-\r
+/*
+ * 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 the com.oreilly.servlet library, 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.servlet;
+
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.fileupload.FileItem;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.Entity;
+import mir.entity.EntityList;
+import mir.log.LoggerWrapper;
+import mir.media.MediaHelper;
+import mir.media.MirMedia;
+import mir.servlet.ServletModule;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleFailure;
+import mir.servlet.ServletModuleUserExc;
+import mir.session.UploadedFile;
+import mir.util.ExceptionFunctions;
+import mir.util.HTTPParsedRequest;
+import mircoders.entity.EntityComment;
+import mircoders.entity.EntityContent;
+import mircoders.entity.EntityUploadedMedia;
+import mircoders.entity.EntityUsers;
+import mircoders.media.MediaUploadProcessor;
+import mircoders.media.UnsupportedMediaFormatExc;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseMediafolder;
+
+/*
+ *  ServletModuleBilder -
+ *  liefert HTML fuer Bilder
+ *
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.25 2003/04/21 02:58:30 zapata Exp $
+ * @author RK, the mir-coders group
+ */
+
+public abstract class ServletModuleUploadedMedia
+        extends mir.servlet.ServletModule {
+
+  //private static DatabaseRights dbRights;
+
+  public static ServletModule getInstance() {
+    return null;
+  }
+
+  public ServletModuleUploadedMedia() {
+    super();
+    logger = new LoggerWrapper("ServletModule.UploadedMedia");
+  }
+
+  public void insert(HttpServletRequest req, HttpServletResponse res)
+          throws ServletModuleExc, ServletModuleUserExc {
+    try {
+      HTTPParsedRequest parsedRequest = new HTTPParsedRequest(req,
+          configuration.getString("Mir.DefaultEncoding"),
+          configuration.getInt("MaxMediaUploadSize")*1024,
+          configuration.getString("TempDir"));
+
+      EntityUsers user = _getUser(req);
+      Map mediaValues = new HashMap();
+
+      mediaValues.put("to_publisher", _getUser(req).getId());
+
+      Iterator i = mainModule.getStorageObject().getFields().iterator();
+      while (i.hasNext()) {
+        String field = (String) i.next();
+        String value = parsedRequest.getParameter(field);
+        if (value!=null)
+          mediaValues.put(field, value);
+      }
+
+      List mediaList = new Vector();
+
+      i = parsedRequest.getFiles().iterator();
+      while (i.hasNext()) {
+        UploadedFile file = new mir.session.CommonsUploadedFileAdapter((FileItem) i.next());
+
+        String suffix = file.getFieldName().substring(5);
+        mediaValues.put("title", parsedRequest.getParameter("media_title" + suffix));
+
+        mediaList.add(MediaUploadProcessor.processMediaUpload(file, mediaValues));
+      }
+
+      String articleid = parsedRequest.getParameter("articleid");
+      String commentid = parsedRequest.getParameter("commentid");
+
+      if (articleid!=null) {
+        EntityContent entContent = (EntityContent) DatabaseContent.getInstance().selectById(articleid);
+
+        i=mediaList.iterator();
+
+        while (i.hasNext()) {
+          entContent.attach(((EntityUploadedMedia) i.next()).getId());
+        }
+
+        ((ServletModuleContent) ServletModuleContent.getInstance())._showObject(articleid, req, res);
+
+        return;
+      }
+
+      if (commentid!=null) {
+        EntityComment comment = (EntityComment) DatabaseComment.getInstance().selectById(commentid);
+
+        i=mediaList.iterator();
+
+        while (i.hasNext()) {
+          comment.attach( ( (EntityUploadedMedia) i.next()).getId());
+        }
+
+        ((ServletModuleComment) ServletModuleComment.getInstance()).showComment(commentid, req, res);
+
+        return;
+      }
+
+      SimpleHash mergeData = new SimpleHash();
+      SimpleHash popups = new SimpleHash();
+      mergeData.put("contentlist", mir.generator.FreemarkerGenerator.makeAdapter(mediaList));
+
+      mergeData.put("count", Integer.toString(mediaList.size()));
+      mergeData.put("from", "1");
+      mergeData.put("to", Integer.toString(mediaList.size()));
+
+      //fetch the popups
+      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
+      // raus damit
+      deliver(req, res, mergeData, popups, templateListString);
+    }
+    catch (Throwable t) {
+      Throwable cause = ExceptionFunctions.traceCauseException(t);
+
+      if (cause instanceof UnsupportedMediaFormatExc) {
+        throw new ServletModuleUserExc("media.error.unsupportedformat", new String[] {});
+      }
+      throw new ServletModuleFailure("ServletModuleUploadedMedia.insert: " + t.toString(), t);
+    }
+  }
+
+  public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+
+    try {
+      HTTPParsedRequest parsedRequest = new HTTPParsedRequest(req,
+          configuration.getString("Mir.DefaultEncoding"),
+          configuration.getInt("MaxMediaUploadSize")*1024,
+          configuration.getString("TempDir"));
+      EntityUsers user = _getUser(req);
+      Map mediaValues = new HashMap();
+
+      Iterator i = mainModule.getStorageObject().getFields().iterator();
+      while (i.hasNext()) {
+        String field = (String) i.next();
+        String value = parsedRequest.getParameter(field);
+        if (value!=null)
+          mediaValues.put(field, value);
+      }
+
+      mediaValues.put("to_publisher", user.getId());
+      mediaValues.put("is_produced", "0");
+      if (!mediaValues.containsKey("is_published"))
+        mediaValues.put("is_published", "0");
+
+      String id = mainModule.set(mediaValues);
+      logger.debug("update: media ID = " + id);
+      _edit(id, req, res);
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure("upload -- exception " + e.toString(), e);
+    }
+
+  }
+
+
+  public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+    // Parameter auswerten
+    SimpleHash mergeData = new SimpleHash();
+    SimpleHash popups = new SimpleHash();
+
+    String query_text = req.getParameter("query_text");
+    mergeData.put("query_text", query_text);
+    if (query_text != null) mergeData.put("query_text_encoded", URLEncoder.encode(query_text));
+    String query_field = req.getParameter("query_field");
+    mergeData.put("query_field", query_field);
+    String query_is_published = req.getParameter("query_is_published");
+    mergeData.put("query_is_published", query_is_published);
+    String query_media_folder = req.getParameter("query_media_folder");
+    mergeData.put("query_media_folder", query_media_folder);
+    String offset = req.getParameter("offset");
+    if (offset == null || offset.equals("")) offset = "0";
+    mergeData.put("offset", offset);
+
+    String order = req.getParameter("order");
+    if (order == null || order.equals("")) order = "webdb_lastchange desc";
+
+    // if in connection mode to content
+    mergeData.put("articleid", req.getParameter("articleid"));
+    mergeData.put("commentid", req.getParameter("commentid"));
+
+
+    // sql basteln
+    String whereClause = "";
+    boolean isFirst = true;
+    if (query_text != null && !query_text.equalsIgnoreCase("")) {
+      whereClause += "lower(" + query_field + ") like lower('%" + query_text + "%')";
+      isFirst = false;
+    }
+    if (query_is_published != null && !query_is_published.equals("")) {
+      if (isFirst == false) whereClause += " and ";
+      whereClause += "is_published='" + query_is_published + "'";
+      isFirst = false;
+    }
+    if (query_media_folder != null && !query_media_folder.equals("")) {
+      if (isFirst == false) whereClause += " and ";
+      whereClause += "to_media_folder='" + query_media_folder + "'";
+    }
+    //theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset);
+
+    // fetch and deliver
+    try {
+      if (query_text != null || query_is_published != null || query_media_folder != null) {
+        EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue(), 10);
+        if (theList != null) {
+          mergeData.put("contentlist", theList);
+          if (theList.getOrder() != null) {
+            mergeData.put("order", theList.getOrder());
+            mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
+          }
+          mergeData.put("count", (new Integer(theList.getCount())).toString());
+          mergeData.put("from", (new Integer(theList.getFrom())).toString());
+          mergeData.put("to", (new Integer(theList.getTo())).toString());
+          if (theList.hasNextBatch())
+            mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
+          if (theList.hasPrevBatch())
+            mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
+        }
+      }
+      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
+
+      deliver(req, res, mergeData, popups, templateListString);
+    }
+    catch (Throwable e) {
+      throw new ServletModuleFailure(e);
+    }
+  }
+
+
+  public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+    try {
+      SimpleHash mergeData = new SimpleHash();
+      SimpleHash popups = new SimpleHash();
+      String maxMedia = MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.MaxMediaUploadItems");
+      String numOfMedia = req.getParameter("medianum");
+
+      mergeData.put("new", "1");
+      mergeData.put("articleid", req.getParameter("articleid"));
+      mergeData.put("commentid", req.getParameter("commentid"));
+
+      popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
+
+      if (numOfMedia==null || numOfMedia.equals("")) {
+        numOfMedia="1";
+      }
+      else if(Integer.parseInt(numOfMedia) > Integer.parseInt(maxMedia)) {
+        numOfMedia = maxMedia;
+      }
+
+      int mediaNum = Integer.parseInt(numOfMedia);
+      SimpleList mediaFields = new SimpleList();
+      for(int i =0; i<mediaNum;i++){
+        Integer mNum = new Integer(i+1);
+        mediaFields.add(mNum.toString());
+      }
+      mergeData.put("medianum",numOfMedia);
+      mergeData.put("mediafields",mediaFields);
+      deliver(req, res, mergeData, popups, templateObjektString);
+    }
+    catch (Exception e) {
+      throw new ServletModuleFailure(e);
+    }
+  }
+
+  public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+    String idParam = req.getParameter("id");
+    _edit(idParam, req, res);
+  }
+
+  private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+    if (idParam != null && !idParam.equals("")) {
+      try {
+        SimpleHash popups = new SimpleHash();
+        popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
+        deliver(req, res, mainModule.getById(idParam), popups,
+                templateObjektString);
+      }
+      catch (Throwable e) {
+        throw new ServletModuleFailure(e);
+      }
+    }
+    else {
+      throw new ServletModuleExc("ServletmoduleUploadedMedia :: _edit without id");
+    }
+  }
+
+
+  /** @todo should be in ServletModule.java */
+  private EntityUsers _getUser(HttpServletRequest req) {
+    HttpSession session = req.getSession(false);
+    return (EntityUsers) session.getAttribute("login.uid");
+  }
+
+  public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+        Entity mediaType = ent.getMediaType();
+        MirMedia mediaHandler;
+
+        ServletContext ctx = MirPropertiesConfiguration.getContext();
+        String fName = ent.getId()+"."+mediaType.getValue("name");
+
+        mediaHandler = MediaHelper.getHandler(mediaType);
+        InputStream in = mediaHandler.getMedia(ent, mediaType);
+
+        res.setContentType(ctx.getMimeType(fName));
+        //important that before calling this res.getWriter was not called first
+        ServletOutputStream out = res.getOutputStream();
+
+        int read ;
+        byte[] buf = new byte[8 * 1024];
+        while((read = in.read(buf)) != -1) {
+          out.write(buf, 0, read);
+        }
+        in.close();
+        out.close();
+      }
+      catch (Throwable e) {
+        throw new ServletModuleFailure(e);
+      }
+    }
+    else logger.error("id not specified.");
+    // no exception allowed
+  }
+
+  public void getIcon(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+  {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+        Entity mediaType = ent.getMediaType();
+        MirMedia mediaHandler;
+
+        ServletContext ctx = MirPropertiesConfiguration.getContext();
+        String fName = ent.getId()+"."+mediaType.getValue("name");
+
+        mediaHandler = MediaHelper.getHandler(mediaType);
+        InputStream in = mediaHandler.getIcon(ent);
+
+        res.setContentType(ctx.getMimeType(fName));
+        //important that before calling this res.getWriter was not called first
+        ServletOutputStream out = res.getOutputStream();
+
+        int read ;
+        byte[] buf = new byte[8 * 1024];
+        while((read = in.read(buf)) != -1) {
+          out.write(buf, 0, read);
+        }
+        in.close();
+        out.close();
+      }
+
+      catch (Throwable e) {
+        throw new ServletModuleFailure(e);
+      }
+    }
+    else logger.error("getIcon: id not specified.");
+    // no exception allowed
+  }
+
+}
+
+
index 56c6e9b..7f26fa0 100755 (executable)
 \r
 package tool;\r
 \r
-import java.util.*;\r
-import java.io.*;\r
-import org.apache.commons.collections.*;\r
-\r
-import mir.util.*;\r
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.Iterator;
+
+import mir.util.ExceptionFunctions;
+import mir.util.PropertiesManipulator;\r
 \r
 public class BundleTool {\r
 \r
index 8837ad0..86d16eb 100755 (executable)
@@ -36,114 +36,106 @@ function openWin(url) {
 </if>
 
 
-<form enctype="multipart/form-data" method="post" action="${config.actionRoot}?module=Audio&do=<if data.new>insert<else>update</if>&id=${data.id}">
-       <if data.articleid>
-               <input type="hidden" name="articleid" value="${data.articleid}">
-       </if>
-       <if data.commentid>
-               <input type="hidden" name="commentid" value="${data.commentid}">
-       </if>
-       <input type="hidden" name="where" value="${data.where}">
-       <input type="hidden" name="offset" value="${data.offset}">
-       <input type="hidden" name="order" value="${data.order}">
-       <input type="hidden" name="id" value="${data.id}">
-
-       <table border="0">
-
-       <if !data.new>
-       <tr>
-       <td align="right" valign="top">
-                       <a href="${config.actionRoot}?module=Audio&do=getMedia&id=${data.id}">
-                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a>&nbsp;&nbsp;
-               </td>
-               <td valign="bottom" class="small">
-                       ${lang("media.created")}: ${data.webdb_create}
-                       <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
-                       <if data.is_published=="1">${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}<br></if>
-                       ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}<br>
-                       ${lang("media.size")}: ${data.human_readable_size}<br>
-                       ${lang("media.rights")}: <b>${data.rightsHashdata[to_rights]["name"]}</b><br>
-               </td>
-       </tr>
-       </if>
-
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.mediafolder")}:</B>
-               </td>
-               <td class="listrow2">
-                       <select name="to_media_folder">
-                       <list extra.mediafolderPopupData as m>
-                               <option value="${m.key}" <if m.key == data.to_media_folder>selected</if>>${m.value}</option>
-                       </list>
-               </select>
-               </td>
-       </tr>
-       
-       <call TextInputTableRow (lang("media.description"), 40, 255, "description", data.description)>
-       <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
-       <call TextInputTableRowLight (lang("year"), 20, 40, "year", data.year)>
-       <call TextInputTableRow (lang("media.location"), 40, 80, "place", data.place)>
-       <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
-       <call TextAreaTableRow (lang("media.keywords"), "", 40, 2, "keywords", data.keywords)>
-       <call TextAreaTableRow (lang("media.comment"), "", 40, 2, "comment", data.comment)>
-       <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
-       
-       <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
-       
-       
-       <if data.new>
-       <tr>
-               <td align="right" class="table-left">
-                       ${lang("media.is_published")} : 
-               </td>
-               <td class="listrow2" style='border: 1px solid #FF0000;'>
-                       <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>> 
-               </td>
-       </tr>
-       <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
-       
-       <list data.mediafields as m>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-                </td>
-               <td class="listrow2">
-                       <input type="text" name="media_title${m}" size="40" maxlength="80" value="">
-               </td>
-       </tr>
-       <tr>
-               <td align="right">
-                       &nbsp;
-               </td>
-               <td class="listrow2">
-                       <INPUT TYPE="file" NAME="mpfile${m}"><br>
-               </td>
-       </tr>
-       </list>
-       <else>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-               </td>
-               <td class="listrow2">
-                       <input type="text" name="title" size="40" maxlength="80" value="${data.title}">
-               </td>
-       </tr>
-       </if>
-
-    <td colspan="2" align="right" class="table-foot">
-       <if data.new>
-      <input type="submit" name="save" value="${lang("insert")}">
-    <else>
-     ${lang("media.is_published")} <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>>
-    &nbsp;&nbsp;<input type="submit" name="save" value="${lang("save")}">
-    </if> </form>
-    </td>
-</table>
-
-<p><a class="link-box" href="${config.actionRoot}?module=Audio&do=list">[&lt;] ${lang("list")} </a> &nbsp;</p>
-
-<include "foot.template">
-</body>
+    <form enctype="multipart/form-data" method="post" action="${config.actionRoot}?module=Audio&do=<if data.new>insert<else>update</if>&id=${data.id}">
+       <if data.articleid>
+               <input type="hidden" name="articleid" value="${data.articleid}">
+       </if>
+       <if data.commentid>
+               <input type="hidden" name="commentid" value="${data.commentid}">
+       </if>
+       <input type="hidden" name="where" value="${data.where}">
+       <input type="hidden" name="offset" value="${data.offset}">
+       <input type="hidden" name="order" value="${data.order}">
+       <input type="hidden" name="id" value="${data.id}">
+    
+      <table border="0">
+    
+        <if !data.new>
+        <tr>
+          <td align="right" valign="top">
+            <a href="${config.actionRoot}?module=Audio&do=getMedia&id=${data.id}">
+            <img src="${config.docRoot}/img/${data.big_icon}" border=0></a>&nbsp;&nbsp;
+               </td>
+               <td valign="bottom" class="small">
+            ${lang("media.created")}: ${data.webdb_create}
+            <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
+            <if data.is_published=="1">${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}<br></if>
+            ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}<br>
+            ${lang("media.size")}: ${data.human_readable_size}<br>
+            ${lang("media.rights")}: <b>${data.rightsHashdata[to_rights]["name"]}</b><br>
+          </td>
+          </tr>
+        </if>
+      
+       <tr>
+               <td align="right" class="table-left">
+                       <b>${lang("media.mediafolder")}:</b>
+               </td>
+               <td class="listrow2">
+                       <select name="to_media_folder">
+                               <list extra.mediafolderPopupData as m>
+                               <option value="${m.key}" <if m.key == data.to_media_folder>selected</if>>${m.value}</option>
+                       </list>
+               </select>
+               </td>
+       </tr>
+       
+          <if !data.new>
+            <call TextInputTableRow (lang("media.title"), 40, 80, "title", data.title)>
+          </if>
+          <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
+          <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
+          <call TextAreaTableRow  (lang("media.description"), "", 40, 2, "description", data.description)>
+          <call TextAreaTableRow  (lang("media.comment"), "", 40, 2, "comment", data.comment)>
+          <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
+       
+          <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
+       
+       
+               <if data.new>
+               <tr>
+                       <td align="right" class="table-left">
+                               ${lang("media.is_published")} : 
+                       </td>
+                       <td class="listrow2" style='border: 1px solid #FF0000;'>
+                               <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>> 
+                       </td>
+               </tr>
+               <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
+               
+               <list data.mediafields as m>
+               <tr>
+                       <td align="right" class="table-left">
+                               <B>${lang("media.title")}:<B>
+                        </td>
+                       <td class="listrow2">
+                               <input type="text" name="media_title${m}" size="40" maxlength="80" value="">
+                       </td>
+               </tr>
+               <tr>
+                       <td align="right">
+                               &nbsp;
+                       </td>
+                       <td class="listrow2">
+                               <input type="file" name="media${m}"><br>
+                       </td>
+               </tr>
+               </list>
+               </if>
+      
+          <td colspan="2" align="right" class="table-foot">
+            <if data.new>
+              <input type="submit" name="save" value="${lang("insert")}">
+            <else>
+              ${lang("media.is_published")} <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>>
+              &nbsp;&nbsp;<input type="submit" name="save" value="${lang("save")}">
+            </if> 
+          </td>
+      </table>
+    </form>
+  
+    <p><a class="link-box" href="${config.actionRoot}?module=Audio&do=list">[&lt;] ${lang("list")} </a> &nbsp;</p>
+  
+    <include "foot.template">
+  </body>
 </html>
index 872fc1e..e4a4060 100755 (executable)
@@ -85,14 +85,14 @@ function openWin(url) {
                </select>
                </td>
        </tr>
-
-       <call TextInputTableRow (lang("media.description"), 40, 255, "description", data.description)>
+       
+       <if !data.new>
+         <call TextInputTableRow (lang("media.title"), 40, 80, "title", data.title)>
+       </if>
        <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
-       <call TextInputTableRowLight (lang("year"), 20, 40, "year", data.year)>
-       <call TextInputTableRow (lang("media.location"), 40, 80, "place", data.place)>
        <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
-       <call TextAreaTableRow (lang("media.keywords"), "", 40, 2, "keywords", data.keywords)>
-       <call TextAreaTableRow (lang("media.comment"), "", 40, 2, "comment", data.comment)>
+       <call TextAreaTableRow  (lang("media.description"), "", 40, 2, "description", data.description)>
+       <call TextAreaTableRow  (lang("media.comment"), "", 40, 2, "comment", data.comment)>
        <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
        
        <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
@@ -123,19 +123,10 @@ function openWin(url) {
                        &nbsp;
                </td>
                <td class="listrow2">
-                       <INPUT TYPE="file" NAME="mpfile${m}"><br>
+                       <input type="file" name="media${m}"><br>
                </td>
        </tr>
        </list>
-       <else>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-               </td>
-               <td class="listrow2">
-                       <input type="text" name="title" size="40" maxlength="80" value="${data.title}">
-               </td>
-       </tr>
        </if>
 
     <td colspan="2" align="right" class="table-foot">
index bcb86c0..897f852 100755 (executable)
@@ -82,14 +82,14 @@ function openWin(url) {
                </td>
        </tr>
 
-       <call TextInputTableRow (lang("media.description"), 40, 255, "description", data.description)>
-       <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
-       <call TextInputTableRowLight (lang("year"), 20, 40, "year", data.year)>
-       <call TextInputTableRow (lang("media.location"), 40, 80, "place", data.place)>
-       <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
-       <call TextAreaTableRow (lang("media.keywords"), "", 40, 2, "keywords", data.keywords)>
-       <call TextAreaTableRow (lang("media.comment"), "", 40, 2, "comment", data.comment)>
-       <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
+        <if !data.new>
+          <call TextInputTableRow (lang("media.title"), 40, 80, "title", data.title)>
+        </if>
+        <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
+        <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
+        <call TextAreaTableRow  (lang("media.description"), "", 40, 2, "description", data.description)>
+        <call TextAreaTableRow  (lang("media.comment"), "", 40, 2, "comment", data.comment)>
+        <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
        
        <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
        
@@ -119,19 +119,10 @@ function openWin(url) {
                        &nbsp;
                </td>
                <td class="listrow2">
-                       <INPUT TYPE="file" NAME="mpfile${m}"><br>
+                       <input type="file" name="media${m}"><br>
                </td>
        </tr>
        </list>
-       <else>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-               </td>
-               <td class="listrow2">
-                       <input type="text" name="title" size="40" maxlength="80" value="${data.title}">
-               </td>
-       </tr>
        </if>
 
     <td colspan="2" align="right" class="table-foot">
index 7728b22..126bdf5 100755 (executable)
@@ -35,116 +35,108 @@ function openWin(url) {
 </if>
 
 
-<form enctype="multipart/form-data" method="post" action="${config.actionRoot}?module=Video&do=<if data.new>insert<else>update</if>&id=${data.id}">
-       <if data.articleid>
-               <input type="hidden" name="articleid" value="${data.articleid}">
-       </if>
-       <if data.commentid>
-               <input type="hidden" name="commentid" value="${data.commentid}">
-       </if>
+    <form enctype="multipart/form-data" method="post" action="${config.actionRoot}?module=Video&do=<if data.new>insert<else>update</if>&id=${data.id}">
+      <if data.articleid>
+        <input type="hidden" name="articleid" value="${data.articleid}">
+      </if>
+      <if data.commentid>
+        <input type="hidden" name="commentid" value="${data.commentid}">
+      </if>
        
-       <input type="hidden" name="where" value="${data.where}">
-       <input type="hidden" name="offset" value="${data.offset}">
-       <input type="hidden" name="order" value="${data.order}">
-       <input type="hidden" name="id" value="${data.id}">
-
-       <table border="0">
-
-       <if !data.new>
-       <tr>
-       <td align="right" valign="top">
-                       <a href="${config.actionRoot}?module=Video&do=getMedia&id=${data.id}">
-                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a>&nbsp;&nbsp;
-               </td>
-               <td valign="bottom" class="small">
-                       ${lang("media.created")}: ${data.webdb_create}
-                       <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
-                       <if data.is_published=="1">${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}<br></if>
-                       ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}<br>
-                       ${lang("media.size")}: ${data.human_readable_size}<br>
-                       ${lang("media.rights")}: <b>${data.rightsHashdata[to_rights]["name"]}</b><br>
-               </td>
-       </tr>
-       </if>
-
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.mediafolder")}:</B>
-               </td>
-               <td class="listrow2">
-                       <select name="to_media_folder">
-                       <list extra.mediafolderPopupData as m>
-                               <option value="${m.key}" <if m.key == data.to_media_folder>selected</if>>${m.value}</option>
-                       </list>
-               </select>
-               </td>
-       </tr>
-
-       <call TextInputTableRow (lang("media.description"), 40, 255, "description", data.description)>
-       <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
-       <call TextInputTableRowLight (lang("year"), 20, 40, "year", data.year)>
-       <call TextInputTableRow (lang("media.location"), 40, 80, "place", data.place)>
-       <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
-       <call TextAreaTableRow (lang("media.keywords"), "", 40, 2, "keywords", data.keywords)>
-       <call TextAreaTableRow (lang("media.comment"), "", 40, 2, "comment", data.comment)>
-       <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
-       
-       <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
-       
-       
-       <if data.new>
-       <tr>
-               <td align="right" class="table-left">
-                       ${lang("media.is_published")} : 
-               </td>
-               <td class="listrow2" style='border: 1px solid #FF0000;'>
-                       <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>> 
-               </td>
-       </tr>
-       <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
-       
-       <list data.mediafields as m>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-                </td>
-               <td class="listrow2">
-                       <input type="text" name="media_title${m}" size="40" maxlength="80" value="">
-               </td>
-       </tr>
-       <tr>
-               <td align="right">
-                       &nbsp;
-               </td>
-               <td class="listrow2">
-                       <INPUT TYPE="file" NAME="mpfile${m}"><br>
-               </td>
-       </tr>
-       </list>
-       <else>
-       <tr>
-               <td align="right" class="table-left">
-                       <B>${lang("media.title")}:<B>
-               </td>
-               <td class="listrow2">
-                       <input type="text" name="title" size="40" maxlength="80" value="${data.title}">
-               </td>
-       </tr>
-       </if>
+      <input type="hidden" name="where" value="${data.where}">
+      <input type="hidden" name="offset" value="${data.offset}">
+      <input type="hidden" name="order" value="${data.order}">
+      <input type="hidden" name="id" value="${data.id}">
 
-    <td colspan="2" align="right" class="table-foot">
-    <if data.new>
-      <input type="submit" name="save" value="${lang("insert")}">
-    <else>
-      ${lang("media.is_published")} <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>>
-      &nbsp;&nbsp;<input type="submit" name="save" value="${lang("save")}">
-    </if> </form>
-    </td>
-</table>
+       <table border="0">
+      
+       <if !data.new>
+       <tr>
+               <td align="right" valign="top">
+                       <a href="${config.actionRoot}?module=Video&do=getMedia&id=${data.id}">
+                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a>&nbsp;&nbsp;
+               </td>
+               <td valign="bottom" class="small">
+                       ${lang("media.created")}: ${data.webdb_create}
+                       <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
+                       <if data.is_published=="1">${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}<br></if>
+                       ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}<br>
+                       ${lang("media.size")}: ${data.human_readable_size}<br>
+                       ${lang("media.rights")}: <b>${data.rightsHashdata[to_rights]["name"]}</b><br>
+               </td>
+               </tr>
+       </if>
+      
+       <tr>
+               <td align="right" class="table-left">
+                       <B>${lang("media.mediafolder")}:</B>
+               </td>
+               <td class="listrow2">
+                       <select name="to_media_folder">
+                               <list extra.mediafolderPopupData as m>
+                               <option value="${m.key}" <if m.key == data.to_media_folder>selected</if>>${m.value}</option>
+                       </list>
+               </select>
+               </td>
+       </tr>
+      
+       <if !data.new>
+         <call TextInputTableRow (lang("media.title"), 40, 80, "title", data.title)>
+       </if>
+       <call TextInputTableRow (lang("media.date"), 8, 8, "date", data.date)>
+       <call TextInputTableRow (lang("media.creator"), 40, 80, "creator", data.creator)>
+       <call TextAreaTableRow  (lang("media.description"), "", 40, 2, "description", data.description)>
+       <call TextAreaTableRow  (lang("media.comment"), "", 40, 2, "comment", data.comment)>
+       <call TextInputTableRow (lang("media.source"), 40, 80, "source", data.source)>
+       
+       <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
+       
+       
+       <if data.new>
+               <tr>
+                       <td align="right" class="table-left">
+                               ${lang("media.is_published")} : 
+                       </td>
+                       <td class="listrow2" style='border: 1px solid #FF0000;'>
+                               <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>> 
+                       </td>
+               </tr>
+               <tr><td colspan="2" class="x-small">&nbsp;</td></tr>
+               
+               <list data.mediafields as m>
+               <tr>
+                       <td align="right" class="table-left">
+                               <B>${lang("media.title")}:<B>
+                        </td>
+                       <td class="listrow2">
+                               <input type="text" name="media_title${m}" size="40" maxlength="80" value="">
+                       </td>
+               </tr>
+               <tr>
+                       <td align="right">
+                               &nbsp;
+                       </td>
+                       <td class="listrow2">
+                               <input type="file" name="media${m}"><br>
+                       </td>
+               </tr>
+               </list>
+       </if>
+      
+        <td colspan="2" align="right" class="table-foot">
+        <if data.new>
+          <input type="submit" name="save" value="${lang("insert")}">
+        <else>
+          ${lang("media.is_published")} <input type="checkbox" name="is_published" value="1"<if data.is_published!="0" && data.is_published!=""> checked</if>>
+          &nbsp;&nbsp;<input type="submit" name="save" value="${lang("save")}">
+        </if> 
+        </td>
+      </table>
+    </form>
 
-<p><a class="link-box" href="${config.actionRoot}?module=Video&do=list">[&lt;] ${lang("list")} </a> &nbsp;</p>
+    <p><a class="link-box" href="${config.actionRoot}?module=Video&do=list">[&lt;] ${lang("list")} </a> &nbsp;</p>
 
-<include "foot.template">
+    <include "foot.template">
 
-</body>
+  </body>
 </html>