当前位置: 首页>>代码示例>>Java>>正文


Java RiotException类代码示例

本文整理汇总了Java中org.apache.jena.riot.RiotException的典型用法代码示例。如果您正苦于以下问题:Java RiotException类的具体用法?Java RiotException怎么用?Java RiotException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RiotException类属于org.apache.jena.riot包,在下文中一共展示了RiotException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moveToNextBinding

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@Override
protected Binding moveToNextBinding() {
	// we need a binding that's ?s ?p ?o
	try {
		Triple triple = triples.next();
		BindingMap binding = BindingFactory.create();
		binding.add(Var.alloc("s"), triple.getSubject());
		binding.add(Var.alloc("p"), triple.getPredicate());
		binding.add(Var.alloc("o"), triple.getObject());
		return binding;
	} catch (RiotException e) {
		// bug in empty results for describe.  this is
		// a workaround. TODO
	}
	return BindingFactory.binding();
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:17,代码来源:MarkLogicQueryEngine.java

示例2: jsonLdAsJenaModel

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
protected static Model jsonLdAsJenaModel(InputStream jsonIn, URI base)
		throws IOException, RiotException {
	Model model = ModelFactory.createDefaultModel();
	
	ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
	try { 
		// TAVERNA-971: set context classloader so jarcache.json is consulted
		// even through OSGi
		Thread.currentThread().setContextClassLoader(RDFToManifest.class.getClassLoader());
		
		// Now we can parse the JSON-LD without network access
		RDFDataMgr.read(model, jsonIn, base.toASCIIString(), Lang.JSONLD);
	} finally { 
		// Restore old context class loader (if any)
		Thread.currentThread().setContextClassLoader(oldCl);
	}
	return model;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:19,代码来源:RDFToManifest.java

示例3: load

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
public ModuleHelper load(final URI base,final Format format) throws IOException {
	final String data=
		new String(
			Files.readAllBytes(this.file),
			StandardCharsets.UTF_8);
	if(!format.equals(Format.RDF_XML) || RDFXMLUtil.isStandaloneDocument(data)) {
		try {
			this.model =ModelFactory.createDefaultModel();
			this.format=format;
			final RDFReader reader = this.model.getReader(format.lang.getLabel());
			reader.setProperty("error-mode", "strict-fatal");
			reader.read(this.model,new StringReader(data),base.toString());
		} catch (final RiotException e) {
			this.model=null;
			this.format=format;
			throw new IOException("Parsing failed",e);
		}
	}
	return this;
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:21,代码来源:ModuleHelper.java

示例4: sendRequest

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
/***************************************************************************
 * Private Methods - Handle Translation
 **************************************************************************/

private Model sendRequest(HttpServletRequest req, String url)
    throws ResponseThrowable
{
    HttpClient client = new HttpClient();
    GetMethod  method = new GetMethod(url);
    method.setRequestHeader("Accept-Encoding", "gzip");
    method.setRequestHeader("Accept"         , _format.getMimetype());
    InputStream is = null;
    try {
        int rspCode = client.executeMethod(method);
        if ( rspCode != 200 ) { throw new ResponseThrowable(rspCode); }

        is = getInputStream(method);
        Model m = ModelFactory.createDefaultModel();
        m.read(is, null, _format.getJenaFormat().getLang().getLabel());
        return m;
    }
    catch (RiotException | IOException e) {
        throw new ResponseThrowable(e, 502);
    }
    finally { IOUtils.closeQuietly(is); method.releaseConnection(); }
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:27,代码来源:FormatHandlerServlet.java

示例5: loadModelFromSPARQL

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
public static void loadModelFromSPARQL(Model m, String uri, boolean filter)
{
	String sDescribe = buildDESCRIBE(uri);

	System.out.println(sDescribe);
	QueryEngineHTTP endpoint
	    = new QueryEngineHTTP(SPARQL_ENDPOINT, sDescribe);
	try {
		Model mTemp = ModelFactory.createDefaultModel();
		endpoint.execDescribe(mTemp);
		if ( filter ) { filterSubject(mTemp, uri); }
		m.add(mTemp);
	}
	catch (RiotException e) {
		System.out.println("Error: " + e.getMessage());
	}
	finally {
		endpoint.close();
	}
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:21,代码来源:VocsUtils.java

示例6: cancelMetricAssessment

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@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.metricName);
		mp.closeAssessment();
	}
	
	logger.info("Closing Iterators");
	try{
		this.iterator.close();
		this.rdfStream.finish();
	}catch (RiotException re){
		logger.info("RDF Stream already closed");
	}

	executor.shutdownNow();
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:22,代码来源:LargeStreamProcessor.java

示例7: cancelMetricAssessment

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@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.metricName);
		mp.closeAssessment();
	}
	
	logger.info("Closing Iterators");
	try{
		this.iterator.close();
		this.rdfStream.finish();
	}catch (RiotException re){
		logger.info("RDF Stream already closed");
	}

	executor.shutdownNow();
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:23,代码来源:StreamProcessor.java

示例8: testWriteWithException

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@Test(expected = WebApplicationException.class)
public void testWriteWithException() throws IOException {

    final FutureCallback<Void> callback = new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void v) {
            throw new AssertionError("Should never happen!");
        }

        @Override
        public void onFailure(final Throwable e) {
            LOGGER.info("Got exception:", e.getMessage());
            assertTrue("Got wrong kind of exception!", e instanceof RiotException);
        }
    };
    addCallback(testRdfStreamStreamingOutput, callback);
    try (final OutputStream mockOutputStream = mock(OutputStream.class, (Answer<Object>) invocation -> {
        throw new RiotException("Expected.");
    })) {
        testRdfStreamStreamingOutput.write(mockOutputStream);
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:24,代码来源:RdfStreamStreamingOutputTest.java

示例9: harvestFromDumps

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
/**
 * Harvests all the triplets from each URI in the @rdfUris list
 */
private void harvestFromDumps() {
	for(String uri : rdfUris) {
		if(uri.isEmpty()) continue;

		logger.info("Harvesting uri [{}]", uri);

		Model model = ModelFactory.createDefaultModel();
		try {
			RDFDataMgr.read(model, uri.trim(), RDFLanguages.RDFXML);
			BulkRequestBuilder bulkRequest = client.prepareBulk();
			addModelToES(model, bulkRequest, true);
		}
		catch (RiotException re) {
			logger.error("Illegal xml character [{}]", re.getLocalizedMessage());
		}
		catch (Exception e) {
			logger.error("Exception when harvesting url: {}. Details: {}",
				uri, e.getLocalizedMessage());
		}
	}
}
 
开发者ID:eea,项目名称:eea.elasticsearch.river.rdf,代码行数:25,代码来源:Harvester.java

示例10: write

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@Override
public void write(final OutputStream output) {
    try {
        LOGGER.debug("Serializing RDF stream in: {}", format);
        write(rdfStream, output, format, mediaType);
    } catch (final IOException | RiotException e) {
        setException(e);
        LOGGER.debug("Error serializing RDF", e.getMessage());
        throw new WebApplicationException(e);
    }
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:12,代码来源:RdfStreamStreamingOutput.java

示例11: read

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@Override
public Stream<? extends Triple> read(final InputStream input, final String base, final RDFSyntax syntax) {
    requireNonNull(input, "The input stream may not be null!");
    requireNonNull(syntax, "The syntax value may not be null!");

    try {
        final org.apache.jena.graph.Graph graph = createDefaultGraph();
        final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                new RuntimeTrellisException("Unsupported RDF Syntax: " + syntax.mediaType()));

        RDFParser.source(input).lang(lang).base(base).parse(graph);

        // Check the graph for any new namespace definitions
        if (nonNull(nsService)) {
            final Set<String> namespaces = nsService.getNamespaces().entrySet().stream().map(Map.Entry::getValue)
                .collect(toSet());
            graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> {
                if (!namespaces.contains(namespace)) {
                    LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace);
                    nsService.setPrefix(prefix, namespace);
                }
            });
        }
        return rdf.asGraph(graph).stream();
    } catch (final RiotException | AtlasException ex) {
        throw new RuntimeTrellisException(ex);
    }
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:29,代码来源:JenaIOService.java

