Version 2

    Before GateIn 3.2

    • UploadHandler and DownloadHandler extend org.exoplatform.web.command.Command. When we need to make a request to these handlers, we must create an url that points to CommandHandler (/command?...) and passes extra parameter so that CommandHandler can determine with Command object (UploadHandler, DownloadHandler....) which will be created and executed
    • org.exoplatform.upload.UploadService parses the request by itseft, and has a memory leak bug (If user doesn't explicitly delete the uploaded files, we can't remove the temporary uploaded files and the UploadResource objects in the cache)

    GateIn 3.2 Upload & Download handler improvements

    Solution

    • Make UploadHandler and DownloadHandler sub-class of WebRequestHandler bound under "/upload" and "/download" pathes
    • Use commons fileupload for reimplementing the UploadHandler
    • Remove CommandHandler that is useless

    Details

    • UploadHandler and DownloadHandler extend org.exoplatform.web.WebRequestHandler. Now we could create request with url point to these Handlers and we don't need Command and CommandHandler any more.
    • org.exoplatform.upload.UploadService now uses commons-apache fileupload library to parse the upload file request, and the memory leak bug is resolved

    Changes needed to use the new Handlers and the new UploadService

    • org.exoplatform.upload.UploadService :
      • We keep old method createUploadResource(HttpServletRequest request) . You can use this method without changing anything. The use of commons-apache inside the new UploadService is transparent
      • We've removed useless method createUploadResource(String uploadId, String encoding, String contentType,double contentLength, InputStream inputStream). We don't see any case that we'll need to use that method
      • Method removeUpload(String uploadId) is deprecated, you should use removeUploadResource(String uploadId) instead
    • To make request to UploadHandler/DownloadHandler you should make url that points to these Handlers, for example : /portal/upload?uploadId=20993057&action=upload . So , our Handlers now are WebRequestHandler instance, to make it works, you must replace :

    /gatein/web/portal/src/main/webapp/WEB-INF/web.xml

     

    ....
        <servlet-mapping>
          <servlet-name>portal</servlet-name>
          <url-pattern>/command/*</url-pattern>
        </servlet-mapping>
    .....

    ....


        <servlet-mapping>

          <servlet-name>portal</servlet-name>

          <url-pattern>/command/*</url-pattern>

        </servlet-mapping>


    .....

     

    with

     

    ....


        <servlet-mapping>

          <servlet-name>portal</servlet-name>

          <url-pattern>/upload/*</url-pattern>

        </servlet-mapping>

        <servlet-mapping>

          <servlet-name>portal</servlet-name>

          <url-pattern>/download/*</url-pattern>

        </servlet-mapping>


    ....

    You should do the same with sample portal project  /gatein/examples/portal/war/src/main/webapp/WEB-INF/web.xml