Changeset 3827

Show
Ignore:
Timestamp:
06/30/11 04:29:38 (11 months ago)
Author:
theuer
Message:

p=theuer r=theuer (closes #640) (closes #641) Changed config files back and deleted .gitignore
Implemented new feature that you can have Java Simple Date Format strings in filename as in ${now} etc.

Location:
print/trunk
Files:
1 removed
6 modified

Legend:

Unmodified
Added
Removed
  • print/trunk

    • Property svn:ignore
      •  

        old new  
         1.gitignore 
         2.gradle 
         3build 
        14target 
        2 build 
        3 .gradle 
  • print/trunk/src/main/java/org/mapfish/print/PDFUtils.java

    r3826 r3827  
    266266 
    267267    private static final Pattern FORMAT_PATTERN = Pattern.compile("^format\\s+(%[-+# 0,(]*\\d*(\\.\\d*)?(d))\\s+(.*)$"); 
     268     
     269    public static String getValueFromString(String val) { 
     270        String str = val; 
     271        while (true) { 
     272            Matcher matcher = VAR_REGEXP.matcher(val); 
     273            if (matcher.find()) { 
     274                str = val.substring(0, matcher.start()); 
     275                final String varName = matcher.group(1); // varName == key 
     276                str += getDateValue(varName); 
     277                val = val.substring(matcher.end()); 
     278            } else { 
     279                break; 
     280            } 
     281        } 
     282        return str; 
     283    } 
     284     
     285    private static String getDateValue(String key) { 
     286        String val = ""; 
     287        if (key.equals("now")) { 
     288            val = new Date().toString(); 
     289        } else if (key.startsWith("now ")) { 
     290            val = formatTime(key); 
     291        } 
     292        return val; 
     293    } 
    268294 
    269295    private static String getContextValue(RenderingContext context, PJsonObject params, String key) { 
     
    332358            return new Date().toString(); 
    333359        } 
     360    } 
     361     
     362    private static String formatTime(String key) throws IllegalArgumentException { 
     363        SimpleDateFormat format = new SimpleDateFormat(key.substring(4)); 
     364        return format.format(new Date()); 
    334365    } 
    335366 
  • print/trunk/src/main/java/org/mapfish/print/config/Config.java

    r3826 r3827  
    3232import org.json.JSONWriter; 
    3333import org.mapfish.print.InvalidValueException; 
     34import org.mapfish.print.PDFUtils; 
    3435import org.mapfish.print.config.layout.Layout; 
    3536import org.mapfish.print.config.layout.Layouts; 
     
    395396        String name = null; 
    396397        if(layout != null) { 
    397             name = layout.getOutputFilename(); 
    398         } 
    399  
     398            name = PDFUtils.getValueFromString(layout.getOutputFilename()); // get the string if it has ${now} or ${now DATEFORMAT} in it 
     399        } 
    400400        return name == null ? outputFilename : name; 
    401401    } 
  • print/trunk/src/main/java/org/mapfish/print/config/layout/Layouts.java

    r3789 r3827  
    2929 */ 
    3030public class Layouts extends HashMap<String, Layout> { 
    31     public static class Wrapper extends DefaultMapWrapper { 
     31    /** 
     32         *  
     33         */ 
     34        private static final long serialVersionUID = 1L; 
     35 
     36        public static class Wrapper extends DefaultMapWrapper { 
    3237        public Wrapper(Class<Layout> type) { 
    3338            super(type); 
  • print/trunk/src/main/webapp/WEB-INF/web.xml

    r3826 r3827  
    99    <init-param> 
    1010      <param-name>config</param-name> 
    11       <param-value>configVector.yaml</param-value> 
     11      <param-value>config.yaml</param-value> 
    1212    </init-param> 
    1313  </servlet> 
  • print/trunk/src/main/webapp/config.yaml

    r3826 r3827  
    4545    host: demo.mapfish.org 
    4646    port: 80 
    47   - !dnsMatch 
    48     host: basemap-web.zen.landcareresearch.co.nz 
    49     port: 80 
    5047 
    5148# the default fileName for the files downloaded from the servlet