Beispiel #1
0
  // Velocity init
  public static void initVelocity() {
    if (velocityCatch == null) {
      System.out.println("init VM");
      velocityCatch = new Object();

      Properties props = new Properties();
      props.setProperty("input.encoding", "UTF-8");
      props.setProperty("output.encoding", "UTF-8");

      if (getConfig().getChild("vmtemplatepath") != null) {
        props.setProperty("file.resource.loader.path", getConfig().getChildText("vmtemplatepath"));
      }
      if (System.getProperty("vmtemplatepath") != null) {
        props.setProperty("file.resource.loader.path", System.getProperty("vmtemplatepath"));
        // Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
        // System.getProperty("vmtemplatepath"));//oder new FIle()?
      }
      System.out.println("vmtemplatepath=" + props.getProperty("vmtemplatepath"));
      try {
        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, VeloLog.getInstance());
        Velocity.init(props);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
Beispiel #2
0
  /**
   * @param va
   * @param fw
   * @throws Exception
   * @throws IOException
   */
  public void generate(VelocityAction va, Writer fw) throws Exception, IOException {
    Assert.isNotNull(va.getContext(), "velocity context must be given");
    Assert.isNotNull(va.getTemplatePath(), "velocity template must be given");

    // get Template
    VelocityContext context = va.getContext();
    String templatePath = va.getTemplatePath();
    InputStream template = null;
    File templateFile = new File(templatePath);
    if (templateFile.exists()) {
      // the template is located on File System
      template = new FileInputStream(templateFile);
    } else {
      // resource may be acceded in classPath
      template = getClass().getResourceAsStream(templatePath);
    }

    Assert.isNotNull(template, "velocity template resource can't be loaded");
    // execute
    Velocity.init();
    String s = IOUtils.toString(template);
    Velocity.evaluate(context, fw, "log", s);

    // close streams
    template.close();
    fw.flush();
    fw.close();
  }
  public String createEmailTemplate(MemberDocumentTempInfo membershipInfo) throws Exception {

    String html = "";

    // configure velocity engine
    Properties p = new Properties();
    p.setProperty("file.resource.loader.path", IMUtil.TEMP_DIR);
    p.setProperty("file.resource.loader.path", IMUtil.TEMP_DIR);
    Velocity.init(p);

    // create temp file
    tempFile = new File(IMUtil.TEMP_DIR + File.separator + TEMPLATE_FILE_NAME);
    FileCopyUtils.copy(contentFields.getBytes(), tempFile);

    // create template and fill it
    VelocityContext context = new VelocityContext();
    context.put("membershipInfo", membershipInfo);
    context.put("user", receiver);

    String language = "fa";
    if (language == "fa") context.put("language", "fa");
    else context.put("language", "en");
    Template template = null;
    template = Velocity.getTemplate(tempFile.getName(), "UTF-8");
    StringWriter sw = new StringWriter();
    template.merge(context, sw);
    html = sw.toString();
    return html;
  }
  /**
   * Creates the REST API documentation in HTML form, using the controllers' data and the velocity
   * template.
   *
   * @param controllers .
   * @return string that contains the documentation in HTML form.
   * @throws Exception .
   */
  public String generateHtmlDocumentation(final List<DocController> controllers) throws Exception {

    logger.log(
        Level.INFO,
        "Generate velocity using template: "
            + velocityTemplatePath
            + (isUserDefineTemplatePath
                ? File.separator + velocityTemplateFileName + " (got template path from user)"
                : "(default template path)"));

    Properties p = new Properties();
    p.setProperty("directive.set.null.allowed", "true");
    if (isUserDefineTemplatePath) {
      p.setProperty("file.resource.loader.path", velocityTemplatePath);
    } else {
      p.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
      p.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    }

    Velocity.init(p);

    VelocityContext ctx = new VelocityContext();

    ctx.put("controllers", controllers);
    ctx.put("version", version);
    ctx.put("docCssPath", docCssPath);

    Writer writer = new StringWriter();

    Template template = Velocity.getTemplate(velocityTemplateFileName);
    template.merge(ctx, writer);

    return writer.toString();
  }
Beispiel #5
0
 public static synchronized MonitorManager getInstance() {
   if (instance == null) {
     instance = new MonitorManager();
   }
   if (!instance.isInitialized) {
     try {
       MonitorManager localMonitorManager = instance;
       PluginController localPluginController =
           (PluginController)
               WebUtils.getServletContextManager().getActor("nds.io.plugincontroller");
       localMonitorManager.oaLmanager =
           new PluginManager(ObjectActionListener.class, localPluginController.getPluginScanner());
       localMonitorManager.oaLmanager.init();
       if (localMonitorManager.oaLmanager.findPlugin("default") != null) {
         localPluginController.getPluginScanner().addDeploymentListener(new a());
         localMonitorManager.reloadObjectActionListeners();
         logger.info("Monitor plugin found.");
         localMonitorManager.isMonitorPluginInstalled = true;
       } else {
         localMonitorManager.isMonitorPluginInstalled = false;
         logger.warning("Monitor plugin not installed.");
       }
       localMonitorManager.isInitialized = true;
       Velocity.init();
     } catch (Exception localException) {
       throw new NDSRuntimeException(localException.getMessage(), localException);
     }
   }
   return instance;
 }
Beispiel #6
0
 /** Instantiates a new exporter velocity. */
 public ExporterVelocity() {
   Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new VelocityLogger());
   try {
     Velocity.init();
   } catch (final Exception e) {
   }
   velocityContext = new VelocityContext();
 }
Beispiel #7
0
 /**
  * 初期化処理。 <br>
  * - 環境を貰い、Velocityを初期化する。 <br>
  * - 注意事項:Eclipse の注釈処理のバグで jar を差し替えるとVelocityが jar 内の リソースを参照出来なくなる。=> Eclipse再起動が必要。
  */
 @Override
 public void init(ProcessingEnvironment env) {
   super.init(env);
   this.environment = env;
   Velocity.setProperty("runtime.log.logsystem.class", "");
   Velocity.setProperty("resource.loader", "class");
   Velocity.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
   Velocity.init();
 }
  static {
    Properties properties = new Properties();
    properties.setProperty("resource.loader", "class");
    properties.setProperty(
        "class.resource.loader.class",
        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    Velocity.init(properties);
  }
Beispiel #9
0
  public static void main(String[] args) throws Exception {
    Velocity.init();
    Template t = Velocity.getTemplate("./templates/poc.vm");

    VelocityContext ctx = new VelocityContext();

    Writer writer = new StringWriter();
    t.merge(ctx, writer);

    System.out.println(writer);
  }
 @Override
 public void init(ServletConfig config) {
   Properties properties = new Properties();
   String basePath =
       System.getProperty("user.dir") + config.getServletContext().getContextPath() + PRE_FIX;
   properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, basePath);
   try {
     Velocity.init(properties);
   } catch (Exception e) {
     throw new VelocityException(e);
   }
 }
Beispiel #11
0
  public static void setup() throws Exception {
    workSpaceDir = Jazmin.environment.getString("deploy.workspace", "./workspace/");
    deployHostname = Jazmin.environment.getString("deploy.hostname", "localhost");
    repoPath = Jazmin.environment.getString("deploy.repo.dir", "./repo");
    antPath = Jazmin.environment.getString("deploy.ant", "ant");
    antCommonLibPath = Jazmin.environment.getString("deploy.ant.lib", "./lib");

    WebServer ws = Jazmin.getServer(WebServer.class);
    if (ws != null) {
      deployHostport = ws.getPort();
    }
    checkWorkspace();
    Velocity.init();
  }
  /**
   * This method will be used for remote registration. Registered patient information will be placed
   * into an xml file for the FormEntry processor.
   *
   * @param paramPatient
   * @param paramString1
   * @param paramString2
   * @throws APIException
   */
  public void registerPatient(Patient paramPatient, String paramString1, String paramString2)
      throws APIException {
    File localFile1 = OpenmrsUtil.getDirectoryInApplicationDataDirectory("amrsregistration");
    File localFile2 = new File(localFile1, "registrationTemplate.xml");
    try {
      String str1 = OpenmrsUtil.getFileAsString(localFile2);

      Properties localProperties = new Properties();
      localProperties.setProperty("resource.loader", "class");
      localProperties.setProperty(
          "class.resource.loader.description", "VelocityClasspathResourceLoader");
      localProperties.setProperty(
          "class.resource.loader.class",
          "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
      localProperties.setProperty(
          "runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");

      Velocity.init(localProperties);
      VelocityContext localVelocityContext = new VelocityContext();
      localVelocityContext.put("locale", Context.getLocale());
      localVelocityContext.put(
          "patient", Context.getPatientService().getPatient(paramPatient.getPatientId()));
      localVelocityContext.put("user", Context.getAuthenticatedUser());
      localVelocityContext.put("fn", new DataExportFunctions());
      localVelocityContext.put("dateEntered", new Date());
      localVelocityContext.put("sid", paramString1);
      localVelocityContext.put("uid", paramString2);
      StringWriter localStringWriter = new StringWriter();
      Velocity.evaluate(localVelocityContext, localStringWriter, super.getClass().getName(), str1);

      String str2 =
          Context.getAdministrationService().getGlobalProperty("remoteformentry.pending_queue_dir");
      File localFile3 = OpenmrsUtil.getDirectoryInApplicationDataDirectory(str2);
      Date localDate = new Date();
      String str3 = "amrsregistration_" + localDate.toString();
      File localFile4 = new File(localFile3, str3);
      try {
        FileWriter localFileWriter = new FileWriter(localFile4);
        localFileWriter.write(localStringWriter.toString());
        localFileWriter.flush();
        localFileWriter.close();
      } catch (IOException localIOException) {
        log.error("Unable to write amrsregistration output file.", localIOException);
      }
    } catch (Exception localException) {
      log.error("Unable to create amrsregistration output file", localException);
      throw new APIException(localException);
    }
  }
Beispiel #13
0
 static {
   try {
     Velocity.setProperty("resource.loader", "file,yadboro");
     Velocity.setProperty(
         "yadboro.resource.loader.class", ClydeVelocityResourceLoader.class.getName());
     Velocity.setProperty("input.encoding", "UTF-8");
     Velocity.setProperty("output.encoding", "UTF-8");
     Velocity.setProperty(
         "runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
     Velocity.setProperty("velocimacro.permissions.allow.inline.local.scope", "true");
     Velocity.init();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /** Default constructor. */
  AbsoluteFileResourceLoaderTestCase() {
    super("AbsoluteFileResourceLoaderTest");

    try {
      assureResultsDirectoryExists(RESULTS_DIR);

      // signify we want to use an absolute path
      Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "");

      Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());

      Velocity.init();
    } catch (Exception e) {
      fail("Cannot setup AbsoluteFileResourceLoaderTest!");
    }
  }
  @Override
  public String getMainScript() throws GenerationException {

    StringBuilder sb = new StringBuilder();

    addComment(
        sb, FORMAT + " simulator compliant export for:\n\n" + lems.textSummary(false, false));

    Velocity.init();

    VelocityContext context = new VelocityContext();

    DLemsWriter writer = new DLemsWriter(lems, new MatlabVisitors());

    try {
      String som = writer.getMainScript();

      DLemsWriter.putIntoVelocityContext(som, context);

      Properties props = new Properties();
      props.put("resource.loader", "class");
      props.put(
          "class.resource.loader.class",
          "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
      VelocityEngine ve = new VelocityEngine();
      ve.init(props);
      Template template = ve.getTemplate(method.getFilename());

      StringWriter sw = new StringWriter();

      template.merge(context, sw);

      sb.append(sw);
    } catch (IOException e1) {
      throw new GenerationException("Problem converting LEMS to SOM", e1);
    } catch (ResourceNotFoundException e) {
      throw new GenerationException("Problem finding template", e);
    } catch (ParseErrorException e) {
      throw new GenerationException("Problem parsing", e);
    } catch (MethodInvocationException e) {
      throw new GenerationException("Problem finding template", e);
    } catch (Exception e) {
      throw new GenerationException("Problem using template", e);
    }

    return sb.toString();
  }
Beispiel #16
0
  @Override
  public void init() throws ServletException {
    super.init();

    Properties _Properties = new Properties();

    _Properties.setProperty("resource.loader", "webapp");
    _Properties.setProperty(
        "webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
    _Properties.setProperty("webapp.resource.loader.path", VELOCITY_TEMPLATES_PREFIX);

    ServletContext _ServletContext = getServletContext();
    Velocity.setApplicationAttribute("javax.servlet.ServletContext", _ServletContext);
    try {
      Velocity.init(_Properties);
    } catch (Exception ex) {
      Logger.getLogger(PAD_IJBC.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
 private VelocityFactory() {
   InputStream is = null;
   try {
     try {
       is = getClass().getClassLoader().getResourceAsStream("velocity.properties");
       Properties prop = new Properties();
       prop.load(is);
       Velocity.init(prop);
       logger.info("Velocity initializing successful!");
     } finally {
       if (is != null) {
         is.close();
       }
     }
   } catch (Exception e) {
     logger.error("Problem initializing Velocity : " + e);
     throw new RuntimeException();
   }
 }
  public void writeFile(String filePath, Map input) {
    Velocity.init();
    VelocityContext context = new VelocityContext();

    // Weather variable.
    BucketEntry weather = MapUtil.getBucket(input, "weather").get(0);
    context.put("wst_insi", MapUtil.getValueOr(weather.getValues(), "wst_insi", "?"));

    // Soil metadata
    context.put("classification", MapUtil.getValueOr(weather.getValues(), "classification", "?"));
    context.put("soil_site", MapUtil.getValueOr(weather.getValues(), "soil_site", "?"));
    context.put("soil_name", MapUtil.getValueOr(weather.getValues(), "soil_name", "?"));
    context.put("sl_source", MapUtil.getValueOr(weather.getValues(), "sl_source", "?"));
    context.put("soil_lat", MapUtil.getValueOr(weather.getValues(), "soil_lat", "?"));
    context.put("soil_long", MapUtil.getValueOr(weather.getValues(), "soil_long", "?"));

    // Setup the soil layers.
    SoilLayer[] layers;
    BucketEntry soil = MapUtil.getBucket(input, "soil").get(0);
    ArrayList data = soil.getDataList();
    layers = new SoilLayer[data.size()];
    double cumThickness = 0.0;
    for (int i = 0; i < data.size(); i++) {
      layers[i] = new SoilLayer();
      layers[i].ReadFrom((Map) data.get(i));
      cumThickness = layers[i].calcThickness(cumThickness);
    }
    context.put("layers", layers);

    // Write template.
    Template template = Velocity.getTemplate("src\\main\\resources\\AgMIPTemplate.apsim");
    FileWriter F;
    try {

      F = new FileWriter("Test.apsim");
      template.merge(context, F);
      F.close();

    } catch (IOException ex) {
      Logger.getLogger(ApsimOutput.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Beispiel #19
0
  /**
   * Initializes the Velocity runtime, first calling loadConfiguration(ServletConvig) to get a
   * java.util.Properties of configuration information and then calling Velocity.init(). Override
   * this to do anything to the environment before the initialization of the singelton takes place,
   * or to initialize the singleton in other ways.
   */
  protected void init() throws ApplicationContextException {
    try {
      Properties p = new Properties();
      logger.config("Loading Velocity properties from [" + this.url + "]");
      p.load(
          WebUtils.getResourceInputStream(
              this.url, getWebApplicationContext().getServletContext()));

      Velocity.init(p);
    } catch (ServletException e) {
      throw new ApplicationContextException(
          "Error loading Velocity config from [" + this.url + "]", e);
    } catch (IOException e) {
      throw new ApplicationContextException(
          "Error loading Velocity config from [" + this.url + "]", e);
    } catch (Exception e) {
      throw new ApplicationContextException(
          "Error initializing Velocity from properties file (loaded OK) @[" + this.url + "]", e);
    }
  }
  @Override
  protected void writePlans(String dir) {
    Properties p = new Properties();
    p.setProperty("resource.loader", "class");
    p.setProperty(
        "class.resource.loader.class",
        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    Velocity.init(p);
    Context context = new VelocityContext();
    context.put("plans", plans);

    Template template = Velocity.getTemplate("pl/poznan/put/transims/demand/matsim/plans.xml.vm");
    File planFile = new File(dir + "\\plans.xml");

    try (Writer writer = new BufferedWriter(new FileWriter(planFile))) {
      template.merge(context, writer);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  @Override
  public void load(Settings settings) throws Exception {
    Environment environment = new Environment(settings);
    if (settings.getAsBoolean("application.template.engine.enable", false)) {
      Properties properties = new Properties();

      if (settings.getAsBoolean("serviceframework.template.loader.classpath.enable", false)) {
        properties.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
        properties.setProperty(
            "classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
      } else {
        properties.setProperty(
            RuntimeConstants.FILE_RESOURCE_LOADER_PATH, environment.templateDirFile().getPath());
      }

      properties.setProperty("input.encoding", "utf-8");
      properties.setProperty("output.encoding", "utf-8");
      properties.setProperty("runtime.log", environment.logsFile().getPath() + "/template");
      Velocity.init(properties);
    }
  }
Beispiel #22
0
  static {
    try {
      // 加载属性
      Properties properties = new Properties();

      if (PathUtil.getInstance().isInJarFile()) { // 判断是否在jar中

      } else {
        properties.setProperty("resource.loader", "class");
        properties.setProperty(
            "class.resource.loader.class",
            "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
      }
      properties.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
      properties.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
      properties.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");
      Velocity.init(properties);
    } catch (Exception e) {
      System.out.println("设置velocity属性错误: " + e);
      System.exit(-1);
    }
  }
Beispiel #23
0
 @PostConstruct
 public void init() {
   Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new Slf4jLogChute());
   Velocity.init();
 }
 static {
   Velocity.init();
 }
Beispiel #25
0
  /** @param args Not used */
  public static void main(final String[] args) {
    LOG.info("Starting service");

    final Properties velocityConfig = new Properties();
    try {
      velocityConfig.load(Start.class.getResourceAsStream("/velocity.properties"));
    } catch (final IOException e1) {
      LOG.error("Cannot read velocity config", e1);
      error("Internal error. Check the logs!");
    }
    Velocity.init(velocityConfig);

    FileReader r;
    try {
      r = new FileReader(new File("config.properties"));
    } catch (final FileNotFoundException e1) {
      error("Missing config file (./config.properties) See config.sample.properties!");
      throw new RuntimeException(e1);
    }

    //
    // Read configuration
    //
    final Properties config = new Properties();
    try {
      config.load(r);
    } catch (final IOException e1) {
      error("Error reading config file (./config.properties)");
      throw new RuntimeException(e1);
    }

    /* *****************************************************
     *
     * HTTP Client
     */

    // httpclient.host
    // Active Collab API host
    String apiHost = config.getProperty("httpclient.apihost");
    if (null == apiHost || apiHost.isEmpty()) {
      error("Missing parameter: 'apihost'");
    }
    if (apiHost.endsWith("/")) {
      apiHost = apiHost.substring(0, apiHost.length() - 1);
    }

    // create client
    final ACHttpClient client =
        new ACHttpClient(
            apiHost,
            getIntValue(config, "httpclient.maxConnections", "20"),
            getIntValue(config, "httpclient.threadPoolSize", "100"),
            true);

    /* *****************************************************
     *
     * Task cache
     */

    // init caches
    TaskCache.init(client);
    CompanyCache.init(
        client,
        getLongValue(config, "cache.company.timeout", "1800000"),
        getLongValue(config, "cache.company.size", "5000"));
    ProjectCache.init(client);

    // creating handlers
    final HandlerList hc = new HandlerList();

    // cookie handling
    hc.addHandler(new FileServerHandler());

    // cookie handling
    hc.addHandler(new ApiKeyCheckerHandler(client));

    // handler for project list
    hc.addHandler(new ProjectListHandler(client));

    // handler for project home
    hc.addHandler(new ProjectHomeHandler());

    // creating the server
    final Server server = new Server(getIntValue(config, "server.port", "8080"));
    server.setHandler(hc);

    try {
      server.start();
    } catch (final Exception e) {
      LOG.error("Cannot start web server", e);
      System.exit(1);
    }
    try {
      server.join();
    } catch (final InterruptedException e) {
      LOG.error("Cannot join web server", e);
      System.exit(2);
    }

    LOG.info("Service stopped");
  }
 private void initVelocity() throws Exception {
   logger.info("initializing the template engine");
   Velocity.init();
   context = new VelocityContext();
 }
  private boolean executeAll(File velocitySources, File outputDirectory)
      throws MojoExecutionException {
    List<File> files = new ArrayList<File>();
    String canoPath;
    try {
      velocitySources = velocitySources.getCanonicalFile();
      listVeloFiles(velocitySources, files);

      canoPath = sourcePathRoot.getCanonicalPath();
      System.out.println("Velocity root path = " + canoPath);
      Velocity.setProperty("file.resource.loader.path", canoPath); // file.getParent());
      Velocity.init();

    } catch (Exception ex) {
      throw new MojoExecutionException("Failed to list files from '" + velocitySources + "'", ex);
    }

    getLog().info("Found " + files.size() + " files in '" + velocitySources + "'...");

    if (files.isEmpty()) return false;

    for (File file : files) {
      try {
        file = file.getCanonicalFile();

        String name = file.getName();
        if (name.endsWith("~") || name.endsWith(".bak")) {
          getLog().info("Skipping: '" + name + "'");
          continue;
        }

        File outFile = getOutputFile(file, velocitySources, outputDirectory);
        if (outFile.exists() && outFile.lastModified() > file.lastModified()) {
          getLog().info("Up-to-date: '" + name + "'");
          continue;
        }
        getLog().info("Executing template '" + name + "'...");

        // context = new VelocityContext();
        String cano = file.getCanonicalPath();
        cano = cano.substring(canoPath.length());
        if (cano.startsWith(File.separator)) cano = cano.substring(File.separator.length());

        org.apache.velocity.Template template = Velocity.getTemplate(cano); // file.getName());

        VelocityContext context = new VelocityContext(); // execution.getParameters());
        context.put("primitives", Primitive.getPrimitives());
        context.put("primitivesNoBool", Primitive.getPrimitivesNoBool());
        context.put("bridJPrimitives", Primitive.getBridJPrimitives());

        StringWriter out = new StringWriter();
        template.merge(context, out);
        out.close();

        outFile.getParentFile().mkdirs();

        FileWriter f = new FileWriter(outFile);
        f.write(out.toString());
        f.close();
        // getLog().info("\tGenerated '" + outFile.getName() + "'");

      } catch (Exception ex) {
        // throw
        new MojoExecutionException("Failed to execute template '" + file + "'", ex)
            .printStackTrace();
      }
    }

    return true;
  }
 @Inject
 public EmailNotificationService(JavaMailSender mailSender, SeyrenConfig seyrenConfig) {
   this.mailSender = mailSender;
   this.seyrenConfig = seyrenConfig;
   Velocity.init();
 }
  @Override
  public void execute() {
    try {
      // we retrive data for the template
      String testPath = request.getUri().replaceFirst("/test", "");
      File testFile = new File(testSourceDirectory + testPath.split("[?]")[0]);
      // if file is a selenium IDE file, we have nothing to do
      if (TestRunnerUtils.IsSeleniumIdeFile(testFile)) {
        String content = TestRunnerUtils.getFileContent(testFile);
        this.contentType = "text/html; charset=utf-8";
        this.content = ChannelBuffers.copiedBuffer(content, CharsetUtil.UTF_8);
      }
      // it's a play! file, so let's go parse and render it with velocity ...
      else {
        List<TestScenario> tests;
        tests = TestRunnerUtils.parseTestFile(testFile);

        // initialize velocity
        Properties props = new Properties();
        props.setProperty(VelocityEngine.RESOURCE_LOADER, "classpath");
        props.setProperty(
            RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
            "org.apache.velocity.runtime.log.Log4JLogChute");
        props.setProperty("runtime.log.logsystem.log4j.logger", "VELOCITY");
        props.setProperty(
            "classpath." + VelocityEngine.RESOURCE_LOADER + ".class",
            ClasspathResourceLoader.class.getName());

        Velocity.init(props);
        VelocityContext context = new VelocityContext();
        // put parameter for template
        context.put("tests", tests);

        // get the template
        Template template = null;
        try {
          template = Velocity.getTemplate("com/logisima/selenium/template/test.vm");
          StringWriter sw = new StringWriter();
          template.merge(context, sw);
          // create the response
          this.contentType = "text/html; charset=utf-8";
          this.content = ChannelBuffers.copiedBuffer(sw.toString(), CharsetUtil.UTF_8);

        } catch (ResourceNotFoundException rnfe) {
          this.status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
          this.contentType = "text/html; charset=utf-8";
          this.content = ChannelBuffers.copiedBuffer(rnfe.toString(), CharsetUtil.UTF_8);
        } catch (ParseErrorException pee) {
          this.status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
          this.contentType = "text/html; charset=utf-8";
          this.content = ChannelBuffers.copiedBuffer(pee.toString(), CharsetUtil.UTF_8);
        } catch (MethodInvocationException mie) {
          this.status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
          this.contentType = "text/html; charset=utf-8";
          this.content = ChannelBuffers.copiedBuffer(mie.toString(), CharsetUtil.UTF_8);
        } catch (Exception e) {
          this.status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
          this.contentType = "text/html; charset=utf-8";
          this.content = ChannelBuffers.copiedBuffer(e.toString(), CharsetUtil.UTF_8);
        }
      }
      // render template
    } catch (IOException e1) {
      this.status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
      this.contentType = "text/html; charset=utf-8";
      this.content = ChannelBuffers.copiedBuffer(e1.toString(), CharsetUtil.UTF_8);
    }
  }