private NotFoundException newIndexNotFoundException( IndexDefinition index, KernelException e ) { return new NotFoundException( "No index was found corresponding to " + index + ".", e ); }
public final <T> T getSingleManagementBean( Class<T> type ) { Iterator<T> beans = getManagementBeans( type ).iterator(); if ( beans.hasNext() ) { T bean = beans.next(); if ( beans.hasNext() ) { throw new NotFoundException( "More than one management bean for " + type.getName() ); } return bean; } throw new NotFoundException( "No management bean found for " + type.getName() ); }
public T getSingle() { final Iterator<T> expanded = iterator(); if ( expanded.hasNext() ) { final T result = expanded.next(); if ( expanded.hasNext() ) { throw new NotFoundException( "More than one relationship found for " + this ); } return result; } return null; }
private static <T> int[] resolveAndValidateTokens( String tokenTypeName, T[] tokens, Function<T,String> getTokenName, ToIntFunction<String> getTokenId ) { int[] tokenIds = new int[tokens.length]; for ( int i = 0; i < tokenIds.length; i++ ) { String tokenName = getTokenName.apply( tokens[i] ); int tokenId = getTokenId.applyAsInt( tokenName ); if ( tokenId == TokenRead.NO_TOKEN ) { throw new NotFoundException( tokenTypeName + " " + tokenName + " not found." ); } tokenIds[i] = tokenId; } return tokenIds; }
@Override public IndexHits<T> query( String key, Object queryOrQueryObject ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return type.query( ktx, name, key, queryOrQueryObject, gds ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public IndexHits<T> get( String key, Object value ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return internalGet( key, value, ktx ) ; } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public IndexHits<T> query( Object queryOrQueryObject ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return type.query( ktx, name, queryOrQueryObject, gds ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
private RecordProxy<NodeRecord,Void> getNodeRecord( long id ) { if ( id < 0 || id >= nodeStore.getHighId() ) { throw new NotFoundException( "id=" + id ); } return recordAccess.getNodeRecords().getOrLoad( id, null ); }
private RecordProxy<RelationshipRecord,Void> getRelationshipRecord( long id ) { if ( id < 0 || id >= relationshipStore.getHighId() ) { throw new NotFoundException( "id=" + id ); } return recordAccess.getRelRecords().getOrLoad( id, null ); }
@Override public long getOtherNodeId( long id ) { long start = sourceId(); long end = targetId(); if ( start == id ) { return end; } if ( end == id ) { return start; } throw new NotFoundException( "Node[" + id + "] not connected to this relationship[" + getId() + "]" ); }
public IndexedEntityRepresentation getIndexedNode( String indexName, String key, String value, long id ) { if ( !nodeIsIndexed( indexName, key, value, id ) ) { throw new NotFoundException(); } Node node = graphDb.getNodeById( id ); return new IndexedEntityRepresentation( node, key, value, new NodeIndexRepresentation( indexName, Collections.emptyMap() ) ); }
public IndexedEntityRepresentation getIndexedRelationship( String indexName, String key, String value, long id ) { if ( !relationshipIsIndexed( indexName, key, value, id ) ) { throw new NotFoundException(); } Relationship node = graphDb.getRelationshipById( id ); return new IndexedEntityRepresentation( node, key, value, new RelationshipIndexRepresentation( indexName, Collections.emptyMap() ) ); }
public void removeNodeIndex( String indexName ) { if ( !graphDb.index().existsForNodes( indexName ) ) { throw new NotFoundException( "No node index named '" + indexName + "'." ); } graphDb.index().forNodes( indexName ).delete(); }
public void removeRelationshipIndex( String indexName ) { if ( !graphDb.index().existsForRelationships( indexName ) ) { throw new NotFoundException( "No relationship index named '" + indexName + "'." ); } graphDb.index().forRelationships( indexName ).delete(); }
private void singleNode( KernelTransaction transaction, NodeCursor nodes ) { transaction.dataRead().singleNode( nodeId, nodes ); if ( !nodes.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.NODE, nodeId ) ); } }
private void singleRelationship( KernelTransaction transaction, RelationshipScanCursor relationships ) { transaction.dataRead().singleRelationship( id, relationships ); if ( !relationships.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.RELATIONSHIP, id ) ); } } }
BatchRelationshipIterable( RecordStorageReader storageReader, long nodeId ) { relationshipCursor = storageReader.allocateRelationshipTraversalCursor(); RecordNodeCursor nodeCursor = storageReader.allocateNodeCursor(); nodeCursor.single( nodeId ); if ( !nodeCursor.next() ) { throw new NotFoundException( "Node " + nodeId + " not found" ); } relationshipCursor.init( nodeId, nodeCursor.allRelationshipsReference() ); }
@Test( expected = QueryExecutionException.class ) public void dirtyContextEntityNotFoundExceptionDuringResultVisitResultInUnstableSnapshotException() throws Exception { Result result = database.execute( "MATCH (n) RETURN n.c" ); result.accept( (Result.ResultVisitor<Exception>) row -> { testCursorContext.markAsDirty(); throw new NotFoundException( new RuntimeException() ); } ); }
@Override public IndexHits<Relationship> get( String key, Object valueOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, valueOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@SuppressWarnings( "rawtypes" ) public PathRepresentation findSinglePath( long startId, long endId, Map<String,Object> map ) { FindParams findParams = new FindParams( startId, endId, map ).invoke(); PathFinder finder = findParams.getFinder(); Node startNode = findParams.getStartNode(); Node endNode = findParams.getEndNode(); Path path = finder.findSinglePath( startNode, endNode ); if ( path == null ) { throw new NotFoundException(); } return findParams.pathRepresentationOf( path ); }