return templates;
}
private void validate(Request request, ClusterState state) throws ElasticSearchException {
if (state.routingTable().hasIndex(request.index)) {
throw new IndexAlreadyExistsException(new Index(request.index));
}
if (state.metaData().hasIndex(request.index)) {
throw new IndexAlreadyExistsException(new Index(request.index));
}
if (request.index.contains(" ")) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must not contain whitespace");
}
if (request.index.contains(",")) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must not contain ',");
}
if (request.index.contains("#")) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must not contain '#");
}
if (!request.index.equals(riverIndexName) && !request.index.equals(PercolatorService.INDEX_NAME) && request.index.charAt(0) == '_') {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must not start with '_'");
}
if (!request.index.toLowerCase().equals(request.index)) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must be lowercase");
}
if (!Strings.validFileName(request.index)) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "must not contain the following characters " + Strings.INVALID_FILENAME_CHARS);
}
if (state.metaData().aliases().containsKey(request.index)) {
throw new InvalidIndexNameException(new Index(request.index), request.index, "an alias with the same name already exists");
}
}