use of org.neo4j.kernel.api.exceptions.schema.ConstraintWithNameAlreadyExistsException in project neo4j by neo4j.
the class Operations method assertSchemaRuleWithNameDoesNotExist.
private void assertSchemaRuleWithNameDoesNotExist(String name) throws IndexWithNameAlreadyExistsException, ConstraintWithNameAlreadyExistsException {
// Check constraints first because some of them will also be backed by indexes
final ConstraintDescriptor constraintWithSameName = allStoreHolder.constraintGetForName(name);
if (constraintWithSameName != null) {
throw new ConstraintWithNameAlreadyExistsException(name);
}
final IndexDescriptor indexWithSameName = allStoreHolder.indexGetForName(name);
if (indexWithSameName != IndexDescriptor.NO_INDEX) {
throw new IndexWithNameAlreadyExistsException(name);
}
if (name.equals(IndexDescriptor.NLI_GENERATED_NAME)) {
throw new IllegalArgumentException("The name '" + IndexDescriptor.NLI_GENERATED_NAME + "' is a reserved name and can't be used when creating indexes");
}
}
Aggregations