@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 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(); } }
return m.read(r, "", "TTL"); } catch (RiotException re) { String message = re.getMessage(); Pattern p = Pattern.compile("line: ([0-9]+)"); Matcher mat = p.matcher(message);
"error writing syntax " + syntax + ": " + e.getMessage());
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()); } }
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); } }
public LangNTriplesSkipBad(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); } }
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); } }
catch (RiotException ex) { ServletOps.errorBadRequest("Bad IRI: "+ex.getMessage()) ;
public LangNTriplesSkipBad(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); } }
private void applyRDFPatch(HttpAction action) { try { String ct = action.getRequest().getContentType(); // If triples or quads, maybe POST. InputStream input = action.request.getInputStream(); DatasetGraph dsg = action.getDataset(); RDFPatchReaderText pr = new RDFPatchReaderText(input); RDFChanges changes = new RDFChangesApply(dsg); // External transaction. Suppress patch recorded TX and TC. changes = new RDFChangesNoTxn(changes); pr.apply(changes); ServletOps.success(action); } catch (RiotException ex) { ServletOps.errorBadRequest("RDF Patch parse error: "+ex.getMessage()); } catch (IOException ex) { ServletOps.errorBadRequest("IOException: "+ex.getMessage()); } }
/** * Parse the request body as a Model. * * @param requestBodyStream rdf request body * @param contentType content type of body * @param resource the fedora resource * @return Model containing triples from request body * @throws MalformedRdfException in case rdf json cannot be parsed */ private Model parseBodyAsModel(final InputStream requestBodyStream, final MediaType contentType, final FedoraResource resource) throws MalformedRdfException { final Lang format = contentTypeToLang(contentType.toString()); final Model inputModel; try { inputModel = createDefaultModel(); inputModel.read(requestBodyStream, getUri(resource).toString(), format.getName().toUpperCase()); return inputModel; } catch (final RiotException e) { throw new BadRequestException("RDF was not parsable: " + e.getMessage(), e); } catch (final RuntimeIOException e) { if (e.getCause() instanceof JsonParseException) { throw new MalformedRdfException(e.getCause()); } throw new RepositoryRuntimeException(e); } }
@Test public void testIncludeReaderException() throws IOException { Model m = ModelFactory.createDefaultModel(); IncludeReader r = new IncludeReader("includefiles/badtoplevel.ttl"); try { m.read(r, "", "TTL"); fail("should have caught bad beta"); } catch (RiotException re) { String message = re.getMessage(); Pattern p = Pattern.compile("line: ([0-9]+)"); Matcher mat = p.matcher(message); assertTrue("did not find line: element in message", mat.find()); int intLine = Integer.parseInt(mat.group(1)); Position where = r.mapLine(intLine); assertEquals("wrong line number", 8, where.lineNumber); assertEquals("wrong path", "includefiles/badtoplevel.ttl", where.pathName); } r.close(); } }
private void doPutPostTxn(HttpAction action, boolean clearFirst) { UploadDetails details = null ; action.beginWrite() ; try { DatasetGraph dsg = decideDataset(action); if ( clearFirst ) dsg.clear() ; StreamRDF dest = StreamRDFLib.dataset(dsg) ; details = Upload.incomingData(action, dest) ; action.commit() ; ServletOps.success(action) ; } catch (RiotException ex) { // Parse error action.abort() ; ServletOps.errorBadRequest(ex.getMessage()) ; } catch (ActionErrorException ex) { action.abort() ; throw ex ; } catch (Exception ex) { // Something else went wrong. Backout. action.abort() ; ServletOps.errorOccurred(ex.getMessage()) ; } finally { action.end() ; } ServletOps.uploadResponse(action, details) ; }
private void doPutPostTxn(HttpAction action, boolean clearFirst) { UploadDetails details = null ; action.beginWrite() ; try { DatasetGraph dsg = decideDataset(action); if ( clearFirst ) dsg.clear() ; StreamRDF dest = StreamRDFLib.dataset(dsg) ; details = Upload.incomingData(action, dest) ; action.commit() ; ServletOps.success(action) ; } catch (RiotException ex) { // Parse error action.abort() ; ServletOps.errorBadRequest(ex.getMessage()) ; } catch (ActionErrorException ex) { action.abort() ; throw ex ; } catch (Exception ex) { // Something else went wrong. Backout. action.abort() ; ServletOps.errorOccurred(ex.getMessage()) ; } finally { action.end() ; } ServletOps.uploadResponse(action, details) ; }
RDFDataMgr.read(results, output, outLang) ; } catch (RiotException ex) { fail("Failed to read results: "+ex.getMessage()) ;
details = Upload.incomingData(action, dest) ; } catch (RiotException ex) { ServletOps.errorBadRequest(ex.getMessage()) ; return ;
/** * 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()) ; } }
/** * 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()) ; } }
obj.key(jParseError).value(ex.getMessage()) ; obj.finishObject() ; obj.finishArray() ;