public void generatePropertiesClass(PropertiesClass propertiesClass, Writer out)
     throws IOException, TemplateException {
   Template template = cfg.getTemplate("properties_class.ftl");
   Environment env = template.createProcessingEnvironment(propertiesClass, out);
   env.setOutputEncoding(outputCharset);
   env.process();
 }
Ejemplo n.º 2
0
  /**
   * método que permite generar fichero de metadatos en carpeta separada comprueba si el fichero
   * manifest tiene un lomes integrado o un metadato externo. si el ODE no tiene metadatos.. no
   * genera nada
   */
  private void obtenerLOMES(String lomFileName) throws Exception {
    FileOutputStream fo = null;
    FileInputStream fin = null;
    Writer out = null;
    File lomes = null;
    Template template;
    try {
      if (pathLomesExterno != null) {
        lomes = new File(dirDestino + File.separator + lomFileName);
        if (!lomes.exists()) lomes.createNewFile();
      }

      if (pathLomesExterno != null && pathLomesExterno.equals("")) {
        // tiene lomes y no es un fichero externo adlcp:location
        template = cfg.getTemplate("lomes.ftl");
        cfg.setDefaultEncoding("UTF-8");
        fo = new FileOutputStream(lomes);
        out = new OutputStreamWriter(fo, "UTF-8");
        Environment env = template.createProcessingEnvironment(root, out);
        env.setOutputEncoding("UTF-8");
        env.process();

        out.flush();

      } else if (pathLomesExterno != null
          && !pathLomesExterno.equals(
              "")) { // fichero externo.. por lo que solamente lo copio al destino
        File origen = new File(pathOde + "/" + pathLomesExterno);
        fin = new FileInputStream(origen);
        fo = new FileOutputStream(lomes);
        int c;
        while ((c = fin.read()) >= 0) {
          fo.write(c);
        }
        fin.close();
        fo.close();
        origen = null;
      }
    } catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug("Error en GeneradorHTML:obtenerLOMES .. " + e.getMessage());
      }
      throw e;
    } finally {
      lomes = null;
      if (fo != null) {
        try {
          fo.close();
        } catch (IOException e) {
        }
      }
      if (fin != null) {
        try {
          fin.close();
        } catch (IOException e) {
        }
      }
    }
  }