Java 类org.neo4j.graphdb.NotFoundException 实例源码

项目:neo4j-websockets    文件:ExceptionToErrorConverter.java   
public Error convert(final Exception exception) {
    Class errorClass = exception.getClass();
    Class causeClass;

    if (errorClass.equals(ConstraintViolationException.class)) {
        causeClass = exception.getCause().getClass();

        /*if (causeClass.equals(UniqueConstraintViolationKernelException.class)) {
            return analyseUniqueConstraintViolation((ConstraintViolationException) exception);
        }*/
    }
    else if (errorClass.equals(NotFoundException.class)) {
        return analyseNotFound((NotFoundException) exception);
    }

    return new Error(
            Error.EXCEPTION,
            exception.getMessage()
    );
}
项目:neo4j-lucene5-index    文件:TestLuceneIndex.java   
@Ignore( "an issue that should be fixed at some point" )
@Test( expected = NotFoundException.class )
public void shouldNotBeAbleToIndexNodeThatIsNotCommitted() throws Exception
{
    Index<Node> index = nodeIndex(
            LuceneIndexImplementation.EXACT_CONFIG );
    Node node = graphDb.createNode();
    String key = "noob";
    String value = "Johan";

    WorkThread thread = new WorkThread( "other thread", index, graphDb, node );
    thread.beginTransaction();
    try
    {
        thread.add( node, key, value );
    }
    finally
    {
        thread.rollback();
    }
}
项目:neo4j-lucene5-index    文件:TestIndexDeletion.java   
@Test
public void shouldThrowIllegalStateForActionsAfterDeletedOnIndex()
{
    restartTx();
    index.delete();
    restartTx();
    try
    {
        index.query( key, "own" );
        fail( "Should fail" );
    }
    catch ( NotFoundException e )
    {
        assertThat( e.getMessage(), containsString( "doesn't exist" ) );
    }
}
项目:neo4j-mobile-android    文件:BatchGraphDatabaseImpl.java   
public Node getNodeById( long id )
{
    NodeBatchImpl node = nodes.get( id );
    if ( node == null )
    {
        try
        {
            node = new NodeBatchImpl( id, this,
                batchInserter.getNodeProperties( id ) );
            nodes.put( id, node );
        }
        catch ( InvalidRecordException e )
        {
            throw new NotFoundException( e );
        }
    }
    return node;
}
项目:neo4j-mobile-android    文件:BatchGraphDatabaseImpl.java   
public Relationship getRelationshipById( long id )
{
    RelationshipBatchImpl rel = rels.get( id );
    if ( rel == null )
    {
        try
        {
            SimpleRelationship simpleRel =
                batchInserter.getRelationshipById( id );
            Map<String,Object> props =
                batchInserter.getRelationshipProperties( id );
            rel = new RelationshipBatchImpl( simpleRel, this, props );
            rels.put( id, rel );
        }
        catch ( InvalidRecordException e )
        {
            throw new NotFoundException( e );
        }
    }
    return rel;
}
项目:neo4j-mobile-android    文件:BatchGraphDatabaseImpl.java   
public Relationship getSingleRelationship( RelationshipType type,
    Direction dir )
{
    Iterator<Relationship> relItr =
        newRelIterator( dir, new RelationshipType[] { type } );
    if ( relItr.hasNext() )
    {
        Relationship rel = relItr.next();
        if ( relItr.hasNext() )
        {
            throw new NotFoundException( "More than one relationship[" +
                type + ", " + dir + "] found for " + this );
        }
        return rel;
    }
    return null;
}
项目:neo4j-mobile-android    文件:FileUtils.java   
public static boolean renameFile( File srcFile, File renameToFile )
{
    if ( !srcFile.exists() )
    {
        throw new NotFoundException( "Source file[" + srcFile.getName()
                + "] not found" );
    }
    if ( renameToFile.exists() )
    {
        throw new NotFoundException( "Target file[" + renameToFile.getName()
                + "] already exists" );
    }
    int count = 0;
    boolean renamed = false;
    do
    {
        renamed = srcFile.renameTo( renameToFile );
        if ( !renamed )
        {
            count++;
            waitSome();
        }
    }
    while ( !renamed && count <= WINDOWS_RETRY_COUNT );
    return renamed;
}
项目:neo4j-mobile-android    文件:NodeImpl.java   
public Relationship getSingleRelationship( NodeManager nodeManager, RelationshipType type,
    Direction dir )
{
    DirectionWrapper direction = RelIdArray.wrap( dir );
    RelationshipType types[] = new RelationshipType[] { type };
    Iterator<Relationship> rels = new IntArrayIterator( getAllRelationshipsOfType( nodeManager,
            direction, types ), this, direction, nodeManager, types, !hasMoreRelationshipsToLoad() );
    if ( !rels.hasNext() )
    {
        return null;
    }
    Relationship rel = rels.next();
    if ( rels.hasNext() )
    {
        throw new NotFoundException( "More than one relationship[" +
            type + ", " + dir + "] found for " + this );
    }
    return rel;
}
项目:neo4j-mobile-android    文件:PropertyIndexManager.java   
public PropertyIndex getIndexFor( int keyId )
{
    PropertyIndex index = idToIndexMap.get( keyId );
    if ( index == null )
    {
        TxCommitHook commitHook = txCommitHooks.get( getTransaction() );
        if ( commitHook != null )
        {
            index = commitHook.getIndex( keyId );
            if ( index != null )
            {
                return index;
            }
        }
        String indexString;
        indexString = persistenceManager.loadIndex( keyId );
        if ( indexString == null )
        {
            throw new NotFoundException( "Index not found [" + keyId + "]" );
        }
        index = new PropertyIndex( indexString, keyId );
        addPropertyIndex( index );
    }
    return index;
}
项目:neo4j-mobile-android    文件:EmbeddedGraphDbImpl.java   
@Override
public synchronized boolean hasNext()
{
    while ( currentNode == null && currentNodeId <= highId )
    {
        try
        {
            currentNode = getNodeById( currentNodeId++ );
        }
        catch ( NotFoundException e )
        {
            // ok we try next
        }
    }
    return currentNode != null;
}
项目:visitmeta    文件:Neo4JMetadata.java   
@Override
public boolean isSingleValue() {
    // TODO handle false Metadata
    String value = "";
    try (Transaction tx = mRepo.beginTx()) {
        value = (String) mMe.getProperty(KEY_META_CARDINALITY);
        tx.success();
    } catch (NotFoundException e) {
        log.warn("This Metadata does not has the Cardinality-Property set! "
                + this);
    }
    if (value.equals(VALUE_META_CARDINALITY_SINGLE)) {
        return true;
    }
    return false;
}
项目:visitmeta    文件:Neo4JMetadata.java   
@Override
public long getDeleteTimestamp() {
    // TODO handle false Metadata
    if(this.isNotify()) {
        return getPublishTimestamp();
    }
    String value = "";
    try (Transaction tx = mRepo.beginTx()) {
        value = mMe.getProperty(KEY_TIMESTAMP_DELETE,
                InternalMetadata.METADATA_NOT_DELETED_TIMESTAMP + "")
                .toString();
        tx.success();
    } catch (NotFoundException e) {
        log.warn("This Metadata does not has a DeleteTimestamp! " + this);
    }
    return Long.parseLong(value);
}
项目:EvilCoder    文件:Traversals.java   
public static Node getStatementForASTNode(Node node)
{
    Node n = node;
    Node parent = node;

    while (true)
    {

        try
        {
            Object property = n.getProperty(NodeKeys.IS_CFG_NODE);
            return n;
        }
        catch (NotFoundException ex)
        {

        }

        Iterable<Relationship> rels = n
                .getRelationships(Direction.INCOMING);
        for (Relationship rel : rels)
        {
            parent = rel.getStartNode();
            break;
        }

        if (n == parent)
            return null;
        n = parent;
    }
}
项目:neo4j-websockets    文件:ExceptionToErrorConverter.java   
protected Error analyseNotFound(final NotFoundException notFoundException) {
    ObjectNode detailsNode = jsonObjectMapper.getObjectMapper().createObjectNode();

    return new Error(
            Error.NOT_FOUND,
            notFoundException.getMessage(),
            detailsNode
    );
}
项目:neo4j-lucene5-index    文件:TestIndexDeletion.java   
@Test
public void shouldThrowIllegalStateForActionsAfterDeletedOnIndex2()
{
    restartTx();
    index.delete();
    restartTx();
    try
    {
        index.add( node, key, value );
    }
    catch ( NotFoundException e )
    {
        assertThat( e.getMessage(), containsString( "doesn't exist" ) );
    }
}
项目:trainbenchmark    文件:Neo4jApiTransformationRepairPosLength.java   
@Override
public void activate(final Collection<Neo4jPosLengthMatch> matches) {
    for (final Neo4jPosLengthMatch match : matches) {
        final Node segment = match.getSegment();
        try {
            final Number lengthNumber = (Number) segment.getProperty(ModelConstants.LENGTH);
            final int length = Neo4jHelper.numberToInt(lengthNumber);

            segment.setProperty(ModelConstants.LENGTH, -length + 1);
        } catch (final NotFoundException e) {
            // do nothing (node has been removed)
        }
    }
}
项目:trainbenchmark    文件:Neo4jCypherTransformationRepairPosLength.java   
@Override
public void activate(final Collection<Neo4jPosLengthMatch> matches) throws IOException {
    for (final Neo4jPosLengthMatch match : matches) {
        try {
            final Map<String, Object> parameters = ImmutableMap.of( //
                QueryConstants.VAR_SEGMENT, match.getSegment() //
            );
            driver.runTransformation(transformationDefinition, parameters);
        } catch (final NotFoundException e) {
            // do nothing (node has been removed)
        }
    }
}
项目:zerograph    文件:NodeResource.java   
/**
 * GET Node {"id": …}
 *
 * Fetch a single node by ID.
 */
