Changeset 3714 for print

Show
Ignore:
Timestamp:
12/21/10 11:49:23 (17 months ago)
Author:
jeichar
Message:

allow temp dir to be overriden in the web.xml r=elemoine closes #537

Location:
print/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • print/trunk/docs/installation.txt

    r3675 r3714  
    1531533. Add a config.yaml file (from the `samples <https://trac.mapfish.org/trac/mapfish/browser/print/trunk/samples>`_, for example) to the root of your web application.  
    154154 
     155Configuring Servlet Temp Directory 
     156++++++++++++++++++++++++++++++++++ 
     157By default the default servlet temporary directory will be used but that behaviour can be overridden setting the init-param *tempdir*.  If this parameter is set the servlet must have write access to the directory. 
     158 
    155159Ruby on rails 
    156 ++++++++++++++ 
     160~~~~~~~~~~~~~ 
    157161 
    158162TODO write the doc. 
    159163 
    160164Command line 
    161 +++++++++++++ 
     165~~~~~~~~~~~~ 
    162166 
    163167For debugging or calling from other environments, you can run the print module from the command line. 
  • print/trunk/src/main/java/org/mapfish/print/servlet/MapPrinterServlet.java

    r3650 r3714  
    4545public class MapPrinterServlet extends BaseMapServlet { 
    4646    private static final long serialVersionUID = -4706371598927161642L; 
    47      
     47    private static final String CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; 
     48 
    4849    private static final String INFO_URL = "/info.json"; 
    4950    private static final String PRINT_URL = "/print.pdf"; 
     
    364365    protected File getTempDir() { 
    365366        if (tempDir == null) { 
    366             tempDir = new File((File) getServletContext(). 
    367                     getAttribute("javax.servlet.context.tempdir"), "mapfish-print"); 
    368             tempDir.mkdirs(); 
     367            String tempDirPath = getInitParameter("tempdir"); 
     368            if (tempDirPath != null) { 
     369                tempDir = new File(tempDirPath); 
     370            } else { 
     371                tempDir = (File) getServletContext().getAttribute(CONTEXT_TEMPDIR); 
     372            } 
     373            if (!tempDir.exists() && !tempDir.mkdirs()) { 
     374                throw new RuntimeException("unable to create dir:" + tempDir); 
     375            } 
     376 
    369377        } 
    370378        LOGGER.debug("Using '" + tempDir.getAbsolutePath() + "' as temporary directory");