private void assertNodeExists( long sourceNode ) throws EntityNotFoundException { if ( !allStoreHolder.nodeExists( sourceNode ) ) { throw new EntityNotFoundException( EntityType.NODE, sourceNode ); } }
throw new NotFoundException( "Node[" + e.entityId() + "] is deleted and cannot be used to create a relationship" );
@Test public void shouldNotAllowModifyingPropertiesOnDeletedRelationship() throws Exception { // given Transaction transaction = newTransaction( AnonymousContext.writeToken() ); int prop1 = transaction.tokenWrite().propertyKeyGetOrCreateForName( "prop1" ); int type = transaction.tokenWrite().relationshipTypeGetOrCreateForName( "RELATED" ); long startNodeId = transaction.dataWrite().nodeCreate(); long endNodeId = transaction.dataWrite().nodeCreate(); long rel = transaction.dataWrite().relationshipCreate( startNodeId, type, endNodeId ); transaction.dataWrite().relationshipSetProperty( rel, prop1, Values.stringValue( "As" ) ); transaction.dataWrite().relationshipDelete( rel ); // When try { transaction.dataWrite().relationshipRemoveProperty( rel, prop1 ); fail( "Should have failed." ); } catch ( EntityNotFoundException e ) { assertThat( e.getMessage(), equalTo( "Unable to load RELATIONSHIP with id " + rel + "." ) ); } commit(); }
throw new NotFoundException( "Node[" + e.entityId() + "] is deleted and cannot be used to create a relationship" );
private void singleNode( long node ) throws EntityNotFoundException { allStoreHolder.singleNode( node, nodeCursor ); if ( !nodeCursor.next() ) { throw new EntityNotFoundException( EntityType.NODE, node ); } }
private void singleRelationship( long relationship ) throws EntityNotFoundException { allStoreHolder.singleRelationship( relationship, relationshipCursor ); if ( !relationshipCursor.next() ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationship ); } }
private static void singleNode( Read read, NodeCursor nodeCursor, long node ) throws EntityNotFoundException { read.singleNode( node, nodeCursor ); if ( !nodeCursor.next() ) { throw new EntityNotFoundException( EntityType.NODE, node ); } }
private static void singleRelationship( Read read, RelationshipScanCursor relationships, long relationship ) throws EntityNotFoundException { read.singleRelationship( relationship, relationships ); if ( !relationships.next() ) { throw new EntityNotFoundException( EntityType.NODE, relationship ); } } }
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 ) ); } } }
@Override public Node getNodeById( long id ) { if ( id < 0 ) { throw new NotFoundException( format( "Node %d not found", id ), new EntityNotFoundException( EntityType.NODE, id ) ); } KernelTransaction ktx = statementContext.getKernelTransactionBoundToThisThread( true ); assertTransactionOpen( ktx ); try ( Statement ignore = ktx.acquireStatement() ) { if ( !ktx.dataRead().nodeExists( id ) ) { throw new NotFoundException( format( "Node %d not found", id ), new EntityNotFoundException( EntityType.NODE, id ) ); } return newNodeProxy( id ); } }
@Override public Relationship getRelationshipById( long id ) { if ( id < 0 ) { throw new NotFoundException( format( "Relationship %d not found", id ), new EntityNotFoundException( EntityType.RELATIONSHIP, id ) ); } KernelTransaction ktx = statementContext.getKernelTransactionBoundToThisThread( true ); assertTransactionOpen( ktx ); try ( Statement ignore = statementContext.get() ) { if ( !ktx.dataRead().relationshipExists( id ) ) { throw new NotFoundException( format( "Relationship %d not found", id ), new EntityNotFoundException( EntityType.RELATIONSHIP, id ) ); } return newRelationshipProxy( id ); } }
@Override public <EXCEPTION extends Exception> void relationshipVisit( long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor ) throws EntityNotFoundException, EXCEPTION { RelationshipData data = this.relationshipData.get( relationshipId ); if ( data == null ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationshipId ); } relationshipVisitor.visit( relationshipId, data.type, data.startNode, data.endNode ); }
@Override public <EXCEPTION extends Exception> void relationshipVisit( long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor ) throws EntityNotFoundException, EXCEPTION { // TODO Please don't create a record for this, it's ridiculous RelationshipRecord record = relationshipStore.getRecord( relationshipId, relationshipStore.newRecord(), CHECK ); if ( !record.inUse() ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationshipId ); } relationshipVisitor.visit( relationshipId, record.getType(), record.getFirstNode(), record.getSecondNode() ); }
@Override public void relationshipAddToExplicitIndex( String indexName, long relationship, String key, Object value ) throws ExplicitIndexNotFoundKernelException, EntityNotFoundException { ktx.assertOpen(); allStoreHolder.singleRelationship( relationship, relationshipCursor ); if ( relationshipCursor.next() ) { allStoreHolder.explicitIndexTxState().relationshipChanges( indexName ).addRelationship( relationship, key, value, relationshipCursor.sourceNodeReference(), relationshipCursor.targetNodeReference() ); } else { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationship ); } }
@Override public Value getNodePropertyValue( long nodeId, int propertyKeyId ) throws EntityNotFoundException { NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), FORCE ); if ( !node.inUse() ) { throw new EntityNotFoundException( EntityType.NODE, nodeId ); } long firstPropertyId = node.getNextProp(); if ( firstPropertyId == Record.NO_NEXT_PROPERTY.intValue() ) { return Values.NO_VALUE; } for ( PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain( firstPropertyId ) ) { PropertyBlock propertyBlock = propertyRecord.getPropertyBlock( propertyKeyId ); if ( propertyBlock != null ) { return propertyBlock.newPropertyValue( propertyStore ); } } return Values.NO_VALUE; }
private void assertNodeExists( long sourceNode ) throws EntityNotFoundException { if ( !allStoreHolder.nodeExists( sourceNode ) ) { throw new EntityNotFoundException( EntityType.NODE, sourceNode ); } }
private void singleNode( KernelTransaction transaction, NodeCursor nodes ) { transaction.dataRead().singleNode( nodeId, nodes ); if ( !nodes.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.NODE, nodeId ) ); } }
private static void singleRelationship( Read read, RelationshipScanCursor relationships, long relationship ) throws EntityNotFoundException { read.singleRelationship( relationship, relationships ); if ( !relationships.next() ) { throw new EntityNotFoundException( EntityType.NODE, relationship ); } } }
private void singleRelationship( long relationship ) throws EntityNotFoundException { allStoreHolder.singleRelationship( relationship, relationshipCursor ); if ( !relationshipCursor.next() ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationship ); } }