Search in sources :

Example 1 with PropertyNotFoundException

use of org.neo4j.kernel.api.exceptions.PropertyNotFoundException in project neo4j by neo4j.

the class RelationshipProxy method getProperty.

@Override
public Object getProperty(String key) {
    if (null == key) {
        throw new IllegalArgumentException("(null) property key is not allowed");
    }
    try (Statement statement = actions.statement()) {
        try {
            int propertyId = statement.readOperations().propertyKeyGetForName(key);
            if (propertyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY) {
                throw new NotFoundException(String.format("No such property, '%s'.", key));
            }
            Object value = statement.readOperations().relationshipGetProperty(getId(), propertyId);
            if (value == null) {
                throw new PropertyNotFoundException(propertyId, EntityType.RELATIONSHIP, getId());
            }
            return value;
        } catch (EntityNotFoundException | PropertyNotFoundException e) {
            throw new NotFoundException(e.getUserMessage(new StatementTokenNameLookup(statement.readOperations())), e);
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Example 2 with PropertyNotFoundException

use of org.neo4j.kernel.api.exceptions.PropertyNotFoundException in project neo4j by neo4j.

the class InternalAutoIndexOperations method propertyAdded.

@Override
public void propertyAdded(DataWriteOperations ops, long entityId, Property property) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            String name = propertyKeyLookup.getTokenById(property.propertyKeyId()).name();
            if (propertyKeysToInclude.get().contains(name)) {
                ensureIndexExists(ops);
                type.add(ops, entityId, name, property.value());
            }
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException | PropertyNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        } catch (TokenNotFoundException e) {
            // KernelException now
            throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(property.propertyKeyId(), e));
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 3 with PropertyNotFoundException

use of org.neo4j.kernel.api.exceptions.PropertyNotFoundException 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);
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Example 4 with PropertyNotFoundException

use of org.neo4j.kernel.api.exceptions.PropertyNotFoundException in project neo4j by neo4j.

the class InternalAutoIndexOperations method propertyChanged.

@Override
public void propertyChanged(DataWriteOperations ops, long entityId, Property oldProperty, Property newProperty) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            String name = propertyKeyLookup.getTokenById(oldProperty.propertyKeyId()).name();
            if (propertyKeysToInclude.get().contains(name)) {
                ensureIndexExists(ops);
                type.remove(ops, entityId, name, oldProperty.value());
                type.add(ops, entityId, name, newProperty.value());
            }
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException | PropertyNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        } catch (TokenNotFoundException e) {
            // KernelException now
            throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(oldProperty.propertyKeyId(), e));
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 5 with PropertyNotFoundException

use of org.neo4j.kernel.api.exceptions.PropertyNotFoundException in project neo4j by neo4j.

the class GraphPropertiesProxy method getProperty.

@Override
public Object getProperty(String key) {
    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().graphGetProperty(propertyKeyId);
            if (value == null) {
                throw new PropertyNotFoundException(propertyKeyId, EntityType.GRAPH, -1);
            }
            return value;
        } catch (PropertyNotFoundException e) {
            throw new NotFoundException(e.getUserMessage(new StatementTokenNameLookup(statement.readOperations())), e);
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException)

Aggregations

PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)5 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)4 NotFoundException (org.neo4j.graphdb.NotFoundException)3 Statement (org.neo4j.kernel.api.Statement)3 StatementTokenNameLookup (org.neo4j.kernel.api.StatementTokenNameLookup)3 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)2 AutoIndexingKernelException (org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException)2 LegacyIndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException)2 TokenNotFoundException (org.neo4j.kernel.impl.core.TokenNotFoundException)2