Package de.businesscode.bcdui.vfs.web
Class VFSServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- de.businesscode.bcdui.vfs.web.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 ondoPost(HttpServletRequest, HttpServletResponse)
anddoDelete(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 callVFSServlet.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 isVFSServlet.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 yetprotected 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 throwingPostException
from here or one subprocessing methodvoid
init(javax.servlet.ServletConfig config)
read configs hereprotected 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
-
-
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
read configs here- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classjavax.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 classjavax.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 throwingPostException
from here or one subprocessing method- Overrides:
doPost
in classjavax.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 isVFSServlet.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
-
-
-