Java 类freemarker.template.MalformedTemplateNameException 实例源码

项目:DarwinSPL    文件:DwFeatureModelSVGGenerator.java   
/**
 * Configures freemarker for usage.
 * @return
 * @throws URISyntaxException
 * @throws TemplateNotFoundException
 * @throws MalformedTemplateNameException
 * @throws ParseException
 * @throws IOException
 * @throws TemplateException
 */
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
    cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

    Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
    URL fileURL = bundle.getEntry("templates/");

    File file = new File(FileLocator.resolve(fileURL).toURI());
    cfg.setDirectoryForTemplateLoading(file);

    Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();

    customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);

    cfg.setCustomNumberFormats(customNumberFormats);

    return cfg;
}
项目:DarwinSPL    文件:DwFeatureModelOverviewGenerator.java   
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
    cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

    Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
    customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);

    cfg.setCustomDateFormats(customDateFormats);
    cfg.setDateTimeFormat("@simle");

    Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
    URL fileURL = bundle.getEntry("templates/");

    File file = new File(FileLocator.resolve(fileURL).toURI());
    cfg.setDirectoryForTemplateLoading(file);

    return cfg;
}
项目:NoMoreOversleeps    文件:WebServlet.java   
/**
 * Sends the main HTML page of the WebUI.
 * 
 * @param response
 * @throws TemplateNotFoundException
 * @throws MalformedTemplateNameException
 * @throws ParseException
 * @throws IOException
 * @throws ServletException
 */
