public static final String XRD = "application/xrd";
public static final String DATA = "application/yang-data";
+ // up to and including draft-ietf-netconf-yang-patch-08
public static final String YANG_PATCH = "application/yang.patch";
public static final String YANG_PATCH_STATUS = "application/yang.patch-status";
+
+ // since draft-ietf-netconf-yang-patch-09
+ public static final String YANG_PATCH_RFC8072 = "application/yang-patch";
}
/**
static final MediaType YANG_PATCH_JSON_TYPE = MediaType.valueOf(MediaTypes.YANG_PATCH + RestconfConstants.JSON);
@VisibleForTesting
static final MediaType YANG_PATCH_XML_TYPE = MediaType.valueOf(MediaTypes.YANG_PATCH + RestconfConstants.XML);
+ private static final MediaType YANG_PATCH_RFC8072_JSON_TYPE =
+ MediaType.valueOf(MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.JSON);
+ private static final MediaType YANG_PATCH_RFC8072_XML_TYPE =
+ MediaType.valueOf(MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML);
private static final Logger LOG = LoggerFactory.getLogger(RestconfDocumentedExceptionMapper.class);
private static final MediaType DEFAULT_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
private static boolean isJsonCompatibleMediaType(final MediaType mediaType) {
return mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)
- || mediaType.isCompatible(YANG_DATA_JSON_TYPE) || mediaType.isCompatible(YANG_PATCH_JSON_TYPE);
+ || mediaType.isCompatible(YANG_DATA_JSON_TYPE)
+ || mediaType.isCompatible(YANG_PATCH_RFC8072_JSON_TYPE)
+ || mediaType.isCompatible(YANG_PATCH_JSON_TYPE);
}
private static boolean isXmlCompatibleMediaType(final MediaType mediaType) {
return mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)
- || mediaType.isCompatible(YANG_DATA_XML_TYPE) || mediaType.isCompatible(YANG_PATCH_XML_TYPE);
+ || mediaType.isCompatible(YANG_DATA_XML_TYPE)
+ || mediaType.isCompatible(YANG_PATCH_RFC8072_XML_TYPE)
+ || mediaType.isCompatible(YANG_PATCH_XML_TYPE);
}
/**
import org.slf4j.LoggerFactory;
@Provider
-@Consumes({Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON})
+@Consumes({
+ Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.JSON
+})
public class JsonToPatchBodyReader extends AbstractToPatchBodyReader {
private static final Logger LOG = LoggerFactory.getLogger(JsonToPatchBodyReader.class);
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.common.patch.PatchStatusContext;
import org.opendaylight.restconf.common.patch.PatchStatusEntity;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory;
-
@Provider
-@Produces({ Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON })
+@Produces({ MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON, MediaTypes.DATA + RestconfConstants.JSON })
public class PatchJsonBodyWriter implements MessageBodyWriter<PatchStatusContext> {
@Override
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.common.patch.PatchStatusContext;
import org.opendaylight.restconf.common.patch.PatchStatusEntity;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
@Provider
-@Produces({ Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML })
+@Produces({ MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML, MediaTypes.DATA + RestconfConstants.XML })
public class PatchXmlBodyWriter implements MessageBodyWriter<PatchStatusContext> {
private static final XMLOutputFactory XML_FACTORY;
import org.xml.sax.SAXException;
@Provider
-@Consumes({Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML})
+@Consumes({
+ Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML,
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML
+})
public class XmlToPatchBodyReader extends AbstractToPatchBodyReader {
private static final Logger LOG = LoggerFactory.getLogger(XmlToPatchBodyReader.class);
private static final Splitter SLASH_SPLITTER = Splitter.on('/');
- public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler,
- DOMMountPointServiceHandler mountPointServiceHandler) {
+ public XmlToPatchBodyReader(final SchemaContextHandler schemaContextHandler,
+ final DOMMountPointServiceHandler mountPointServiceHandler) {
super(schemaContextHandler, mountPointServiceHandler);
}
@Patch
@Path("/data/{identifier:.+}")
@Consumes({
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML,
Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
- Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML
+ Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML,
})
@Produces({
+ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
})
@Patch
@Path("/data")
@Consumes({
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML,
Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML
})
@Produces({
+ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
})
PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
-
/**
* Partially modify the target data resource.
*
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
/**
*/
@GET
@Path("/host-meta")
- @Produces({Rfc8040.MediaTypes.XRD + RestconfConstants.XML})
+ @Produces({ MediaTypes.XRD + RestconfConstants.XML })
Response readXrdData();
/**
*/
@GET
@Path("/host-meta.json")
- @Produces({Rfc8040.MediaTypes.XRD + RestconfConstants.JSON})
+ @Produces({ MediaTypes.XRD + RestconfConstants.JSON, MediaType.APPLICATION_JSON })
Response readJsonData();
}
@Path("/operations")
@Produces({
Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
Rfc8040.MediaTypes.DATA,
MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML,
@Path("/operations/{identifier:.+}")
@Produces({
Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
Rfc8040.MediaTypes.DATA,
MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML,
@Path("/yang-library-version")
@Produces({
Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
+ Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
Rfc8040.MediaTypes.DATA,
MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML,