private static ReasonerFactory createInstance( Resource root, Class<?> c ) { try { return (ReasonerFactory) c.newInstance(); } catch (Exception e) { throw new AssemblerException( root, "could not create instance of " + c.getName(), e ); } }
@Override protected void exec() { try { FusekiServer server = buildServer(serverConfig); info(server, serverConfig); server.start(); server.join(); System.exit(0); } catch (AssemblerException ex) { if ( ex.getCause() != null ) System.err.println(ex.getCause().getMessage()); else System.err.println(ex.getMessage()); } }
@Override public String toString() { String parent = super.toString(); String frame = frameStrings(); return frame.equals( "" ) ? parent : parent + "\n doing:\n" + frame; }
private Object openBySpecificType( Assembler a, Resource root, Mode mode, Resource type ) { Assembler toUse = assemblerFor( type ); Class<? extends Assembler> aClass = toUse == null ? null : toUse.getClass(); Frame frame = new Frame( root, type, aClass ); try { if (toUse == null) throw new NoImplementationException( this, root, type ); else return toUse.open( a, root, mode ); } catch (AssemblerException e) { throw e.pushDoing( frame ); } catch (Exception e) { AssemblerException x = new AssemblerException( root, "caught: " + e.getMessage(), e ); throw x.pushDoing( frame ); } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, VocabTDB2.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphViewSwitchable) ; DatasetGraphSwitchable dsg = ((GraphViewSwitchable)graph).getDataset(); if ( dsg != null ) dsg.close() ; } }
public void testFail() { Resource root = resourceInModel( "x rdf:type A" ); AssemblerGroup g = AssemblerGroup.create(); g.implementWith( resource( "A" ), new ShantAssemble() ); try { g.open( root ); fail( "shouldn't get past exception" ); } catch (AssemblerException e) { AssemblerGroup.Frame frame = new AssemblerGroup.Frame( resource( "x" ), resource( "A" ), ShantAssemble.class ); assertEquals( listOfOne( frame ), e.getDoing() ); } }
private Object openBySpecificType( Assembler a, Resource root, Mode mode, Resource type ) { Assembler toUse = assemblerFor( type ); Class<? extends Assembler> aClass = toUse == null ? null : toUse.getClass(); Frame frame = new Frame( root, type, aClass ); try { if (toUse == null) throw new NoImplementationException( this, root, type ); else return toUse.open( a, root, mode ); } catch (AssemblerException e) { throw e.pushDoing( frame ); } catch (Exception e) { AssemblerException x = new AssemblerException( root, "caught: " + e.getMessage(), e ); throw x.pushDoing( frame ); } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, VocabTDB2.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphViewSwitchable) ; DatasetGraphSwitchable dsg = ((GraphViewSwitchable)graph).getDataset(); if ( dsg != null ) dsg.close() ; } }
public void testFail() { Resource root = resourceInModel( "x rdf:type A" ); AssemblerGroup g = AssemblerGroup.create(); g.implementWith( resource( "A" ), new ShantAssemble() ); try { g.open( root ); fail( "shouldn't get past exception" ); } catch (AssemblerException e) { AssemblerGroup.Frame frame = new AssemblerGroup.Frame( resource( "x" ), resource( "A" ), ShantAssemble.class ); assertEquals( listOfOne( frame ), e.getDoing() ); } }
private static ReasonerFactory createInstance( Resource root, Class<?> c ) { try { return (ReasonerFactory) c.newInstance(); } catch (Exception e) { throw new AssemblerException( root, "could not create instance of " + c.getName(), e ); } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
@Override protected void exec() { try { FusekiServer server = buildServer(serverConfig); info(server); try { server.start(); } catch (FusekiException ex) { if ( ex.getCause() instanceof BindException ) { Fuseki.serverLog.error("Failed to start server: "+ex.getCause().getMessage()+ ": port="+serverConfig.port) ; System.exit(1); } throw ex; } catch (Exception ex) { throw new FusekiException("Failed to start server: " + ex.getMessage(), ex) ; } server.join(); System.exit(0); } catch (AssemblerException ex) { if ( ex.getCause() != null ) System.err.println(ex.getCause().getMessage()); else System.err.println(ex.getMessage()); } }
@Override public String toString() { String parent = super.toString(); String frame = frameStrings(); return frame.equals( "" ) ? parent : parent + "\n doing:\n" + frame; }
private SecurityEvaluator getEvaluatorImpl(Assembler a, Resource evaluatorImpl ) { Object obj = a.open(a, evaluatorImpl, Mode.ANY); if (obj instanceof SecurityEvaluator) { return (SecurityEvaluator) obj; } throw new AssemblerException( evaluatorImpl, String.format( "%s does not specify a SecurityEvaluator instance", evaluatorImpl)); }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
@Override protected void exec() { try { FusekiServer server = buildServer(serverConfig); info(server); try { server.start(); } catch (FusekiException ex) { if ( ex.getCause() instanceof BindException ) { Fuseki.serverLog.error("Failed to start server: "+ex.getCause().getMessage()+ ": port="+serverConfig.port) ; System.exit(1); } throw ex; } catch (Exception ex) { throw new FusekiException("Failed to start server: " + ex.getMessage(), ex) ; } server.join(); System.exit(0); } catch (AssemblerException ex) { if ( ex.getCause() != null ) System.err.println(ex.getCause().getMessage()); else System.err.println(ex.getMessage()); } }
if ( ! SecurityEvaluator.class.isAssignableFrom(method.getReturnType())) throw new AssemblerException( root, String.format( "%s (found at %s for %s) getInstance() must return an instance of SecurityEvaluator", factoryName, EVALUATOR_FACTORY, root )); throw new AssemblerException( root, String.format( "%s (found at %s for %s) getInstance() must be a static method", factoryName, EVALUATOR_FACTORY, root )); throw new AssemblerException( root, String.format( ERROR_FINDING_FACTORY, factoryName, e.getMessage() ), e); throw new AssemblerException( root, String.format( ERROR_FINDING_FACTORY, factoryName, e.getMessage() ), e); throw new AssemblerException( root, String.format( "Class %s (found at %s for %s) could not be loaded", factoryName, EVALUATOR_FACTORY, root )); throw new AssemblerException( root, String.format( "%s (found at %s for %s) must implement a static getInstance() that returns an instance of SecurityEvaluator", factoryName, EVALUATOR_FACTORY, root )); throw new AssemblerException( root, String.format( ERROR_FINDING_FACTORY, factoryName, e.getMessage() ), e); throw new AssemblerException( root, String.format( ERROR_FINDING_FACTORY, factoryName, e.getMessage() ), e);
@Test public void createGraphEmbed() { String f = dirAssem+"/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build( f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); }
/** Format:: access:entry ("user1" <http://host/graphname1> <http://host/graphname2> ) ; */ private void parseList(Multimap<String, Node> map, Resource root, GNode entry) { List<Node> members = GraphList.members(entry); // string, then URIs. if ( members.isEmpty() ) throw new AssemblerException(root, "Found access:entry with an empty list"); Node userNode = members.get(0); if ( ! Util.isSimpleString(userNode) ) throw new AssemblerException(root, "User name is not a string: "+NodeFmtLib.str(userNode)); String user = userNode.getLiteralLexicalForm(); List<Node> graphs = members.subList(1, members.size()); accessEntries(root, map, user, graphs); }
@Test public void createGraphEmbed() { String f = dirAssem + "/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build(f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphViewSwitchable) ; DatasetGraphSwitchable ds = ((GraphViewSwitchable)graph).getDataset() ; if ( ds != null ) ds.close() ; }