private OntModelSpec getRequiredOntModelSpecField( String name ) { OntModelSpec result = getOntModelSpecField( name ); if (result == null) throw new NotFoundException( name ); return result; }
public Object create(Resource type) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, type) ; } catch (ARQException ex) { throw ex; } catch (NotFoundException ex) { throw new CmdException("Not found: "+ex.getMessage()) ; } catch (JenaException ex) { throw ex ; } catch (Exception ex) { throw new CmdException("Error creating", ex) ; } return thing ; } }
public Object create(Resource type) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, type) ; } catch (ARQException ex) { throw ex; } catch (NotFoundException ex) { throw new CmdException("Not found: "+ex.getMessage()) ; } catch (JenaException ex) { throw ex ; } catch (Exception ex) { throw new CmdException("Error creating", ex) ; } return thing ; } }
private OntModelSpec getRequiredOntModelSpecField( String name ) { OntModelSpec result = getOntModelSpecField( name ); if (result == null) throw new NotFoundException( name ); return result; }
@Override public Dataset createDataset() { if ( modAssembler.getAssemblerFile() == null ) return null ; try { dataset = (Dataset)modAssembler.create(DatasetAssemblerVocab.tDataset) ; if ( dataset == null ) throw new CmdException("No dataset description found in: "+modAssembler.getAssemblerFile()) ; } catch (CmdException | ARQException ex) { throw ex ; } catch (NotFoundException ex) { throw new CmdException("Not found: "+ex.getMessage()) ; } catch (JenaException ex) { throw ex ; } catch (Exception ex) { throw new CmdException("Error creating dataset", ex) ; } return dataset ; }
public InputStream open() throws IOException { InputStream in = fm.open(filenameOrIRI); if (in == null) { throw new NotFoundException(filenameOrIRI); } return in; } };
@Override public Dataset createDataset() { if ( modAssembler.getAssemblerFile() == null ) return null ; try { dataset = (Dataset)modAssembler.create(DatasetAssemblerVocab.tDataset) ; if ( dataset == null ) throw new CmdException("No dataset description found in: "+modAssembler.getAssemblerFile()) ; } catch (CmdException | ARQException ex) { throw ex ; } catch (NotFoundException ex) { throw new CmdException("Not found: "+ex.getMessage()) ; } catch (JenaException ex) { throw ex ; } catch (Exception ex) { throw new CmdException("Error creating dataset", ex) ; } return dataset ; }
public static void checkUrl(URL url) { try { HttpURLConnection connection = (HttpURLConnection)url.openConnection(); try { connection.setRequestMethod("GET"); connection.connect(); int code = connection.getResponseCode(); if(code != 200) { //logger.info("Health check status: fail"); throw new NotFoundException(url.toString()); } } finally { connection.disconnect(); } //logger.info("Health check status: success"); } catch(Exception e) { throw new RuntimeException(e); } } }
private static Reader open(String filenameOrURL) { try { InputStream in = FileManager.get().open(filenameOrURL); if (in == null) throw new NotFoundException(filenameOrURL); return new InputStreamReader(in, "UTF-8"); } catch (UnsupportedEncodingException ex) { // Can't happen, UTF-8 is always supported return null; } }
/** Slurp up a whole file: map filename as necessary */ public String readWholeFileAsUTF8(String filename) { InputStream in = open(filename) ; if ( in == null ) throw new NotFoundException("File not found: "+filename) ; return readWholeFileAsUTF8(in) ; }
/** Slurp up a whole file: map filename as necessary */ public String readWholeFileAsUTF8(String filename) { InputStream in = open(filename) ; if ( in == null ) throw new NotFoundException("File not found: "+filename) ; return readWholeFileAsUTF8(in) ; }
/** Read a file and obtain an SSE item expression */ public static Item readFile(String filename, PrefixMapping pmap) { FileInputStream in = null ; try { in = new FileInputStream(filename) ; long len = in.getChannel().size() ; if ( len == 0 ) return Item.nil ; return parse(in, pmap) ; } catch (FileNotFoundException ex) { throw new NotFoundException("Not found: "+filename) ; } catch (IOException ex) { throw new ARQException("IOExeption: "+filename, ex) ; } finally { IO.close(in) ; } }
throw new NotFoundException("Not found: "+filenameOrURI) ;
throw new NotFoundException("Not found: "+filenameOrURI) ;
@Override protected Model readModelWorker(Model model, String filenameOrURI, String baseURI, String syntax) { // Doesn't call open() - we want to make the syntax guess // based on the mapped URI. String mappedURI = mapURI(filenameOrURI) ; if ( log.isDebugEnabled() && !mappedURI.equals(filenameOrURI) ) log.debug("Map: " + filenameOrURI + " => " + mappedURI) ; Lang lang = (syntax != null) ? RDFLanguages.nameToLang(syntax) : RDFLanguages.resourceNameToLang(mappedURI, Lang.RDFXML) ; // Not : RDFDataMgr.read(model, mappedURI, baseURI, lang); // Allow model.read to be overridden e.g. by OntModel which does import processing. if ( baseURI == null ) baseURI = SysRIOT.chooseBaseIRI(filenameOrURI) ; try(TypedInputStream in = streamManager.openNoMapOrNull(mappedURI)) { if ( in == null ) { FmtLog.debug(log, "Failed to locate '%s'", mappedURI); throw new NotFoundException("Not found: "+filenameOrURI) ; } Lang lang2 = RDFDataMgr.determineLang(mappedURI, in.getContentType(), lang); // May be overridden by model implementation. model.read(in, baseURI, lang2.getName()) ; } return model ; }