| 1 37 package org.webharvest.runtime.processors; 38 39 import org.webharvest.definition.CallParamDef; 40 import org.webharvest.exception.HttpException; 41 import org.webharvest.runtime.Scraper; 42 import org.webharvest.runtime.ScraperContext; 43 import org.webharvest.runtime.templaters.BaseTemplater; 44 import org.webharvest.runtime.variables.IVariable; 45 46 49 public class CallParamProcessor extends BaseProcessor { 50 51 private CallParamDef callParamDef; 52 53 public CallParamProcessor(CallParamDef callParamDef) { 54 super(callParamDef); 55 56 this.callParamDef = callParamDef; 57 } 58 59 public IVariable execute(Scraper scraper, ScraperContext context) { 60 String name = BaseTemplater.execute( callParamDef.getName(), scraper.getScriptEngine() ); 61 IVariable variable = getBodyListContent(callParamDef, scraper, context); 62 63 CallProcessor callProcessor = scraper.getRunningFunction(); 64 if (callProcessor != null) { 65 callProcessor.addContextVariable(name, variable); 66 } else { 67 throw new HttpException("Usage of call-param processor is not allowed outside of call processor!"); 68 } 69 70 return variable; 71 } 72 73 } | Popular Tags |