You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2013/09/26 17:05:53 UTC

[5/5] git commit: MARMOTTA-322: ttd for fixzing some details in the sparql endpoint

MARMOTTA-322: ttd for fixzing some details in the sparql endpoint


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/7122c515
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/7122c515
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/7122c515

Branch: refs/heads/develop
Commit: 7122c51502d9358c49806e3ee516ea22cc2679c5
Parents: 5f0045d
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Sep 26 17:05:38 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Sep 26 17:05:38 2013 +0200

----------------------------------------------------------------------
 .../marmotta/commons/http/LMFHttpUtils.java     | 148 -------------------
 .../commons/http/MarmottaHttpUtils.java         | 145 ++++++++++++++++++
 .../commons/http/ContentTypeMatchingTest.java   |   8 +-
 .../commons/http/MarmottaHttpUtilsTest.java     |  40 +++++
 .../ldclient/api/endpoint/Endpoint.java         |   2 +-
 .../services/provider/AbstractHttpProvider.java |   2 +-
 .../core/webservices/io/ExportWebService.java   |  10 +-
 .../resource/ResourceWebService.java            |  16 +-
 .../triplestore/ContextWebService.java          |  10 +-
 .../endpoint/LinkedDataEndpointServiceImpl.java |   4 +-
 .../sparql/webservices/SparqlWebService.java    |  22 +--
 .../webservices/SparqlWebServiceTest.java       |  17 ++-
 .../services/VersionSerializerServiceImpl.java  |   4 +-
 .../webservices/MementoWebService.java          |  10 +-
 14 files changed, 243 insertions(+), 195 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/LMFHttpUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/LMFHttpUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/LMFHttpUtils.java
