use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class RelationshipProxy method getPropertyKeys.
@Override
public Iterable<String> getPropertyKeys() {
try (Statement statement = actions.statement()) {
List<String> keys = new ArrayList<>();
PrimitiveIntIterator properties = statement.readOperations().relationshipGetPropertyKeys(getId());
while (properties.hasNext()) {
keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
}
return keys;
} catch (EntityNotFoundException e) {
throw new NotFoundException("Relationship not found", e);
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.");
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class RelationshipProxy method getProperty.
@Override
public Object getProperty(String key, Object defaultValue) {
if (null == key) {
throw new IllegalArgumentException("(null) property key is not allowed");
}
try (Statement statement = actions.statement()) {
int propertyId = statement.readOperations().propertyKeyGetForName(key);
Object value = statement.readOperations().relationshipGetProperty(getId(), propertyId);
return value == null ? defaultValue : value;
} catch (EntityNotFoundException e) {
throw new NotFoundException(e);
}
}
use of org.neo4j.graphdb.NotFoundException 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.graphdb.NotFoundException in project graphdb by neo4j-attic.
the class SingleJvmTest method testMixingEntitiesFromWrongDbs.
@Test
public void testMixingEntitiesFromWrongDbs() throws Exception {
initializeDbs(1);
GraphDatabaseService haDb1 = haDbs.get(0);
GraphDatabaseService mDb = master.getGraphDb();
Transaction tx = mDb.beginTx();
Node masterNode;
try {
masterNode = mDb.createNode();
mDb.getReferenceNode().createRelationshipTo(masterNode, CommonJobs.REL_TYPE);
tx.success();
} finally {
tx.finish();
}
tx = haDb1.beginTx();
// try throw in node that does not exist and no tx on mdb
try {
Node node = haDb1.createNode();
mDb.getReferenceNode().createRelationshipTo(node, CommonJobs.KNOWS);
fail("Should throw not found exception");
} catch (NotFoundException e) {
// good
} finally {
tx.finish();
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class DeferringLocksIT method removeNodeChangeNodeProperty.
@Test(timeout = TEST_TIMEOUT)
public void removeNodeChangeNodeProperty() throws Exception {
// GIVEN
final Barrier.Control barrier = new Barrier.Control();
final long nodeId;
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
nodeId = node.getId();
node.setProperty(PROPERTY_KEY, VALUE_1);
tx.success();
}
// WHEN
Future<Void> future = t2.execute(new WorkerCommand<Void, Void>() {
@Override
public Void doWork(Void state) throws Exception {
try (Transaction tx = db.beginTx()) {
db.getNodeById(nodeId).delete();
tx.success();
barrier.reached();
}
return null;
}
});
try {
try (Transaction tx = db.beginTx()) {
barrier.await();
db.getNodeById(nodeId).setProperty(PROPERTY_KEY, VALUE_2);
tx.success();
barrier.release();
}
} catch (TransactionFailureException e) {
// Node was already deleted, fine.
assertThat(e.getCause(), instanceOf(InvalidRecordException.class));
}
future.get();
try (Transaction tx = db.beginTx()) {
try {
db.getNodeById(nodeId);
assertEquals(VALUE_2, db.getNodeById(nodeId).getProperty(PROPERTY_KEY, VALUE_2));
} catch (NotFoundException e) {
// Fine, its gone
}
tx.success();
}
}
Aggregations