You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2013/02/19 13:52:00 UTC
[29/52] [partial] code contribution,
initial import of relevant modules of LMF-3.0.0-SNAPSHOT based on
revision 4bf944319368 of the default branch at https://code.google.com/p/lmf/
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/main/java/org/apache/marmotta/ldclient/provider/rdf/SPARQLProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/main/java/org/apache/marmotta/ldclient/provider/rdf/SPARQLProvider.java b/ldclient/ldclient-provider-rdf/src/main/java/org/apache/marmotta/ldclient/provider/rdf/SPARQLProvider.java
new file mode 100644
index 0000000..3cdeb97
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/main/java/org/apache/marmotta/ldclient/provider/rdf/SPARQLProvider.java
@@ -0,0 +1,186 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.provider.rdf;
+
+import com.google.common.base.Preconditions;
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+import org.apache.marmotta.ldclient.exception.DataRetrievalException;
+import org.apache.marmotta.ldclient.services.provider.AbstractHttpProvider;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.TupleQueryResultHandler;
+import org.openrdf.query.TupleQueryResultHandlerException;
+import org.openrdf.query.resultio.QueryResultIO;
+import org.openrdf.query.resultio.QueryResultParseException;
+import org.openrdf.query.resultio.TupleQueryResultFormat;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A data provider that allows accessing SPARQL endpoints for retrieving the data associated with a resource. The
+ * data provider will execute SPARQL statements of the form
+ * SELECT ?p ?o WHERE { resource ?p ?o }
+ * to retrieve all "outgoing" properties of a resource.
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class SPARQLProvider extends AbstractHttpProvider {
+
+ public static final String PROVIDER_NAME = "SPARQL";
+ private static Logger log = LoggerFactory.getLogger(SPARQLProvider.class);
+
+
+ /**
+ * Return the name of this data provider. To be used e.g. in the configuration and in log messages.
+ *
+ * @return
+ */
+ @Override
+ public String getName() {
+ return PROVIDER_NAME;
+ }
+
+ /**
+ * Return the list of mime types accepted by this data provider.
+ *
+ * @return
+ */
+ @Override
+ public String[] listMimeTypes() {
+ return new String[]{"application/sparql-results+xml"};
+ }
+
+ /**
+ * Build the URL to use to call the webservice in order to retrieve the data for the resource passed as argument.
+ * In many cases, this will just return the URI of the resource (e.g. Linked Data), but there might be data providers
+ * that use different means for accessing the data for a resource, e.g. SPARQL or a Cache.
+ *
+ *
+ *
+ * @param resourceUri
+ * @param endpoint endpoint configuration for the data provider (optional)
+ * @return
+ */
+ @Override
+ public List<String> buildRequestUrl(String resourceUri, Endpoint endpoint) {
+ Preconditions.checkNotNull(resourceUri);
+ Preconditions.checkNotNull(endpoint);
+ try {
+ String contentType = "application/sparql-results+xml";
+ if(endpoint.getContentTypes().size() > 0) {
+ contentType = endpoint.getContentTypes().iterator().next().toStringNoParameters();
+ }
+
+ String query = "SELECT ?p ?o WHERE { <{uri}> ?p ?o }";
+
+ String url = endpoint.getEndpointUrl()
+ .replace("{query}", URLEncoder.encode(query.replace("{uri}", resourceUri), "UTF-8"))
+ .replace("{contenttype}", URLEncoder.encode(contentType, "UTF-8"));
+
+ return Collections.singletonList(url);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("encoding UTF-8 not supported; the Java environment is severely broken");
+ }
+ }
+
+ /**
+ * Parse the HTTP response entity returned by the web service call and return its contents as a Sesame RDF
+ * repository. The content type returned by the web service is passed as argument to help the implementation
+ * decide how to parse the data.
+ *
+ *
+ *
+ *
+ * @param resourceUri
+ * @param in input stream as returned by the remote webservice
+ * @param contentType content type as returned in the HTTP headers of the remote webservice
+ * @return an RDF repository containing an RDF representation of the dataset located at the remote resource.
+ * @throws java.io.IOException in case an error occurs while reading the input stream
+ */
+ @Override
+ public List<String> parseResponse(final String resourceUri, String requestUrl, final Repository triples, InputStream in, String contentType) throws DataRetrievalException {
+ TupleQueryResultFormat format = QueryResultIO.getParserFormatForMIMEType(contentType, TupleQueryResultFormat.SPARQL);
+
+
+ try {
+
+ QueryResultIO.parse(in,format,
+ new TupleQueryResultHandler() {
+
+ RepositoryConnection con;
+ URI subject;
+
+ @Override
+ public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
+ subject = triples.getValueFactory().createURI(resourceUri);
+ try {
+ con = triples.getConnection();
+ } catch (RepositoryException e) {
+ throw new TupleQueryResultHandlerException("error while creating repository connection",e);
+ }
+ }
+
+ @Override
+ public void endQueryResult() throws TupleQueryResultHandlerException {
+ try {
+ con.commit();
+ con.close();
+ } catch (RepositoryException e) {
+ throw new TupleQueryResultHandlerException("error while closing repository connection",e);
+ }
+ }
+
+ @Override
+ public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException {
+
+ try {
+ Value predicate = bindingSet.getValue("p");
+ Value object = bindingSet.getValue("o");
+
+ if(predicate instanceof URI) {
+ con.add(triples.getValueFactory().createStatement(subject,(URI)predicate,object));
+ } else {
+ log.error("ignoring binding as predicate {} is not a URI",predicate);
+ }
+ } catch (RepositoryException e) {
+ throw new TupleQueryResultHandlerException("error while adding triple to repository connection",e);
+ }
+ }
+ },
+ triples.getValueFactory());
+
+ return Collections.emptyList();
+ } catch (QueryResultParseException e) {
+ throw new DataRetrievalException("parse error while trying to parse remote SPARQL results",e);
+ } catch (TupleQueryResultHandlerException e) {
+ throw new DataRetrievalException("parse error while trying to parse remote SPARQL results",e);
+ } catch (IOException e) {
+ throw new DataRetrievalException("I/O error while trying to read remote RDF content",e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint b/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
new file mode 100644
index 0000000..ddc4102
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
@@ -0,0 +1 @@
+org.apache.marmotta.ldclient.endpoint.rdf.LinkedDataEndpoint
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider b/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
new file mode 100644
index 0000000..9bdcef3
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
@@ -0,0 +1,5 @@
+# add the RDF data providers
+org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider
+org.apache.marmotta.ldclient.provider.rdf.CacheProvider
+org.apache.marmotta.ldclient.provider.rdf.RegexUriProvider
+org.apache.marmotta.ldclient.provider.rdf.SPARQLProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestLinkedDataProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestLinkedDataProvider.java b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestLinkedDataProvider.java
new file mode 100644
index 0000000..182d647
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestLinkedDataProvider.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldclient.test.rdf;
+
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
+import org.apache.marmotta.ldclient.model.ClientResponse;
+import org.apache.marmotta.ldclient.services.ldclient.LDClient;
+import org.apache.marmotta.ldclient.test.helper.TestLDClient;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+
+/**
+ * Test if the LinkedDataProvider is working properly.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TestLinkedDataProvider {
+
+ private static final String DBPEDIA = "http://dbpedia.org/resource/Berlin";
+ private static final String GEONAMES = "http://sws.geonames.org/3020251/";
+
+ private LDClientService ldclient;
+
+ @Before
+ public void setupClient() {
+ ldclient = new TestLDClient(new LDClient());
+ }
+
+ @After
+ public void shutdownClient() {
+ ldclient.shutdown();
+ }
+
+ /**
+ * This method tests accessing the DBPedia Linked Data service, which uses Virtuoso and delivers RDF/XML as
+ * well as text/turtle.
+ *
+ * @throws Exception
+ * @todo find a better way to deal with errors actually in the services and not in the code
+ */
+ @Test
+ public void testDBPedia() throws Exception {
+ Assume.assumeTrue(ldclient.ping(DBPEDIA));
+
+ ClientResponse respBerlin = ldclient.retrieveResource(DBPEDIA);
+
+ RepositoryConnection conBerlin = respBerlin.getTriples().getConnection();
+ conBerlin.begin();
+ Assert.assertTrue(conBerlin.size() > 0);
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("dbpedia-berlin.sparql");
+ BooleanQuery testLabel = conBerlin.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ conBerlin.commit();
+ conBerlin.close();
+ }
+
+ /**
+ * This method tests accessing the GeoNames Linked Data service, which uses HTTP negotiation with redirection to
+ * plan RDF files.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGeoNames() throws Exception {
+ Assume.assumeTrue(ldclient.ping(GEONAMES));
+
+ ClientResponse respEmbrun = ldclient.retrieveResource(GEONAMES);
+
+ RepositoryConnection conEmbrun = respEmbrun.getTriples().getConnection();
+ conEmbrun.begin();
+ Assert.assertTrue(conEmbrun.size() > 0);
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("geonames-embrun.sparql");
+ BooleanQuery testLabel = conEmbrun.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ conEmbrun.commit();
+ conEmbrun.close();
+ }
+
+ /**
+ * This method tests accessing the RDFohloh Linked Data service, which uses HTTP negotiation with redirection to
+ * plan RDF files.
+ *
+ * @throws Exception
+ *
+ */
+ /*
+ @Test
+ public void testRDFOhloh() throws Exception {
+
+ String uriMarmotta = "http://rdfohloh.wikier.org/project/marmotta";
+ ClientResponse respMarmotta = ldclient.retrieveResource(uriMarmotta);
+
+ RepositoryConnection conMarmotta = respMarmotta.getTriples().getConnection();
+ conMarmotta.begin();
+ Assert.assertTrue(conMarmotta.size() > 0);
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("geonames-embrun.sparql");
+ BooleanQuery testLabel = conMarmotta.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ conMarmotta.commit();
+ conMarmotta.close();
+ }
+ */
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestSPARQLProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestSPARQLProvider.java b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestSPARQLProvider.java
new file mode 100644
index 0000000..a2f60d9
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestSPARQLProvider.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldclient.test.rdf;
+
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
+import org.apache.marmotta.ldclient.endpoint.rdf.SPARQLEndpoint;
+import org.apache.marmotta.ldclient.model.ClientConfiguration;
+import org.apache.marmotta.ldclient.model.ClientResponse;
+import org.apache.marmotta.ldclient.services.ldclient.LDClient;
+import org.apache.marmotta.ldclient.test.helper.TestLDClient;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TestSPARQLProvider {
+
+ /**
+ * This method tests accessing the DBPedia SPARQL service, which uses Virtuoso and delivers RDF/XML as
+ * well as text/turtle.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDBPedia() throws Exception {
+
+ ClientConfiguration config = new ClientConfiguration();
+ config.addEndpoint(new SPARQLEndpoint("DBPedia (SPARQL)","http://dbpedia.org/sparql","^http://dbpedia\\.org/resource/.*"));
+
+ LDClientService ldclient = new TestLDClient(new LDClient(config));
+
+ String uriBerlin = "http://dbpedia.org/resource/Berlin";
+ ClientResponse respBerlin = ldclient.retrieveResource(uriBerlin);
+
+ RepositoryConnection conBerlin = respBerlin.getTriples().getConnection();
+ conBerlin.begin();
+ Assert.assertTrue(conBerlin.size() > 0);
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("dbpedia-berlin.sparql");
+ BooleanQuery testLabel = conBerlin.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ conBerlin.commit();
+ conBerlin.close();
+
+ ldclient.shutdown();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestStanbolProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestStanbolProvider.java b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestStanbolProvider.java
new file mode 100644
index 0000000..157ff1c
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/java/org/apache/marmotta/ldclient/test/rdf/TestStanbolProvider.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldclient.test.rdf;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
+import org.apache.marmotta.ldclient.endpoint.rdf.StanbolEndpoint;
+import org.apache.marmotta.ldclient.model.ClientConfiguration;
+import org.apache.marmotta.ldclient.model.ClientResponse;
+import org.apache.marmotta.ldclient.services.ldclient.LDClient;
+import org.apache.marmotta.ldclient.test.helper.TestLDClient;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+
+import java.io.InputStream;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TestStanbolProvider {
+
+ /**
+ * This method tests accessing the DBPedia SPARQL service, which uses Virtuoso and delivers RDF/XML as
+ * well as text/turtle.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDBPedia() throws Exception {
+
+ ClientConfiguration config = new ClientConfiguration();
+ config.addEndpoint(new StanbolEndpoint("DBPedia (Stanbol Cache)","http://dev.iks-project.eu:8080/entityhub/site/dbpedia/","^http://dbpedia\\.org/resource/.*"));
+
+ LDClientService ldclient = new TestLDClient(new LDClient(config));
+
+ String uriBerlin = "http://dbpedia.org/resource/Berlin";
+ ClientResponse respBerlin = ldclient.retrieveResource(uriBerlin);
+
+ RepositoryConnection conBerlin = respBerlin.getTriples().getConnection();
+ conBerlin.begin();
+ Assert.assertTrue(conBerlin.size() > 0);
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("dbpedia-berlin.sparql");
+ BooleanQuery testLabel = conBerlin.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ conBerlin.commit();
+ conBerlin.close();
+
+ ldclient.shutdown();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/dbpedia-berlin.sparql
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/dbpedia-berlin.sparql b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/dbpedia-berlin.sparql
new file mode 100644
index 0000000..1dcdfe1
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/dbpedia-berlin.sparql
@@ -0,0 +1,7 @@
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX dbp: <http://dbpedia.org/ontology/>
+ASK {
+ <http://dbpedia.org/resource/Berlin> rdfs:label "Berlin"@en .
+ <http://dbpedia.org/resource/Berlin> rdf:type dbp:City
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/geonames-embrun.sparql
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/geonames-embrun.sparql b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/geonames-embrun.sparql
new file mode 100644
index 0000000..7211c36
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/geonames-embrun.sparql
@@ -0,0 +1,7 @@
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX gn: <http://www.geonames.org/ontology#>
+ASK {
+ <http://sws.geonames.org/3020251/> gn:name "Embrun" .
+ <http://sws.geonames.org/3020251/> rdf:type gn:Feature
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/ohloh-marmotta.sparql
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/ohloh-marmotta.sparql b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/ohloh-marmotta.sparql
new file mode 100644
index 0000000..5067284
--- /dev/null
+++ b/ldclient/ldclient-provider-rdf/src/test/resources/org/apache/marmotta/ldclient/test/rdf/ohloh-marmotta.sparql
@@ -0,0 +1,8 @@
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+PREFIX doap: <http://usefulinc.com/ns/doap#>
+ASK {
+ http://rdfohloh.wikier.org/project/marmotta> doap:name "Apache Marmotta (incubator)" .
+ <http://rdfohloh.wikier.org/project/marmotta> rdf:type doap:Project
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdfa/.classpath
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdfa/.classpath b/ldclient/ldclient-provider-rdfa/.classpath
new file mode 100644
index 0000000..90df7da
--- /dev/null
+++ b/ldclient/ldclient-provider-rdfa/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdfa/.project
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdfa/.project b/ldclient/ldclient-provider-rdfa/.project
new file mode 100644
index 0000000..88bb971
--- /dev/null
+++ b/ldclient/ldclient-provider-rdfa/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ldclient-provider-rdfa</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.jdt.core.prefs b/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..60105c1
--- /dev/null
+++ b/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.m2e.core.prefs b/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ldclient/ldclient-provider-rdfa/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-rdfa/pom.xml
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-rdfa/pom.xml b/ldclient/ldclient-provider-rdfa/pom.xml
new file mode 100644
index 0000000..74cd227
--- /dev/null
+++ b/ldclient/ldclient-provider-rdfa/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2013 Salzburg Research.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ldclient-provider-rdfa</artifactId>
+ <name>LDClient Provider: RDFa Resource Access</name>
+
+ <description>
+ This package allows the Linked Data Client to access HTML pages with embedded RDFa annotations as
+ Linked Data.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-provider-rdf</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>at.newmedialab.sesame</groupId>
+ <artifactId>sesame-commons</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.sesame</groupId>
+ <artifactId>sesame-tools-rio-rdfa</artifactId>
+ </dependency>
+
+
+ </dependencies>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.classpath
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.classpath b/ldclient/ldclient-provider-vimeo/.classpath
new file mode 100644
index 0000000..bf96ac0
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.classpath
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.project
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.project b/ldclient/ldclient-provider-vimeo/.project
new file mode 100644
index 0000000..268d40d
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ldclient-provider-vimeo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.core.resources.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.core.resources.prefs b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..dc1b414
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.jdt.core.prefs b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..69c31cd
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.m2e.core.prefs b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.component
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.component b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..465bc68
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="ldclient-provider-vimeo">
+ <wb-resource deploy-path="/" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/" source-path="/src/main/resources"/>
+ </wb-module>
+</project-modules>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.project.facet.core.xml
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.project.facet.core.xml b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..c78d932
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jst.utility" version="1.0"/>
+</faceted-project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/pom.xml
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/pom.xml b/ldclient/ldclient-provider-vimeo/pom.xml
new file mode 100644
index 0000000..c82db6c
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2013 The Apache Software Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ldclient-provider-vimeo</artifactId>
+ <name>LDClient Provider: Vimeo Resources</name>
+
+ <description>
+ This package enables the Linked Data Client to access the metadata of Vimeo Videos as if they were published
+ as Linked Data (RDF) by mapping the Vimeo API to the Ontology for Media Resources.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-provider-xml</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.sesame</groupId>
+ <artifactId>sesame-commons</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-queryparser-sparql</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-rio-turtle</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoChannelEndpoint.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoChannelEndpoint.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoChannelEndpoint.java
new file mode 100644
index 0000000..d869071
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoChannelEndpoint.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.endpoint.vimeo;
+
+import org.apache.marmotta.commons.http.ContentType;
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+
+/**
+ * Register the Vimeo Channel Provider for all channel URIs in Vimeo
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoChannelEndpoint extends Endpoint {
+
+ public VimeoChannelEndpoint() {
+ super("Vimeo Channel (Channel)", "Vimeo Channel", "^http://vimeo\\.com/channels/.*", null, 86400L);
+ setPriority(PRIORITY_HIGH);
+ addContentType(new ContentType("application","xml"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoGroupEndpoint.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoGroupEndpoint.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoGroupEndpoint.java
new file mode 100644
index 0000000..eff2937
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoGroupEndpoint.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.endpoint.vimeo;
+
+import org.apache.marmotta.commons.http.ContentType;
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+
+/**
+ * Register the Vimeo Channel Provider for all group URIs in Vimeo.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoGroupEndpoint extends Endpoint {
+
+ public VimeoGroupEndpoint() {
+ super("Vimeo Channel (Group)", "Vimeo Channel", "^http://vimeo\\.com/groups/.*", null, 86400L);
+ setPriority(PRIORITY_HIGH);
+ addContentType(new ContentType("application","xml"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoVideoEndpoint.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoVideoEndpoint.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoVideoEndpoint.java
new file mode 100644
index 0000000..0045ae3
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/endpoint/vimeo/VimeoVideoEndpoint.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.endpoint.vimeo;
+
+import org.apache.marmotta.commons.http.ContentType;
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+
+/**
+ * Register the Youtube Channel Provider for all links to all user GData channels in YouTube
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoVideoEndpoint extends Endpoint {
+
+ public VimeoVideoEndpoint() {
+ super("Vimeo Video", "Vimeo Video", "^http://vimeo\\.com/[0-9]+", null, 86400L);
+ setPriority(PRIORITY_HIGH);
+ addContentType(new ContentType("application","xml"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoChannelProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoChannelProvider.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoChannelProvider.java
new file mode 100644
index 0000000..1559e72
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoChannelProvider.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.provider.vimeo;
+
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+import org.apache.marmotta.ldclient.api.provider.DataProvider;
+import org.apache.marmotta.ldclient.provider.xml.AbstractXMLDataProvider;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathURIMapper;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathValueMapper;
+import org.openrdf.model.URI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoChannelProvider extends AbstractXMLDataProvider implements DataProvider {
+
+ private static final String NS_MEDIA = "http://www.w3.org/ns/ma-ont#";
+
+ private static Map<String,XPathValueMapper> mediaOntMappings = new HashMap<String, XPathValueMapper>();
+ static {
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#hasMember", new XPathURIMapper("/videos/video/url")); // URI
+ }
+
+ private static Logger log = LoggerFactory.getLogger(VimeoVideoProvider.class);
+
+
+ /**
+ * Return the name of this data provider. To be used e.g. in the configuration and in log messages.
+ *
+ * @return
+ */
+ @Override
+ public String getName() {
+ return "Vimeo Channel";
+ }
+
+ /**
+ * Return the list of mime types accepted by this data provider.
+ *
+ * @return
+ */
+ @Override
+ public String[] listMimeTypes() {
+ return new String[] { "application/xml"};
+ }
+
+ /**
+ * Build the URL to use to call the webservice in order to retrieve the data for the resource passed as argument.
+ * In many cases, this will just return the URI of the resource (e.g. Linked Data), but there might be data providers
+ * that use different means for accessing the data for a resource, e.g. SPARQL or a Cache.
+ *
+ *
+ * @param resource
+ * @param endpoint endpoint configuration for the data provider (optional)
+ * @return
+ */
+ @Override
+ public List<String> buildRequestUrl(String resource, Endpoint endpoint) {
+ if(resource.startsWith("http://vimeo.com/channels/")) {
+ String channel_id = resource.substring("http://vimeo.com/channels/".length());
+ String url = "http://vimeo.com/api/v2/channel/" + channel_id + "/videos.xml";
+ return Collections.singletonList(url);
+ } else if(resource.startsWith("http://vimeo.com/groups/")) {
+ String channel_id = resource.substring("http://vimeo.com/groups/".length());
+ String url = "http://vimeo.com/api/v2/group/" + channel_id + "/videos.xml";
+ return Collections.singletonList(url);
+ } else
+ throw new RuntimeException("invalid Vimeo URI: "+resource);
+ }
+
+ /**
+ * Return a mapping table mapping from RDF properties to XPath Value Mappers. Each entry in the map is evaluated
+ * in turn; in case the XPath expression yields a result, the property is added for the processed resource.
+ *
+ * @return
+ * @param requestUrl
+ */
+ @Override
+ protected Map<String, XPathValueMapper> getXPathMappings(String requestUrl) {
+ return mediaOntMappings;
+ }
+
+ /**
+ * Return a list of URIs that should be added as types for each processed resource.
+ *
+ * @return
+ * @param resource
+ */
+ @Override
+ protected List<String> getTypes(URI resource) {
+ return Collections.singletonList(NS_MEDIA + "Collection");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoVideoProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoVideoProvider.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoVideoProvider.java
new file mode 100644
index 0000000..847b9cb
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/VimeoVideoProvider.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.provider.vimeo;
+
+import at.newmedialab.sesame.commons.model.Namespaces;
+import com.google.common.collect.ImmutableList;
+import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
+import org.apache.marmotta.ldclient.api.provider.DataProvider;
+import org.apache.marmotta.ldclient.provider.vimeo.mapping.VimeoDateMapper;
+import org.apache.marmotta.ldclient.provider.xml.AbstractXMLDataProvider;
+import org.apache.marmotta.ldclient.provider.xml.mapping.CommaSeparatedMapper;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathLiteralMapper;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathURIMapper;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathValueMapper;
+import org.openrdf.model.URI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A data provider that allows to wrap Vimeo Videos.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoVideoProvider extends AbstractXMLDataProvider implements DataProvider {
+
+ private static final String NS_MEDIA = "http://www.w3.org/ns/ma-ont#";
+
+ private static Map<String,XPathValueMapper> mediaOntMappings = new HashMap<String, XPathValueMapper>();
+ static {
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#title", new XPathLiteralMapper("/videos/video/title"));
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#locator", new XPathLiteralMapper("/videos/video/url","anyURI")); // URI
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#hasCreator", new XPathURIMapper("/videos/video/user_url")); // URI
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#hasPublisher", new XPathURIMapper("/videos/video/user_url")); // URI
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#date", new VimeoDateMapper("/videos/video/upload_date"));
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#description", new XPathLiteralMapper("/videos/video/description"));
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#hasKeyword", new CommaSeparatedMapper("/videos/video/tags"));
+ mediaOntMappings.put("http://www.w3.org/ns/ma-ont#duration", new XPathLiteralMapper("/videos/video/duration","integer"));
+ mediaOntMappings.put("http://xmlns.com/foaf/0.1/thumbnail", new XPathLiteralMapper("/videos/video/thumbnail_large","anyURI"));
+ mediaOntMappings.put("http://rdfs.org/sioc/ns#num_views", new XPathLiteralMapper("/videos/video/stats_number_of_plays","integer"));
+ mediaOntMappings.put("http://rdfs.org/sioc/ns#num_replies", new XPathLiteralMapper("/videos/video/stats_number_of_comments","integer"));
+ }
+
+
+ private static Logger log = LoggerFactory.getLogger(VimeoVideoProvider.class);
+
+
+ /**
+ * Return the name of this data provider. To be used e.g. in the configuration and in log messages.
+ *
+ * @return
+ */
+ @Override
+ public String getName() {
+ return "Vimeo Video";
+ }
+
+ /**
+ * Return the list of mime types accepted by this data provider.
+ *
+ * @return
+ */
+ @Override
+ public String[] listMimeTypes() {
+ return new String[] { "application/xml"};
+ }
+
+ /**
+ * Build the URL to use to call the webservice in order to retrieve the data for the resource passed as argument.
+ * In many cases, this will just return the URI of the resource (e.g. Linked Data), but there might be data providers
+ * that use different means for accessing the data for a resource, e.g. SPARQL or a Cache.
+ *
+ *
+ * @param resource
+ * @param endpoint endpoint configuration for the data provider (optional)
+ * @return
+ */
+ @Override
+ public List<String> buildRequestUrl(String resource, Endpoint endpoint) {
+ if(resource.startsWith("http://vimeo.com/")) {
+ String video_id = resource.substring("http://vimeo.com/".length());
+ String url = "http://vimeo.com/api/v2/video/" + video_id + ".xml";
+ return Collections.singletonList(url);
+ } else
+ throw new RuntimeException("invalid Vimeo URI: "+resource);
+ }
+
+
+ /**
+ * Return a mapping table mapping from RDF properties to XPath Value Mappers. Each entry in the map is evaluated
+ * in turn; in case the XPath expression yields a result, the property is added for the processed resource.
+ *
+ * @return
+ * @param requestUrl
+ */
+ @Override
+ protected Map<String, XPathValueMapper> getXPathMappings(String requestUrl) {
+ return mediaOntMappings;
+ }
+
+ /**
+ * Return a list of URIs that should be added as types for each processed resource.
+ *
+ * @return
+ * @param resource
+ */
+ @Override
+ protected List<String> getTypes(URI resource) {
+ return ImmutableList.of(NS_MEDIA + "MediaResource", NS_MEDIA + "VideoTrack", Namespaces.NS_LMF_TYPES + "VimeoVideo");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/mapping/VimeoDateMapper.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/mapping/VimeoDateMapper.java b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/mapping/VimeoDateMapper.java
new file mode 100644
index 0000000..09c16af
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/java/org/apache/marmotta/ldclient/provider/vimeo/mapping/VimeoDateMapper.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.provider.vimeo.mapping;
+
+import at.newmedialab.sesame.commons.model.Namespaces;
+import at.newmedialab.sesame.commons.util.DateUtils;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathValueMapper;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class VimeoDateMapper extends XPathValueMapper {
+
+ public VimeoDateMapper(String xpath) {
+ super(xpath);
+ }
+
+ /**
+ * Take the selected value, process it according to the mapping definition, and create Sesame Values using the
+ * factory passed as argument.
+ *
+ *
+ * @param resourceUri
+ * @param selectedValue
+ * @param factory
+ * @return
+ */
+ @Override
+ public List<Value> map(String resourceUri, String selectedValue, ValueFactory factory) {
+ Date date = DateUtils.parseDate(selectedValue);
+ return Collections.singletonList((Value) factory.createLiteral(DateUtils.ISO8601FORMAT.format(date), factory.createURI(Namespaces.NS_XSD + "dateTime")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint b/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
new file mode 100644
index 0000000..c441d18
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.endpoint.Endpoint
@@ -0,0 +1,3 @@
+org.apache.marmotta.ldclient.endpoint.vimeo.VimeoVideoEndpoint
+org.apache.marmotta.ldclient.endpoint.vimeo.VimeoChannelEndpoint
+org.apache.marmotta.ldclient.endpoint.vimeo.VimeoGroupEndpoint
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider b/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
new file mode 100644
index 0000000..8bf67ac
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/main/resources/META-INF/services/org.apache.marmotta.ldclient.api.provider.DataProvider
@@ -0,0 +1,2 @@
+org.apache.marmotta.ldclient.provider.vimeo.VimeoVideoProvider
+org.apache.marmotta.ldclient.provider.vimeo.VimeoChannelProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/test/java/org/apache/marmotta/ldclient/test/vimeo/TestVimeoProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/test/java/org/apache/marmotta/ldclient/test/vimeo/TestVimeoProvider.java b/ldclient/ldclient-provider-vimeo/src/test/java/org/apache/marmotta/ldclient/test/vimeo/TestVimeoProvider.java
new file mode 100644
index 0000000..cd36a86
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/test/java/org/apache/marmotta/ldclient/test/vimeo/TestVimeoProvider.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldclient.test.vimeo;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
+import org.apache.marmotta.ldclient.model.ClientResponse;
+import org.apache.marmotta.ldclient.services.ldclient.LDClient;
+import org.apache.marmotta.ldclient.test.helper.TestLDClient;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.Rio;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TestVimeoProvider {
+
+ private LDClientService ldclient;
+
+ private static Logger log = LoggerFactory.getLogger(TestVimeoProvider.class);
+
+ @Before
+ public void setupClient() {
+ ldclient = new TestLDClient(new LDClient());
+ }
+
+ @After
+ public void shutdownClient() {
+ ldclient.shutdown();
+ }
+
+ /**
+ * This method tests accessing the Youtube Video service via the GData API.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testVideo() throws Exception {
+
+ String uriLMFVideo = "http://vimeo.com/7223527";
+ ClientResponse respLMFVideo = ldclient.retrieveResource(uriLMFVideo);
+
+ RepositoryConnection conLMFVideo = respLMFVideo.getTriples().getConnection();
+ conLMFVideo.begin();
+ Assert.assertTrue(conLMFVideo.size() > 0);
+
+ conLMFVideo.export(Rio.createWriter(RDFFormat.TURTLE, System.out));
+
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("vimeo-video.sparql");
+ BooleanQuery testLabel = conLMFVideo.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ if(log.isDebugEnabled()) {
+ StringWriter out = new StringWriter();
+ conLMFVideo.export(Rio.createWriter(RDFFormat.TURTLE, out));
+ log.debug("DATA:");
+ log.debug(out.toString());
+ }
+
+ conLMFVideo.commit();
+ conLMFVideo.close();
+ }
+
+ /**
+ * This method tests accessing the Vimeo Channel service via the Vimeo API.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testChannel() throws Exception {
+
+ String uriChannel = "http://vimeo.com/channels/ninlive09";
+ ClientResponse respChannel = ldclient.retrieveResource(uriChannel);
+
+ RepositoryConnection conChannel = respChannel.getTriples().getConnection();
+ conChannel.begin();
+ Assert.assertTrue(conChannel.size() > 0);
+
+ conChannel.export(Rio.createWriter(RDFFormat.TURTLE, System.out));
+
+
+ // run a SPARQL test to see if the returned data is correct
+ InputStream sparql = this.getClass().getResourceAsStream("vimeo-channel.sparql");
+ BooleanQuery testLabel = conChannel.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+ Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+ if(log.isDebugEnabled()) {
+ StringWriter out = new StringWriter();
+ conChannel.export(Rio.createWriter(RDFFormat.TURTLE, out));
+ log.debug("DATA:");
+ log.debug(out.toString());
+ }
+
+ conChannel.commit();
+ conChannel.close();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-channel.sparql
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-channel.sparql b/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-channel.sparql
new file mode 100644
index 0000000..e8f0ffa
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-channel.sparql
@@ -0,0 +1,7 @@
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX ma: <http://www.w3.org/ns/ma-ont#>
+ASK {
+ <http://vimeo.com/channels/ninlive09> ma:hasMember <http://vimeo.com/8344405> .
+ <http://vimeo.com/channels/ninlive09> rdf:type ma:Collection
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-video.sparql
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-video.sparql b/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-video.sparql
new file mode 100644
index 0000000..672224f
--- /dev/null
+++ b/ldclient/ldclient-provider-vimeo/src/test/resources/org/apache/marmotta/ldclient/test/vimeo/vimeo-video.sparql
@@ -0,0 +1,7 @@
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX ma: <http://www.w3.org/ns/ma-ont#>
+ASK {
+ <http://vimeo.com/7223527> ma:title "4 Jahreszeiten | 4 Seasons" .
+ <http://vimeo.com/7223527> rdf:type ma:VideoTrack
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.classpath
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.classpath b/ldclient/ldclient-provider-xml/.classpath
new file mode 100644
index 0000000..1b28ee5
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.project
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.project b/ldclient/ldclient-provider-xml/.project
new file mode 100644
index 0000000..97882ca
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ldclient-provider-xml</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.settings/org.eclipse.core.resources.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.settings/org.eclipse.core.resources.prefs b/ldclient/ldclient-provider-xml/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..2b76340
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.settings/org.eclipse.jdt.core.prefs b/ldclient/ldclient-provider-xml/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..69c31cd
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.settings/org.eclipse.m2e.core.prefs b/ldclient/ldclient-provider-xml/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.component
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.component b/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..16e84bd
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="ldclient-provider-xml">
+ <wb-resource deploy-path="/" source-path="/src/main/java"/>
+ </wb-module>
+</project-modules>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.project.facet.core.xml
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.project.facet.core.xml b/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..c78d932
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jst.utility" version="1.0"/>
+</faceted-project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/pom.xml
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/pom.xml b/ldclient/ldclient-provider-xml/pom.xml
new file mode 100644
index 0000000..fd65fc4
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2013 The Apache Software Foundation
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <artifactId>ldclient-provider-xml</artifactId>
+ <name>LDClient Provider: XML Resource Access</name>
+
+ <description>
+ Provides base functionality for all Linked Data resources offering data in various XML formats. Specific
+ data providers / parsers can derive from these base classes.
+ </description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.lmf</groupId>
+ <artifactId>ldclient-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.newmedialab.sesame</groupId>
+ <artifactId>sesame-commons</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c32963d5/ldclient/ldclient-provider-xml/src/main/java/org/apache/marmotta/ldclient/provider/xml/AbstractXMLDataProvider.java
----------------------------------------------------------------------
diff --git a/ldclient/ldclient-provider-xml/src/main/java/org/apache/marmotta/ldclient/provider/xml/AbstractXMLDataProvider.java b/ldclient/ldclient-provider-xml/src/main/java/org/apache/marmotta/ldclient/provider/xml/AbstractXMLDataProvider.java
new file mode 100644
index 0000000..fd6cfce
--- /dev/null
+++ b/ldclient/ldclient-provider-xml/src/main/java/org/apache/marmotta/ldclient/provider/xml/AbstractXMLDataProvider.java
@@ -0,0 +1,171 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.ldclient.provider.xml;
+
+import at.newmedialab.sesame.commons.model.Namespaces;
+import org.apache.marmotta.ldclient.exception.DataRetrievalException;
+import org.apache.marmotta.ldclient.provider.xml.mapping.XPathValueMapper;
+import org.apache.marmotta.ldclient.services.provider.AbstractHttpProvider;
+import org.jdom2.Attribute;
+import org.jdom2.CDATA;
+import org.jdom2.Comment;
+import org.jdom2.Document;
+import org.jdom2.Element;
+import org.jdom2.JDOMException;
+import org.jdom2.Namespace;
+import org.jdom2.Text;
+import org.jdom2.input.SAXBuilder;
+import org.jdom2.input.sax.XMLReaders;
+import org.jdom2.xpath.XPathExpression;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Abstract implementation of a data provider based on XML documents. Implementing classes need to provide
+ * a mapping table mapping from RDF property URIs to XPath Value Mappers that are evaluated on the XML document
+ * (getXPathMappings method), as well as a list of URIs used as types for the created resource.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public abstract class AbstractXMLDataProvider extends AbstractHttpProvider {
+
+
+ /**
+ * Return a mapping table mapping from RDF properties to XPath Value Mappers. Each entry in the map is evaluated
+ * in turn; in case the XPath expression yields a result, the property is added for the processed resource.
+ *
+ * @return
+ * @param requestUrl
+ */
+ protected abstract Map<String,XPathValueMapper> getXPathMappings(String requestUrl);
+
+
+ /**
+ * Return a list of URIs that should be added as types for each processed resource.
+ *
+ * @return
+ * @param resource
+ */
+ protected abstract List<String> getTypes(URI resource);
+
+
+ /**
+ * Provide namespace mappings for the XPath expressions from namespace prefix to namespace URI. May be overridden
+ * by subclasses as appropriate, the default implementation returns an empty map.
+ *
+ * @return
+ */
+ protected Map<String,String> getNamespaceMappings() {
+ return Collections.emptyMap();
+ }
+
+
+ /**
+ * Parse the HTTP response entity returned by the web service call and return its contents as a Sesame RDF
+ * repository. The content type returned by the web service is passed as argument to help the implementation
+ * decide how to parse the data.
+ *
+ *
+ * @param resource the subject of the data retrieval
+ * @param in input stream as returned by the remote webservice
+ * @param contentType content type as returned in the HTTP headers of the remote webservice
+ * @return an RDF repository containing an RDF representation of the dataset located at the remote resource.
+ * @throws java.io.IOException in case an error occurs while reading the input stream
+ */
+ @Override
+ public List<String> parseResponse(String resource, String requestUrl, Repository triples, InputStream in, String contentType) throws DataRetrievalException {
+ // build a JDOM document
+ try {
+ SAXBuilder parser = new SAXBuilder(XMLReaders.NONVALIDATING);
+ Document doc = parser.build(in);
+
+
+ Set<Namespace> namespaces = new HashSet<Namespace>();
+ for(Map.Entry<String,String> ns : getNamespaceMappings().entrySet()) {
+ namespaces.add(Namespace.getNamespace(ns.getKey(), ns.getValue()));
+ }
+
+
+ RepositoryConnection con = triples.getConnection();
+ ValueFactory vf = con.getValueFactory();
+
+ Resource subject = vf.createURI(resource);
+
+ for(Map.Entry<String,XPathValueMapper> mapping : getXPathMappings(requestUrl).entrySet()) {
+ XPathExpression<Object> xpath = mapping.getValue().getCompiled();
+
+ org.openrdf.model.URI predicate = triples.getValueFactory().createURI(mapping.getKey());
+ for(Object value : xpath.evaluate(doc)) {
+ String str_value;
+ if(value instanceof Element) {
+ str_value = ((Element) value).getValue();
+ } else if(value instanceof Text) {
+ str_value = ((Text) value).getValue();
+ } else if(value instanceof Attribute) {
+ str_value = ((Attribute) value).getValue();
+ } else if(value instanceof CDATA) {
+ str_value = ((CDATA) value).getValue();
+ } else if(value instanceof Comment) {
+ str_value = ((Comment) value).getValue();
+ } else {
+ str_value = value.toString();
+ }
+ List<Value> objects = mapping.getValue().map(resource, str_value,triples.getValueFactory());
+ for(Value object : objects) {
+ Statement stmt = triples.getValueFactory().createStatement(subject,predicate,object);
+ con.add(stmt);
+ }
+ }
+ }
+
+ org.openrdf.model.URI ptype = triples.getValueFactory().createURI(Namespaces.NS_RDF + "type");
+
+ for(String typeUri : getTypes(vf.createURI(resource))) {
+ Resource type_resource = vf.createURI(typeUri);
+ con.add(vf.createStatement(subject, ptype, type_resource));
+ }
+
+ con.commit();
+ con.close();
+
+ return Collections.emptyList();
+
+ } catch (JDOMException e) {
+ throw new DataRetrievalException("could not parse XML response. It is not in proper XML format",e);
+ } catch (IOException e) {
+ throw new DataRetrievalException("I/O error while parsing XML response",e);
+ } catch (RepositoryException e) {
+ throw new DataRetrievalException("repository error while parsing XML response",e);
+ }
+
+ }
+
+
+}