@Override
public PropertyContainer get(RequestInterface request, DatabaseInterface database) throws ClientError, ServerError {
    long id = resolveNode(database, request.getArgument("id")).getId();
    try {
        Node node = database.getNode(id);
        responder.sendBody(node);
        return node;
    } catch (NotFoundException ex) {
        throw new ClientError("Node " + id + " not found");
    }
}
项目:zerograph    文件:NodeResource.java   
/**
 * SET Node {"id": …, "labels": …, "properties": …}
 *
 * Replace all labels and properties on a node identified by ID.
 * This will not create a node with the given ID if one does not
 * already exist.
 */
@Override
public PropertyContainer set(RequestInterface request, DatabaseInterface database) throws ClientError, ServerError {
    long id = resolveNode(database, request.getArgument("id")).getId();
    List labelNames = request.getArgumentAsList("labels");
    Map<String, Object> properties = request.getArgumentAsMap("properties");
    try {
        Node node = database.putNode(id, labelNames, properties);
        responder.sendBody(node);
        return node;
    } catch (NotFoundException ex) {
        throw new ClientError("Node " + id + " not found");
    }
}
项目:zerograph    文件:NodeResource.java   
/**
 * PATCH Node {"id": …, "labels": …}
 * PATCH Node {"id": …, "properties": …}
 * PATCH Node {"id": …, "labels": …, "properties": …}
 *
 * Add new labels and properties to a node identified by ID.
 * This will not create a node with the given ID if one does not
 * already exist and any existing labels and properties will be
 * maintained.
 */
@Override
public PropertyContainer patch(RequestInterface request, DatabaseInterface database) throws ClientError, ServerError {
    long id = resolveNode(database, request.getArgument("id")).getId();
    List labelNames = request.getArgumentAsList("labels", new ArrayList());
    Map<String, Object> properties = request.getArgumentAsMap("properties", new HashMap<String, Object>());
    try {
        Node node = database.patchNode(id, labelNames, properties);
        responder.sendBody(node);
        return node;
    } catch (NotFoundException ex) {
        throw new ClientError("Node " + id + " not found");
    }
}
项目:zerograph    文件:NodeResource.java   
/**
 * DELETE node {"id": …}
 *
 * Delete a node identified by ID.
 */
@Override
public PropertyContainer delete(RequestInterface request, DatabaseInterface database) throws ClientError, ServerError {
    long id = resolveNode(database, request.getArgument("id")).getId();
    try {
        database.deleteNode(id);
        return null;
    } catch (NotFoundException ex) {
        throw new ClientError("Node " + id + " not found");
    }
}
项目:zerograph    文件:RelResource.java   
/**
 * GET Rel {"id": …}
 *
 * Fetch a single relationship by ID.
 */
@Override
public PropertyContainer get(RequestInterface request, DatabaseInterface context) throws ClientError, ServerError {
    long id = request.getArgumentAsLong("id");
    try {
        Relationship rel = context.getRelationship(id);
        responder.sendBody(rel);
        return rel;
    } catch (NotFoundException ex) {
        throw new ClientError("Relationship " + id + " not found!");
    }
}
项目:zerograph    文件:RelResource.java   
/**
 * SET Rel {"id": …, "properties": …}
 *
 * Replace all properties on a relationship identified by ID.
 * This will not create a relationship with the given ID if one does not
 * already exist.
 */
@Override
public PropertyContainer set(RequestInterface request, DatabaseInterface context) throws ClientError, ServerError {
    long id = request.getArgumentAsLong("id");
    Map<String, Object> properties = request.getArgumentAsMap("properties");
    try {
        Relationship rel = context.putRelationship(id, properties);
        responder.sendBody(rel);
        return rel;
    } catch (NotFoundException ex) {
        throw new ClientError("Relationship " + id + " not found");
    }
}
项目:zerograph    文件:RelResource.java   
/**
 * PATCH Rel {"id": …, "properties": …}
 *
 * Add new properties to a relationship identified by ID.
 * This will not create a relationship with the given ID if one does not
 * already exist and any existing properties will be
 * maintained.
 */
@Override
public PropertyContainer patch(RequestInterface request, DatabaseInterface context) throws ClientError, ServerError {
    long id = request.getArgumentAsLong("id");
    Map<String, Object> properties = request.getArgumentAsMap("properties");
    try {
        Relationship rel = context.patchRelationship(id, properties);
        responder.sendBody(rel);
        return rel;
    } catch (NotFoundException ex) {
        throw new ClientError("Relationship " + id + " not found");
    }
}
项目:zerograph    文件:RelResource.java   
/**
 * DELETE Rel {"id": …}
 *
 * Delete a relationship identified by ID.
 */
