You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/02/19 18:04:23 UTC

[3/51] [abbrv] reorganized repository

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/CoreIT.java
----------------------------------------------------------------------
diff --git a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/CoreIT.java b/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/CoreIT.java
deleted file mode 100644
index 167a73e..0000000
--- a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/CoreIT.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 at.newmedialab.lmf.client.test.search;
-
-import at.newmedialab.lmf.client.ClientConfiguration;
-import at.newmedialab.lmf.client.clients.CoresClient;
-import at.newmedialab.lmf.search.api.indexing.SolrIndexingService;
-import kiwi.core.test.base.JettyLMF;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class CoreIT {
-
-    private final static Logger log = LoggerFactory.getLogger(CoreIT.class);
-
-    private static JettyLMF lmf;
-
-    private static ClientConfiguration config;
-
-    private static SolrIndexingService indexingService;
-
-    @BeforeClass
-    public static void init() {
-        lmf = new JettyLMF("/LMF",8080);
-        config = new ClientConfiguration("http://localhost:8080/LMF");
-        indexingService = lmf.getService(SolrIndexingService.class);
-
-    }
-
-    @AfterClass
-    public static void tearDown() {
-        lmf.shutdown();
-    }
-
-
-    @Test
-    public void testCreateCore() throws Exception {
-        String program = "title = rdfs:label :: xsd:string ;";
-
-        CoresClient client = new CoresClient(config);
-
-        client.createCoreConfiguration("lmfclient", program);
-
-        // wait for thread to finish
-        do {
-            log.info("waiting for server to finish ...");
-            Thread.sleep(500);
-        } while(indexingService.isRunning());
-
-        List<String> coreNames = client.listCores();
-        assertThat(coreNames, hasItem("lmfclient"));
-
-        String testProgram = client.getCoreConfiguration("lmfclient");
-        assertThat(testProgram, is(equalToIgnoringWhiteSpace(program)));
-
-        client.deleteCore("lmfclient");
-        List<String> coreNames2 = client.listCores();
-        assertThat(coreNames2, not(hasItem("lmfclient")));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/SearchIT.java
----------------------------------------------------------------------
diff --git a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/SearchIT.java b/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/SearchIT.java
deleted file mode 100644
index 19155b7..0000000
--- a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/search/SearchIT.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012 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 at.newmedialab.lmf.client.test.search;
-
-import at.newmedialab.lmf.client.ClientConfiguration;
-import at.newmedialab.lmf.client.clients.SearchClient;
-import at.newmedialab.lmf.client.test.ldpath.LDPathIT;
-import at.newmedialab.lmf.search.api.indexing.SolrIndexingService;
-import kiwi.core.api.importer.ImportService;
-import kiwi.core.exception.io.LMFImportException;
-import kiwi.core.test.base.JettyLMF;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.common.SolrDocumentList;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.InputStream;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class SearchIT {
-
-    private final static Logger log = LoggerFactory.getLogger(SearchIT.class);
-
-
-
-    private static JettyLMF lmf;
-
-    private static ClientConfiguration config;
-
-    // the tests require the demo-data.foaf to be loaded; we do so by first calling the import service before we start with tests
-    private static ImportService importService;
-
-    private static SolrIndexingService indexingService;
-
-    @BeforeClass
-    public static void init() throws LMFImportException, InterruptedException {
-        lmf = new JettyLMF("/LMF",8080);
-
-        config = new ClientConfiguration("http://localhost:8080/LMF");
-
-        importService = lmf.getService(ImportService.class);
-
-        indexingService = lmf.getService(SolrIndexingService.class);
-
-        // load initial data
-        InputStream data =  LDPathIT.class.getResourceAsStream("/demo-data.foaf");
-
-        importService.importData(data,"application/rdf+xml",null,null);
-
-        // wait for thread to finish
-        do {
-            log.info("waiting for server to finish indexing ...");
-            Thread.sleep(1000);
-        } while(indexingService.isRunning());
-    }
-
-    @AfterClass
-    public static void tearDown() {
-        lmf.shutdown();
-    }
-
-
-    // assumes the demo-data.foaf is loaded on the server
-    @Test
-    public void searchTest() throws Exception {
-        SearchClient client = new SearchClient(config);
-
-        SolrQuery query = new SolrQuery("summary:Sepp");
-        SolrDocumentList result = client.search("dc",query);
-
-        Assert.assertTrue(result.size() > 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/sparql/SPARQLIT.java
----------------------------------------------------------------------
diff --git a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/sparql/SPARQLIT.java b/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/sparql/SPARQLIT.java
deleted file mode 100644
index 9441732..0000000
--- a/client/lmf-client-java/src/test/java/at/newmedialab/lmf/client/test/sparql/SPARQLIT.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012 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 at.newmedialab.lmf.client.test.sparql;
-
-import at.newmedialab.lmf.client.ClientConfiguration;
-import at.newmedialab.lmf.client.clients.SPARQLClient;
-import at.newmedialab.lmf.client.model.sparql.SPARQLResult;
-import at.newmedialab.lmf.client.test.ldpath.LDPathIT;
-import at.newmedialab.lmf.client.test.search.CoreIT;
-import at.newmedialab.lmf.search.api.indexing.SolrIndexingService;
-import kiwi.core.api.importer.ImportService;
-import kiwi.core.exception.io.LMFImportException;
-import kiwi.core.test.base.JettyLMF;
-import org.hamcrest.Matcher;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.InputStream;
-
-import static org.hamcrest.Matchers.*;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class SPARQLIT {
-    private final static Logger log = LoggerFactory.getLogger(SPARQLIT.class);
-
-    private static JettyLMF lmf;
-
-    private static ClientConfiguration config;
-
-    // the tests require the demo-data.foaf to be loaded; we do so by first calling the import service before we start with tests
-    private static ImportService importService;
-
-
-    @BeforeClass
-    public static void init() throws LMFImportException {
-        lmf = new JettyLMF("/LMF",8080);
-        config = new ClientConfiguration("http://localhost:8080/LMF");
-
-        importService = lmf.getService(ImportService.class);
-
-        // load initial data
-        InputStream data =  LDPathIT.class.getResourceAsStream("/demo-data.foaf");
-
-        importService.importData(data,"application/rdf+xml",null,null);
-    }
-
-    @AfterClass
-    public static void tearDown() {
-        lmf.shutdown();
-    }
-
-
-    @Test
-    public void testSparqlSelect() throws Exception {
-        SPARQLClient client = new SPARQLClient(config);
-
-        SPARQLResult result = client.select("SELECT ?r ?n WHERE { ?r <http://xmlns.com/foaf/0.1/name> ?n }");
-        Assert.assertEquals(3, result.size());
-        Assert.assertThat(result, (Matcher) hasItems(hasKey("r"), hasKey("n")));
-        Assert.assertThat(result,(Matcher)hasItem(hasValue(hasProperty("content", equalTo("Sepp Huber")))));
-    }
-
-
-    @Test
-    public void testSparqlAsk() throws Exception {
-        SPARQLClient client = new SPARQLClient(config);
-
-        boolean result = client.ask("ASK { ?r <http://xmlns.com/foaf/0.1/name> ?n }");
-        Assert.assertTrue(result);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/lmf-client-java/src/test/resources/demo-data.foaf
----------------------------------------------------------------------
diff --git a/client/lmf-client-java/src/test/resources/demo-data.foaf b/client/lmf-client-java/src/test/resources/demo-data.foaf
deleted file mode 100644
index bdd8de0..0000000
--- a/client/lmf-client-java/src/test/resources/demo-data.foaf
+++ /dev/null
@@ -1,80 +0,0 @@
-<!--
-  ~ Copyright (c) 2012 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.
-  -->
-
-<rdf:RDF
-        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-        xmlns:foaf="http://xmlns.com/foaf/0.1/"
-        xmlns:dc="http://purl.org/dc/elements/1.1/"
-        xmlns:skos="http://www.w3.org/2004/02/skos/core#"
-        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
-        >
-
-    <foaf:Person rdf:about="http://localhost:8080/LMF/resource/hans_meier" xmlns:foaf="http://xmlns.com/foaf/0.1/">
-        <foaf:name>Hans Meier</foaf:name>
-        <dc:description>Hans Meier is a software engineer living in Salzburg</dc:description>
-        <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.software_engineering"/>
-        <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.linux"/>
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Java" />
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
-        <foaf:based_near rdf:resource="http://sws.geonames.org/2766824/"/>
-        <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/hans_meier.jpg"/>
-
-        <foaf:knows rdf:resource="http://bblfish.net/people/henry/card#me" />
-        <foaf:knows rdf:resource="http://dbpedia.org/resource/James_Gosling"/>
-    </foaf:Person>
-
-    <foaf:Person rdf:about="http://localhost:8080/LMF/resource/sepp_huber" xmlns:foaf="http://xmlns.com/foaf/0.1/">
-        <foaf:name>Sepp Huber</foaf:name>
-        <dc:description>Sepp Huber is an alpinist living in Traunstein. He is a good climber, but not as famous as his cousin Alexander Huber.</dc:description>
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
-        <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
-        <foaf:based_near rdf:resource="http://dbpedia.org/resource/Traunstein"/>
-
-        <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
-        <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/hans_meier" />
-    </foaf:Person>
-
-    <foaf:Person rdf:about="http://localhost:8080/LMF/resource/anna_schmidt" xmlns:foaf="http://xmlns.com/foaf/0.1/">
-        <foaf:name>Anna Schmidt</foaf:name>
-        <dc:description>Anna Schmidt is working as PR manager for mountaineers coming from Garmisch-Partenkirchen. She likes mountaineering and is also a Linux enthusiast.</dc:description>
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
-        <foaf:interest rdf:resource="http://dbpedia.org/resource/Linux"/>
-        <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
-        <foaf:based_near rdf:resource="http://dbpedia.org/resource/Garmisch-Partenkirchen"/>
-        <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/anna_schmidt.jpg"/>
-
-        <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
-        <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/sepp_huber" />
-    </foaf:Person>
-
-    <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.linux">
-        <rdfs:label>GNU/Linux</rdfs:label>
-    </skos:Concept>
-
-    <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.software_engineering">
-        <rdfs:label>Software Engineering</rdfs:label>
-    </skos:Concept>
-
-    <skos:Concept rdf:about="http://dbpedia.org/resource/Java">
-        <rdfs:label>Java</rdfs:label>
-    </skos:Concept>
-
-    <skos:Concept rdf:about="http://dbpedia.org/resource/Climbing">
-        <rdfs:label>Climbing</rdfs:label>
-    </skos:Concept>
-
-</rdf:RDF>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/pom.xml
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/pom.xml b/client/marmotta-client-java/pom.xml
new file mode 100644
index 0000000..7747910
--- /dev/null
+++ b/client/marmotta-client-java/pom.xml
@@ -0,0 +1,194 @@
+<?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>org.apache.marmotta</groupId>
+        <artifactId>marmotta-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>marmotta-client-java</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache Marmotta Client Library for Java</name>
+    <description>
+        A Java Library for accessing a remote LMF installation using REST webservice calls.
+    </description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>2.5</version>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>/tmp/lmf-test</directory>
+                            <followSymlinks>true</followSymlinks>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.solr</groupId>
+            <artifactId>solr-solrj</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-core-asl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-ext</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jul-to-slf4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+
+        <!-- LMF Testing Package -->
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>lmf-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty-embedded</artifactId>
+            <version>6.1.26</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.restassured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.tempus-fugit</groupId>
+            <artifactId>tempus-fugit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.jatl</groupId>
+            <artifactId>jatl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>lmf-core</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>lmf-ldpath</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>lmf-sparql</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/ClientConfiguration.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/ClientConfiguration.java
new file mode 100644
index 0000000..06a46f7
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/ClientConfiguration.java
@@ -0,0 +1,126 @@
+/**
+ * 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 at.newmedialab.lmf.client;
+
+import org.apache.http.conn.ClientConnectionManager;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ClientConfiguration {
+
+	/**
+	 * The URI at which the LMF installation can be located
+	 */
+	private String lmfUri;
+
+	/**
+	 * (Optional) user to authenticate with the LMF system
+	 */
+	private String lmfUser;
+
+	/**
+	 * (Optional) password to authenticate with the LMF system
+	 */
+	private String lmfPassword;
+
+	/**
+	 * (Optional) context in the LMF system
+	 */
+	private String lmfContext;
+
+	/**
+	 * Socket timeout for established HTTP connections. Connection will be
+	 * closed afterwards. Default: 60 seconds.
+	 */
+	private int soTimeout = 60000;
+
+	/**
+	 * Connection timeout for opening HTTP connections. If idle for this time,
+	 * will be closed. Default: 10 seconds.
+	 */
+	private int connectionTimeout = 10000;
+	
+	private ClientConnectionManager conectionManager;
+
+	public ClientConfiguration(String lmfUri) {
+		this.lmfUri = lmfUri;
+	}
+
+	public ClientConfiguration(String lmfUri, String lmfUser, String lmfPassword) {
+		this.lmfUri = lmfUri;
+		this.lmfUser = lmfUser;
+		this.lmfPassword = lmfPassword;
+	}
+
+	public String getLmfUri() {
+		return lmfUri;
+	}
+
+	public void setLmfUri(String lmfUri) {
+		this.lmfUri = lmfUri;
+	}
+
+	public String getLmfUser() {
+		return lmfUser;
+	}
+
+	public void setLmfUser(String lmfUser) {
+		this.lmfUser = lmfUser;
+	}
+
+	public String getLmfPassword() {
+		return lmfPassword;
+	}
+
+	public void setLmfPassword(String lmfPassword) {
+		this.lmfPassword = lmfPassword;
+	}
+
+	public String getLmfContext() {
+		return lmfContext;
+	}
+
+	public void setLmfContext(String lmfContext) {
+		this.lmfContext = lmfContext;
+	}
+
+	public int getSoTimeout() {
+		return soTimeout;
+	}
+
+	public void setSoTimeout(int soTimeout) {
+		this.soTimeout = soTimeout;
+	}
+
+	public int getConnectionTimeout() {
+		return connectionTimeout;
+	}
+
+	public void setConnectionTimeout(int connectionTimeout) {
+		this.connectionTimeout = connectionTimeout;
+	}
+
+    public ClientConnectionManager getConectionManager() {
+        return conectionManager;
+    }
+
+    public void setConectionManager(ClientConnectionManager conectionManager) {
+        this.conectionManager = conectionManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/LMFClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/LMFClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/LMFClient.java
new file mode 100644
index 0000000..8c11b05
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/LMFClient.java
@@ -0,0 +1,110 @@
+/**
+ * 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 at.newmedialab.lmf.client;
+
+import at.newmedialab.lmf.client.clients.ClassificationClient;
+import at.newmedialab.lmf.client.clients.ConfigurationClient;
+import at.newmedialab.lmf.client.clients.CoresClient;
+import at.newmedialab.lmf.client.clients.ImportClient;
+import at.newmedialab.lmf.client.clients.LDPathClient;
+import at.newmedialab.lmf.client.clients.ResourceClient;
+import at.newmedialab.lmf.client.clients.SPARQLClient;
+import at.newmedialab.lmf.client.clients.SearchClient;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LMFClient {
+    
+    public static final String VERSION = "0.1.0";
+
+    private ClientConfiguration config;
+
+
+    public LMFClient(ClientConfiguration config) {
+        this.config = config;
+    }
+    
+    /**
+     * Return a client to access the LMF Resource Service. Supports creating and deleting resources as well as
+     * updating and retrieving the metadata and content of resources.
+     *
+     * @return
+     */
+    public ResourceClient getResourceClient() {
+        return new ResourceClient(config);
+    }
+
+
+    /**
+     * Return a client that allows to access and modify the server configuration.
+     * @return
+     */
+    public ConfigurationClient getConfigurationClient() {
+        return new ConfigurationClient(config);
+    }
+
+    /**
+     * Return a client that allows executing SPARQL 1.1 queries and updates on the LMF Server.
+     * @return
+     */
+    public SPARQLClient getSPARQLClient() {
+        return new SPARQLClient(config);
+    }
+
+    /**
+     * Return a client that allows importing of datasets and ontologies on the LMF Server.
+     * @return
+     */
+    public ImportClient getImportClient() {
+        return new ImportClient(config);
+    }
+
+
+    /**
+     * Return a client that allows running SOLR searches on the LMF semantic search cores
+     */
+    public SearchClient getSearchClient() {
+        return new SearchClient(config);
+    }
+
+
+    /**
+     * Return a client that allows reading and modifying the LMF semantic search cores.
+     */
+    public CoresClient getSearchCoresClient() {
+        return new CoresClient(config);
+    }
+
+    /**
+     * Return a client that allows accessing the LDPath service for evaluating LDPath queries.
+     * @return
+     */
+    public LDPathClient getLDPathClient() {
+        return new LDPathClient(config);
+    }
+
+
+    /**
+     * Return a client that allows managing and training classifiers and classifying text.
+     * @return
+     */
+    public ClassificationClient getClassificationClient() {
+        return new ClassificationClient(config);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ClassificationClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ClassificationClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ClassificationClient.java
new file mode 100644
index 0000000..9e6aee6
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ClassificationClient.java
@@ -0,0 +1,362 @@
+/**
+ * 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 at.newmedialab.lmf.client.clients;
+
+import at.newmedialab.lmf.client.ClientConfiguration;
+import at.newmedialab.lmf.client.exception.LMFClientException;
+import at.newmedialab.lmf.client.model.classification.Classification;
+import at.newmedialab.lmf.client.model.rdf.URI;
+import at.newmedialab.lmf.client.util.HTTPUtil;
+import com.google.common.base.Preconditions;
+import com.google.common.io.ByteStreams;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentProducer;
+import org.apache.http.entity.EntityTemplate;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A client supporting access to the LMF Classification Services. Allows creating and removing classifiers as
+ * well as training classifiers with sample data and the classification of textual documents.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ClassificationClient {
+
+    private static Logger log = LoggerFactory.getLogger(ClassificationClient.class);
+
+    private static final String URL_CLASSIFICATION_SERVICE = "/classifier";
+
+
+    private ClientConfiguration config;
+
+    public ClassificationClient(ClientConfiguration config) {
+        this.config = config;
+    }
+
+
+    /**
+     * Create a new classifier with the given name. The service will take care of creating the appropriate
+     * configuration entries and work files in the LMF work directory.
+     *
+     * @param name a string identifying the classifier; should only consist of alphanumeric characters (no white spaces)
+     */
+    public boolean createClassifier(String name) throws LMFClientException, IOException {
+        Preconditions.checkArgument(name.matches("^\\p{Alnum}+$"));
+
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpPost post = new HttpPost(config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + name);
+        
+        try {
+
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 403:
+                    log.debug("classifier {} already existed, not creating new",name);
+                    return true;
+                case 200:
+                    log.debug("classifier {} created",name);
+                    return true;
+                default:
+                    log.error("error creating classifier {}: {} {}",new Object[] {name,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    return true;
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            return false;
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Remove the classifier with the given name from the system configuration.
+     *
+     * @param name       a string identifying the classifier; should only consist of alphanumeric characters (no white spaces)
+     * @param removeData also remove all training and model data of this classifier from the file system
+     */
+    public void removeClassifier(String name, boolean removeData) throws LMFClientException, IOException {
+        Preconditions.checkArgument(name.matches("^\\p{Alnum}+$"));
+
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpDelete delete = new HttpDelete(config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + name + (removeData?"?removeData=true":""));
+            
+            try {
+            
+            HttpResponse response = httpClient.execute(delete);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classifier {} deleted", name);
+                    break;
+                case 404:
+                    log.error("classifier {} does not exist, cannot delete", name);
+                    break;
+                default:
+                    log.error("error deleting classifier {}: {} {}",new Object[] {name,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            delete.abort();
+            log.error("could not encode URI parameter",e);
+        } finally {
+            delete.releaseConnection();
+        }
+    }
+
+
+    /**
+     * List all classifiers registered in the classification service.
+     *
+     * @return a collection of Classifier instances representing all registered classifiers
+     */
+    public Collection<String> listClassifiers() throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/list";
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/json");
+
+        try {
+            
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classifiers listed successfully");
+                    ObjectMapper mapper = new ObjectMapper();
+                    List<String> result = mapper.readValue(response.getEntity().getContent(),new TypeReference<List<String>>(){});
+                    
+                    return result;
+                default:
+                    log.error("error retrieving list of classifiers: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving list of classifiers: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Add training data to the classifier identified by the given name and for the concept passed as argument. Note
+     * that training data is not immediately taken into account by the classifier. Retraining of the classifier will
+     * take place when a certain threshold of training datasets has been added or when a certain (configurable) time has
+     * passed.
+     *
+     * @param name        a string identifying the classifier; should only consist of alphanumeric characters (no white spaces)
+     * @param concept_uri the URI of the concept which to train with the sample text
+     * @param sampleText  the sample text for the concept
+     */
+    public void trainClassifier(String name, String concept_uri, final String sampleText) throws LMFClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + URLEncoder.encode(name,"utf-8") + "/train?concept=" + URLEncoder.encode(concept_uri,"utf-8");
+
+        HttpPost post = new HttpPost(serviceUrl);
+        post.setHeader("Content-Type", "text/plain");
+        
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(new ByteArrayInputStream(sampleText.getBytes("utf-8")), outstream);
+            }
+        };
+        
+        post.setEntity(new EntityTemplate(cp));
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classifier {} updated successfully",name);
+                    break;
+                default:
+                    log.error("error updating classifier {}: {} {}",new Object[] {name,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating classifier "+name+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Retrain the classifier with the given name immediately. Will read in the training data and create a new
+     * classification model.
+     *
+     * @param name
+     * @throws LMFClientException
+     */
+    public void retrainClassifier(String name) throws LMFClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + URLEncoder.encode(name,"utf-8") + "/retrain";
+
+        HttpPost post = new HttpPost(serviceUrl);
+        
+        try {
+            
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classifier {} retrained successfully",name);
+                    break;
+                default:
+                    log.error("error retraining classifier {}: {} {}",new Object[] {name,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating classifier "+name+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Get classifications from the given classifier for the given text. The classifications will be ordered by
+     * descending probability, so that classifications with higher probability will be first. A classification object
+     * consists of a KiWiUriResource identifying the classified concept and a probability indicating how likely it is
+     * that the text matches the given concept.
+     *
+     * @param classifier a string identifying the classifier; should only consist of alphanumeric characters (no white spaces)
+     * @param text       the text to classify
+     * @return a list of classifications ordered by descending probability
+     */
+    public List<Classification> getAllClassifications(String classifier, final String text) throws LMFClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + classifier+"/classify";
+
+        HttpPost post = new HttpPost(serviceUrl);
+        post.setHeader("Content-Type", "text/plain");
+        
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(new ByteArrayInputStream(text.getBytes("utf-8")), outstream);
+            }
+        };
+        
+        post.setEntity(new EntityTemplate(cp));
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classification {} executed successfully",classifier);
+                    ObjectMapper mapper = new ObjectMapper();
+                    List<Map<String,String>> jsonResult =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<List<Map<String,String>>>(){});
+
+                    List<Classification> result = new LinkedList<Classification>();
+                    for(Map<String,String> entry : jsonResult) {
+                        result.add(new Classification(new URI(entry.get("concept")), Double.parseDouble(entry.get("probability"))));
+                    }
+                    return result;
+                default:
+                    log.error("error executing classifier {}: {} {}",new Object[] {classifier,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error executing classifier "+classifier+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Get classifications from the given classifier for the given text. The classifications will be ordered by
+     * descending probability, so that classifications with higher probability will be first. Only classifications with
+     * a probability higher than the threshold will be considered. A classification object
+     * consists of a KiWiUriResource identifying the classified concept and a probability indicating how likely it is
+     * that the text matches the given concept.
+     *
+     * @param classifier a string identifying the classifier; should only consist of alphanumeric characters (no white spaces)
+     * @param text       the text to classify
+     * @param threshold  the minimum probability of a classification to be considered in the result
+     * @return a list of classifications ordered by descending probability, all having higher probability than threshold
+     */
+    public List<Classification> getAllClassifications(String classifier, final String text, double threshold) throws LMFClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CLASSIFICATION_SERVICE + "/" + classifier+"/classify?threshold="+threshold;
+
+        HttpPost post = new HttpPost(serviceUrl);
+        post.setHeader("Content-Type", "text/plain");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(new ByteArrayInputStream(text.getBytes("utf-8")), outstream);
+            }
+        };
+        post.setEntity(new EntityTemplate(cp));
+        
+        try {
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("classification {} executed successfully",classifier);
+                    ObjectMapper mapper = new ObjectMapper();
+                    List<Map<String,String>> jsonResult =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<List<Map<String,String>>>(){});
+
+                    List<Classification> result = new LinkedList<Classification>();
+                    for(Map<String,String> entry : jsonResult) {
+                        result.add(new Classification(new URI(entry.get("concept")), Double.parseDouble(entry.get("probability"))));
+                    }
+                    return result;
+                default:
+                    log.error("error executing classifier {}: {} {}",new Object[] {classifier,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error executing classifier "+classifier+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ConfigurationClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ConfigurationClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ConfigurationClient.java
new file mode 100644
index 0000000..1d5dd5a
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ConfigurationClient.java
@@ -0,0 +1,264 @@
+/**
+ * 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 at.newmedialab.lmf.client.clients;
+
+import at.newmedialab.lmf.client.ClientConfiguration;
+import at.newmedialab.lmf.client.exception.LMFClientException;
+import at.newmedialab.lmf.client.exception.NotFoundException;
+import at.newmedialab.lmf.client.model.config.Configuration;
+import at.newmedialab.lmf.client.util.HTTPUtil;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentProducer;
+import org.apache.http.entity.EntityTemplate;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A client that supports accessing the configuration webservice of the Linked Media Framework. May be used for
+ * retrieving as well as changing properties.
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ConfigurationClient {
+    private static Logger log = LoggerFactory.getLogger(ConfigurationClient.class);
+
+    private static final String URL_CONFIG_SERVICE = "/config";
+
+
+    private ClientConfiguration config;
+
+    public ConfigurationClient(ClientConfiguration config) {
+        this.config = config;
+    }
+
+    /**
+     * Return a list of all configuration keys that are currently set in the LMF configuration.
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public Set<String> listConfigurationKeys() throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpGet get = new HttpGet(config.getLmfUri() + URL_CONFIG_SERVICE + "/list");
+        get.setHeader("Accept", "application/json");
+
+        try {
+            
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("configurations listed successfully");
+                    ObjectMapper mapper = new ObjectMapper();
+                    Map<String,Map<String,Object>> result =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,Map<String,Object>>>(){});
+                    return result.keySet();
+                default:
+                    log.error("error retrieving list of configuration keys: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving list of configuration keys: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Return a list of all configurations (keys and values) that are currently set in the LMF configuration.
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public Set<Configuration> listConfigurations(String prefix) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CONFIG_SERVICE + "/list" + (prefix != null? "?prefix="+ URLEncoder.encode(prefix,"utf-8") : "");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/json");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("configurations listed successfully");
+                    ObjectMapper mapper = new ObjectMapper();
+                    Map<String,Map<String,Object>> resultMap =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,Map<String,Object>>>(){});
+                    
+                    Set<Configuration> result = new HashSet<Configuration>();
+                    for(Map.Entry<String,Map<String,Object>> entry : resultMap.entrySet()) {
+                        result.add(new Configuration(entry.getKey(),entry.getValue().get("value")));
+                    }
+                    return result;
+                default:
+                    log.error("error retrieving list of configuration keys: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving list of configuration keys: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Return the configuration with the given key, or null if it does not exist
+     * @param key
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public Configuration getConfiguration(String key) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CONFIG_SERVICE + "/data/" + URLEncoder.encode(key,"utf-8");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/json");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("configuration {} retrieved successfully",key);
+                    ObjectMapper mapper = new ObjectMapper();
+                    Map<String,Object> resultMap =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,Object>>(){});
+
+                    if(resultMap.isEmpty()) {
+                        return null;
+                    } else {
+                        return new Configuration(key,resultMap.get(key));
+                    }
+                case 404:
+                    log.info("configuration with key {} does not exist", key);
+                    return null;
+                default:
+                    log.error("error retrieving configuration {}: {} {}",new Object[] {key,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving configuration "+key+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Update the configuration "key" with the given value. Value can be either a list of values or one of the
+     * primitive types String, Boolean, Integer, Double
+     * @param key
+     * @param value
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void setConfiguration(String key, final Object value) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CONFIG_SERVICE + "/data/" + URLEncoder.encode(key,"utf-8");
+
+        HttpPost post = new HttpPost(serviceUrl);
+        post.setHeader("Content-Type", "application/json");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ObjectMapper mapper = new ObjectMapper();
+                if(value instanceof Collection) {
+                    mapper.writeValue(outstream,value);
+                } else {
+                    mapper.writeValue(outstream, Collections.singletonList(value.toString()));
+                }
+            }
+        };
+        post.setEntity(new EntityTemplate(cp));
+        
+        try {
+
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("configuration {} updated successfully",key);
+                    break;
+                case 404:
+                    log.error("configuration with key {} does not exist",key);
+                    throw new NotFoundException("configuration with key "+key+" does not exist");
+                default:
+                    log.error("error updating configuration {}: {} {}",new Object[] {key,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating configuration "+key+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }        
+    }
+
+    /**
+     * Remove the configuration with the given key.
+     *
+     * @param key
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void deleteConfiguration(String key) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CONFIG_SERVICE + "/data/" + URLEncoder.encode(key,"utf-8");
+
+        HttpDelete delete = new HttpDelete(serviceUrl);
+            
+        try {
+            HttpResponse response = httpClient.execute(delete);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("configuration {} deleted successfully",key);
+                    break;
+                case 404:
+                    log.error("configuration with key {} does not exist",key);
+                    throw new NotFoundException("configuration with key "+key+" does not exist");
+                default:
+                    log.error("error deleting configuration {}: {} {}",new Object[] {key,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error deleting configuration "+key+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            delete.releaseConnection();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ContextClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ContextClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ContextClient.java
new file mode 100644
index 0000000..a066e47
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ContextClient.java
@@ -0,0 +1,80 @@
+/**
+ * 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 at.newmedialab.lmf.client.clients;
+
+import at.newmedialab.lmf.client.ClientConfiguration;
+import at.newmedialab.lmf.client.util.HTTPUtil;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * Context Client 
+ * 	
+ * @author Sergio Fernández
+ *
+ */
+public class ContextClient {
+	
+    private static Logger log = LoggerFactory.getLogger(ContextClient.class);
+
+    private ClientConfiguration config;
+
+    public ContextClient(ClientConfiguration config) {
+        this.config = config;
+    }
+    
+    public boolean delete(String uri) {
+    	boolean result = false;
+        HttpClient httpClient = HTTPUtil.createClient(config);
+       
+        HttpDelete delete = new HttpDelete(uri);
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(delete);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug(uri + "cleanned");
+                    result = true;
+                    break;
+                case 404:
+                    log.error(uri + " is not a suitable context");
+                    result = false;
+                default:
+                    log.error("error cleanning context: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});                
+            }
+        
+        } catch (ClientProtocolException e) {
+			log.error(e.getMessage(), e);
+			result = false;
+		} catch (IOException e) {
+			log.error(e.getMessage(), e);
+			result = false;
+		} finally {
+		    delete.releaseConnection();
+        }
+        return result;
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/CoresClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/CoresClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/CoresClient.java
new file mode 100644
index 0000000..4092a55
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/CoresClient.java
@@ -0,0 +1,297 @@
+/**
+ * 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 at.newmedialab.lmf.client.clients;
+
+import at.newmedialab.lmf.client.ClientConfiguration;
+import at.newmedialab.lmf.client.exception.LMFClientException;
+import at.newmedialab.lmf.client.exception.NotFoundException;
+import at.newmedialab.lmf.client.util.HTTPUtil;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.CharStreams;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentProducer;
+import org.apache.http.entity.EntityTemplate;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.List;
+
+/**
+ * A client allowing to retrieve and configure the SOLR cores that are registered in the LMF server.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class CoresClient {
+
+    private static Logger log = LoggerFactory.getLogger(CoresClient.class);
+
+    private static final String URL_CORES_SERVICE  = "/solr/cores";
+
+    private ClientConfiguration config;
+
+    public CoresClient(ClientConfiguration config) {
+        this.config = config;
+    }
+
+
+    /**
+     * Retrieve a list of all core names registered and activated in the LMF server.
+     * 
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public List<String> listCores() throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CORES_SERVICE;
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/json");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("active cores retrieved successfully");
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+                    List<String> result =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<List<String>>(){});
+
+                    return result;
+
+                default:
+                    log.error("error retrieving active cores: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving active cores: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Return the LDPath program configured for the core with the name passed as argument. 
+     * 
+     * Note that this library provides no further functionality for evaluating LDPath programs. You may use the
+     * separate LDPath libraries at http://code.google.com/p/ldpath/.
+     * 
+     * @param coreName name of the core for which to retrieve the LDPath program
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public String getCoreConfiguration(String coreName) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CORES_SERVICE + "/" + URLEncoder.encode(coreName,"utf-8");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "text/plain");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("core {} retrieved successfully",coreName);
+                    return CharStreams.toString(new InputStreamReader(response.getEntity().getContent(),"utf-8"));
+                default:
+                    log.error("error retrieving core {}: {} {}",new Object[] {coreName,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving core "+coreName+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Create the core configuration for the given core using the LDPath program passed  as argument.
+     *
+     * Note that this library provides no further functionality for evaluating LDPath programs. You may use the
+     * separate LDPath libraries at http://code.google.com/p/ldpath/.
+     *
+     * @param coreName     the name of the core to update
+     * @param coreProgram  the LDPath program to use as core configuration
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void createCoreConfiguration(String coreName, final String coreProgram) throws IOException, LMFClientException {
+        createCoreConfiguration(coreName, new ByteArrayInputStream(coreProgram.getBytes("utf-8")));
+    }
+
+
+    /**
+     * Update the core configuration for the given core using the LDPath program passed  as argument.
+     *
+     * Note that this library provides no further functionality for evaluating LDPath programs. You may use the
+     * separate LDPath libraries at http://code.google.com/p/ldpath/.
+     *
+     * @param coreName     the name of the core to update
+     * @param coreProgram  InputStream providing the LDPath program to use as core configuration
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void createCoreConfiguration(String coreName, final InputStream coreProgram) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CORES_SERVICE + "/" + URLEncoder.encode(coreName,"utf-8");
+
+        HttpPost post = new HttpPost(serviceUrl);
+        post.setHeader("Content-Type", "text/plain");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(coreProgram,outstream);
+            }
+        };
+        post.setEntity(new EntityTemplate(cp));
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(post);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("core {} updated successfully",coreName);
+                    break;
+                default:
+                    log.error("error updating core {}: {} {}",new Object[] {coreName,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating core "+coreName+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Set/update the core configuration for the given core using the LDPath program passed  as argument.
+     *
+     * Note that this library provides no further functionality for evaluating LDPath programs. You may use the
+     * separate LDPath libraries at http://code.google.com/p/ldpath/.
+     *
+     * @param coreName     the name of the core to update
+     * @param coreProgram  the LDPath program to use as core configuration
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void updateCoreConfiguration(String coreName, final String coreProgram) throws IOException, LMFClientException {
+        updateCoreConfiguration(coreName,new ByteArrayInputStream(coreProgram.getBytes("utf-8")));
+    }
+
+    /**
+     * Update the core configuration for the given core using the LDPath program passed  as argument.
+     *
+     * Note that this library provides no further functionality for evaluating LDPath programs. You may use the
+     * separate LDPath libraries at http://code.google.com/p/ldpath/.
+     *
+     * @param coreName     the name of the core to update
+     * @param coreProgram  InputStream providing the LDPath program to use as core configuration
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void updateCoreConfiguration(String coreName, final InputStream coreProgram) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CORES_SERVICE + "/" + URLEncoder.encode(coreName,"utf-8");
+
+        HttpPut put = new HttpPut(serviceUrl);
+        put.setHeader("Content-Type", "text/plain");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(coreProgram,outstream);
+            }
+        };
+        put.setEntity(new EntityTemplate(cp));
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(put);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("core {} updated successfully",coreName);
+                    break;
+                default:
+                    log.error("error updating core {}: {} {}",new Object[] {coreName,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating core "+coreName+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            put.releaseConnection();
+        }
+    }
+
+
+    /**
+     * Remove the core with the name passed as argument.
+     *
+     * @param coreName   name of the core to delete
+     * @throws IOException
+     * @throws NotFoundException  in case the core with this name does not exist
+     * @throws LMFClientException
+     */
+    public void deleteCore(String coreName) throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_CORES_SERVICE + "/" + URLEncoder.encode(coreName,"utf-8");
+
+        HttpDelete delete = new HttpDelete(serviceUrl);
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(delete);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("core {} deleted successfully",coreName);
+                    break;
+                case 404:
+                    log.error("core {} does not exist and could not be deleted", coreName);
+                    throw new NotFoundException("core "+coreName+" does not exist and could not be deleted");
+                default:
+                    log.error("error deleting core {}: {} {}",new Object[] {coreName,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error updating core "+coreName+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            delete.releaseConnection();
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/75439f3a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ImportClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ImportClient.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ImportClient.java
new file mode 100644
index 0000000..e389e5d
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/clients/ImportClient.java
@@ -0,0 +1,173 @@
+/**
+ * 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 at.newmedialab.lmf.client.clients;
+
+import at.newmedialab.lmf.client.ClientConfiguration;
+import at.newmedialab.lmf.client.exception.LMFClientException;
+import at.newmedialab.lmf.client.util.HTTPUtil;
+import com.google.common.io.ByteStreams;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentProducer;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.util.EntityUtils;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This client class provides support for importing ontologies in various formats into the Linked Media Framework.
+ * 
+ * Author: Sebastian Schaffert
+ */
+public class ImportClient {
+
+    private static Logger log = LoggerFactory.getLogger(ImportClient.class);
+
+    private static final String URL_TYPES_SERVICE = "/import/types";
+    private static final String URL_UPLOAD_SERVICE = "/import/upload";
+
+    private ClientConfiguration config;
+    
+    private Set<String> acceptableTypes;
+
+    public ImportClient(ClientConfiguration config) {
+        this.acceptableTypes = new HashSet<String>();
+        this.config = config;
+        try {
+            this.acceptableTypes = getSupportedTypes();
+        } catch (IOException e) {
+            log.error("I/O Exception while trying to retrieve supported types",e);
+        } catch (LMFClientException e) {
+            log.error("Client Exception while trying to retrieve supported types",e);
+        }
+    }
+
+    /**
+     * Return a set of mime types representing the types that are accepted by the LMF server.
+     * 
+     * @return
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public Set<String> getSupportedTypes() throws IOException, LMFClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getLmfUri() + URL_TYPES_SERVICE;
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/json");
+        
+        try {
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("list of import types retrieved successfully");
+                    ObjectMapper mapper = new ObjectMapper();
+                    Set<String> result =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Set<String>>(){});
+                    return result;
+                 default:
+                    log.error("error retrieving list of import types: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new LMFClientException("error retrieving list of import types: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Upload/Import a dataset in the LMF Server. The dataset is given as an Inputstream that contains data of the
+     * mime type passed as argument. The mime type must be one of the acceptable types of the server.
+     *
+     * @param in InputStream to read the dataset from; will be consumed by this method
+     * @param mimeType mime type of the input data
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void uploadDataset(final InputStream in, final String mimeType) throws IOException, LMFClientException {
+        //Preconditions.checkArgument(acceptableTypes.contains(mimeType));
+
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpPost post = HTTPUtil.createPost(URL_UPLOAD_SERVICE, config);
+        post.setHeader("Content-Type", mimeType);
+        
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(in,outstream);
+            }
+        };
+        post.setEntity(new EntityTemplate(cp));
+        
+        ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
+            @Override
+            public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
+                EntityUtils.consume(response.getEntity());
+                switch(response.getStatusLine().getStatusCode()) {
+                    case 200:
+                        log.debug("dataset uploaded updated successfully");
+                        return true;
+                    case 412:
+                        log.error("mime type {} not acceptable by import service",mimeType);
+                        return false;
+                    default:
+                        log.error("error uploading dataset: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                        return false;
+                }
+            }
+        };
+
+        try {
+            httpClient.execute(post, handler);
+        } catch(IOException ex) {
+            post.abort();
+            throw ex;
+        } finally {
+            post.releaseConnection();
+        }
+
+    }
+
+    /**
+     * Upload the data contained in the string using the given mime type; convenience method wrapping the generic
+     * InputStream-based method.
+     *
+     * @param data
+     * @param mimeType
+     * @throws IOException
+     * @throws LMFClientException
+     */
+    public void uploadDataset(String data, String mimeType) throws IOException, LMFClientException {
+        uploadDataset(new ByteArrayInputStream(data.getBytes("utf-8")), mimeType);
+    }
+
+}