String source = readTemplate(template);
if (source != null) {
if (logger.isTraceEnabled())
logger.trace("Template [" + template + "]=" + source);
// Create template
final PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate(template).setSource(source).execute()
.actionGet();
if (!response.isAcknowledged()) {
throw new Exception("Could not define template [" + template
+ "].");
} else {
if (logger.isDebugEnabled()) {
logger.debug("Template [" + template