use of org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException in project neo4j by neo4j.
the class RelationshipProxy method setProperty.
@Override
public void setProperty(String key, Object value) {
try (Statement statement = actions.statement()) {
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName(key);
statement.dataWriteOperations().relationshipSetProperty(getId(), Property.property(propertyKeyId, value));
} catch (IllegalArgumentException e) {
// Trying to set an illegal value is a critical error - fail this transaction
actions.failTransaction();
throw e;
} catch (EntityNotFoundException e) {
throw new NotFoundException(e);
} catch (IllegalTokenNameException e) {
// TODO: Maybe throw more context-specific error than just IllegalArgument
throw new IllegalArgumentException(e);
} catch (InvalidTransactionTypeKernelException e) {
throw new ConstraintViolationException(e.getMessage(), e);
} catch (AutoIndexingKernelException e) {
throw new IllegalStateException("Auto indexing encountered a failure while setting property: " + e.getMessage(), e);
}
}
use of org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException in project neo4j by neo4j.
the class NodeProxy method createRelationshipTo.
@Override
public Relationship createRelationshipTo(Node otherNode, RelationshipType type) {
if (otherNode == null) {
throw new IllegalArgumentException("Other node is null.");
}
//}
try (Statement statement = actions.statement()) {
int relationshipTypeId = statement.tokenWriteOperations().relationshipTypeGetOrCreateForName(type.name());
long relationshipId = statement.dataWriteOperations().relationshipCreate(relationshipTypeId, nodeId, otherNode.getId());
return actions.newRelationshipProxy(relationshipId, nodeId, relationshipTypeId, otherNode.getId());
} catch (IllegalTokenNameException | RelationshipTypeIdNotFoundKernelException e) {
throw new IllegalArgumentException(e);
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node[" + e.entityId() + "] is deleted and cannot be used to create a relationship");
} catch (InvalidTransactionTypeKernelException e) {
throw new ConstraintViolationException(e.getMessage(), e);
}
}
Aggregations