use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldRunSimpleReadOnlyProcedure.
@Test
public void shouldRunSimpleReadOnlyProcedure() throws Throwable {
// Given
CallableProcedure proc = compile(SingleReadOnlyProcedure.class).get(0);
// When
RawIterator<Object[], ProcedureException> out = proc.apply(new BasicContext(), new Object[0]);
// Then
assertThat(asList(out), contains(new Object[] { "Bonnie" }, new Object[] { "Clyde" }));
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class OperationsFacade method callProcedure.
private RawIterator<Object[], ProcedureException> callProcedure(QualifiedName name, Object[] input, final AccessMode override) throws ProcedureException {
statement.assertOpen();
final SecurityContext procedureSecurityContext = tx.securityContext().withMode(override);
final RawIterator<Object[], ProcedureException> procedureCall;
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
BasicContext ctx = new BasicContext();
ctx.put(Context.KERNEL_TRANSACTION, tx);
ctx.put(Context.THREAD, Thread.currentThread());
ctx.put(Context.SECURITY_CONTEXT, procedureSecurityContext);
procedureCall = procedures.callProcedure(ctx, name, input);
}
return new RawIterator<Object[], ProcedureException>() {
@Override
public boolean hasNext() throws ProcedureException {
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
return procedureCall.hasNext();
}
}
@Override
public Object[] next() throws ProcedureException {
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
return procedureCall.next();
}
}
};
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class OperationsFacade method callFunction.
private Object callFunction(QualifiedName name, Object[] input, final AccessMode mode) throws ProcedureException {
statement.assertOpen();
try (KernelTransaction.Revertable ignore = tx.overrideWith(tx.securityContext().withMode(mode))) {
BasicContext ctx = new BasicContext();
ctx.put(Context.KERNEL_TRANSACTION, tx);
ctx.put(Context.THREAD, Thread.currentThread());
return procedures.callFunction(ctx, name, input);
}
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class OperationsFacade method aggregationFunction.
private CallableUserAggregationFunction.Aggregator aggregationFunction(QualifiedName name, final AccessMode mode) throws ProcedureException {
statement.assertOpen();
try (KernelTransaction.Revertable ignore = tx.overrideWith(tx.securityContext().withMode(mode))) {
BasicContext ctx = new BasicContext();
ctx.put(Context.KERNEL_TRANSACTION, tx);
ctx.put(Context.THREAD, Thread.currentThread());
return procedures.createAggregationFunction(ctx, name);
}
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class NonTransactionalDbmsOperations method functionCallDbms.
@Override
public Object functionCallDbms(QualifiedName name, Object[] input, SecurityContext securityContext) throws ProcedureException {
BasicContext ctx = new BasicContext();
ctx.put(Context.SECURITY_CONTEXT, securityContext);
return procedures.callFunction(ctx, name, input);
}
Aggregations