Search in sources :

Example 1 with IndexWithNameAlreadyExistsException

use of org.neo4j.kernel.api.exceptions.schema.IndexWithNameAlreadyExistsException 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");
    }
}
Also used : ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) NodeKeyConstraintDescriptor(org.neo4j.internal.schema.constraints.NodeKeyConstraintDescriptor) UniquenessConstraintDescriptor(org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor) IndexBackedConstraintDescriptor(org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor) IndexWithNameAlreadyExistsException(org.neo4j.kernel.api.exceptions.schema.IndexWithNameAlreadyExistsException) ConstraintWithNameAlreadyExistsException(org.neo4j.kernel.api.exceptions.schema.ConstraintWithNameAlreadyExistsException) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Aggregations

ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexBackedConstraintDescriptor (org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor)1 NodeKeyConstraintDescriptor (org.neo4j.internal.schema.constraints.NodeKeyConstraintDescriptor)1 UniquenessConstraintDescriptor (org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)1 ConstraintWithNameAlreadyExistsException (org.neo4j.kernel.api.exceptions.schema.ConstraintWithNameAlreadyExistsException)1 IndexWithNameAlreadyExistsException (org.neo4j.kernel.api.exceptions.schema.IndexWithNameAlreadyExistsException)1