private void sendMainPage(HttpServletResponse response) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, ServletException
{
    HashMap<String, Object> model = new HashMap<String, Object>();
    model.put("version", Main.VERSION);
    model.put("system", PlatformData.computerName);
    model.put("actionButtons", this.determineWebUIButtons());
    model.put("webcamKey", NMOConfiguration.INSTANCE.integrations.webUI.webcamSecurityKey);
    model.put("camTotal", WebcamCapture.webcams.length);
    model.put("message", NMOConfiguration.INSTANCE.integrations.webUI.message);
    model.put("username", NMOConfiguration.INSTANCE.integrations.webUI.username);
    String[] cc = new String[WebcamCapture.webcams.length];
    for (int i = 0; i < WebcamCapture.webcams.length; i++)
    {
        cc[i] = WebcamCapture.webcams[i].cc;
    }
    model.put("webcams", cc);
    for (Integration integration : Main.integrations)
    {
        model.put("integration_" + integration.id, integration.isEnabled());
    }
    try
    {
        WebTemplate.renderTemplate("nmo.ftl", response, model);
    }
    catch (TemplateException e)
    {
        throw new ServletException(e);
    }
}
项目:lj-projectbuilder    文件:GeneratorService.java   
public Template getTemplate(String templatePath)
        throws IOException, TemplateNotFoundException, MalformedTemplateNameException, ParseException {
    @SuppressWarnings("deprecation")
    Configuration cfg = new Configuration();
    if (templatePath.startsWith("classpath:")) {
        cfg.setClassForTemplateLoading(FindClass.class, ".." + Constants.FILE_SEP);
        templatePath = templatePath.replace("classpath:", "");
    } else {
        cfg.setDirectoryForTemplateLoading(new File(templatePath));         
    }
    Template template = cfg.getTemplate(templatePath);
    return template;
}
项目:hub-email-extension    文件:EmailMessagingService.java   
public void sendEmailMessage(final EmailTarget emailTarget, final ExtensionProperties hubConfiguredProperties)
        throws MessagingException, TemplateNotFoundException, MalformedTemplateNameException, ParseException,
        IOException, TemplateException {
    final String emailAddress = StringUtils.trimToEmpty(emailTarget.getEmailAddress());
    final String templateName = StringUtils.trimToEmpty(emailTarget.getTemplateName());
    final Map<String, Object> model = emailTarget.getModel();
    if (StringUtils.isBlank(emailAddress) || StringUtils.isBlank(templateName)) {
        // we've got nothing to do...might as well get out of here...
        return;
    }

    ExtensionProperties properties = localProperties;
    // use the hub global configuration as default and let the local
    // properties file value override the values from
    // the Hub
    if (hubConfiguredProperties != null) {
        properties = new ExtensionProperties(localProperties.getAppProperties(), hubConfiguredProperties.getAppProperties());
    }

    final Session session = createMailSession(properties);
    final Map<String, String> contentIdsToFilePaths = new HashMap<>();
    populateModelWithAdditionalProperties(properties, model, templateName, contentIdsToFilePaths);
    final String html = getResolvedTemplate(model, templateName);

    final MimeMultipartBuilder mimeMultipartBuilder = new MimeMultipartBuilder();
    mimeMultipartBuilder.addHtmlContent(html);
    mimeMultipartBuilder.addTextContent(Jsoup.parse(html).text());
    mimeMultipartBuilder.addEmbeddedImages(contentIdsToFilePaths);
    final MimeMultipart mimeMultipart = mimeMultipartBuilder.build();

    final String resolvedSubjectLine = getResolvedSubjectLine(model);
    final Message message = createMessage(emailAddress, resolvedSubjectLine, session, mimeMultipart, properties);
    javaMailWrapper.sendMessage(properties, session, message);
}
项目:hub-email-extension    文件:EmailMessagingService.java   
private String getResolvedTemplate(final Map<String, Object> model, final String templateName)
        throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException,
        TemplateException {
    final StringWriter stringWriter = new StringWriter();
    final Template template = configuration.getTemplate(templateName);
    template.process(model, stringWriter);
    return stringWriter.toString();
}
项目:schedule    文件:TmplMarker.java   
public void process(EntityMeta meta) throws TemplateNotFoundException, MalformedTemplateNameException,
        ParseException, IOException, TemplateException, URISyntaxException {
    init();
    URL context = ClassLoader.getSystemResource("");
    URL tpls = ClassLoader.getSystemResource(tmplPath);
    File tmplDir = new File(tpls.toURI());
    if (tmplDir.exists() && tmplDir.isDirectory()) {
        File[] fiels = tmplDir.listFiles();
        if (fiels != null && fiels.length > 0) {
            for (File file : fiels) {
                String name = file.getName();
                Template template = cfg.getTemplate(name);
                Writer writer = null;
                if ("entity.ftlh".equals(name)) {
                    writer = writeJavaFile(context, meta);
                } else if ("mybatis.ftlh".equals(name)) {
                    writer = writerBatiesFile(context, meta);
                }
                if (writer != null) {
                    try {
                        template.process(meta, writer);
                    } finally {
                        writer.close();
                    }
                }

            }
        }
    }
}
项目:rest2java    文件:Rest2Java.java   
private void generateBuilderClasses(Configuration cfg, APISpec apiSpec) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
        IOException, TemplateException {

    /* Get the template (uses cache internally) */
    Template temp = cfg.getTemplate("builderTemplate.ftl");
    Writer out = new OutputStreamWriter(System.out);
    temp.process(apiSpec, out);
}
项目:rest2java    文件:Rest2Java.java   
private void generateApiClass(Configuration cfg, APISpec apiSpec) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
        IOException, TemplateException {

    Template temp = cfg.getTemplate("apiTemplate.ftl");
    Writer out = new OutputStreamWriter(System.out);
    temp.process(apiSpec, out);
}
项目:NoMoreOversleeps    文件:WebTemplate.java   
public static final void renderTemplate(String template, HttpServletResponse response, Object model) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, TemplateException, IOException
{
    StringWriter writer = new StringWriter();
    PARSER.getTemplate(template).process(model, writer);
    response.getWriter().append(writer.toString());
}
项目:NoMoreOversleeps    文件:WebTemplate.java   
public static final void renderTemplate(String template, HttpServletResponse response, Object model, Writer writer) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, TemplateException, IOException
{
    StringWriter writer_ = new StringWriter();
    PARSER.getTemplate(template).process(model, writer_);
    writer.append(writer_.toString());
}
项目:NoMoreOversleeps    文件:WebTemplate.java   
public static final String renderBody(String template, Object model) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, TemplateException, IOException
{
    StringWriter writer = new StringWriter();
    PARSER.getTemplate(template).process(model, writer);
    return writer.toString();
}
项目:hub-email-extension    文件:EmailMessagingService.java   
public void sendEmailMessage(final EmailTarget emailTarget) throws MessagingException, TemplateNotFoundException,
        MalformedTemplateNameException, ParseException, IOException, TemplateException {
    sendEmailMessage(emailTarget, null);
}
项目:voj    文件:MailSender.java   
/**
 * 解析电子邮件模板内容.
 * @param templateLocation - 电子邮件模板相对路径
 * @param model - 电子邮件的附加信息
 * @return 解析后的电子邮件内容
 * @throws TemplateException 
 * @throws IOException 
 * @throws ParseException 
 * @throws MalformedTemplateNameException 
 * @throws TemplateNotFoundException 
 */
public String getMailContent(String templateLocation, Map<String, Object> model)
        throws TemplateNotFoundException, MalformedTemplateNameException, 
            ParseException, IOException, TemplateException {
    model.put("baseUrl", baseUrl);

    return FreeMarkerTemplateUtils.processTemplateIntoString(
            freeMarkerConfigurer.getConfiguration().getTemplate(templateLocation), model);
}
项目:cmake4cdt    文件:CMakeProjectGenerator.java   
/**
 * @param fmModel
 * @param fmConfig
 * @throws CoreException 
 * @throws IOException 
 * @throws TemplateException 
 * @throws ParseException 
 * @throws MalformedTemplateNameException 
 * @throws TemplateNotFoundException 
 */
private void instantiateTemplate(Map<String, Object> fmModel, Configuration fmConfig) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, TemplateException, IOException, CoreException {
    generateFile(fmModel, fmConfig.getTemplate("CMakeLists.txt"), project.getFile("CMakeLists.txt"));
    generateFile(fmModel, fmConfig.getTemplate("main.cpp"), project.getFile("main.cpp"));

}