示例12: read

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
@Override
public Stream<? extends Triple> read(final InputStream input, final String base, final RDFSyntax syntax) {
    requireNonNull(input, "The input stream may not be null!");
    requireNonNull(syntax, "The syntax value may not be null!");

    try {
        final org.apache.jena.graph.Graph graph = createDefaultGraph();
        final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                new RuntimeRepositoryException("Unsupported RDF Syntax: " + syntax.mediaType));

        RDFParser.source(input).lang(lang).base(base).parse(graph);

        // Check the graph for any new namespace definitions
        if (nonNull(nsService)) {
            final Set<String> namespaces = nsService.getNamespaces().entrySet().stream().map(Map.Entry::getValue)
                .collect(toSet());
            graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> {
                if (!namespaces.contains(namespace)) {
                    LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace);
                    nsService.setPrefix(prefix, namespace);
                }
            });
        }
        return rdf.asGraph(graph).stream();
    } catch (final RiotException | AtlasException ex) {
        throw new RuntimeRepositoryException(ex);
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:29,代码来源:JenaIOService.java

示例13: deserialize

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
private static Dataset deserialize(final String data) {
    final DatasetGraph dataset = create();
    try (final StringReader reader = new StringReader(data)) {
        read(dataset, reader, null, NQUADS);
    } catch (final RiotException ex) {
        LOGGER.error("Error reading dataset: {}", ex.getMessage());
        return null;
    }
    return rdf.asDataset(dataset);
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file-streaming,代码行数:11,代码来源:EventProcessor.java

示例14: stringToQuad

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
/**
 * Parse a string into a Quad
 * @param rdf the RDF object
 * @param line the line of text
 * @return the Quad
 */
public static Optional<Quad> stringToQuad(final RDF rdf, final String line) {
    final DatasetGraph dataset = create();
    try {
        fromString(line).lang(NQUADS).parse(dataset);
    } catch (final RiotException ex) {
        LOGGER.warn("Skipping invalid data value: {}", line);
        return empty();
    }
    final Iterator<org.apache.jena.sparql.core.Quad> i = dataset.find();
    if (i.hasNext()) {
        return of(i.next()).map(x -> asQuad(rdf, x));
    }
    return empty();
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:21,代码来源:FileUtils.java

示例15: setFormat

import org.apache.jena.riot.RiotException; //导入依赖的package包/类
/**
 * Set the format for an input or output, handling ontologies
 * @param inputOutput The input or output CWL Element
 * @param format The format URI
 */
private void setFormat(CWLElement inputOutput, String format) {
    inputOutput.setFormat(format);
    try {
        if (!rdfService.ontPropertyExists(format)) {
            Model ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
            ontModel.read(format, null, "RDF/XML");
            rdfService.addToOntologies(ontModel);
        }
        String formatLabel = rdfService.getOntLabel(format);
        inputOutput.setType(inputOutput.getType() + " [" + formatLabel + "]");
    } catch (RiotException ex) {
        inputOutput.setType(inputOutput.getType() + " [format]");
    }
}
 
开发者ID:common-workflow-language,项目名称:cwlviewer,代码行数:20,代码来源:CWLService.java


注:本文中的org.apache.jena.riot.RiotException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。