Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.neo4j.shell.kernel;
import java.io.Serializable;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.PropertyContainer;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.ResourceIterable;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.event.KernelEventHandler;
import org.neo4j.graphdb.event.TransactionEventHandler;
import org.neo4j.graphdb.index.AutoIndexer;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.graphdb.index.IndexPopulationProgress;
import org.neo4j.graphdb.index.RelationshipAutoIndexer;
import org.neo4j.graphdb.index.RelationshipIndex;
import org.neo4j.graphdb.schema.ConstraintCreator;
import org.neo4j.graphdb.schema.ConstraintDefinition;
import org.neo4j.graphdb.schema.IndexCreator;
import org.neo4j.graphdb.schema.IndexDefinition;
import org.neo4j.graphdb.schema.Schema;
import org.neo4j.graphdb.security.URLAccessValidationError;
import org.neo4j.graphdb.traversal.BidirectionalTraversalDescription;
import org.neo4j.graphdb.traversal.TraversalDescription;
import org.neo4j.helpers.collection.IterableWrapper;
import org.neo4j.helpers.collection.PrefetchingResourceIterator;
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.security.AccessMode;
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.kernel.impl.store.StoreId;
public class ReadOnlyGraphDatabaseProxy implements GraphDatabaseService, GraphDatabaseAPI, IndexManager
{
private final GraphDatabaseAPI actual;
public ReadOnlyGraphDatabaseProxy( GraphDatabaseAPI graphDb )
{
this.actual = graphDb;
}
public Node readOnly( Node actual )
{
return new ReadOnlyNodeProxy( actual );
}
public Relationship readOnly( Relationship actual )
{
return new ReadOnlyRelationshipProxy( actual );
}
private static T readOnly()
{
throw readOnlyException();
}
private static UnsupportedOperationException readOnlyException()
{
return new UnsupportedOperationException( "Read only Graph Database!" );
}
@Override
public InternalTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode )
{
return actual.beginTransaction( type, accessMode );
}
@Override
public Transaction beginTx()
{
return actual.beginTx();
}
@Override
public Result execute( String query )
{
return execute( query, Collections.emptyMap() );
}
@Override
public Result execute( String query, Map parameters )
{
return readOnly();
}
@Override
public Node createNode()
{
return readOnly();
}
@Override
public Node createNode( Label... labels )
{
return readOnly();
}
public boolean enableRemoteShell()
{
throw new UnsupportedOperationException( "Cannot enable Remote Shell from Remote Shell" );
}
public boolean enableRemoteShell( Map initialProperties )
{
return enableRemoteShell();
}
@Override
public ResourceIterable getAllNodes()
{
return nodes( actual.getAllNodes() );
}
@Override
public Node getNodeById( long id )
{
return new ReadOnlyNodeProxy( actual.getNodeById( id ) );
}
@Override
public Relationship getRelationshipById( long id )
{
return new ReadOnlyRelationshipProxy( actual.getRelationshipById( id ) );
}
@Override
public ResourceIterable getAllRelationships()
{
return new ResourceIterable()
{
@Override
public ResourceIterator iterator()
{
final ResourceIterator iterator = actual.getAllRelationships().iterator();
return new PrefetchingResourceIterator()
{
@Override
protected Relationship fetchNextOrNull()
{
return new ReadOnlyRelationshipProxy( iterator.next() );
}
@Override
public void close()
{
iterator.close();
}
};
}
};
}
@Override
public ResourceIterable