Repository: marmotta Updated Branches: refs/heads/develop 31c26b740 -> 488d4e6f8
fixed bug parsing accept header Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/488d4e6f Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/488d4e6f Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/488d4e6f Branch: refs/heads/develop Commit: 488d4e6f8f78b1806ed413c3acfa6e4f313fdc46 Parents: 31c26b7 Author: Sergio Fernández <[email protected]> Authored: Mon Nov 10 18:26:31 2014 +0100 Committer: Sergio Fernández <[email protected]> Committed: Tue Nov 11 11:10:40 2014 +0100 ---------------------------------------------------------------------- .../jaxrs/exceptionmappers/HttpErrorExceptionMapper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/488d4e6f/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java index 9d71d8b..fd37e56 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java @@ -16,6 +16,8 @@ */ package org.apache.marmotta.platform.core.jaxrs.exceptionmappers; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; import freemarker.template.TemplateException; import org.apache.commons.lang3.StringUtils; import org.apache.marmotta.commons.http.ContentType; @@ -74,9 +76,9 @@ public class HttpErrorExceptionMapper implements CDIExceptionMapper<HttpErrorExc boolean htmlError = true; //HTML still by default if (exceptionHeaders.containsKey("Accept")) { final String acceptHeader = exceptionHeaders.get("Accept"); - final ContentType bestContentType = MarmottaHttpUtils.bestContentType(Arrays.asList(MarmottaHttpUtils.parseContentType("text/html"), MarmottaHttpUtils.parseContentType("application/json")), - Arrays.asList(MarmottaHttpUtils.parseContentType(acceptHeader))); - htmlError = bestContentType == null || !bestContentType.matches(MarmottaHttpUtils.parseContentType("application/json")); + final ContentType bestContentType = MarmottaHttpUtils.bestContentType(Arrays.asList(new ContentType("text", "html"), new ContentType("application", "json")), + MarmottaHttpUtils.parseAcceptHeader(acceptHeader)); + htmlError = bestContentType == null || !bestContentType.matches(new ContentType("application", "json")); } Response.ResponseBuilder responseBuilder;
