Search in sources :

Example 6 with InvalidTransactionTypeKernelException

use of org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException in project neo4j by neo4j.

the class NodeEntity method createRelationshipTo.

@Override
public Relationship createRelationshipTo(Node otherNode, RelationshipType type) {
    if (otherNode == null) {
        throw new IllegalArgumentException("Other node is null.");
    }
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    int relationshipTypeId;
    try {
        relationshipTypeId = transaction.tokenWrite().relationshipTypeGetOrCreateForName(type.name());
    } catch (IllegalTokenNameException e) {
        throw new IllegalArgumentException(e);
    } catch (TokenCapacityExceededKernelException e) {
        throw new ConstraintViolationException(e.getMessage(), e);
    } catch (KernelException e) {
        throw new TransactionFailureException("Unknown error trying to create relationship type token", e);
    }
    try {
        long relationshipId = transaction.dataWrite().relationshipCreate(nodeId, relationshipTypeId, otherNode.getId());
        return internalTransaction.newRelationshipEntity(relationshipId, nodeId, relationshipTypeId, otherNode.getId());
    } 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);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException) TokenCapacityExceededKernelException(org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException) EntityNotFoundException(org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException) IllegalTokenNameException(org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) TokenCapacityExceededKernelException(org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException) LabelNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException) KernelException(org.neo4j.exceptions.KernelException)

Example 7 with InvalidTransactionTypeKernelException

use of org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException in project neo4j by neo4j.

the class RelationshipEntity method removeProperty.

@Override
public Object removeProperty(String key) {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    int propertyKeyId;
    try {
        propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName(key);
    } catch (IllegalTokenNameException e) {
        throw new IllegalArgumentException(format("Invalid property key '%s'.", key), e);
    } catch (KernelException e) {
        throw new TransactionFailureException("Unknown error trying to get property key token", e);
    }
    try {
        return transaction.dataWrite().relationshipRemoveProperty(id, propertyKeyId).asObjectCopy();
    } catch (InvalidTransactionTypeKernelException e) {
        throw new ConstraintViolationException(e.getMessage(), e);
    } catch (EntityNotFoundException e) {
        throw new NotFoundException(e);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException) EntityNotFoundException(org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException) IllegalTokenNameException(org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) TokenCapacityExceededKernelException(org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException) KernelException(org.neo4j.exceptions.KernelException)

Aggregations

InvalidTransactionTypeKernelException (org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException)7 KernelException (org.neo4j.exceptions.KernelException)4 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)4 NotFoundException (org.neo4j.graphdb.NotFoundException)4 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)4 EntityNotFoundException (org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException)4 PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)4 IllegalTokenNameException (org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException)4 TokenCapacityExceededKernelException (org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 Test (org.junit.jupiter.api.Test)2 LabelNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException)2 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)1 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)1 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)1 Locks (org.neo4j.kernel.impl.locking.Locks)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1 StorageReader (org.neo4j.storageengine.api.StorageReader)1