Search in sources :

Example 16 with NotFoundException

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);
}
Also used : Relationship(org.neo4j.graphdb.Relationship) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) QueryContext(org.neo4j.index.lucene.QueryContext)

Example 17 with NotFoundException

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);
}
Also used : RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) Node(org.neo4j.graphdb.Node) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) PropertiesRepresentation(org.neo4j.server.rest.repr.PropertiesRepresentation) ScoredNodeRepresentation(org.neo4j.server.rest.repr.ScoredNodeRepresentation) NodeRepresentation(org.neo4j.server.rest.repr.NodeRepresentation) ScoredRelationshipRepresentation(org.neo4j.server.rest.repr.ScoredRelationshipRepresentation) PathRepresentation(org.neo4j.server.rest.repr.PathRepresentation) ConstraintDefinitionRepresentation(org.neo4j.server.rest.repr.ConstraintDefinitionRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) Representation(org.neo4j.server.rest.repr.Representation) IndexDefinitionRepresentation(org.neo4j.server.rest.repr.IndexDefinitionRepresentation) WeightedPathRepresentation(org.neo4j.server.rest.repr.WeightedPathRepresentation) RelationshipIndexRootRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRootRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipRepresentation(org.neo4j.server.rest.repr.RelationshipRepresentation) ValueRepresentation(org.neo4j.server.rest.repr.ValueRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRootRepresentation(org.neo4j.server.rest.repr.NodeIndexRootRepresentation) DatabaseRepresentation(org.neo4j.server.rest.repr.DatabaseRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) IterableWrapper(org.neo4j.helpers.collection.IterableWrapper) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation)

Example 18 with NotFoundException

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);
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Relationship(org.neo4j.graphdb.Relationship) NotFoundException(org.neo4j.graphdb.NotFoundException)

Example 19 with NotFoundException

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);
    }
}
Also used : BadInputException(org.neo4j.server.rest.repr.BadInputException) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) EvaluationException(org.neo4j.server.rest.domain.EvaluationException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ListEntityRepresentation(org.neo4j.server.rest.repr.ListEntityRepresentation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 20 with NotFoundException

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);
}
Also used : RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) Relationship(org.neo4j.graphdb.Relationship) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) PropertiesRepresentation(org.neo4j.server.rest.repr.PropertiesRepresentation) ScoredNodeRepresentation(org.neo4j.server.rest.repr.ScoredNodeRepresentation) NodeRepresentation(org.neo4j.server.rest.repr.NodeRepresentation) ScoredRelationshipRepresentation(org.neo4j.server.rest.repr.ScoredRelationshipRepresentation) PathRepresentation(org.neo4j.server.rest.repr.PathRepresentation) ConstraintDefinitionRepresentation(org.neo4j.server.rest.repr.ConstraintDefinitionRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) Representation(org.neo4j.server.rest.repr.Representation) IndexDefinitionRepresentation(org.neo4j.server.rest.repr.IndexDefinitionRepresentation) WeightedPathRepresentation(org.neo4j.server.rest.repr.WeightedPathRepresentation) RelationshipIndexRootRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRootRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipRepresentation(org.neo4j.server.rest.repr.RelationshipRepresentation) ValueRepresentation(org.neo4j.server.rest.repr.ValueRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRootRepresentation(org.neo4j.server.rest.repr.NodeIndexRootRepresentation) DatabaseRepresentation(org.neo4j.server.rest.repr.DatabaseRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) IterableWrapper(org.neo4j.helpers.collection.IterableWrapper) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation)

Aggregations

NotFoundException (org.neo4j.graphdb.NotFoundException)87 Node (org.neo4j.graphdb.Node)43 Test (org.junit.Test)36 Relationship (org.neo4j.graphdb.Relationship)24 Transaction (org.neo4j.graphdb.Transaction)24 Statement (org.neo4j.kernel.api.Statement)18 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)14 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)13 ReentrantLock (java.util.concurrent.locks.ReentrantLock)8 EndNodeNotFoundException (org.neo4j.server.rest.domain.EndNodeNotFoundException)7 StartNodeNotFoundException (org.neo4j.server.rest.domain.StartNodeNotFoundException)7 RelationshipType (org.neo4j.graphdb.RelationshipType)5 ReadOperations (org.neo4j.kernel.api.ReadOperations)4 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)4 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)4 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)4 Race (org.neo4j.test.Race)4 ArrayList (java.util.ArrayList)3 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)3 StatementTokenNameLookup (org.neo4j.kernel.api.StatementTokenNameLookup)3