Class VFSServlet

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class VFSServlet
    extends javax.servlet.http.HttpServlet
    implements following REST API to upload binary data using file streaming API of apache commons-fileupload, see http://commons.apache.org/proper/commons-fileupload/streaming.html accepting POST for INSERT/UPDATE streams and DELETE for deleting them configuration (via servlet parameter): folder-name: abstract name which is used as prefix for all incoming file-names, read documentation on doPost(HttpServletRequest, HttpServletResponse) and doDelete(HttpServletRequest, HttpServletResponse) for more information and exception handling.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  VFSServlet.FileDAO
      abstraction to write into VFS, client has finally to call VFSServlet.FileDAO.commit()
      static class  VFSServlet.JdbcFileDAO
      unfortunately we cant work with DatabaseFileSystem / DatabaseFileObject directly to store data, so we do here lowlevel BLOB handling, works with bcd_virtualFileSystem binding-set NOT THREADSAFE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.logging.log4j.Logger logger  
    • Constructor Summary

      Constructors 
      Constructor Description
      VFSServlet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected VFSServlet.FileDAO createFileDao​(javax.servlet.http.HttpServletRequest req)
      create a DAO implementation for current request, default is VFSServlet.JdbcFileDAO
      protected void doDelete​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      TODO API: pathInfo contains identifier (path) to delete delimited via space not implemented yet
      protected void doPost​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      supports multipart encoded data, multifile is NOT supported as the field-name is taken as uri (path), you may want to throw custom exception to process on client, you may do it throwing PostException from here or one subprocessing method
      void init​(javax.servlet.ServletConfig config)
      read configs here
      protected void processFieldItem​(org.apache.commons.fileupload.FileItemStream item, VFSServlet.FileDAO fileDao)
      processes field item (non-file), default implementation ignores it
      • Methods inherited from class javax.servlet.http.HttpServlet

        doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected org.apache.logging.log4j.Logger logger
    • Constructor Detail

      • VFSServlet

        public VFSServlet()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletConfig config)
                  throws javax.servlet.ServletException
        read configs here
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
        Parameters:
        config -
        Throws:
        javax.servlet.ServletException
      • doDelete

        protected void doDelete​(javax.servlet.http.HttpServletRequest req,
                                javax.servlet.http.HttpServletResponse resp)
                         throws javax.servlet.ServletException,
                                java.io.IOException
        TODO API: pathInfo contains identifier (path) to delete delimited via space not implemented yet
        Overrides:
        doDelete in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse resp)
                       throws javax.servlet.ServletException,
                              java.io.IOException
        supports multipart encoded data, multifile is NOT supported as the field-name is taken as uri (path), you may want to throw custom exception to process on client, you may do it throwing PostException from here or one subprocessing method
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • createFileDao

        protected VFSServlet.FileDAO createFileDao​(javax.servlet.http.HttpServletRequest req)
                                            throws java.lang.Exception
        create a DAO implementation for current request, default is VFSServlet.JdbcFileDAO
        Parameters:
        req -
        Returns:
        Throws:
        java.lang.Exception
      • processFieldItem

        protected void processFieldItem​(org.apache.commons.fileupload.FileItemStream item,
                                        VFSServlet.FileDAO fileDao)
        processes field item (non-file), default implementation ignores it
        Parameters:
        item -
        fileDao -