use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.
the class SchemaImpl method getIndexState.
@Override
public IndexState getIndexState(final IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
InternalIndexState indexState = readOps.indexGetState(descriptor);
switch(indexState) {
case POPULATING:
return POPULATING;
case ONLINE:
return ONLINE;
case FAILED:
return FAILED;
default:
throw new IllegalArgumentException(String.format("Illegal index state %s", indexState));
}
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.
the class SchemaImpl method getIndexFailure.
@Override
public String getIndexFailure(IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
return readOps.indexGetFailure(descriptor);
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.
the class AwaitIndexProcedureTest method shouldThrowAnExceptionIfTheIndexDoesNotExist.
@Test
public void shouldThrowAnExceptionIfTheIndexDoesNotExist() throws SchemaRuleNotFoundException, IndexNotFoundKernelException {
when(operations.propertyKeyGetForName(anyString())).thenReturn(0);
when(operations.labelGetForName(anyString())).thenReturn(0);
when(operations.indexGetForLabelAndPropertyKey(any())).thenThrow(new SchemaRuleNotFoundException(INDEX_RULE, SchemaDescriptorFactory.forLabel(0, 0)));
try {
procedure.awaitIndex(":Person(name)", timeout, timeoutUnits);
fail("Expected an exception");
} catch (ProcedureException e) {
assertThat(e.status(), is(Status.Schema.IndexNotFound));
}
}
use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.
the class ResampleIndexProcedureTest method shouldThrowAnExceptionIfTheIndexDoesNotExist.
@Test
public void shouldThrowAnExceptionIfTheIndexDoesNotExist() throws SchemaRuleNotFoundException, IndexNotFoundKernelException {
when(operations.labelGetForName(anyString())).thenReturn(0);
when(operations.propertyKeyGetForName(anyString())).thenReturn(0);
when(operations.indexGetForLabelAndPropertyKey(any())).thenThrow(new SchemaRuleNotFoundException(INDEX_RULE, SchemaDescriptorFactory.forLabel(0, 0)));
try {
procedure.resampleIndex(":Person(name)");
fail("Expected an exception");
} catch (ProcedureException e) {
assertThat(e.status(), is(Status.Schema.IndexNotFound));
}
}
Aggregations