1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.cocoon.components.pipeline.ProcessingPipeline; 19 import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; 20 import org.apache.cocoon.components.treeprocessor.InvokeContext; 21 import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; 22 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; 23 import org.apache.cocoon.environment.Environment; 24 25 import java.util.Map ; 26 27 32 33 public class ReadNode extends AbstractProcessingNode implements ParameterizableProcessingNode { 34 35 private String readerName; 36 37 private VariableResolver source; 38 39 private VariableResolver mimeType; 40 41 private int statusCode; 42 43 private Map parameters; 44 45 52 public ReadNode(String name, VariableResolver source, VariableResolver mimeType, int statusCode) { 53 this.readerName = name; 54 this.source = source; 55 this.mimeType = mimeType; 56 this.statusCode = statusCode; 57 } 58 59 public void setParameters(Map parameterMap) { 60 this.parameters = parameterMap; 61 } 62 63 public final boolean invoke(Environment env, InvokeContext context) 64 throws Exception { 65 66 Map objectModel = env.getObjectModel(); 67 68 ProcessingPipeline pipeline = context.getProcessingPipeline(); 69 70 pipeline.setReader( 71 this.readerName, 72 source.resolve(context, objectModel), 73 VariableResolver.buildParameters(this.parameters, context, objectModel), 74 this.mimeType.resolve(context, objectModel) 75 ); 76 77 if (this.statusCode >= 0) { 79 env.setStatus(this.statusCode); 80 } 81 82 if (! context.isBuildingPipelineOnly()) { 83 return pipeline.process(env); 85 86 } else { 87 return true; 89 } 90 } 91 } 92 | Popular Tags |