use of org.neo4j.kernel.api.exceptions.EntityNotFoundException in project neo4j by neo4j.
the class InternalAutoIndexOperations method propertyRemoved.
@Override
public void propertyRemoved(DataWriteOperations ops, long entityId, int propertyKey) throws AutoIndexingKernelException {
if (enabled) {
try {
String name = propertyKeyLookup.getTokenById(propertyKey).name();
if (propertyKeysToInclude.get().contains(name)) {
ensureIndexExists(ops);
type.remove(ops, entityId, name);
}
} catch (LegacyIndexNotFoundKernelException | EntityNotFoundException e) {
throw new AutoIndexingKernelException(e);
} catch (TokenNotFoundException e) {
// KernelException now
throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(propertyKey, e));
}
}
}
use of org.neo4j.kernel.api.exceptions.EntityNotFoundException in project neo4j by neo4j.
the class NodeProxy method getAllProperties.
@Override
public Map<String, Object> getAllProperties() {
try (Statement statement = actions.statement()) {
try (Cursor<NodeItem> node = statement.readOperations().nodeCursorById(nodeId)) {
try (Cursor<PropertyItem> propertyCursor = statement.readOperations().nodeGetProperties(node.get())) {
Map<String, Object> properties = new HashMap<>();
// Get all properties
while (propertyCursor.next()) {
String name = statement.readOperations().propertyKeyGetName(propertyCursor.get().propertyKeyId());
properties.put(name, propertyCursor.get().value());
}
return properties;
}
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node not found", e);
}
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
}
}
use of org.neo4j.kernel.api.exceptions.EntityNotFoundException in project neo4j by neo4j.
the class NodeProxy method getProperty.
@Override
public Object getProperty(String key) throws NotFoundException {
if (null == key) {
throw new IllegalArgumentException("(null) property key is not allowed");
}
try (Statement statement = actions.statement()) {
try {
int propertyKeyId = statement.readOperations().propertyKeyGetForName(key);
if (propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY) {
throw new NotFoundException(format("No such property, '%s'.", key));
}
Object value = statement.readOperations().nodeGetProperty(nodeId, propertyKeyId);
if (value == null) {
throw new PropertyNotFoundException(propertyKeyId, EntityType.NODE, nodeId);
}
return value;
} catch (EntityNotFoundException | PropertyNotFoundException e) {
throw new NotFoundException(e.getUserMessage(new StatementTokenNameLookup(statement.readOperations())), e);
}
}
}
use of org.neo4j.kernel.api.exceptions.EntityNotFoundException in project neo4j by neo4j.
the class NodeProxy method getDegree.
@Override
public int getDegree(RelationshipType type) {
try (Statement statement = actions.statement()) {
ReadOperations ops = statement.readOperations();
int typeId = ops.relationshipTypeGetForName(type.name());
if (typeId == NO_ID) {
// This type doesn't even exist. Return 0
return 0;
}
return ops.nodeGetDegree(nodeId, Direction.BOTH, typeId);
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node not found.", e);
}
}
use of org.neo4j.kernel.api.exceptions.EntityNotFoundException in project neo4j by neo4j.
the class InternalAutoIndexOperations method entityRemoved.
@Override
public void entityRemoved(DataWriteOperations ops, long entityId) throws AutoIndexingKernelException {
if (enabled) {
try {
ensureIndexExists(ops);
type.remove(ops, entityId);
} catch (LegacyIndexNotFoundKernelException | EntityNotFoundException e) {
throw new AutoIndexingKernelException(e);
}
}
}
Aggregations