use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class NodeManager method getNodeForProxy.
NodeImpl getNodeForProxy(long nodeId) {
NodeImpl node = nodeCache.get(nodeId);
if (node != null) {
return node;
}
ReentrantLock loadLock = lockId(nodeId);
try {
node = nodeCache.get(nodeId);
if (node != null) {
return node;
}
if (!persistenceManager.loadLightNode(nodeId)) {
throw new NotFoundException("Node[" + nodeId + "] not found.");
}
node = new NodeImpl(nodeId);
nodeCache.put(nodeId, node);
return node;
} finally {
loadLock.unlock();
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class NodeManager method getRelationshipById.
public Relationship getRelationshipById(long relId) throws NotFoundException {
RelationshipImpl relationship = relCache.get(relId);
if (relationship != null) {
return new RelationshipProxy(relId, this);
}
ReentrantLock loadLock = lockId(relId);
try {
relationship = relCache.get(relId);
if (relationship != null) {
return new RelationshipProxy(relId, this);
}
RelationshipRecord data = persistenceManager.loadLightRelationship(relId);
if (data == null) {
throw new NotFoundException("Relationship[" + relId + "]");
}
int typeId = data.getType();
RelationshipType type = getRelationshipTypeById(typeId);
if (type == null) {
throw new NotFoundException("Relationship[" + data.getId() + "] exist but relationship type[" + typeId + "] not found.");
}
final long startNodeId = data.getFirstNode();
final long endNodeId = data.getSecondNode();
relationship = newRelationshipImpl(relId, startNodeId, endNodeId, type, typeId, false);
relCache.put(relId, relationship);
return new RelationshipProxy(relId, this);
} finally {
loadLock.unlock();
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class NodeManager method getRelForProxy.
RelationshipImpl getRelForProxy(long relId) {
RelationshipImpl relationship = relCache.get(relId);
if (relationship != null) {
return relationship;
}
ReentrantLock loadLock = lockId(relId);
try {
relationship = relCache.get(relId);
if (relationship != null) {
return relationship;
}
RelationshipRecord data = persistenceManager.loadLightRelationship(relId);
if (data == null) {
throw new NotFoundException("Relationship[" + relId + "] not found.");
}
int typeId = data.getType();
RelationshipType type = getRelationshipTypeById(typeId);
if (type == null) {
throw new NotFoundException("Relationship[" + data.getId() + "] exist but relationship type[" + typeId + "] not found.");
}
relationship = newRelationshipImpl(relId, data.getFirstNode(), data.getSecondNode(), type, typeId, false);
relCache.put(relId, relationship);
return relationship;
} finally {
loadLock.unlock();
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class AbstractShellIT method assertNodeDoesntExist.
protected void assertNodeDoesntExist(long id) {
try (Transaction ignore = db.beginTx()) {
db.getNodeById(id);
fail("Relationship " + id + " shouldn't exist");
} catch (NotFoundException e) {
// Good
}
}
use of org.neo4j.graphdb.NotFoundException in project blueprints by tinkerpop.
the class Neo4jGraph method removeVertex.
public void removeVertex(final Vertex vertex) {
this.autoStartTransaction();
try {
final Node node = ((Neo4jVertex) vertex).getRawVertex();
for (final Relationship relationship : node.getRelationships(org.neo4j.graphdb.Direction.BOTH)) {
relationship.delete();
}
node.delete();
} catch (NotFoundException nfe) {
throw ExceptionFactory.vertexWithIdDoesNotExist(vertex.getId());
} catch (IllegalStateException ise) {
// wrap the neo4j exception so that the message is consistent in blueprints.
throw ExceptionFactory.vertexWithIdDoesNotExist(vertex.getId());
}
}
Aggregations