= ContentNegotiationServiceXRoDomainType
:Notice: 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.

Handles content negotiation for accept headers requiring `application/json` or `application/xml` and specifying an x-ro-domain-type; will delegate to any available xref:refguide:applib:index/services/conmap/ContentMappingService.adoc[ContentMappingService] s to (try to) map the result object into the required representation if possible.

In the accept header the profile is also checked dependent on the resource being invoked; either `profile="urn:org.restfulobjects:repr-types/object"` for an object representation, or `profile="profile=urn:org.restfulobjects:repr-types/action-result"` for an action result.

If the accept header specifies `application/xml` then the service additionally verifies that the (mapped) domain object's runtime type is annotated with the JAXB _javax.xml.bind.annotation.XmlRootElement_ annotation so that RestEasy is able to unambiguously serialize it.

== API

[source,java]
.ContentNegotiationServiceXRoDomainType.java
----
class ContentNegotiationServiceXRoDomainType {
  public static final String X_RO_DOMAIN_TYPE;
  Response.ResponseBuilder buildResponse(IResourceContext resourceContext, ManagedObject objectAdapter)     // <.>
  Response.ResponseBuilder buildResponse(IResourceContext resourceContext, ObjectAndActionInvocation objectAndActionInvocation)     // <.>
}
----

<.> xref:#buildResponse_IResourceContext_ManagedObject[buildResponse(IResourceContext, ManagedObject)]
+
--
search for an accept header in form `application/xml;profile=urn:org.restfulobjects:repr-types/object;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto` 
--
<.> xref:#buildResponse_IResourceContext_ObjectAndActionInvocation[buildResponse(IResourceContext, ObjectAndActionInvocation)]
+
--
search for an accept header in form `application/xml;profile=urn:org.restfulobjects:repr-types/action-result;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto` 
--

== Members

[#buildResponse_IResourceContext_ManagedObject]
=== buildResponse(IResourceContext, ManagedObject)

search for an accept header in form `application/xml;profile=urn:org.restfulobjects:repr-types/object;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto` 

[#buildResponse_IResourceContext_ObjectAndActionInvocation]
=== buildResponse(IResourceContext, ObjectAndActionInvocation)

search for an accept header in form `application/xml;profile=urn:org.restfulobjects:repr-types/action-result;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto` 

include::hooks/ContentNegotiationServiceXRoDomainType_usage-notes.adoc[]
