Mercurial > hg > digilib-old
changeset 555:88ed97d08b97 digilibPDF
still refactoring
author | robcast |
---|---|
date | Thu, 16 Dec 2010 14:31:48 +0100 |
parents | 1d5609ae2335 |
children | 5cc180bb0a5c |
files | servlet/src/digilib/servlet/ImageJobDescription.java servlet/src/digilib/servlet/PDFCache.java servlet/src/digilib/servlet/PDFFileWorker.java servlet/src/digilib/servlet/PDFJobDescription.java servlet/src/digilib/servlet/ParameterMap.java |
diffstat | 5 files changed, 49 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/digilib/servlet/ImageJobDescription.java Thu Dec 16 11:40:54 2010 +0100 +++ b/servlet/src/digilib/servlet/ImageJobDescription.java Thu Dec 16 14:31:48 2010 +0100 @@ -31,10 +31,6 @@ public class ImageJobDescription extends ParameterMap { - String[] parameter_list = {"fn","pn","dw","dh", - "wx", "wy", "ww", "wh", "ws", - "mo", "rot", "cont", "brgt", "rgbm", "rbgm", - "ddpi", "ddpix", "ddpiy", "scale"}; DigilibConfiguration dlConfig = null; protected static Logger logger = Logger.getLogger("digilib.servlet"); @@ -175,10 +171,10 @@ } public DocuDirectory getFileDirectory() throws FileOpException{ - if(fileDir==null){ + if(fileDir == null){ DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); - - fileDir = dirCache.getDirectory(getFilePath()); + String fp = getFilePath(); + fileDir = dirCache.getDirectory(fp); if (fileDir == null) { throw new FileOpException("Directory " + getFilePath() + " not found."); }
--- a/servlet/src/digilib/servlet/PDFCache.java Thu Dec 16 11:40:54 2010 +0100 +++ b/servlet/src/digilib/servlet/PDFCache.java Thu Dec 16 14:31:48 2010 +0100 @@ -122,10 +122,12 @@ public void processRequest(HttpServletRequest request, HttpServletResponse response) { + String docid = ""; + try { // evaluate request ( make a PDFJobDeclaration , get the DocumentId) PDFJobDescription pdfji = new PDFJobDescription(request, dlConfig); - String docid = pdfji.getDocumentId(); + docid = pdfji.getDocumentId(); // if some invalid data has been entered ... if(!pdfji.checkValidity()) { @@ -157,6 +159,11 @@ // should be work in progress notifyUser(status, docid, request, response); } + } catch (Exception e) { + // error in pdf creation + logger.error(e.getMessage()); + notifyUser(STATUS_ERROR, docid, request, response); + } } /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servlet/src/digilib/servlet/PDFFileWorker.java Thu Dec 16 14:31:48 2010 +0100 @@ -0,0 +1,23 @@ +/** + * + */ +package digilib.servlet; + +import java.io.File; +import java.util.concurrent.Callable; + +/** + * @author casties + * + */ +public class PDFFileWorker implements Callable<File> { + protected PDFStreamWorker streamWorker; + + @Override + public File call() throws Exception { + // TODO Auto-generated method stub + return null; + } + + +}
--- a/servlet/src/digilib/servlet/PDFJobDescription.java Thu Dec 16 11:40:54 2010 +0100 +++ b/servlet/src/digilib/servlet/PDFJobDescription.java Thu Dec 16 14:31:48 2010 +0100 @@ -8,6 +8,7 @@ import org.apache.log4j.Logger; import digilib.io.DocuDirectory; +import digilib.io.FileOpException; import digilib.io.FileOps; @@ -43,8 +44,9 @@ * * @param dlcfg The DigilibConfiguration. * @param request + * @throws FileOpException */ - public PDFJobDescription(HttpServletRequest request, DigilibConfiguration dlcfg) { + public PDFJobDescription(HttpServletRequest request, DigilibConfiguration dlcfg) throws FileOpException { super(30); dlConfig = dlcfg; this.setWithRequest(request); @@ -59,35 +61,33 @@ // width of client in pixels newParameter("dw", new Integer(0), null, 's'); // height of client in pixels - newParameter("dh", new Integer(0), null, 's'); + newParameter("dh", new Integer(500), null, 's'); } /** - * Read in the request object. + * Read the request object. * * @param request + * @throws FileOpException */ - public void setWithRequest(HttpServletRequest request) { + public void setWithRequest(HttpServletRequest request) throws FileOpException { + // read matching request parameters for the parameters in this map for (String k : params.keySet()) { if (request.getParameterMap().containsKey(k)) { setValueFromString(k, request.getParameter(k)); } } // process parameters - try { - pages = new NumRange(getAsString("pgs")); - ImageJobDescription ij = ImageJobDescription.setFrom(this, dlConfig); - DocuDirectory dir = ij.getFileDirectory(); - int dirsize = dir.size(FileOps.CLASS_IMAGE); - pages.setMaxnum(dirsize); - } catch (Exception e) { - logger.warn("Problem with parsing page numbers: "+e.toString()); - } + pages = new NumRange(getAsString("pgs")); + ImageJobDescription ij = ImageJobDescription.setFrom(this, dlConfig); + DocuDirectory dir = ij.getFileDirectory(); + int dirsize = dir.size(FileOps.CLASS_IMAGE); + pages.setMaxnum(dirsize); } /** - * Generate the filename of the pdf to be created. + * Generate a filename for the pdf to be created. * * @return */
--- a/servlet/src/digilib/servlet/ParameterMap.java Thu Dec 16 11:40:54 2010 +0100 +++ b/servlet/src/digilib/servlet/ParameterMap.java Thu Dec 16 14:31:48 2010 +0100 @@ -128,7 +128,7 @@ */ public String getAsString(String key) { Parameter p = params.get(key); - return (p != null) ? p.getAsString() : null; + return (p != null) ? p.getAsString() : ""; } /** Get the Parameter with the corresponding key.