You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/27 14:01:11 UTC

[6/12] MARMOTTA-108: renamed packages in marmotta-client-java also did some cleanup (removed clients for services that are not part of marmotta)

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/KiWiCollections.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/KiWiCollections.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/KiWiCollections.java
deleted file mode 100644
index 631fa5e..0000000
--- a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/KiWiCollections.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * 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 at.newmedialab.lmf.client.util;
-
-import java.text.Format;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * This class contains static helper methods for supporting java collections
- * in Java 5.
- *
- * @author Sebastian Schaffert
- */
-public class KiWiCollections {
-
-    /**
-     * Convert any iterable into a list
-     * @param <T>
-     * @param iterable
-     * @return
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> List<T> toList(Iterable<T> iterable) {
-        return toCollection(LinkedList.class,iterable);
-    }
-
-    /**
-     * Convert any iterable into a set
-     * @param <T>
-     * @param iterable
-     * @return
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> Set<T> toSet(Iterable<T> iterable) {
-        return toCollection(HashSet.class,iterable);
-    }
-
-    private static <C extends Collection<T>,T> C toCollection(Class<C> cls, Iterable<T> iterable) {
-        try {
-            C result = cls.newInstance();
-
-            for(T item : iterable) {
-                result.add(item);
-            }
-
-            return result;
-        } catch(InstantiationException ex) {
-            return null;
-        } catch(IllegalAccessException ex) {
-            return null;
-        }
-    }
-
-    public static <T> T first(Iterable<T> iterable) {
-        return iterable.iterator().next();
-    }
-
-
-    public static <T> String fold(Collection<T> elements, String separator) {
-        StringBuilder builder = new StringBuilder();
-        ArrayList<T> list = new ArrayList<T>(elements);
-        for(int i=0; i<list.size(); i++) {
-            builder.append(list.get(i).toString());
-            if(i < list.size()-1) {
-                builder.append(separator);
-            }
-        }
-        return builder.toString();
-    }
-
-
-    public static <T> String fold(Collection<T> elements, Format format, String separator) {
-        StringBuilder builder = new StringBuilder();
-        ArrayList<T> list = new ArrayList<T>(elements);
-        for(int i=0; i<list.size(); i++) {
-            builder.append(format.format(list.get(i)));
-            if(i < list.size()-1) {
-                builder.append(separator);
-            }
-        }
-        return builder.toString();
-    }
-
-    public static <T> String fold(Collection<T> elements, StringSerializer<T> format, String separator) {
-        StringBuilder builder = new StringBuilder();
-        ArrayList<T> list = new ArrayList<T>(elements);
-        for(int i=0; i<list.size(); i++) {
-            builder.append(format.serialize(list.get(i)));
-            if(i < list.size()-1) {
-                builder.append(separator);
-            }
-        }
-        return builder.toString();
-    }
-
-
-    /**
-     * Concatenate the collection of lists passed as argument into a new array list.
-     * @param lists
-     * @param <T>
-     * @return
-     */
-    public static <T> List<T> concat(Collection<? extends Collection<T>> lists) {
-        int size = 0;
-        for(Collection<T> list : lists) {
-            size += list.size();
-        }
-        List<T> result = new ArrayList<T>(size);
-        for(Collection<T> list : lists) {
-            result.addAll(list);
-        }
-        return result;
-    }
-
-
-    public interface StringSerializer<T> {
-        public String serialize(T t);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/RDFJSONParser.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/RDFJSONParser.java b/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/RDFJSONParser.java
deleted file mode 100644
index ac3624b..0000000
--- a/client/marmotta-client-java/src/main/java/at/newmedialab/lmf/client/util/RDFJSONParser.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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 at.newmedialab.lmf.client.util;
-
-import at.newmedialab.lmf.client.exception.ParseException;
-import at.newmedialab.lmf.client.model.meta.Metadata;
-import at.newmedialab.lmf.client.model.rdf.BNode;
-import at.newmedialab.lmf.client.model.rdf.Literal;
-import at.newmedialab.lmf.client.model.rdf.RDFNode;
-import at.newmedialab.lmf.client.model.rdf.URI;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Parse RDF/JSON into a map-based representation.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class RDFJSONParser {
-
-    private static final String HTTP = "http://";
-    private static final String VALUE = "value";
-    private static final String TYPE = "type";
-    private static final String TYPE_BNODE = "bnode";
-    private static final String TYPE_URI = "uri";
-    private static final String TYPE_LITERAL = "literal";
-    private static final String LANG = "lang";
-    private static final String DATATYPE = "datatype";
-
-    public static Map<String,Metadata> parseRDFJSON(InputStream data) throws ParseException {
-        ObjectMapper mapper = new ObjectMapper();
-        try {
-            Map<String,Map<String,Set<Map<String,String>>>> subjects = mapper.readValue(data, new TypeReference<Map<String,Map<String,Set<Map<String,String>>>>>(){});
-
-            // convert "raw" map into a map to Metadata objects
-            Map<String,Metadata> result = new HashMap<String, Metadata>();
-            for(Map.Entry<String,Map<String,Set<Map<String,String>>>> subject : subjects.entrySet()) {
-                Metadata m = new Metadata(subject.getKey());
-                result.put(subject.getKey(),m);
-
-                for(Map.Entry<String,Set<Map<String,String>>> property : subject.getValue().entrySet()) {
-                    Set<RDFNode> propValue = new HashSet<RDFNode>();
-                    for(Map<String,String> value : property.getValue()) {
-                        propValue.add(parseRDFJSONNode(value));
-                    }
-                    m.put(property.getKey(),propValue);
-                }
-            }
-            return result;
-
-        } catch (IOException e) {
-            throw new ParseException("could not parse JSON data",e);
-        }
-
-    }
-
-    /**
-     * Parse the representation of a node in RDF/JSON into an RDFNode object
-     * @param nodeDef
-     * @return
-     */
-    public static RDFNode parseRDFJSONNode(Map<String, String> nodeDef) {
-        RDFNode object;
-
-        if( nodeDef.get(TYPE).equals(TYPE_URI) ) {
-            object = new URI(nodeDef.get(VALUE));
-        } else if( nodeDef.get(TYPE).equals(TYPE_BNODE) ) {
-            object = new BNode(nodeDef.get(VALUE));
-        } else {
-            if( nodeDef.get(LANG) != null ) {
-                object = new Literal(nodeDef.get(VALUE),nodeDef.get(LANG));
-            } else if( nodeDef.get(DATATYPE) != null) {
-                object = new Literal(nodeDef.get(VALUE),new URI(nodeDef.get(DATATYPE)));
-            } else {
-                object = new Literal(nodeDef.get(VALUE));
-            }
-        }
-        return object;
-    }
-    
-   
-    public static void serializeRDFJSON(Map<String,Metadata> data, OutputStream out) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
-
-
-        Map<String,Map<String,Set<Map<String,String>>>> subjects = new HashMap<String, Map<String, Set<Map<String, String>>>>();
-
-        
-        for(Map.Entry<String,Metadata> subject : data.entrySet()) {
-            //add or get predicate map
-            Map<String,Set<Map<String,String>>> predicates = new HashMap<String,Set<Map<String,String>>>();
-            subjects.put(subject.getKey(),predicates);
-            
- 
-            for(Map.Entry<String,Set<RDFNode>> predicate : subject.getValue().entrySet()) {
-                //add or get object set
-                Set<Map<String,String>> objects = new HashSet<Map<String,String>>();
-                predicates.put(predicate.getKey(),objects);
-
-                //add objects
-                for(RDFNode objectNode : predicate.getValue()) {
-                    Map<String,String> object = new HashMap<String,String>();
-                    if( objectNode instanceof Literal) {
-                        object.put(TYPE,TYPE_LITERAL);
-                        object.put(VALUE,((Literal)objectNode).getContent());
-                        if(((Literal) objectNode).getLanguage() != null )
-                            object.put(LANG,((Literal) objectNode).getLanguage());
-                        if(((Literal) objectNode).getType() != null)
-                            object.put(DATATYPE,((Literal) objectNode).getType().getUri());
-                    } else {
-                        if( objectNode instanceof URI ) {
-                            object.put(TYPE,TYPE_URI);
-                            object.put(VALUE,((URI)objectNode).getUri());
-                        } else {
-                            object.put(TYPE,TYPE_BNODE);
-                            object.put(VALUE,((BNode)objectNode).getAnonId());
-                        }
-                    }
-                    objects.add(object);
-                }
-            }
-                
-        }
-        mapper.writeValue(out,subjects);
-                
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/ClientConfiguration.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/ClientConfiguration.java
new file mode 100644
index 0000000..479c02d
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/ClientConfiguration.java
@@ -0,0 +1,126 @@
+/**
+ * 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.client;
+
+import org.apache.http.conn.ClientConnectionManager;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ClientConfiguration {
+
+	/**
+	 * The URI at which the Marmotta installation can be located
+	 */
+	private String marmottaUri;
+
+	/**
+	 * (Optional) user to authenticate with the Marmotta system
+	 */
+	private String marmottaUser;
+
+	/**
+	 * (Optional) password to authenticate with the Marmotta system
+	 */
+	private String marmottaPassword;
+
+	/**
+	 * (Optional) context in the Marmotta system
+	 */
+	private String marmottaContext;
+
+	/**
+	 * 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 marmottaUri) {
+		this.marmottaUri = marmottaUri;
+	}
+
+	public ClientConfiguration(String marmottaUri, String marmottaUser, String marmottaPassword) {
+		this.marmottaUri = marmottaUri;
+		this.marmottaUser = marmottaUser;
+		this.marmottaPassword = marmottaPassword;
+	}
+
+	public String getMarmottaUri() {
+		return marmottaUri;
+	}
+
+	public void setMarmottaUri(String marmottaUri) {
+		this.marmottaUri = marmottaUri;
+	}
+
+	public String getMarmottaUser() {
+		return marmottaUser;
+	}
+
+	public void setMarmottaUser(String marmottaUser) {
+		this.marmottaUser = marmottaUser;
+	}
+
+	public String getMarmottaPassword() {
+		return marmottaPassword;
+	}
+
+	public void setMarmottaPassword(String marmottaPassword) {
+		this.marmottaPassword = marmottaPassword;
+	}
+
+	public String getMarmottaContext() {
+		return marmottaContext;
+	}
+
+	public void setMarmottaContext(String marmottaContext) {
+		this.marmottaContext = marmottaContext;
+	}
+
+	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/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/MarmottaClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/MarmottaClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/MarmottaClient.java
new file mode 100644
index 0000000..d0e1da0
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/MarmottaClient.java
@@ -0,0 +1,83 @@
+/**
+ * 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.client;
+
+import org.apache.marmotta.client.clients.ConfigurationClient;
+import org.apache.marmotta.client.clients.ImportClient;
+import org.apache.marmotta.client.clients.LDPathClient;
+import org.apache.marmotta.client.clients.ResourceClient;
+import org.apache.marmotta.client.clients.SPARQLClient;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class MarmottaClient {
+    
+    public static final String VERSION = "0.1.0";
+
+    private ClientConfiguration config;
+
+
+    public MarmottaClient(ClientConfiguration config) {
+        this.config = config;
+    }
+    
+    /**
+     * Return a client to access the Marmotta 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 Marmotta Server.
+     * @return
+     */
+    public SPARQLClient getSPARQLClient() {
+        return new SPARQLClient(config);
+    }
+
+    /**
+     * Return a client that allows importing of datasets and ontologies on the Marmotta Server.
+     * @return
+     */
+    public ImportClient getImportClient() {
+        return new ImportClient(config);
+    }
+
+
+    /**
+     * Return a client that allows accessing the LDPath service for evaluating LDPath queries.
+     * @return
+     */
+    public LDPathClient getLDPathClient() {
+        return new LDPathClient(config);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ConfigurationClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ConfigurationClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ConfigurationClient.java
new file mode 100644
index 0000000..d315f19
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ConfigurationClient.java
@@ -0,0 +1,264 @@
+/**
+ * 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.client.clients;
+
+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.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.exception.MarmottaClientException;
+import org.apache.marmotta.client.exception.NotFoundException;
+import org.apache.marmotta.client.model.config.Configuration;
+import org.apache.marmotta.client.util.HTTPUtil;
+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 Apache Marmotta. 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 Marmotta configuration.
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public Set<String> listConfigurationKeys() throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpGet get = new HttpGet(config.getMarmottaUri() + 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 MarmottaClientException("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 Marmotta configuration.
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public Set<Configuration> listConfigurations(String prefix) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + 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 MarmottaClientException("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 MarmottaClientException
+     */
+    public Configuration getConfiguration(String key) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + 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 MarmottaClientException("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 MarmottaClientException
+     */
+    public void setConfiguration(String key, final Object value) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + 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 MarmottaClientException("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 MarmottaClientException
+     */
+    public void deleteConfiguration(String key) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + 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 MarmottaClientException("error deleting configuration "+key+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            delete.releaseConnection();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ContextClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ContextClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ContextClient.java
new file mode 100644
index 0000000..40568db
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ContextClient.java
@@ -0,0 +1,80 @@
+/**
+ * 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.client.clients;
+
+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.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.util.HTTPUtil;
+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/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ImportClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ImportClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ImportClient.java
new file mode 100644
index 0000000..10ff1bb
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ImportClient.java
@@ -0,0 +1,173 @@
+/**
+ * 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.client.clients;
+
+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.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.exception.MarmottaClientException;
+import org.apache.marmotta.client.util.HTTPUtil;
+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 Apache Marmotta.
+ * 
+ * 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 (MarmottaClientException 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 Marmotta server.
+     * 
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public Set<String> getSupportedTypes() throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + 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 MarmottaClientException("error retrieving list of import types: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Upload/Import a dataset in the Marmotta 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 MarmottaClientException
+     */
+    public void uploadDataset(final InputStream in, final String mimeType) throws IOException, MarmottaClientException {
+        //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 MarmottaClientException
+     */
+    public void uploadDataset(String data, String mimeType) throws IOException, MarmottaClientException {
+        uploadDataset(new ByteArrayInputStream(data.getBytes("utf-8")), mimeType);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/LDPathClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/LDPathClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/LDPathClient.java
new file mode 100644
index 0000000..9bc59b6
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/LDPathClient.java
@@ -0,0 +1,164 @@
+/**
+ * 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.client.clients;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.exception.ContentFormatException;
+import org.apache.marmotta.client.exception.MarmottaClientException;
+import org.apache.marmotta.client.exception.NotFoundException;
+import org.apache.marmotta.client.model.rdf.RDFNode;
+import org.apache.marmotta.client.util.HTTPUtil;
+import org.apache.marmotta.client.util.RDFJSONParser;
+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.IOException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LDPathClient {
+
+    private static Logger log = LoggerFactory.getLogger(LDPathClient.class);
+
+    private static final String URL_PATH_SERVICE  = "/ldpath/path";
+    private static final String URL_PROGRAM_SERVICE = "/ldpath/program";
+
+
+    private ClientConfiguration config;
+
+    public LDPathClient(ClientConfiguration config) {
+        this.config = config;
+    }
+
+
+    /**
+     * Evaluate the path query passed as second argument, starting at the resource with the uri given as first argument.
+     * Returns a List of RDFNode objects.
+     *
+     *
+     * @param uri  the uri of the resource where to start the path evaluation
+     * @param path the path to evaluate
+     * @return a list of RDFNodes representing the result of the path evaluation as returned by the server
+     * @throws MarmottaClientException
+     * @throws IOException
+     */
+    public List<RDFNode> evaluatePath(String uri, String path) throws MarmottaClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + URL_PATH_SERVICE + "?path=" + URLEncoder.encode(path, "utf-8")
+                                                                  + "&uri="  + URLEncoder.encode(uri, "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("LDPath Path Query {} evaluated successfully",path);
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+                    List<Map<String,String>> serverResult =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<List<Map<String,String>>>(){});
+
+                    
+                    List<RDFNode> result = new ArrayList<RDFNode>();
+                    for(Map<String,String> value : serverResult) {
+                        result.add(RDFJSONParser.parseRDFJSONNode(value));
+                    }
+                    return result;
+                case 400:
+                    log.error("the server did not accept the uri ({}) or path ({}) arguments",uri,path);
+                    throw new ContentFormatException("the server did not accept the uri ("+uri+") or path ("+path+") arguments");
+                case 404:
+                    log.error("the resource with URI {} does not exist on the server",uri);
+                    throw new NotFoundException("the resource with URI "+uri+" does not exist on the server");
+                default:
+                    log.error("error evaluating LDPath Path Query {}: {} {}",new Object[] {path,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error evaluating LDPath Path Query "+path+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+
+    }
+    
+    
+    public Map<String,List<RDFNode>> evaluateProgram(String uri, String program) throws MarmottaClientException, IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + URL_PROGRAM_SERVICE + "?program=" + URLEncoder.encode(program, "utf-8")
+                                                                                   + "&uri="  + URLEncoder.encode(uri, "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("LDPath Program Query evaluated successfully:\n{}",program);
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+                    Map<String,List<Map<String,String>>> serverResult =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,List<Map<String,String>>>>(){});
+
+
+                    Map<String,List<RDFNode>> result = new HashMap<String, List<RDFNode>>();
+                    for(Map.Entry<String,List<Map<String,String>>> field : serverResult.entrySet()) {
+                        List<RDFNode> row = new ArrayList<RDFNode>();
+                        for(Map<String,String> node : field.getValue()) {
+                            row.add(RDFJSONParser.parseRDFJSONNode(node));
+                        }
+                        result.put(field.getKey(),row);
+                    }
+                    return result;
+                case 400:
+                    log.error("the server did not accept the uri ({}) or program ({}) arguments",uri,program);
+                    throw new ContentFormatException("the server did not accept the uri ("+uri+") or program ("+program+") arguments");
+                case 404:
+                    log.error("the resource with URI {} does not exist on the server",uri);
+                    throw new NotFoundException("the resource with URI "+uri+" does not exist on the server");
+                default:
+                    log.error("error evaluating LDPath Program Query: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error evaluating LDPath Program Query: "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ResourceClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ResourceClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ResourceClient.java
new file mode 100644
index 0000000..6367e59
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/ResourceClient.java
@@ -0,0 +1,372 @@
+/**
+ * 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.client.clients;
+
+import com.google.common.collect.ImmutableMap;
+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.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpOptions;
+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.apache.http.util.EntityUtils;
+import org.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.exception.ContentFormatException;
+import org.apache.marmotta.client.exception.MarmottaClientException;
+import org.apache.marmotta.client.exception.NotFoundException;
+import org.apache.marmotta.client.model.content.Content;
+import org.apache.marmotta.client.model.content.StreamContent;
+import org.apache.marmotta.client.model.meta.Metadata;
+import org.apache.marmotta.client.util.HTTPUtil;
+import org.apache.marmotta.client.util.RDFJSONParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ResourceClient {
+
+    private static Logger log = LoggerFactory.getLogger(ResourceClient.class);
+
+    private static final String URL_RESOURCE_SERVICE = "/resource";
+    
+    private ClientConfiguration config;
+
+    public ResourceClient(ClientConfiguration config) {
+        this.config = config;
+
+    }
+
+    /**
+     * Create a resource in the remote Marmotta installation
+     * @param uri
+     * @return
+     * @throws IOException
+     */
+    public boolean createResource(String uri) throws IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+            
+        HttpPost post = new HttpPost(getServiceUrl(uri));
+        
+        try {
+            
+            HttpResponse response = httpClient.execute(post);
+            
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200: 
+                    log.debug("resource {} already existed, not creating new",uri);
+                    return true;
+                case 201: 
+                    log.debug("resource {} created",uri);
+                    return true;
+                default:
+                    log.error("error creating resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    return true;
+            }
+            
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            return false;
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+    /**
+     * Test whether the resource with the provided URI exists.
+     * <p/>
+     * Uses an OPTIONS call to the resource web service to determine whether the resource exists or not
+     *
+     * @param uri
+     * @return
+     * @throws IOException
+     */
+    public boolean existsResource(String uri) throws IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpOptions options = new HttpOptions(getServiceUrl(uri));
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(options);
+
+            if(response.containsHeader("Access-Control-Allow-Methods") && response.getFirstHeader("Access-Control-Allow-Methods").getValue().equals("POST")) {
+                return false;
+            } else if(response.containsHeader("Access-Control-Allow-Methods") && response.getFirstHeader("Access-Control-Allow-Methods").getValue().contains("GET")) {
+                return true;
+            } else {
+                log.warn("OPTIONS response did not contain a access-control-allow-methods header");
+                return false; 
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            return false;
+        } finally {
+            options.releaseConnection();
+        }
+    }
+
+    /**
+     * Return the resource metadata for the resource with the given URI, if it exists. Returns null if the
+     * resource exists but there is no metadata. Throws an exception if the resource does not exist or some
+     * other error code was returned.
+     *
+     * @param uri
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public Metadata getResourceMetadata(String uri) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpGet get = new HttpGet(getServiceUrl(uri));
+        get.setHeader("Accept", "application/rdf+json; rel=meta");
+        
+        try {
+            
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("metadata for resource {} retrieved",uri);
+                    Map<String,Metadata> result = RDFJSONParser.parseRDFJSON(response.getEntity().getContent());
+                    if(result.containsKey(uri)) {
+                        return result.get(uri);
+                    } else {
+                        return null;
+                    }
+                case 406:
+                    log.error("server does not support metadata type application/json for resource {}, cannot retrieve", uri);
+                    throw new ContentFormatException("server does not support metadata type application/json for resource "+uri);
+                case 404:
+                    log.error("resource {} does not exist, cannot retrieve", uri);
+                    throw new NotFoundException("resource "+uri+" does not exist, cannot retrieve");
+                default:
+                    log.error("error retrieving resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error retrieving resource "+uri+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            throw new MarmottaClientException("could not encode URI parameter");
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Update (overwrite) the metadata of the resource identified by the given uri. The metadata will be serialised to
+     * application/json and sent to the Apache Marmotta server. The given metadata will override any metadata
+     * for the resource already existing on the server. The resource has to exist or be created before updating, otherwise
+     * the method will throw a NotFoundException.
+     *
+     * @param uri        the URI of the resource to update
+     * @param metadata   the metadata to upload to the resource
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public void updateResourceMetadata(final String uri, final Metadata metadata) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpPut put = new HttpPut(getServiceUrl(uri));
+        put.setHeader("Content-Type", "application/rdf+json; rel=meta");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                RDFJSONParser.serializeRDFJSON(ImmutableMap.of(uri, metadata), outstream);
+            }
+        };
+        put.setEntity(new EntityTemplate(cp));
+
+        try {
+            
+            HttpResponse response = httpClient.execute(put);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("metadata for resource {} updated",uri);
+                    break;
+                case 415:
+                    log.error("server does not support metadata type application/json for resource {}, cannot update", uri);
+                    throw new ContentFormatException("server does not support metadata type application/json for resource "+uri);
+                case 404:
+                    log.error("resource {} does not exist, cannot update", uri);
+                    throw new NotFoundException("resource "+uri+" does not exist, cannot update");
+                default:
+                    log.error("error updating resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error updating resource "+uri+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            throw new MarmottaClientException("could not encode URI parameter");
+        } finally {
+            put.releaseConnection();
+        }
+    }
+
+    /**
+     * Retrieve the (human-readable) content of the given mimeType of the given resource. Will return a content
+     * object that allows reading the input stream. In case no content of the given mime type exists for the resource,
+     * will throw a ContentFormatException.
+     *
+     * @param uri
+     * @param mimeType
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public Content getResourceContent(String uri, String mimeType) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpGet get = new HttpGet(getServiceUrl(uri));
+        get.setHeader("Accept", mimeType+"; rel=content");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("metadata for resource {} retrieved",uri);
+                    Content content = new StreamContent(response.getEntity().getContent(),response.getEntity().getContentType().getValue(),response.getEntity().getContentLength());
+                    return content;
+                case 406:
+                    log.error("server does not offer content type {} for resource {}, cannot retrieve", mimeType, uri);
+                    throw new ContentFormatException("server does not offer content type "+mimeType+" for resource "+uri);
+                case 404:
+                    log.error("resource {} does not exist, cannot retrieve content", uri);
+                    throw new NotFoundException("resource "+uri+" does not exist, cannot retrieve");
+                default:
+                    log.error("error retrieving resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error retrieving resource "+uri+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+            throw new MarmottaClientException("could not encode URI parameter");
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Update the content of the resource identified by the URI given as argument. The resource has to exist before
+     * content can be uploaded to it. Any existing content will be overridden. The stream of the content object
+     * will be consumed by this method. Throws ContentFormatException if the content type is not supported,
+     * NotFoundException if the resource does not exist.
+     * @param uri
+     * @param content
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public void updateResourceContent(final String uri, final Content content) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpPut put = new HttpPut(getServiceUrl(uri));
+        put.setHeader("Content-Type", content.getMimeType()+"; rel=content");
+        ContentProducer cp = new ContentProducer() {
+            @Override
+            public void writeTo(OutputStream outstream) throws IOException {
+                ByteStreams.copy(content.getStream(),outstream);
+            }
+        };
+        put.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("content for resource {} updated",uri);
+                    return true;
+                case 406:
+                    log.error("server does not support content type {} for resource {}, cannot update", content.getMimeType(),uri);
+                    return false;
+                case 404:
+                    log.error("resource {} does not exist, cannot update", uri);
+                    return false;
+                default:
+                    log.error("error updating resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    return false;
+                }
+            }
+        };
+
+        try {
+            httpClient.execute(put, handler);
+        } catch(IOException ex) {
+            put.abort();
+            throw ex;
+        } finally {
+            put.releaseConnection();
+        }
+
+    }
+    
+    
+    public void deleteResource(String uri) throws IOException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        HttpDelete delete = new HttpDelete(getServiceUrl(uri));
+        
+        try {
+            
+            HttpResponse response = httpClient.execute(delete);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("resource {} deleted",uri);
+                    break;
+                case 400:
+                    log.error("resource {} invalid, cannot delete", uri);
+                    break;
+                case 404:
+                    log.error("resource {} does not exist, cannot delete", uri);
+                    break;
+                default:
+                    log.error("error deleting resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            log.error("could not encode URI parameter",e);
+        } finally {
+            delete.releaseConnection();
+        }
+    }
+    
+    private String getServiceUrl(String uri) throws UnsupportedEncodingException {
+        return config.getMarmottaUri() + URL_RESOURCE_SERVICE + "?uri=" + URLEncoder.encode(uri,"utf-8");    
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/SPARQLClient.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/SPARQLClient.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/SPARQLClient.java
new file mode 100644
index 0000000..902920f
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/clients/SPARQLClient.java
@@ -0,0 +1,227 @@
+/**
+ * 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.client.clients;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.exception.MarmottaClientException;
+import org.apache.marmotta.client.model.rdf.BNode;
+import org.apache.marmotta.client.model.rdf.Literal;
+import org.apache.marmotta.client.model.rdf.RDFNode;
+import org.apache.marmotta.client.model.rdf.URI;
+import org.apache.marmotta.client.model.sparql.SPARQLResult;
+import org.apache.marmotta.client.util.HTTPUtil;
+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.IOException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class SPARQLClient {
+
+    private static Logger log = LoggerFactory.getLogger(SPARQLClient.class);
+
+    private static final String URL_QUERY_SERVICE  = "/sparql/select";
+    private static final String URL_UPDATE_SERVICE = "/sparql/update";
+
+    private ClientConfiguration config;
+
+    public SPARQLClient(ClientConfiguration config) {
+        this.config = config;
+    }
+
+    /**
+     * Run a SPARQL Select query against the Marmotta Server and return the results as SPARQL Result. Results will be
+     * transfered and parsed using the SPARQL JSON format.
+     * @param query a SPARQL Select query to run on the database
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    @SuppressWarnings("unchecked")
+    public SPARQLResult select(String query) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + URL_QUERY_SERVICE + "?query=" + URLEncoder.encode(query, "utf-8");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/sparql-results+json");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("SPARQL Query {} evaluated successfully",query);
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+                    Map<String,Map<String,List<?>>> resultMap =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,Map<String,List<?>>>>(){});
+
+                    if(resultMap.isEmpty()) {
+                        return null;
+                    } else {
+                        List<?> head = resultMap.get("head").get("vars");
+                        Set<String> fieldNames = new HashSet<String>();
+                        for(Object o : head) {
+                            if(o instanceof String) {
+                                fieldNames.add((String)o);
+                            }
+                        }
+
+                        SPARQLResult result = new SPARQLResult(fieldNames);
+
+                        List<?> bindings = resultMap.get("results").get("bindings");
+                        for(Object o : bindings) {
+                            if(o instanceof Map) {
+                                Map<String,RDFNode> row = new HashMap<String, RDFNode>();
+                                for(Map.Entry<String,?> entry : ((Map<String,?>)o).entrySet()) {
+                                    Map<String,String> nodeDef = (Map<String,String>) entry.getValue();
+                                    RDFNode node = null;
+                                    if("uri".equalsIgnoreCase(nodeDef.get("type"))) {
+                                        node = new URI(nodeDef.get("value"));
+                                    } else if("literal".equalsIgnoreCase(nodeDef.get("type")) ||
+                                              "typed-literal".equalsIgnoreCase(nodeDef.get("type"))) {
+                                        String lang = nodeDef.get("xml:lang");
+                                        String datatype = nodeDef.get("datatype");
+
+                                        if(lang != null) {
+                                            node = new Literal(nodeDef.get("value"),lang);
+                                        } else if(datatype != null) {
+                                            node = new Literal(nodeDef.get("value"),new URI(datatype));
+                                        } else {
+                                            node = new Literal(nodeDef.get("value"));
+                                        }
+                                    } else if("bnode".equalsIgnoreCase(nodeDef.get("type"))) {
+                                        node = new BNode(nodeDef.get("value"));
+                                    } else {
+                                        log.error("unknown result node type: {}",nodeDef.get("type"));
+                                    }
+                                    
+                                    if(node != null) {
+                                        row.put(entry.getKey(),node);
+                                    }
+                                }
+                                result.add(row);
+                            }
+                        }
+                        return result;
+                    }
+                default:
+                    log.error("error evaluating SPARQL Select Query {}: {} {}",new Object[] {query,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error evaluating SPARQL Select Query "+query+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Carry out a SPARQL ASK Query and return either true or false, depending on the query result.
+     *
+     * @param askQuery
+     * @return
+     * @throws IOException
+     * @throws MarmottaClientException
+     */
+    public boolean ask(String askQuery) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + URL_QUERY_SERVICE + "?query=" + URLEncoder.encode(askQuery, "utf-8");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        get.setHeader("Accept", "application/sparql-results+json");
+        
+        try {
+
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("SPARQL ASK Query {} evaluated successfully",askQuery);
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+                    Map<String,Object> resultMap =
+                            mapper.readValue(response.getEntity().getContent(),new TypeReference<Map<String,Object>>(){});
+
+                    if(resultMap.isEmpty()) {
+                        return false;
+                    } else {
+                        Boolean result = resultMap.get("boolean") != null && ((String)resultMap.get("boolean")).equalsIgnoreCase("true");
+                        return result;
+                    }
+                default:
+                    log.error("error evaluating SPARQL ASK Query {}: {} {}",new Object[] {askQuery,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error evaluating SPARQL ASK Query "+askQuery+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    /**
+     * Execute a SPARQL Update query according to the SPARQL 1.1 standard. The query will only be passed to the server,
+     * which will react either with ok (in this the method simply returns) or with error (in this case, the method
+     * throws an MarmottaClientException).
+     *
+     * @param updateQuery         the SPARQL Update 1.1 query string
+     * @throws IOException        in case a connection problem occurs
+     * @throws MarmottaClientException in case the server returned and error and did not execute the update
+     */
+    public void update(String updateQuery) throws IOException, MarmottaClientException {
+        HttpClient httpClient = HTTPUtil.createClient(config);
+
+        String serviceUrl = config.getMarmottaUri() + URL_UPDATE_SERVICE + "?update=" + URLEncoder.encode(updateQuery, "utf-8");
+
+        HttpGet get = new HttpGet(serviceUrl);
+        
+        try {
+                
+            HttpResponse response = httpClient.execute(get);
+
+            switch(response.getStatusLine().getStatusCode()) {
+                case 200:
+                    log.debug("SPARQL UPDATE Query {} evaluated successfully",updateQuery);
+                    break;
+                default:
+                    log.error("error evaluating SPARQL UPDATE Query {}: {} {}",new Object[] {updateQuery,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
+                    throw new MarmottaClientException("error evaluating SPARQL UPDATE Query "+updateQuery +": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
+            }
+
+        } finally {
+            get.releaseConnection();
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/ContentFormatException.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/ContentFormatException.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/ContentFormatException.java
new file mode 100644
index 0000000..9b3d561
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/ContentFormatException.java
@@ -0,0 +1,82 @@
+/**
+ * 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.client.exception;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ContentFormatException extends MarmottaClientException {
+
+	private static final long serialVersionUID = -5253029627499560617L;
+
+	/**
+     * Constructs a new exception with <code>null</code> as its detail message.
+     * The cause is not initialized, and may subsequently be initialized by a
+     * call to {@link #initCause}.
+     */
+    public ContentFormatException() {
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message.  The
+     * cause is not initialized, and may subsequently be initialized by
+     * a call to {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for
+     *                later retrieval by the {@link #getMessage()} method.
+     */
+    public ContentFormatException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message and
+     * cause.  <p>Note that the detail message associated with
+     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * this exception's detail message.
+     *
+     * @param message the detail message (which is saved for later retrieval
+     *                by the {@link #getMessage()} method).
+     * @param cause   the cause (which is saved for later retrieval by the
+     *                {@link #getCause()} method).  (A <tt>null</tt> value is
+     *                permitted, and indicates that the cause is nonexistent or
+     *                unknown.)
+     * @since 1.4
+     */
+    public ContentFormatException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Constructs a new exception with the specified cause and a detail
+     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
+     * typically contains the class and detail message of <tt>cause</tt>).
+     * This constructor is useful for exceptions that are little more than
+     * wrappers for other throwables (for example, {@link
+     * java.security.PrivilegedActionException}).
+     *
+     * @param cause the cause (which is saved for later retrieval by the
+     *              {@link #getCause()} method).  (A <tt>null</tt> value is
+     *              permitted, and indicates that the cause is nonexistent or
+     *              unknown.)
+     * @since 1.4
+     */
+    public ContentFormatException(Throwable cause) {
+        super(cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/MarmottaClientException.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/MarmottaClientException.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/MarmottaClientException.java
new file mode 100644
index 0000000..c8116ef
--- /dev/null
+++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/exception/MarmottaClientException.java
@@ -0,0 +1,82 @@
+/**
+ * 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.client.exception;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class MarmottaClientException extends Exception{
+
+	private static final long serialVersionUID = 1282449548464135384L;
+
+	/**
+     * Constructs a new exception with <code>null</code> as its detail message.
+     * The cause is not initialized, and may subsequently be initialized by a
+     * call to {@link #initCause}.
+     */
+    public MarmottaClientException() {
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message.  The
+     * cause is not initialized, and may subsequently be initialized by
+     * a call to {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for
+     *                later retrieval by the {@link #getMessage()} method.
+     */
+    public MarmottaClientException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message and
+     * cause.  <p>Note that the detail message associated with
+     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * this exception's detail message.
+     *
+     * @param message the detail message (which is saved for later retrieval
+     *                by the {@link #getMessage()} method).
+     * @param cause   the cause (which is saved for later retrieval by the
+     *                {@link #getCause()} method).  (A <tt>null</tt> value is
+     *                permitted, and indicates that the cause is nonexistent or
+     *                unknown.)
+     * @since 1.4
+     */
+    public MarmottaClientException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Constructs a new exception with the specified cause and a detail
+     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
+     * typically contains the class and detail message of <tt>cause</tt>).
+     * This constructor is useful for exceptions that are little more than
+     * wrappers for other throwables (for example, {@link
+     * java.security.PrivilegedActionException}).
+     *
+     * @param cause the cause (which is saved for later retrieval by the
+     *              {@link #getCause()} method).  (A <tt>null</tt> value is
+     *              permitted, and indicates that the cause is nonexistent or
+     *              unknown.)
+     * @since 1.4
+     */
+    public MarmottaClientException(Throwable cause) {
+        super(cause);
+    }
+}