use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class DatabaseActions method getIndexedRelationshipsByQuery.
public ListRepresentation getIndexedRelationshipsByQuery(String indexName, String key, String query, String sort) {
if (!graphDb.index().existsForRelationships(indexName)) {
throw new NotFoundException();
}
if (query == null) {
return toListRelationshipRepresentation();
}
Index<Relationship> index = graphDb.index().forRelationships(indexName);
IndexResultOrder order = getOrdering(sort);
QueryContext queryCtx = order.updateQueryContext(new QueryContext(query));
return toListRelationshipRepresentation(index.query(key, queryCtx), order);
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class DatabaseActions method getIndexedNodes.
public ListRepresentation getIndexedNodes(String indexName, final String key, final String value) {
if (!graphDb.index().existsForNodes(indexName)) {
throw new NotFoundException();
}
Index<Node> index = graphDb.index().forNodes(indexName);
final IndexRepresentation indexRepresentation = new NodeIndexRepresentation(indexName);
final IndexHits<Node> indexHits = index.get(key, value);
final IterableWrapper<Representation, Node> results = new IterableWrapper<Representation, Node>(indexHits) {
@Override
protected Representation underlyingObjectToObject(Node node) {
return new IndexedEntityRepresentation(node, key, value, indexRepresentation);
}
};
return new ListRepresentation(RepresentationType.NODE, results);
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class ExtensionService method relationship.
private Relationship relationship(long id) throws RelationshipNotFoundException {
try (Transaction tx = graphDb.beginTx()) {
Relationship relationship = graphDb.getRelationshipById(id);
tx.success();
return relationship;
} catch (NotFoundException e) {
throw new RelationshipNotFoundException(e);
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class RestfulGraphDatabase method createPagedTraverser.
@POST
@Path(PATH_TO_CREATE_PAGED_TRAVERSERS)
public Response createPagedTraverser(@PathParam("nodeId") long startNode, @PathParam("returnType") TraverserReturnType returnType, @QueryParam("pageSize") @DefaultValue(FIFTY_ENTRIES) int pageSize, @QueryParam("leaseTime") @DefaultValue(SIXTY_SECONDS) int leaseTimeInSeconds, String body) {
try {
validatePageSize(pageSize);
validateLeaseTime(leaseTimeInSeconds);
String traverserId = actions.createPagedTraverser(startNode, input.readMap(body), pageSize, leaseTimeInSeconds);
URI uri = new URI("node/" + startNode + "/paged/traverse/" + returnType + "/" + traverserId);
return output.created(new ListEntityRepresentation(actions.pagedTraverse(traverserId, returnType), uri.normalize()));
} catch (EvaluationException e) {
return output.badRequest(e);
} catch (BadInputException e) {
return output.badRequest(e);
} catch (NotFoundException e) {
return output.notFound(e);
} catch (URISyntaxException e) {
return output.serverError(e);
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class DatabaseActions method getIndexedRelationships.
public ListRepresentation getIndexedRelationships(String indexName, final String key, final String value) {
if (!graphDb.index().existsForRelationships(indexName)) {
throw new NotFoundException();
}
Index<Relationship> index = graphDb.index().forRelationships(indexName);
final IndexRepresentation indexRepresentation = new RelationshipIndexRepresentation(indexName);
IterableWrapper<Representation, Relationship> result = new IterableWrapper<Representation, Relationship>(index.get(key, value)) {
@Override
protected Representation underlyingObjectToObject(Relationship relationship) {
return new IndexedEntityRepresentation(relationship, key, value, indexRepresentation);
}
};
return new ListRepresentation(RepresentationType.RELATIONSHIP, result);
}
Aggregations