當前位置: 首頁>>代碼示例>>Java>>正文


Java TemplateException類代碼示例

本文整理匯總了Java中freemarker.template.TemplateException的典型用法代碼示例。如果您正苦於以下問題:Java TemplateException類的具體用法?Java TemplateException怎麽用?Java TemplateException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TemplateException類屬於freemarker.template包,在下文中一共展示了TemplateException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleRequestShouldThrowException

import freemarker.template.TemplateException; //導入依賴的package包/類
@Test
public void handleRequestShouldThrowException() throws TemplateException, KeyOperationException, IOException {
    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage("Email");
    LinkGeneratorLambdaHandler handler = mock(LinkGeneratorLambdaHandler.class);
    doCallRealMethod().when(handler).handleRequest(any(), any());
    Exception ex = new TemplateException("Message", null);
    doThrow(ex).when(handler).getUploadPageUrlFromRequest(any(), any());
    
    Context context = mock(Context.class);
    LambdaLogger logger = mock(LambdaLogger.class);
    doNothing().when(logger).log(anyString());
    doReturn(logger).when(context).getLogger();
    
    handler.handleRequest(mock(LinkGeneratorRequest.class), context);
}
 
開發者ID:julianghionoiu,項目名稱:tdl-auth,代碼行數:17,代碼來源:LinkGeneratorLambdaTest.java

示例2: templateConfiguration

import freemarker.template.TemplateException; //導入依賴的package包/類
private static Configuration templateConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setLogTemplateExceptions(false);
  try {
    configuration.setSetting("object_wrapper",
        "DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
            + "iterableSupport=true, exposeFields=true)");
  } catch (TemplateException e) {
    e.printStackTrace();
  }
  configuration.setAPIBuiltinEnabled(true);
  configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
      "templates/ccda");
  return configuration;
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:17,代碼來源:CCDAExporter.java

示例3: allSignatures