deleted file mode 100644
index 503cd87..0000000
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/LMFHttpUtils.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.commons.http;
-
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LMFHttpUtils {
-
-
-
-
-
-    /**
-     * A utility method for parsing HTTP Content-Type and Accept header, taking into account different parameters that
-     * are typically passed. Recognized parameters:
-     * - charset: gives the charset of the content
-     * - q: gives the precedence of the content
-     * The result is an ordered list of content types in order of the computed preference in the header value passed as
-     * string argument.
-     * <p/>
-     * Author: Sebastian Schaffert
-     *
-     *
-     */
-    public static List<ContentType> parseAcceptHeader(String header) {
-        String[] components = header.split(",");
-        List<ContentType> contentTypes = new ArrayList<ContentType>(components.length);
-        for(String c : components) {
-            String mt[] = c.split(";");
-
-            String[] tst = mt[0].split("/");
-
-            if(tst.length == 2) {
-                ContentType type = parseContentType(c);
-                if(type != null) {
-                    contentTypes.add(type);
-                }
-            }
-        }
-
-        Collections.sort(contentTypes);
-
-        return contentTypes;
-    }
-
-
-    public static List<ContentType> parseStringList(Collection<String> types) {
-        List<ContentType> contentTypes = new ArrayList<ContentType>(types.size());
-        for(String c : types) {
-            ContentType type = parseContentType(c);
-            if(type != null) {
-                contentTypes.add(type);
-            }
-        }
-        return contentTypes;
-    }
-
-
-    public static ContentType parseContentType(String c) {
-        String mt[] = c.split(";");
-
-        String[] tst = mt[0].split("/");
-
-        if(tst.length == 2) {
-            ContentType type = new ContentType(tst[0],tst[1]);
-
-            // add parameters
-            for(int i=1; i<mt.length; i++) {
-                String[] kv = mt[i].split("=");
-                if(kv.length == 2) {
-                    type.setParameter(kv[0].trim(),kv[1].trim());
-
-                    if("charset".equalsIgnoreCase(kv[0].trim())) {
-                        type.setCharset(Charset.forName(kv[1].trim()));
-                    }
-                }
-            }
-
-            return type;
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Determine the best content type out of the selection of content types we offer and the ordered list of content
-     * types requested by the peer.
-     *
-     * TODO: implement remove variant selection algorithm (RFC 2296, http://tools.ietf.org/html/rfc2296)
-     *
-     * @param offeredTypes list of offered types in order of precedence
-     * @param requestedTypes list of requested types in order of precedence - may contain wildcards
-     * @return
-     */
-    public static ContentType bestContentType(List<ContentType> offeredTypes, List<ContentType> requestedTypes) {
-        // check for directly matching types
-        for(ContentType requested : requestedTypes) {
-            for(ContentType offered : offeredTypes) {
-                if(requested.matches(offered)) {
-                    return offered;
-                }
-            }
-        }
-        // check for qualified subtypes also
-        for(ContentType requested : requestedTypes) {
-            for(ContentType offered : offeredTypes) {
-                if(requested.matchesSubtype(offered)) {
-                    return offered;
-                }
-            }
-        }
-
-        // check for wildcard matching types
-        for(ContentType requested : requestedTypes) {
-            for(ContentType offered : offeredTypes) {
-                if(requested.matchesWildcard(offered)) {
-                    return offered;
-                }
-            }
-        }
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/MarmottaHttpUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/MarmottaHttpUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/MarmottaHttpUtils.java
new file mode 100644
index 0000000..3fedb6c
--- /dev/null
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/http/MarmottaHttpUtils.java
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.commons.http;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class MarmottaHttpUtils {
+
+    /**
+     * A utility method for parsing HTTP Content-Type and Accept header, taking into account different parameters that
+     * are typically passed. Recognized parameters:
+     * - charset: gives the charset of the content
+     * - q: gives the precedence of the content
+     * The result is an ordered list of content types in order of the computed preference in the header value passed as
+     * string argument.
+     * <p/>
+     * Author: Sebastian Schaffert
+     *
+     *
+     */
+    public static List<ContentType> parseAcceptHeader(String header) {
+        String[] components = header.split(",");
+        List<ContentType> contentTypes = new ArrayList<ContentType>(components.length);
+        for(String c : components) {
+            String mt[] = c.split(";");
+
+            String[] tst = mt[0].split("/");
+
+            if(tst.length == 2) {
+                ContentType type = parseContentType(c);
+                if(type != null) {
+                    contentTypes.add(type);
+                }
+            }
+        }
+
+        Collections.sort(contentTypes);
+
+        return contentTypes;
+    }
+
+
+    public static List<ContentType> parseStringList(Collection<String> types) {
+        List<ContentType> contentTypes = new ArrayList<ContentType>(types.size());
+        for(String c : types) {
+            ContentType type = parseContentType(c);
+            if(type != null) {
+                contentTypes.add(type);
+            }
+        }
+        return contentTypes;
+    }
+
+
+    public static ContentType parseContentType(String c) {
+        String mt[] = c.split(";");
+
+        String[] tst = mt[0].split("/");
+
+        if(tst.length == 2) {
+            ContentType type = new ContentType(tst[0],tst[1]);
+
+            // add parameters
+            for(int i=1; i<mt.length; i++) {
+                String[] kv = mt[i].split("=");
+                if(kv.length == 2) {
+                    type.setParameter(kv[0].trim(),kv[1].trim());
+
+                    if("charset".equalsIgnoreCase(kv[0].trim())) {
+                        type.setCharset(Charset.forName(kv[1].trim()));
+                    }
+                }
+            }
+
+            return type;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Determine the best content type out of the selection of content types we offer and the ordered list of content
+     * types requested by the peer.
+     *
+     * TODO: implement remove variant selection algorithm (RFC 2296, http://tools.ietf.org/html/rfc2296)
+     *
+     * @param offeredTypes list of offered types in order of precedence
+     * @param requestedTypes list of requested types in order of precedence - may contain wildcards
+     * @return
+     */
+    public static ContentType bestContentType(List<ContentType> offeredTypes, List<ContentType> requestedTypes) {
+        // check for directly matching types
+        for(ContentType requested : requestedTypes) {
+            for(ContentType offered : offeredTypes) {
+                if(requested.matches(offered)) {
+                    return offered;
+                }
+            }
+        }
+        // check for qualified subtypes also
+        for(ContentType requested : requestedTypes) {
+            for(ContentType offered : offeredTypes) {
+                if(requested.matchesSubtype(offered)) {
+                    return offered;
+                }
+            }
+        }
+
+        // check for wildcard matching types
+        for(ContentType requested : requestedTypes) {
+            for(ContentType offered : offeredTypes) {
+                if(requested.matchesWildcard(offered)) {
+                    return offered;
+                }
+            }
+        }
+        
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
index 90e60c6..23931b3 100644
--- a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
@@ -18,7 +18,7 @@
 package org.apache.marmotta.commons.http;
 
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -100,7 +100,7 @@ public class ContentTypeMatchingTest {
         accepted.add(accepted1);
         accepted.add(accepted2);
 
-        Assert.assertEquals(offered2, LMFHttpUtils.bestContentType(offered,accepted));
+        Assert.assertEquals(offered2, MarmottaHttpUtils.bestContentType(offered,accepted));
     }
 
     @Test
@@ -120,7 +120,7 @@ public class ContentTypeMatchingTest {
         accepted.add(accepted1);
         accepted.add(accepted2);
 
-        Assert.assertEquals(offered1, LMFHttpUtils.bestContentType(offered,accepted));
+        Assert.assertEquals(offered1, MarmottaHttpUtils.bestContentType(offered,accepted));
     }
 
     @Test
@@ -140,7 +140,7 @@ public class ContentTypeMatchingTest {
         accepted.add(accepted1);
         accepted.add(accepted2);
 
-        Assert.assertEquals(offered3, LMFHttpUtils.bestContentType(offered,accepted));
+        Assert.assertEquals(offered3, MarmottaHttpUtils.bestContentType(offered,accepted));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/MarmottaHttpUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/MarmottaHttpUtilsTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/MarmottaHttpUtilsTest.java
new file mode 100644
index 0000000..260b7bd
--- /dev/null
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/MarmottaHttpUtilsTest.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.commons.http;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * MarmottaHttpUtils tests
+ * 
+ * @author Sergio Fernández
+ */
+public class MarmottaHttpUtilsTest {
+
+    @Test
+    public void testConentTypeMatching() throws Exception {
+        assertEquals("application/rdf+xml", MarmottaHttpUtils.bestContentType(ImmutableList.of(new ContentType("application", "rdf+xml")), ImmutableList.of(new ContentType("application", "rdf+xml"))).getMime());
+        assertEquals("application/rdf+xml", MarmottaHttpUtils.bestContentType(ImmutableList.of(new ContentType("application", "rdf+xml")), ImmutableList.of(new ContentType("application", "xml"))).getMime());
+        assertEquals(null, MarmottaHttpUtils.bestContentType(ImmutableList.of(new ContentType("text", "tutle")), ImmutableList.of(new ContentType("text", "plain"))));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/libraries/ldclient/ldclient-api/src/main/java/org/apache/marmotta/ldclient/api/endpoint/Endpoint.java
----------------------------------------------------------------------
diff --git a/libraries/ldclient/ldclient-api/src/main/java/org/apache/marmotta/ldclient/api/endpoint/Endpoint.java b/libraries/ldclient/ldclient-api/src/main/java/org/apache/marmotta/ldclient/api/endpoint/Endpoint.java
index 16759d8..45be4e3 100644
--- a/libraries/ldclient/ldclient-api/src/main/java/org/apache/marmotta/ldclient/api/endpoint/Endpoint.java
+++ b/libraries/ldclient/ldclient-api/src/main/java/org/apache/marmotta/ldclient/api/endpoint/Endpoint.java
@@ -26,7 +26,7 @@ import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
-import static org.apache.marmotta.commons.http.LMFHttpUtils.parseAcceptHeader;
+import static org.apache.marmotta.commons.http.MarmottaHttpUtils.parseAcceptHeader;
 
 /**
  * Definition of a Linked Data Endpoint. Contains information how to query the

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/libraries/ldclient/ldclient-core/src/main/java/org/apache/marmotta/ldclient/services/provider/AbstractHttpProvider.java
----------------------------------------------------------------------
diff --git a/libraries/ldclient/ldclient-core/src/main/java/org/apache/marmotta/ldclient/services/provider/AbstractHttpProvider.java b/libraries/ldclient/ldclient-core/src/main/java/org/apache/marmotta/ldclient/services/provider/AbstractHttpProvider.java
index ef89751..8f45da0 100644
--- a/libraries/ldclient/ldclient-core/src/main/java/org/apache/marmotta/ldclient/services/provider/AbstractHttpProvider.java
+++ b/libraries/ldclient/ldclient-core/src/main/java/org/apache/marmotta/ldclient/services/provider/AbstractHttpProvider.java
@@ -51,7 +51,7 @@ import java.util.List;
 import java.util.Queue;
 import java.util.Set;
 
-import static org.apache.marmotta.commons.http.LMFHttpUtils.parseContentType;
+import static org.apache.marmotta.commons.http.MarmottaHttpUtils.parseContentType;
 
 /**
  * Add file description here!

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java
index 36e0c4f..caad296 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java
@@ -25,7 +25,7 @@ import org.apache.marmotta.platform.core.api.exporter.ExportService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.apache.marmotta.platform.core.exception.io.UnsupportedExporterException;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.openrdf.model.URI;
 import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
@@ -97,13 +97,13 @@ public class ExportWebService {
     public Response downloadData(@HeaderParam("Accept") String types, @QueryParam("format") String qFormat, @QueryParam("context") String context_string) throws IOException {
         List<ContentType> acceptedTypes;
         if(qFormat != null) {
-            acceptedTypes = LMFHttpUtils.parseAcceptHeader(qFormat);
+            acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(qFormat);
         } else {
-            acceptedTypes = LMFHttpUtils.parseAcceptHeader(types);
+            acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(types);
         }
-        List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(exportService.getProducedTypes());
+        List<ContentType> offeredTypes  = MarmottaHttpUtils.parseStringList(exportService.getProducedTypes());
 
-        final ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);
+        final ContentType bestType = MarmottaHttpUtils.bestContentType(offeredTypes,acceptedTypes);
 
         // create a file name for the export, preferrably with a good extension ...
         String fileName;

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
index f2e76eb..3de0d7d 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
@@ -46,7 +46,7 @@ import javax.ws.rs.core.Response.Status;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.commons.http.ContentType;
 import org.apache.marmotta.commons.http.ETagGenerator;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.apache.marmotta.commons.http.UriUtil;
 import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
@@ -389,13 +389,13 @@ public class ResourceWebService {
                 // FIXME String appendix = uuid == null ? "?uri=" + URLEncoder.encode(uri, "utf-8") :
                 // "/" + uuid;
 
-                List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
+                List<ContentType> offeredTypes  = MarmottaHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
                 for(ContentType t : offeredTypes) {
                 	t.setParameter("rel", "meta");
                 }
                 String contentmime = contentService.getContentType(r);
                 if(contentmime != null) {
-                	ContentType tContent = LMFHttpUtils.parseContentType(contentmime);
+                	ContentType tContent = MarmottaHttpUtils.parseContentType(contentmime);
                 	tContent.setParameter("rel", "content");
                 	offeredTypes.add(0,tContent);
                 }
@@ -404,8 +404,8 @@ public class ResourceWebService {
                 	return build406(Collections.<ContentType>emptyList(), offeredTypes);
                 }
 
-                List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(types);
-                ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);
+                List<ContentType> acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(types);
+                ContentType bestType = MarmottaHttpUtils.bestContentType(offeredTypes,acceptedTypes);
 
                 log.debug("identified best type: {}",bestType);
 
@@ -516,7 +516,7 @@ public class ResourceWebService {
 
             // the offered types are those sent by the client in the Content-Type header; if the rel attribute is not
             // given, we add the default rel value
-            List<ContentType> types = LMFHttpUtils.parseAcceptHeader(mimetype);
+            List<ContentType> types = MarmottaHttpUtils.parseAcceptHeader(mimetype);
             for(ContentType type : types) {
                 if(type.getParameter("rel") == null) {
                     type.setParameter("rel",configurationService.getStringConfiguration("linkeddata.mime.rel.default", "meta"));
@@ -525,7 +525,7 @@ public class ResourceWebService {
 
             // the acceptable types are all types for content and the meta types we have parsers for; we do not care so
             // much about the order ...
-            List<ContentType> acceptable = LMFHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
+            List<ContentType> acceptable = MarmottaHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
             for(ContentType a : acceptable) {
                 a.setParameter("rel", "meta");
             }
@@ -534,7 +534,7 @@ public class ResourceWebService {
             acceptable.add(0,allContent);
 
             // determine the best match between the offered types and the acceptable types
-            ContentType bestType = LMFHttpUtils.bestContentType(types,acceptable);
+            ContentType bestType = MarmottaHttpUtils.bestContentType(types,acceptable);
 
             if (bestType != null) {
                 if (configurationService.getBooleanConfiguration("linkeddata.redirect.put", true)) {

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
index 9e7e413..b61651f 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
@@ -46,7 +46,7 @@ import javax.ws.rs.core.Response.Status;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.exporter.ExportService;
 import org.apache.marmotta.platform.core.api.triplestore.ContextService;
@@ -198,13 +198,13 @@ public class ContextWebService {
     private URI buildExportUri(String uri, String accept, String format) throws URISyntaxException {
         List<ContentType> acceptedTypes;
         if(format != null) {
-            acceptedTypes = LMFHttpUtils.parseAcceptHeader(format);
+            acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(format);
         } else {
-            acceptedTypes = LMFHttpUtils.parseAcceptHeader(accept);
+            acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(accept);
         }
-        List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(exportService.getProducedTypes());
+        List<ContentType> offeredTypes  = MarmottaHttpUtils.parseStringList(exportService.getProducedTypes());
         offeredTypes.removeAll(Collections.unmodifiableList(Arrays.asList(new ContentType("text", "html"), new ContentType("application", "xhtml+xml"))));
-        final ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes, acceptedTypes);
+        final ContentType bestType = MarmottaHttpUtils.bestContentType(offeredTypes, acceptedTypes);
         return new URI(configurationService.getBaseUri() + "export/download?context=" + uri + "&format=" + bestType.getMime());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-ldcache/src/main/java/org/apache/marmotta/platform/ldcache/services/endpoint/LinkedDataEndpointServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldcache/src/main/java/org/apache/marmotta/platform/ldcache/services/endpoint/LinkedDataEndpointServiceImpl.java b/platform/marmotta-ldcache/src/main/java/org/apache/marmotta/platform/ldcache/services/endpoint/LinkedDataEndpointServiceImpl.java
index 2f426c8..5fc55fa 100644
--- a/platform/marmotta-ldcache/src/main/java/org/apache/marmotta/platform/ldcache/services/endpoint/LinkedDataEndpointServiceImpl.java
+++ b/platform/marmotta-ldcache/src/main/java/org/apache/marmotta/platform/ldcache/services/endpoint/LinkedDataEndpointServiceImpl.java
@@ -21,7 +21,7 @@ import org.apache.marmotta.platform.ldcache.api.endpoint.LinkedDataEndpointServi
 import com.google.common.base.Joiner;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
 import org.openrdf.model.URI;
 import org.slf4j.Logger;
@@ -191,7 +191,7 @@ public class LinkedDataEndpointServiceImpl implements LinkedDataEndpointService
         endpoint.setDefaultExpiry(configurationService.getLongConfiguration("ldcache.endpoint." + label + ".expiry"));
         endpoint.setActive(configurationService.getBooleanConfiguration("ldcache.endpoint." + label + ".active"));
         endpoint.setContentTypes(new HashSet<ContentType>(
-                LMFHttpUtils.parseAcceptHeader(
+                MarmottaHttpUtils.parseAcceptHeader(
                         configurationService.getStringConfiguration("ldcache.endpoint." + label + ".contenttype",""))
         ));
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java
index 48e6e4c..06ab136 100644
--- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java
+++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java
@@ -49,7 +49,7 @@ import javax.ws.rs.core.UriBuilder;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.exporter.ExportService;
 import org.apache.marmotta.platform.core.api.templating.TemplatingService;
@@ -234,14 +234,14 @@ public class SparqlWebService {
 	        	List<ContentType> acceptedTypes;
 	        	List<ContentType> offeredTypes;
 	        	if (resultType != null) {
-	        		acceptedTypes = LMFHttpUtils.parseAcceptHeader(resultType);
+	        		acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(resultType);
 	        	} else {
-	        		acceptedTypes = LMFHttpUtils.parseAcceptHeader(acceptHeader);
+	        		acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(acceptHeader);
 	        	}
 	        	if (QueryType.TUPLE.equals(queryType)) {
-	        		offeredTypes  = LMFHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json", "text/html", "application/rdf+xml", "text/csv"));
+	        		offeredTypes  = MarmottaHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json", "text/html", "application/rdf+xml", "text/csv"));
 	        	} else if (QueryType.BOOL.equals(queryType)) {
-	        		offeredTypes  = LMFHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json", "text/html", "application/rdf+xml", "text/csv"));
+	        		offeredTypes  = MarmottaHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json", "text/html", "application/rdf+xml", "text/csv"));
 	        	} else if (QueryType.GRAPH.equals(queryType)) {
 	        		Set<String> producedTypes = new HashSet<String>(exportService.getProducedTypes());
 	        		producedTypes.remove("application/xml");
@@ -249,13 +249,13 @@ public class SparqlWebService {
 	        		producedTypes.remove("text/plain");
 	        		producedTypes.remove("text/html");
 	        		producedTypes.remove("application/xhtml+xml");
-	        		offeredTypes  = LMFHttpUtils.parseStringList(producedTypes);
+	        		offeredTypes  = MarmottaHttpUtils.parseStringList(producedTypes);
 	        	} else {
 	        		return Response.status(Response.Status.BAD_REQUEST).entity("no result format specified or unsupported result format").build();
 	        	}
-	            ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes, acceptedTypes);
+	            ContentType bestType = MarmottaHttpUtils.bestContentType(offeredTypes, acceptedTypes);
 	            if (bestType == null) {
-	            	return Response.status(Response.Status.BAD_REQUEST).entity("no result format specified or unsupported result format").build();
+	            	return Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).entity("no result format specified or unsupported result format").build();
 	            } else {
 	        		//return buildQueryResponse(resultType, query);
 	            	return buildQueryResponse(bestType, query, queryType);
@@ -397,9 +397,9 @@ public class SparqlWebService {
                 return Response.ok().build();
             } else {
                 if (resultType == null) {
-                    List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(request.getHeader("Accept"));
-                    List<ContentType> offeredTypes = LMFHttpUtils.parseStringList(Lists.newArrayList("*/*", "text/html"));
-                    ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes, acceptedTypes);
+                    List<ContentType> acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(request.getHeader("Accept"));
+                    List<ContentType> offeredTypes = MarmottaHttpUtils.parseStringList(Lists.newArrayList("*/*", "text/html"));
+                    ContentType bestType = MarmottaHttpUtils.bestContentType(offeredTypes, acceptedTypes);
                     if (bestType != null) {
                         resultType = bestType.getMime();
                     }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-sparql/src/test/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/test/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebServiceTest.java b/platform/marmotta-sparql/src/test/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebServiceTest.java
index 8d0486c..006c9a6 100644
--- a/platform/marmotta-sparql/src/test/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebServiceTest.java
+++ b/platform/marmotta-sparql/src/test/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebServiceTest.java
@@ -133,10 +133,22 @@ public class SparqlWebServiceTest {
     public void testConstructContentNegotiationPlain() throws IOException, InterruptedException {
         expect().
         	log().ifError().
+    		statusCode(415).
+    	given().
+    		header("Accept", "text/plain").
+    		param("query", "CONSTRUCT { <http://www.wikier.org/foaf#wikier2> ?p ?o } WHERE { <http://www.wikier.org/foaf#wikier> ?p ?o }").
+		when().
+    		get("/sparql/select");
+    }
+    
+    @Test
+    public void testConstructContentNegotiationTurtle() throws IOException, InterruptedException {
+        expect().
+        	log().ifError().
     		statusCode(200).
     		contentType("text/turtle").
     	given().
-    		header("Accept", "plain/text").
+    		header("Accept", "text/turtle").
     		param("query", "CONSTRUCT { <http://www.wikier.org/foaf#wikier2> ?p ?o } WHERE { <http://www.wikier.org/foaf#wikier> ?p ?o }").
 		when().
     		get("/sparql/select");
@@ -171,8 +183,7 @@ public class SparqlWebServiceTest {
     public void testDescribeContentNegotiationPlain() throws IOException, InterruptedException {
         expect().
         	log().ifError().
-    		statusCode(200).
-    		contentType("text/turle").
+    		statusCode(415).
     	given().
     		header("Accept", "plain/text").
     		param("query", "DESCRIBE <http://www.wikier.org/foaf#wikier>").

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/services/VersionSerializerServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/services/VersionSerializerServiceImpl.java b/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/services/VersionSerializerServiceImpl.java
index 9eefe34..c288f67 100644
--- a/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/services/VersionSerializerServiceImpl.java
+++ b/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/services/VersionSerializerServiceImpl.java
@@ -20,7 +20,7 @@ package org.apache.marmotta.platform.versioning.services;
 import org.apache.marmotta.platform.versioning.api.VersionSerializerService;
 import org.apache.marmotta.platform.versioning.io.VersionSerializer;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.Any;
@@ -49,7 +49,7 @@ public class VersionSerializerServiceImpl implements VersionSerializerService {
     @Override
     public VersionSerializer getSerializer(List<ContentType> type) throws IOException {
         for(VersionSerializer serializer : serializers) {
-            if(LMFHttpUtils.bestContentType(serializer.getContentTypes(),type) != null) return serializer;
+            if(MarmottaHttpUtils.bestContentType(serializer.getContentTypes(),type) != null) return serializer;
         }
         throw new IOException("Cannot find serializer for " + type);
     }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/7122c515/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/webservices/MementoWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/webservices/MementoWebService.java b/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/webservices/MementoWebService.java
index 2661fea..fc12de1 100644
--- a/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/webservices/MementoWebService.java
+++ b/platform/marmotta-versioning/src/main/java/org/apache/marmotta/platform/versioning/webservices/MementoWebService.java
@@ -38,7 +38,7 @@ import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.apache.marmotta.commons.collections.CollectionUtils;
 import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.apache.marmotta.commons.http.MarmottaHttpUtils;
 import org.apache.marmotta.kiwi.versioning.model.Version;
 import org.openrdf.model.URI;
 import org.openrdf.repository.RepositoryConnection;
@@ -263,7 +263,7 @@ public class MementoWebService {
 
                 final URI resource = ResourceUtils.getUriResource(conn, resource_string);
 
-                List<ContentType> types = LMFHttpUtils.parseAcceptHeader(types_string);
+                List<ContentType> types = MarmottaHttpUtils.parseAcceptHeader(types_string);
 
                 //get versions
                 final RepositoryResult<Version> versions = versioningService.listVersions(resource);
@@ -315,9 +315,9 @@ public class MementoWebService {
      * @throws IllegalArgumentException if no type is supported
      */
     private ContentType getContentType(String types) throws IllegalArgumentException {
-        List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(types);
-        List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(lmfIOService.getProducedTypes());
-        ContentType type = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);
+        List<ContentType> acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(types);
+        List<ContentType> offeredTypes  = MarmottaHttpUtils.parseStringList(lmfIOService.getProducedTypes());
+        ContentType type = MarmottaHttpUtils.bestContentType(offeredTypes,acceptedTypes);
         if(type == null) throw new IllegalArgumentException("Requested type is not supported");
         return type;
     }