Search in sources :

Example 1 with UnableToValidateConstraintException

use of org.neo4j.kernel.api.exceptions.schema.UnableToValidateConstraintException in project neo4j by neo4j.

the class ConstraintEnforcingEntityOperations method validateNoExistingNodeWithExactValues.

private void validateNoExistingNodeWithExactValues(KernelStatement state, UniquenessConstraintDescriptor constraint, ExactPredicate[] propertyValues, long modifiedNode) throws ConstraintValidationException {
    try {
        NewIndexDescriptor index = constraint.ownedIndexDescriptor();
        assertIndexOnline(state, index);
        int labelId = index.schema().getLabelId();
        state.locks().optimistic().acquireExclusive(state.lockTracer(), INDEX_ENTRY, indexEntryResourceId(labelId, propertyValues));
        long existing = entityReadOperations.nodeGetFromUniqueIndexSeek(state, index, propertyValues);
        if (existing != NO_SUCH_NODE && existing != modifiedNode) {
            throw new UniquePropertyValueValidationException(constraint, VALIDATION, new IndexEntryConflictException(existing, NO_SUCH_NODE, OrderedPropertyValues.of(propertyValues)));
        }
    } catch (IndexNotFoundKernelException | IndexBrokenKernelException | IndexNotApplicableKernelException e) {
        throw new UnableToValidateConstraintException(constraint, e);
    }
}
Also used : UniquePropertyValueValidationException(org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException) IndexNotApplicableKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) UnableToValidateConstraintException(org.neo4j.kernel.api.exceptions.schema.UnableToValidateConstraintException) IndexBrokenKernelException(org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)

Aggregations

IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)1 IndexNotApplicableKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException)1 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)1 IndexBrokenKernelException (org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException)1 UnableToValidateConstraintException (org.neo4j.kernel.api.exceptions.schema.UnableToValidateConstraintException)1 UniquePropertyValueValidationException (org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException)1 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)1