Example #1
0
        private void AssertYieldsErrors(string json, params Neo4jError[] expectedErrors)
        {
            StatementDeserializer de = new StatementDeserializer(new ByteArrayInputStreamAnonymousInnerClass(this, UTF8.encode(json)));

            while (de.MoveNext())
            {
                de.Current;
            }

            IEnumerator <Neo4jError> actual   = de.Errors();
            IEnumerator <Neo4jError> expected = asList(expectedErrors).GetEnumerator();

            while (actual.MoveNext())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue(expected.hasNext());
                Neo4jError error = actual.Current;
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Neo4jError expectedError = expected.next();

                assertThat(error.Message, equalTo(expectedError.Message));
                assertThat(error.Status(), equalTo(expectedError.Status()));
            }

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(expected.hasNext());
        }
Example #2
0
        private void ExecuteStatements(StatementDeserializer statements, ExecutionResultSerializer output, IList <Neo4jError> errors, HttpServletRequest request)
        {
            try
            {
                bool hasPrevious = false;
                while (statements.MoveNext())
                {
                    Statement statement = statements.Current;
                    try
                    {
                        bool hasPeriodicCommit = _engine.isPeriodicCommit(statement.StatementConflict());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        if ((statements.HasNext() || hasPrevious) && hasPeriodicCommit)
                        {
                            throw new QueryExecutionKernelException(new InvalidSemanticsException("Cannot execute another statement after executing " + "PERIODIC COMMIT statement in the same transaction"));
                        }

                        if (!hasPrevious && hasPeriodicCommit)
                        {
                            _context.closeTransactionForPeriodicCommit();
                        }

                        hasPrevious = true;
                        TransactionalContext tc = _txManagerFacade.create(request, _queryService, _type, _loginContext, statement.StatementConflict(), statement.Parameters());
                        Result result           = SafelyExecute(statement, hasPeriodicCommit, tc);
                        output.StatementResult(result, statement.IncludeStats(), statement.ResultDataContents());
                        output.Notifications(result.Notifications);
                    }
                    catch (Exception e) when(e is KernelException || e is CypherException || e is AuthorizationViolationException || e is WriteOperationsNotAllowedException)
                    {
                        errors.Add(new Neo4jError(e.status(), e));
                        break;
                    }
                    catch (DeadlockDetectedException e)
                    {
                        errors.Add(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.DeadlockDetected, e));
                    }
                    catch (IOException e)
                    {
                        errors.Add(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Network.CommunicationError, e));
                        break;
                    }
                    catch (Exception e)
                    {
                        Exception cause = e.InnerException;
                        if (cause is Org.Neo4j.Kernel.Api.Exceptions.Status_HasStatus)
                        {
                            errors.Add(new Neo4jError(((Org.Neo4j.Kernel.Api.Exceptions.Status_HasStatus)cause).Status(), cause));
                        }
                        else
                        {
                            errors.Add(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ExecutionFailed, e));
                        }

                        break;
                    }
                }

                addToCollection(statements.Errors(), errors);
            }
            catch (Exception e)
            {
                errors.Add(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError, e));
            }
        }