Converted media Interface to use streams (Java IO) instead of byte buffers of
[mir.git] / source / mircoders / servlet / ServletModuleOpenIndy.java
index f7fb134..f7fddf0 100755 (executable)
@@ -73,9 +73,23 @@ import mircoders.media.MediaRequest;
  *    open-postings to the newswire
  *
  * @author $Author: mh $
- * @version $Revision: 1.38.2.1 $ $Date: 2002/09/01 21:31:44 $
+ * @version $Revision: 1.38.2.2 $ $Date: 2002/11/01 05:38:21 $
  *
  * $Log: ServletModuleOpenIndy.java,v $
+ * Revision 1.38.2.2  2002/11/01 05:38:21  mh
+ * Converted media Interface to use streams (Java IO) instead of byte buffers of
+ * the entire uplaoded files. These saves loads of unecessary memory use. JAI
+ * still consumes quite a bit though.
+ *
+ * A new temporary file (for JAI) parameter is necessary and is in the config.properties file.
+ *
+ * A nice side effect of this work is the FileHandler interface which is
+ * basically a call back mechanism for WebdbMultipartRequest which allows the
+ * uploaded file to handled by different classes. For example, for a media
+ * upload, the content-type, etc.. needs to be determined, but if say the
+ * FileEditor had a feature to upload static files... another handler wood be
+ * needed. Right now only the MediaRequest handler exists.
+ *
  * Revision 1.38.2.1  2002/09/01 21:31:44  mh
  * Mir goes GPL
  *
@@ -285,13 +299,15 @@ public class ServletModuleOpenIndy extends ServletModule
                boolean setTopic = false;
 
     try {
-      WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
 
+      WebdbMultipartRequest mp = null;
       EntityList mediaList = null;
       try {
         // new MediaRequest, "1" is the id for the openPosting user
-        mediaList = new MediaRequest(mp, "1").getMedia(true, true);
-      } catch (MirMediaUserException e) {
+        MediaRequest mediaReq = new MediaRequest("1", true, true);
+        mp = new WebdbMultipartRequest(req, (FileHandler)mediaReq);
+        mediaList = mediaReq.getEntityList();
+      } catch (FileHandlerUserException e) {
         throw new ServletModuleUserException(e.getMsg());
       }
           
@@ -396,7 +412,7 @@ public class ServletModuleOpenIndy extends ServletModule
       theLog.printDebugInfo("rsync: "+exitValue);
 
     }
-    catch (MirMediaException e) { throw new ServletModuleException("MediaException: "+ e.toString());}
+    catch (FileHandlerException e) { throw new ServletModuleException("MediaException: "+ e.toString());}
     catch (IOException e) { throw new ServletModuleException("IOException: "+ e.toString());}
     catch (StorageObjectException e) { throw new ServletModuleException("StorageObjectException" + e.toString());}
     catch (ModuleException e) { throw new ServletModuleException("ModuleException"+e.toString());}