@Override
public PropertyContainer delete(RequestInterface request, DatabaseInterface context) throws ClientError, ServerError {
    long id = request.getArgumentAsLong("id");
    try {
        context.deleteRelationship(id);
        return null;
    } catch (NotFoundException ex) {
        throw new ClientError("Relationship " + id + " not found");
    }
}
项目:zerograph    文件:Database.java   
@Override
public Node putNode(long id, List labelNames, Map properties) throws NotFoundException {
    Node node = database.getNodeById(id);
    Lock writeLock = transaction.acquireWriteLock(node);
    Lock readLock = transaction.acquireReadLock(node);
    removeLabels(node);
    removeProperties(node);
    addLabels(node, labelNames);
    addProperties(node, properties);
    readLock.release();
    writeLock.release();
    return node;
}
项目:zerograph    文件:Database.java   
@Override
public Node patchNode(long id, List labelNames, Map properties) throws NotFoundException {
    Node node = database.getNodeById(id);
    Lock writeLock = transaction.acquireWriteLock(node);
    Lock readLock = transaction.acquireReadLock(node);
    addLabels(node, labelNames);
    addProperties(node, properties);
    readLock.release();
    writeLock.release();
    return node;
}
项目:zerograph    文件:Database.java   
@Override
public void deleteNode(long id) throws NotFoundException {
    Node node = database.getNodeById(id);
    Lock writeLock = transaction.acquireWriteLock(node);
    node.delete();
    writeLock.release();
}
项目:zerograph    文件:Database.java   
@Override
public Relationship putRelationship(long id, Map properties) throws NotFoundException {
    Relationship rel = database.getRelationshipById(id);
    Lock writeLock = transaction.acquireWriteLock(rel);
    Lock readLock = transaction.acquireReadLock(rel);
    removeProperties(rel);
    addProperties(rel, properties);
    readLock.release();
    writeLock.release();
    return rel;
}
项目:zerograph    文件:Database.java   
@Override
public Relationship patchRelationship(long id, Map properties) throws NotFoundException {
    Relationship rel = database.getRelationshipById(id);
    Lock writeLock = transaction.acquireWriteLock(rel);
    Lock readLock = transaction.acquireReadLock(rel);
    addProperties(rel, properties);
    readLock.release();
    writeLock.release();
    return rel;
}
项目:zerograph    文件:Database.java   
@Override
public void deleteRelationship(long id) throws NotFoundException {
    Relationship rel = database.getRelationshipById(id);
    Lock writeLock = transaction.acquireWriteLock(rel);
    rel.delete();
    writeLock.release();
}
项目:neo4j-mobile-android    文件:AbstractGraphDatabase.java   
public final <T> T getSingleManagementBean( Class<T> type )
{
    Iterator<T> beans = getManagementBeans( type ).iterator();
    if ( beans.hasNext() )
    {
        T bean = beans.next();
        if ( beans.hasNext() )
            throw new NotFoundException( "More than one management bean for " + type.getName() );
        return bean;
    }
    return null;
}
项目:neo4j-mobile-android    文件:IndexManagerImpl.java   
public Map<String, String> getConfiguration( Index<? extends PropertyContainer> index )
{
    Map<String, String> config = indexStore.get( index.getEntityType(), index.getName() );
    if ( config == null )
    {
        throw new NotFoundException( "No " + index.getEntityType().getSimpleName() +
                " index '" + index.getName() + "' found" );
    }
    return config;
}
项目:neo4j-mobile-android    文件:StandardExpander.java   
public T getSingle()
{
    final Iterator<T> expanded = iterator();
    if ( expanded.hasNext() )
    {
        final T result = expanded.next();
        if ( expanded.hasNext() )
        {
            throw new NotFoundException(
                    "More than one relationship found for " + this );
        }
        return result;
    }
    return null;
}
项目:neo4j-mobile-android    文件:PropertyIndexHolder.java   
String getStringKey( int keyId )
{
    String stringKey = idToIndex.get( keyId );
    if ( stringKey == null )
    {
        throw new NotFoundException( "No such property index[" + keyId + 
            "]" );
    }
    return stringKey;
}
项目:neo4j-mobile-android    文件:RelationshipTypeHolder.java   
String getName( int id )
{
    String name = idToName.get( id );
    if ( name == null )
    {
        throw new NotFoundException( "No such relationship type[" + id + 
            "]" );
    }
    return name;
}
项目:neo4j-mobile-android    文件:BatchInserterImpl.java   
private NodeRecord getNodeRecord( long id )
{
    if ( id < 0 || id >= getNodeStore().getHighId() )
    {
        throw new NotFoundException( "id=" + id );
    }
    return getNodeStore().getRecord( id );
}
项目:neo4j-mobile-android    文件:BatchInserterImpl.java   
private RelationshipRecord getRelationshipRecord( long id )
{
    if ( id < 0 || id >= getRelationshipStore().getHighId() )
    {
        throw new NotFoundException( "id=" + id );
    }
    return getRelationshipStore().getRecord( id );
}
项目:neo4j-mobile-android    文件:BatchGraphDatabaseImpl.java   
public Object getProperty( String key )
{
    Object val = properties.get( key );
    if ( val == null )
    {
        throw new NotFoundException( key );
    }
    return val;
}
项目:neo4j-mobile-android    文件:BatchGraphDatabaseImpl.java   
public Object removeProperty( String key )
{
    Object val = properties.remove( key );
    if ( val == null )
    {
        throw new NotFoundException( "Property " + key );
    }
    return val;
}