}
public Map act(Redirector redirector, SourceResolver resolver,
Map objectModel, String source, Parameters parameters)
throws Exception {
Response response = ObjectModelHelper.getResponse(objectModel);
Calendar calendar = Calendar.getInstance(DateUtils.UTC_TIME_ZONE);
Map values = new HashMap(3);
/* Get the current time and output as the last modified header */
String value = this.formatter.format(calendar);
long maxage = calendar.getTime().getTime();
response.setHeader("Last-Modified", value);
values.put("last-modified", value);
/* Advance the time as much as required */
calendar.add(Calendar.DATE, this.days);
calendar.add(Calendar.HOUR, this.hours);
calendar.add(Calendar.MINUTE, this.minutes);
calendar.add(Calendar.SECOND, this.seconds);
/* Recalculate time and age to see what changed */
maxage = calendar.getTime().getTime() - maxage;
/* If we got more than one second everything is quite normal */
if (maxage > 1000) {
value = this.formatter.format(calendar);
response.setHeader("Expires", value);
values.put("expires", value);
value = "max-age=" + Long.toString(maxage / 1000l);
response.setHeader("Cache-Control", value);
values.put("cache-control", value);
/* If we got less than one second (even negatives) no cache */
} else {
/* We still hold the old value from Last-Modified here */
response.setHeader("Expires", value);
values.put("expires", value);
response.setHeader("Cache-Control", "no-cache");
values.put("cache-control", "no-cache");
}
/* Return the headers */
return(Collections.unmodifiableMap(values));