/** * Validate a proposed alias. */ public void validateAlias(String alias, String index, @Nullable String indexRouting, Function<String, IndexMetaData> indexLookup) { validateAliasStandalone(alias, indexRouting); if (!Strings.hasText(index)) { throw new IllegalArgumentException("index name is required"); } IndexMetaData indexNamedSameAsAlias = indexLookup.apply(alias); if (indexNamedSameAsAlias != null) { throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(), alias, "an index exists with the same name as the alias"); } }
aliasValidator.validateAliasStandalone(alias); if (request.indexPatterns.contains(alias.name())) { throw new IllegalArgumentException("Alias [" + alias.name() +
/** * Allows to partially validate an alias, without knowing which index it'll get applied to. * Useful with index templates containing aliases. Checks also that it is possible to parse * the alias filter via {@link org.elasticsearch.common.xcontent.XContentParser}, * without validating it as a filter though. * @throws IllegalArgumentException if the alias is not valid */ public void validateAliasStandalone(Alias alias) { validateAliasStandalone(alias.name(), alias.indexRouting()); if (Strings.hasLength(alias.filter())) { try { XContentHelper.convertToMap(XContentFactory.xContent(alias.filter()), alias.filter(), false); } catch (Exception e) { throw new IllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e); } } }
/** * Validate a proposed alias. */ public void validateAlias(String alias, String index, @Nullable String indexRouting, Function<String, IndexMetaData> indexLookup) { validateAliasStandalone(alias, indexRouting); if (!Strings.hasText(index)) { throw new IllegalArgumentException("index name is required"); } IndexMetaData indexNamedSameAsAlias = indexLookup.apply(alias); if (indexNamedSameAsAlias != null) { throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(), alias, "an index exists with the same name as the alias"); } }
/** * Validate a proposed alias. */ public void validateAlias(String alias, String index, @Nullable String indexRouting, Function<String, IndexMetaData> indexLookup) { validateAliasStandalone(alias, indexRouting); if (!Strings.hasText(index)) { throw new IllegalArgumentException("index name is required"); } IndexMetaData indexNamedSameAsAlias = indexLookup.apply(alias); if (indexNamedSameAsAlias != null) { throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(), alias, "an index exists with the same name as the alias"); } }
/** * Validate a proposed alias. */ public void validateAlias(String alias, String index, @Nullable String indexRouting, Function<String, IndexMetaData> indexLookup) { validateAliasStandalone(alias, indexRouting); if (!Strings.hasText(index)) { throw new IllegalArgumentException("index name is required"); } IndexMetaData indexNamedSameAsAlias = indexLookup.apply(alias); if (indexNamedSameAsAlias != null) { throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(), alias, "an index exists with the same name as the alias"); } }
aliasValidator.validateAliasStandalone(alias); if (request.template.equals(alias.name())) { throw new IllegalArgumentException("Alias [" + alias.name() + "] cannot be the same as the template pattern [" + request.template + "]");
aliasValidator.validateAliasStandalone(alias); if (request.indexPatterns.contains(alias.name())) { throw new IllegalArgumentException("Alias [" + alias.name() +
aliasValidator.validateAliasStandalone(alias); if (request.template.equals(alias.name())) { throw new IllegalArgumentException("Alias [" + alias.name() + "] cannot be the same as the template pattern [" + request.template + "]");
aliasValidator.validateAliasStandalone(alias); if (request.indexPatterns.contains(alias.name())) { throw new IllegalArgumentException("Alias [" + alias.name() +
private void validateAlias(String alias, String index, String indexRouting, MetaData metaData) { validateAliasStandalone(alias, indexRouting); if (!Strings.hasText(index)) { throw new IllegalArgumentException("index name is required"); } assert metaData != null; if (metaData.hasIndex(alias)) { throw new InvalidAliasNameException(new Index(index), alias, "an index exists with the same name as the alias"); } }
/** * Allows to partially validate an alias, without knowing which index it'll get applied to. * Useful with index templates containing aliases. Checks also that it is possible to parse * the alias filter via {@link org.elasticsearch.common.xcontent.XContentParser}, * without validating it as a filter though. * @throws IllegalArgumentException if the alias is not valid */ public void validateAliasStandalone(Alias alias) { validateAliasStandalone(alias.name(), alias.indexRouting()); if (Strings.hasLength(alias.filter())) { try { XContentHelper.convertToMap(XContentFactory.xContent(alias.filter()), alias.filter(), false); } catch (Exception e) { throw new IllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e); } } }
/** * Allows to partially validate an alias, without knowing which index it'll get applied to. * Useful with index templates containing aliases. Checks also that it is possible to parse * the alias filter via {@link org.elasticsearch.common.xcontent.XContentParser}, * without validating it as a filter though. * @throws IllegalArgumentException if the alias is not valid */ public void validateAliasStandalone(Alias alias) { validateAliasStandalone(alias.name(), alias.indexRouting()); if (Strings.hasLength(alias.filter())) { try { XContentHelper.convertToMap(XContentFactory.xContent(alias.filter()), alias.filter(), false); } catch (Exception e) { throw new IllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e); } } }
/** * Allows to partially validate an alias, without knowing which index it'll get applied to. * Useful with index templates containing aliases. Checks also that it is possible to parse * the alias filter via {@link org.elasticsearch.common.xcontent.XContentParser}, * without validating it as a filter though. * @throws IllegalArgumentException if the alias is not valid */ public void validateAliasStandalone(Alias alias) { validateAliasStandalone(alias.name(), alias.indexRouting()); if (Strings.hasLength(alias.filter())) { try { XContentHelper.convertToMap(XContentFactory.xContent(alias.filter()), alias.filter(), false); } catch (Exception e) { throw new IllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e); } } }
/** * Allows to partially validate an alias, without knowing which index it'll get applied to. * Useful with index templates containing aliases. Checks also that it is possible to parse * the alias filter via {@link org.elasticsearch.common.xcontent.XContentParser}, * without validating it as a filter though. * @throws IllegalArgumentException if the alias is not valid */ public void validateAliasStandalone(Alias alias) { validateAliasStandalone(alias.name(), alias.indexRouting()); if (Strings.hasLength(alias.filter())) { try (XContentParser parser = XContentFactory.xContent(alias.filter()).createParser(alias.filter())) { parser.map(); } catch (Throwable e) { throw new IllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e); } } }