public TransactionAbortedException( Resource root, Throwable t ) { super( root, makeMessage( root, t ), t ); }
private static String makeMessage( Resource root, Throwable t ) { return "the loading of content into " + nice( root ) + " was aborted because of " + t.getMessage() ; } }
protected void addContent( Resource root, Model m, Content c ) { if (m.supportsTransactions()) { m.begin(); try { c.fill( m ); m.commit(); } catch (Throwable t) { m.abort(); throw new TransactionAbortedException( root, t ); } } else c.fill( m ); }
public void testContentTransactionsAbort() { final List<String> history = new ArrayList<>(); final Model expected = model( "_x rdf:value '17'xsd:integer" ); final Model toDeliver = model( "" ).add( expected ); Assembler a = new MockTransactionModel( history, toDeliver, true, true ); try { Resource root = resourceInModel ( "x rdf:type ja:Model; x ja:content y; y rdf:type ja:Content" + "; y rdf:type ja:LiteralContent; y ja:literalContent '_:x\\srdf:value\\s17\\s.'" ); a.open( Assembler.content, root ); fail( "should throw (wrapped) failing exception" ); } catch (TransactionAbortedException e) { assertEquals( resource( "x" ), e.getRoot() ); assertEquals( listOfStrings( "supports[true] begin add abort" ), history ); assertIsoModels( expected, toDeliver ); } }
protected void addContent( Resource root, Model m, Content c ) { if (m.supportsTransactions()) { m.begin(); try { c.fill( m ); m.commit(); } catch (Throwable t) { m.abort(); throw new TransactionAbortedException( root, t ); } } else c.fill( m ); }
public void testContentTransactionsAbort() { final List<String> history = new ArrayList<>(); final Model expected = model( "_x rdf:value '17'xsd:integer" ); final Model toDeliver = model( "" ).add( expected ); Assembler a = new MockTransactionModel( history, toDeliver, true, true ); try { Resource root = resourceInModel ( "x rdf:type ja:Model; x ja:content y; y rdf:type ja:Content" + "; y rdf:type ja:LiteralContent; y ja:literalContent '_:x\\srdf:value\\s17\\s.'" ); a.open( Assembler.content, root ); fail( "should throw (wrapped) failing exception" ); } catch (TransactionAbortedException e) { assertEquals( resource( "x" ), e.getRoot() ); assertEquals( listOfStrings( "supports[true] begin add abort" ), history ); assertIsoModels( expected, toDeliver ); } }
private static String makeMessage( Resource root, Throwable t ) { return "the loading of content into " + nice( root ) + " was aborted because of " + t.getMessage() ; } }
public TransactionAbortedException( Resource root, Throwable t ) { super( root, makeMessage( root, t ), t ); }