1 16 package org.apache.cocoon.environment.commandline; 17 18 import org.apache.avalon.framework.logger.Logger; 19 20 import org.apache.cocoon.Constants; 21 import org.apache.cocoon.environment.ObjectModelHelper; 22 23 import java.io.File ; 24 import java.io.OutputStream ; 25 import java.net.MalformedURLException ; 26 import java.util.Map ; 27 import java.util.List ; 28 29 36 public class FileSavingEnvironment extends AbstractCommandLineEnvironment { 37 38 protected boolean modified = true; 39 protected long sourceLastModified = 0L; 40 41 public FileSavingEnvironment(String uri, 42 long lastModified, 43 File context, 44 Map attributes, 45 Map parameters, 46 Map links, 47 List gatheredLinks, 48 CommandLineContext cliContext, 49 OutputStream stream, 50 Logger log) 51 throws MalformedURLException { 52 super(uri, null, context, stream, log); 53 this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, 54 new CommandLineRequest(this, null, uri, null, attributes, parameters)); 55 this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, 56 new CommandLineResponse()); 57 this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, 58 cliContext); 59 this.sourceLastModified = lastModified; 60 if (links != null) { 61 this.objectModel.put(Constants.LINK_OBJECT, links); 62 } 63 if (gatheredLinks != null) { 64 this.objectModel.put(Constants.LINK_COLLECTION_OBJECT, gatheredLinks); 65 } 66 } 67 68 public FileSavingEnvironment(String uri, 69 File context, 70 Map attributes, 71 Map parameters, 72 Map links, 73 List gatheredLinks, 74 CommandLineContext cliContext, 75 OutputStream stream, 76 Logger log) 77 throws MalformedURLException { 78 this(uri, 0L, context, attributes, parameters, links, gatheredLinks, cliContext, stream, log); 79 } 80 81 89 public boolean isResponseModified(long cacheLastModified) { 90 if (cacheLastModified != 0) { 91 return cacheLastModified / 1000 > sourceLastModified / 1000; 92 } 93 return true; 94 } 95 96 99 public void setResponseIsNotModified() { 100 this.modified = false; 101 } 102 103 public boolean isModified() { 104 return this.modified; 105 } 106 } 107 | Popular Tags |