@Override public void write(final OutputStream output) { try { LOGGER.debug("Serializing RDF stream in: {}", format); write(rdfStream, output, format, mediaType, namespaces); } catch (final RiotException e) { setException(e); LOGGER.debug("Error serializing RDF", e.getMessage()); throw new WebApplicationException(e); } }
@Override public void read(Reader reader, String baseURI, ContentType ct, StreamRDF output, Context context) { throw new RiotException("RDF Thrift : Reading binary data from a java.io.reader is not supported. Please use an InputStream") ; } }
/** * Parse RDF content */ public static void parse(HttpAction action, StreamRDF dest, InputStream input, Lang lang, String base) { try { if ( ! RDFParserRegistry.isRegistered(lang) ) ServletOps.errorBadRequest("No parser for language '"+lang.getName()+"'") ; ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(action.log); RDFParser.create() .errorHandler(errorHandler) .source(input) .lang(lang) .base(base) .parse(dest); } catch (RuntimeIOException ex) { if ( ex.getCause() instanceof CharacterCodingException ) throw new RiotException("Character Coding Error: "+ex.getMessage()); throw ex; } catch (RiotException ex) { ServletOps.errorBadRequest("Parse error: "+ex.getMessage()) ; } }
/** * Harvests all the triplets from each URI in the @rdfUris list */ private void harvestFromDumps() { for(String uri : rdfUris) { if(uri.isEmpty()) continue; //TODO:LOG - DONE logger.info("Harvesting uri [{}]", uri); Model model = ModelFactory.createDefaultModel(); try { RDFDataMgr.read(model, uri.trim(), RDFLanguages.RDFXML); //TODO: prepareBulk - DONE BulkRequest bulkRequest = new BulkRequest(); addModelToES(model, bulkRequest, true); } catch (RiotException re) { //TODO:LOG - DONE logger.error("Illegal xml character [{}]", re.getLocalizedMessage()); } catch (Exception e) { //TODO:LOG - DONE logger.error("Exception when harvesting url: {}. Details: {}", uri, e.getLocalizedMessage()); } } }
/** * Parse RDF content */ public static void parse(HttpAction action, StreamRDF dest, InputStream input, Lang lang, String base) { try { if ( ! RDFParserRegistry.isRegistered(lang) ) ServletOps.errorBadRequest("No parser for language '"+lang.getName()+"'") ; ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(action.log); RDFParser.create() .errorHandler(errorHandler) .source(input) .lang(lang) .base(base) .parse(dest); } catch (RuntimeIOException ex) { if ( ex.getCause() instanceof CharacterCodingException ) throw new RiotException("Character Coding Error: "+ex.getMessage()); throw ex; } catch (RiotException ex) { ServletOps.errorBadRequest("Parse error: "+ex.getMessage()) ; } }
@Override public void cancelMetricAssessment() throws ProcessorNotInitialised { if(this.isInitalised == false) throw new ProcessorNotInitialised("Streaming will not start as processor has not been initalised"); forcedCancel = true; for (MetricProcess mp : lstMetricConsumers){ logger.info("Closing and clearing quads queue for "+ mp.getMetricName()); mp.closeAssessment(); } logger.info("Closing Iterators"); try { this.iterator.close(); this.rdfStream.finish(); } catch (RiotException e){ logger.warn("RDF Stream already closed. Exception Raised: {}",e.getMessage()); } executor.shutdownNow(); } }
private void checkStateForReceive() { if (closedByProducer || closedByConsumer) { throw new RiotException("Pipe closed"); } else if (consumerThread != null && !consumerThread.isAlive()) { throw new RiotException("Consumer dead"); } }
return m.read(r, "", "TTL"); } catch (RiotException re) { String message = re.getMessage(); Pattern p = Pattern.compile("line: ([0-9]+)"); Matcher mat = p.matcher(message);
private void checkStateForReceive() { if (closedByProducer || closedByConsumer) { throw new RiotException("Pipe closed"); } else if (consumerThread != null && !consumerThread.isAlive()) { throw new RiotException("Consumer dead"); } }
"error writing syntax " + syntax + ": " + e.getMessage());
@Override public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) { XMLInputFactory xf = XMLInputFactory.newInstance() ; XMLStreamReader xReader ; try { xReader = xf.createXMLStreamReader(in) ; } catch (XMLStreamException e) { throw new RiotException("Can't initialize StAX parsing engine", e) ; } read(xReader, baseURI, output) ; }
private void actOnRDFPatch(HttpAction action) { try { String ct = action.getRequest().getContentType(); InputStream input = action.request.getInputStream(); RDFPatch patch = RDFPatchOps.read(input); try ( OutputStream out = output.output() ) { String fn = output.currentFilename().getFileName().toString(); if ( action.verbose ) { Node id = patch.getId(); String idStr = id == null ? "<unset>" : NodeFmtLib.str(id); action.log.info(format("[%d] Log: %s ==>> %s", action.id, idStr, fn)); } else { action.log.info(format("[%d] Log: %s", action.id, fn)); } RDFPatchOps.write(out, patch); } ServletOps.success(action); } catch (RiotException ex) { ServletOps.errorBadRequest("RDF Patch parse error: "+ex.getMessage()); } catch (IOException ex) { ServletOps.errorBadRequest("IOException: "+ex.getMessage()); } }
@Override public void triple(Triple triple) { count++ ; if ( count > limit ) throw new RiotException("Limit ("+limit+") reached") ; super.triple(triple) ; }
throw new ResultSetException(format("Line %d: Data %s contains error: %s", lineNum, token, ex.getMessage()));
@Override public void quad(Quad quad) { count++ ; if ( count > limit ) throw new RiotException("Limit ("+limit+") reached") ; super.quad(quad) ; }
} catch (RiotException ex) throw new ResultSetException(format("Line %d: Data %s contains error: %s", lineNum, token, ex.getMessage()));
/** report a warning - do not carry on */ @Override public void warning(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; }
public LangNQuadsSkipBad(TokenizerTextForgiving tokens, ParserProfile profile, StreamRDF dest) { try { base = new PeekIterator<>(new Wrapper(tokens, profile, dest)); } catch (RiotException e) { bad = e; profile.getErrorHandler().warning(e.getMessage(), -1, -1); } }
/** report an error - do not carry on */ @Override public void error(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; }
public LangNQuadsSkipBad(TokenizerTextForgiving tokens, ParserProfile profile, StreamRDF dest) { try { base = new PeekIterator<>(new Wrapper(tokens, profile, dest)); } catch (RiotException e) { bad = e; profile.getErrorHandler().warning(e.getMessage(), -1, -1); } }