import freemarker.template.TemplateException; //導入依賴的package包/類
public void allSignatures(String inputFile) throws IOException, TemplateException {
    Configuration cfg = new Configuration();
    Template template = cfg.getTemplate(inputFile);
    Map<String, Object> data = new HashMap<String, Object>();

    template.process(data, new OutputStreamWriter(System.out)); //TP
    template.process(data, new OutputStreamWriter(System.out), null); //TP
    template.process(data, new OutputStreamWriter(System.out), null, null); //TP
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:10,代碼來源:FreemarkerUsage.java

示例4: createDroolRule

import freemarker.template.TemplateException; //導入依賴的package包/類
public String createDroolRule(Rule rule) throws TemplateException, IOException {
  try {
    Template temp = cfg.getTemplate(templateName);
    Writer out = new StringWriter();
    temp.process(createMap(rule), out);
    return out.toString();
  } catch (IOException iE) {
    logger.error("Problem getting rule template file." + iE.getMessage());
    throw iE;
  } catch (TemplateException tE) {
    logger.error("Problem writing Drool rule." + tE.getMessage());
    throw tE;
  } catch (Exception e) {
    logger.error("Problem creating rule: " + e.getMessage());
    throw e;
  }
}
 
開發者ID:edgexfoundry,項目名稱:support-rulesengine,代碼行數:18,代碼來源:RuleCreator.java

示例5: generateUserDockerrunFileTest

import freemarker.template.TemplateException; //導入依賴的package包/類
@Test
public void generateUserDockerrunFileTest() throws IOException, TemplateException {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("awsEBDockerrunVersion", "2");
    parameters.put("hostPort", "80");
    parameters.put("configFile", "config.yml");
    parameters.put("containerPort", "80");
    parameters.put("memory", "2");
    parameters.put("awsEBDockerrunVersion", "6144");
    FileGenerator.generateUserDockerrunFile(
            "src/test/resources/DockerrunTemplate.ftlh",
            "src/test/resources/testUserDockerrunFile.aws.json",
            parameters
    );

    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> generatedTestData = mapper.readValue(new File("src/test/resources/testUserDockerrunFile.aws.json"), Map.class);
    Map<String, Object> expectedTestData = mapper.readValue(new File("src/test/resources/expectedDockerrunFile.aws.json"), Map.class);

    for (String k : generatedTestData.keySet()) {
        Assert.assertTrue(generatedTestData.get(k).equals(expectedTestData.get(k)));
    }

    File generatedTestFile = new File("src/test/resources/testUserDockerrunFile.aws.json");
    generatedTestFile.delete();
}
 
開發者ID:tsiq,項目名稱:magic-beanstalk,代碼行數:27,代碼來源:FileGeneratorTest.java

示例6: generateDefaultDockerrunFileTest

import freemarker.template.TemplateException; //導入依賴的package包/類
@Test
public void generateDefaultDockerrunFileTest() throws IOException, TemplateException {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("awsEBDockerrunVersion", "2");
    parameters.put("hostPort", "80");
    parameters.put("configFile", "config.yml");
    parameters.put("containerPort", "80");
    parameters.put("memory", "2");
    parameters.put("awsEBDockerrunVersion", "6144");
    FileGenerator.generateDefaultDockerrunFile(
            "src/test/resources/defaultGeneratedDockerrun.aws.json",
            parameters
    );

    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> generatedTestData = mapper.readValue(new File("src/test/resources/defaultGeneratedDockerrun.aws.json"), Map.class);
    Map<String, Object> expectedTestData = mapper.readValue(new File("src/test/resources/expectedDockerrunFile.aws.json"), Map.class);

    for (String k : generatedTestData.keySet()) {
        Assert.assertTrue(generatedTestData.get(k).equals(expectedTestData.get(k)));
    }

    File generatedTestFile = new File("src/test/resources/defaultGeneratedDockerrun.aws.json");
    generatedTestFile.delete();
}
 
開發者ID:tsiq,項目名稱:magic-beanstalk,代碼行數:26,代碼來源:FileGeneratorTest.java

示例7: LinkGeneratorLambdaHandler

import freemarker.template.TemplateException; //導入依賴的package包/類
LinkGeneratorLambdaHandler(String region, String jwtEncryptKeyArn, String pageStorageBucket, String authVerifyEndpointURL,
                           AWSCredentialsProvider awsCredential, String introPageTemplateName) throws IOException, TemplateException {
    AWSKMS kmsClient = AWSKMSClientBuilder.standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    AmazonS3 s3client = AmazonS3ClientBuilder
            .standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    kmsEncrypt = new KMSEncrypt(kmsClient, jwtEncryptKeyArn);
    this.pageStorageBucket = pageStorageBucket;
    this.authVerifyEndpointURL = authVerifyEndpointURL;
    this.pageUploader = new PageUploader(s3client, pageStorageBucket);


    this.introPageTemplate = new IntroPageTemplate(introPageTemplateName);
}
 
開發者ID:julianghionoiu,項目名稱:tdl-auth,代碼行數:20,代碼來源:LinkGeneratorLambdaHandler.java

示例8: displayTestTemplate

import freemarker.template.TemplateException; //導入依賴的package包/類
@Override
public String displayTestTemplate(User user) {

    String applicationPropertyUrl = environment.getProperty("spring.application.url");
    String siteName = mailUI.getMessage("mail.site.name");
    String greeting = "YOUSA!";

    Map<String, Object> model = new Hashtable<>();
    model.put("siteName", siteName);
    model.put("greeting", greeting);
    model.put("user", user);
    model.put("applicationPropertyUrl", applicationPropertyUrl);

    String result = null;

    try {
        Template template = fm.getTemplate("tests/test.ftl");
        result = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
    } catch (IOException | TemplateException e) {
        logger.error("Problem merging test template : " + e.getMessage());
    }
    return result;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:24,代碼來源:FmServiceImpl.java

示例9: createRssPostContent

import freemarker.template.TemplateException; //導入依賴的package包/類
@Override
public String createRssPostContent(Post post) {
    String html = null;

    Map<String, Object> model = new Hashtable<>();

    model.put("post", post);
    model.put("baseurl", applicationSettings.getBaseUrl());

    try {
        Template template = fm.getTemplate("posts/rss_post.ftl");
        html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
    } catch (IOException | TemplateException e) {
        logger.error("Problem merging post template : " + e.getMessage());
    }
    return html;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:18,代碼來源:FmServiceImpl.java

示例10: createPostHtml

import freemarker.template.TemplateException; //導入依賴的package包/類
@Override
public String createPostHtml(Post post, String templateName) {
    String html = null;
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy");
    String postCreated = post.getPostDate().format(formatter);

    Map<String, Object> model = new Hashtable<>();

    model.put("post", post);
    model.put("postCreated", postCreated);
    model.put("shareSiteName",
            StringUtils.deleteWhitespace(applicationSettings.getSiteName()));
    model.put("shareUrl",
            String.format("%s/post/%s", applicationSettings.getBaseUrl(), post.getPostName()));

    String displayType = templateName == null ? post.getDisplayType().name().toLowerCase() : templateName;
    String ftl = String.format("posts/%s.ftl", displayType);

    try {
        Template template = fm.getTemplate(ftl);
        html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
    } catch (IOException | TemplateException e) {
        logger.error("Problem merging post template : " + e.getMessage());
    }
    return html;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:27,代碼來源:FmServiceImpl.java

示例11: createPostAtoZs

import freemarker.template.TemplateException; //導入依賴的package包/類
@Override
public String createPostAtoZs() {
    String html = null;

    String backToTop = mailUI.getMessage("posts.az.page.backtotop");
    String azFileName = environment.getProperty("posts.az.file.name");
    String azFilePath = applicationSettings.getPostAtoZFilePath();

    Map<String, Object> model = new Hashtable<>();
    model.put("alphaLinks", postService.getAlphaLInks());
    model.put("alphaPosts", postService.getAlphaPosts());
    model.put("backToTop", backToTop);

    try {
        Template template = fm.getTemplate("posts/az.ftl");
        html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
        InputStream in = IOUtils.toInputStream(html, "UTF-8");
        FileUtils.copyInputStreamToFile(in, new File(azFilePath + azFileName));
    } catch (IOException | TemplateException e) {
        logger.error("Problem creating A-to-Z template or HTML file: " + e.getMessage());
    }
    return html;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:24,代碼來源:FmServiceImpl.java

示例12: generateMessage

import freemarker.template.TemplateException; //導入依賴的package包/類
private String generateMessage(String trigger, Map executionData, Map config) {

        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("trigger", trigger);
        model.put("executionData", executionData);
        model.put("config", config);

        StringWriter sw = new StringWriter();
        try {
            Template template = FREEMARKER_CFG.getTemplate(DINGTALK_MESSAGE_TEMPLATE);
            template.process(model, sw);

        } catch (IOException ioEx) {
            throw new DingtalkNotificationPluginException("Error loading Dingtalk notification message template: [" + ioEx.getMessage() + "].", ioEx);
        } catch (TemplateException templateEx) {
            throw new DingtalkNotificationPluginException("Error merging Dingtalk notification message template: [" + templateEx.getMessage() + "].", templateEx);
        }

        return sw.toString();
    }
 
開發者ID:nongfenqi,項目名稱:dingtalk-incoming-webhoot-plugin,代碼行數:21,代碼來源:DingtalkNotificationPlugin.java

示例13: writeMiddle

import freemarker.template.TemplateException; //導入依賴的package包/類
@SuppressWarnings({"nls"})
@Override
protected void writeMiddle(SectionWriter writer) throws IOException
{
	List<Option<?>> options = listState.getOptions();
	for( Option<?> option : options )
	{
		writer.writeTag("li");
		writer.writeTag("input", "type", "hidden", "name", listState.getName(), "value", option.getValue());
		loopVars[0] = new BeanModel(option, wrapper);
		try
		{
			body.render(writer);
		}
		catch( TemplateException e )
		{
			SectionUtils.throwRuntime(e);
		}
		writer.endTag("li");
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:ListRendererDirective.java

示例14: writeMiddle

import freemarker.template.TemplateException; //導入依賴的package包/類
@Override
protected void writeMiddle(SectionWriter writer) throws IOException
{
	List<ListOption<Object>> optionList = renderer.renderOptionList(writer);
	for( ListOption<Object> listOption : optionList )
	{
		Option<Object> option = listOption.getOption();
		HtmlBooleanState state = listOption.getBooleanState();
		state.setLabel(new TextLabel(option.getName(), true));
		loopVars[0] = new BeanModel(option, wrapper);
		loopVars[1] = new BeanModel(state, wrapper);
		try
		{
			body.render(writer);
		}
		catch( TemplateException e )
		{
			throw Throwables.propagate(e);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:BooleanListDirective.java

示例15: generateContent

import freemarker.template.TemplateException; //導入依賴的package包/類
public String generateContent(String mainChallengeTitle,
                              String sponsorName,
                              String codingSessionDurationLabel, String username,
                              String token,
                              String authVerifyEndpointUrl,
                              Date expirationDate,
                              String journeyId)
        throws IOException, TemplateException {
    StringWriter stringWriter = new StringWriter();
    Map<String, String> contentParams = new HashMap<>();
    contentParams.put("MAIN_CHALLENGE_TITLE", mainChallengeTitle);
    contentParams.put("SPONSOR", sponsorName);
    contentParams.put("EXPIRATION_DATE", dateFormatter.format(expirationDate));
    contentParams.put("CODING_SESSION_DURATION", codingSessionDurationLabel);
    contentParams.put("API_VERIFY_ENDPOINT", authVerifyEndpointUrl);
    contentParams.put("USERNAME", username);
    contentParams.put("TOKEN", token);
    contentParams.put("JOURNEY_ID", journeyId);
    template.process(contentParams, stringWriter);
    return stringWriter.toString();
}
 
開發者ID:julianghionoiu,項目名稱:tdl-auth,代碼行數:22,代碼來源:IntroPageTemplate.java


注:本文中的freemarker.template.TemplateException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。