Package digilib.servlet
Class PDFGenerator
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- digilib.servlet.PDFGenerator
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
@WebServlet(name="PDFGenerator", urlPatterns={"/PDFGenerator/*","/PDFCache/*","/servlet/PDFCache/*"}) public class PDFGenerator extends javax.servlet.http.HttpServlet
A class for handling user requests for pdf documents made from digilib images. If a document does not already exist, it will be enqueued for generation; if it does exist, it is sent to the user.- Author:
- cmielack, casties
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PDFGenerator.PDFStatus
Document status.
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
accountlog
logger for accounting requestsprotected static org.slf4j.Logger
authlog
logger for authentication relatedstatic String
ERROR_PAGE_KEY
static String
INSTANCE_KEY
static String
IOERROR_PAGE_KEY
protected static org.slf4j.Logger
logger
gengeral logger for this classstatic String
version
static String
WIP_PAGE_KEY
-
Constructor Summary
Constructors Constructor Description PDFGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Future<File>
createNewPdfDocument(PDFRequest pdfji, String filename)
create new thread for pdf generation.String
decodeDocid(String encid)
void
doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
void
doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
String
encodeDocid(String docid)
File
getCacheDirectory()
File
getCacheFile(String filename)
returns a File object based on filename in the cache directory.String
getDownloadFilename(PDFRequest pdfji)
generate the filename the user is going to receive the pdf asString
getDownloadFilename(String docid)
generate the filename the user is going to receive the pdf asPDFGenerator.PDFStatus
getStatus(String documentid)
check the status of the document corresponding to the documentidFile
getTempDirectory()
File
getTempFile(String filename)
returns a File object based on filename in the temp directory.void
init(javax.servlet.ServletConfig config)
void
notifyUser(PDFGenerator.PDFStatus status, String documentid, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
depending on the documents status, redirect the user to the appropriate waiting or download page.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
version
public static String version
-
accountlog
protected static org.slf4j.Logger accountlog
logger for accounting requests
-
logger
protected static org.slf4j.Logger logger
gengeral logger for this class
-
authlog
protected static org.slf4j.Logger authlog
logger for authentication related
-
INSTANCE_KEY
public static final String INSTANCE_KEY
- See Also:
- Constant Field Values
-
WIP_PAGE_KEY
public static final String WIP_PAGE_KEY
- See Also:
- Constant Field Values
-
ERROR_PAGE_KEY
public static final String ERROR_PAGE_KEY
- See Also:
- Constant Field Values
-
IOERROR_PAGE_KEY
public static final String IOERROR_PAGE_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
-
notifyUser
public void notifyUser(PDFGenerator.PDFStatus status, String documentid, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
depending on the documents status, redirect the user to the appropriate waiting or download page.- Parameters:
status
-documentid
-request
-response
-
-
getStatus
public PDFGenerator.PDFStatus getStatus(String documentid)
check the status of the document corresponding to the documentid
-
createNewPdfDocument
public Future<File> createNewPdfDocument(PDFRequest pdfji, String filename) throws FileNotFoundException
create new thread for pdf generation.- Parameters:
pdfji
-filename
-- Returns:
- Throws:
FileNotFoundException
-
getDownloadFilename
public String getDownloadFilename(PDFRequest pdfji)
generate the filename the user is going to receive the pdf as- Parameters:
pdfji
-- Returns:
-
getDownloadFilename
public String getDownloadFilename(String docid)
generate the filename the user is going to receive the pdf as- Parameters:
docid
-- Returns:
-
getCacheDirectory
public File getCacheDirectory()
-
getTempDirectory
public File getTempDirectory()
-
getTempFile
public File getTempFile(String filename)
returns a File object based on filename in the temp directory.- Parameters:
filename
-- Returns:
-
getCacheFile
public File getCacheFile(String filename)
returns a File object based on filename in the cache directory.- Parameters:
filename
-- Returns:
-
-