Class FileServingServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet
-
- edu.cornell.mannlib.vitro.webapp.filestorage.serving.FileServingServlet
-
- All Implemented Interfaces:
MultipartRequestWrapper.ParsingStrategy,Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
@WebServlet(name="serveFiles", urlPatterns="/file/*") public class FileServingServlet extends VitroHttpServletHandles a request to serve an uploaded file from the file storage system.
The path of the request should be the "alias URL" of the desired file. We need to:
- Use the alias URL to find the URI of the file bytestream object.
- Find the file surrogate object to get the MIME type of the file, and confirm the filename.
- Set the MIME type on the output stream and serve the bytes.
If the request is superficially correct, but no such file can be found, return a 404. If there is a break in the data structures within the model or the file system, return a 500.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet
VitroHttpServlet.PickListSorter
-
-
Field Summary
-
Fields inherited from class edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet
HTML_MIMETYPE, JSON_LD_MIMETYPE, JSON_MIMETYPE, N3_MIMETYPE, publicDateFormat, RDFXML_MIMETYPE, TTL_MIMETYPE, XHTML_MIMETYPE
-
-
Constructor Summary
Constructors Constructor Description FileServingServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoGet(javax.servlet.http.HttpServletRequest rawRequest, javax.servlet.http.HttpServletResponse response)doGet does nothing.protected voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)A POST request is treated the same as a GET request.voidinit()Get a reference to the File Storage system.-
Methods inherited from class edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet
dumpRequestParameters, isAuthorizedToDisplayPage, maximumMultipartFileSize, redirectToInsufficientAuthorizationPage, redirectToLoginPage, redirectUnauthorizedRequest, service, sortForPickList, stashFileSizeException
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
-
-
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletExceptionGet a reference to the File Storage system.- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest rawRequest, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOExceptionDescription copied from class:VitroHttpServletdoGet does nothing.- Overrides:
doGetin classVitroHttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOExceptionA POST request is treated the same as a GET request.- Overrides:
doPostin classVitroHttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
-