X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fimpl%2FRestconfDocumentedExceptionMapper.java;h=d564d4cbd40d92ff18bc19fdb6c6c04698a12bcf;hp=63a5b1b54055a81cd3f8f3f736365c4e99e1d8b8;hb=61bc22edce038c773f19e716e1a99147876232ed;hpb=7343e5ed39a37cb10bb16d8b153c0e008c704673 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java index 63a5b1b540..d564d4cbd4 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java @@ -16,7 +16,6 @@ import static org.opendaylight.controller.sal.rest.api.Draft02.RestConfModule.ER import static org.opendaylight.controller.sal.rest.api.Draft02.RestConfModule.ERROR_TAG_QNAME; import static org.opendaylight.controller.sal.rest.api.Draft02.RestConfModule.ERROR_TYPE_QNAME; import static org.opendaylight.controller.sal.rest.api.Draft02.RestConfModule.NAMESPACE; - import com.google.common.base.Charsets; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -69,6 +68,7 @@ import org.xml.sax.InputSource; public class RestconfDocumentedExceptionMapper implements ExceptionMapper { private final static Logger LOG = LoggerFactory.getLogger(RestconfDocumentedExceptionMapper.class); + private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); @Context private HttpHeaders headers; @@ -78,16 +78,19 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper accepts = headers.getAcceptableMediaTypes(); + accepts.remove(MediaType.WILDCARD_TYPE); LOG.debug("Accept headers: {}", accepts); + final MediaType mediaType; if (accepts != null && accepts.size() > 0) { mediaType = accepts.get(0); // just pick the first one + } else { + // Default to the content type if there's no Accept header + mediaType = MediaType.APPLICATION_JSON_TYPE; } LOG.debug("Using MediaType: {}", mediaType); @@ -175,8 +178,7 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper