private String executeInternal(String templateName, Object value) { Preconditions.checkNotNull(templateName, "templateName cannot be null."); Preconditions.checkNotNull(value, "values cannot be null."); Template template; try { template = this.configuration.getTemplate(templateName); } catch (IOException ex) { throw new DataException( String.format("Exception thrown while loading template '%s'", templateName), ex ); } try (StringWriter writer = new StringWriter()) { template.process(value, writer); return writer.toString(); } catch (IOException e) { throw new ConnectException("Exception while processing template", e); } catch (InvalidReferenceException e) { throw new DataException( String.format( "Exception thrown while processing template. Offending expression '%s'", e.getBlamedExpressionString() ), e); } catch (TemplateException e) { throw new ConnectException("Exception while processing template", e); } }
String renderTemplate(Change change, Template template, String namespace) { Map<String, String> value = values(change, namespace); try (StringWriter writer = new StringWriter()) { template.process(value, writer); return writer.toString(); } catch (IOException e) { throw new DataException("Exception while processing template", e); } catch (InvalidReferenceException e) { throw new DataException( String.format( "Exception thrown while processing template. Offending expression '%s'", e.getBlamedExpressionString() ), e); } catch (TemplateException e) { throw new DataException("Exception while processing template", e); } }
String renderTemplate(Change change, Template template, String namespace) { Map<String, String> value = values(change, namespace); try (StringWriter writer = new StringWriter()) { template.process(value, writer); return writer.toString(); } catch (IOException e) { throw new DataException("Exception while processing template", e); } catch (InvalidReferenceException e) { throw new DataException( String.format( "Exception thrown while processing template. Offending expression '%s'", e.getBlamedExpressionString() ), e); } catch (TemplateException e) { throw new DataException("Exception while processing template", e); } }
private String executeInternal(String templateName, Object value) { Preconditions.checkNotNull(templateName, "templateName cannot be null."); Preconditions.checkNotNull(value, "values cannot be null."); Template template; try { template = this.configuration.getTemplate(templateName); } catch (IOException ex) { throw new DataException( String.format("Exception thrown while loading template '%s'", templateName), ex ); } try (StringWriter writer = new StringWriter()) { template.process(value, writer); return writer.toString(); } catch (IOException e) { throw new ConnectException("Exception while processing template", e); } catch (InvalidReferenceException e) { throw new DataException( String.format( "Exception thrown while processing template. Offending expression '%s'", e.getBlamedExpressionString() ), e); } catch (TemplateException e) { throw new ConnectException("Exception while processing template", e); } }
} catch (Exception e) { _logger.error(MessageFormat.format("Exception occurred while applying template change on {0}, with error message {1}.", templateString, e.getMessage())); generatedString = MessageFormat.format("ERROR occurred during applying template change to the following variable: {0}\n\n Detailed Message: {1}",((InvalidReferenceException) e).getBlamedExpressionString(), e.getMessage()); break;
} catch (Exception e) { _logger.error(MessageFormat.format("Exception occurred while applying template change on {0}, with error message {1}.", templateString, e.getMessage())); generatedString = MessageFormat.format("ERROR occurred during applying template change to the following variable: {0}\n\n Detailed Message: {1}",((InvalidReferenceException) e).getBlamedExpressionString(), e.getMessage()); break;