Introduce restconf.server.api.HttpGetResource
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / jaxrs / JaxRsRestconf.java
index 4a56692bb2038687822677f23ad56d5872ca6547..69803105dcb0a81fa102634b16dbb999e1736b0a 100644 (file)
@@ -45,7 +45,6 @@ import javax.ws.rs.ext.ParamConverterProvider;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.restconf.api.ApiPath;
-import org.opendaylight.restconf.api.FormattableBody;
 import org.opendaylight.restconf.api.MediaTypes;
 import org.opendaylight.restconf.api.QueryParameters;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
@@ -646,7 +645,7 @@ public final class JaxRsRestconf implements ParamConverterProvider {
         MediaTypes.APPLICATION_YANG_DATA_JSON, MediaType.APPLICATION_JSON
     })
     public void operationsGET(@Suspended final AsyncResponse ar) {
-        completeOperationsGet(server.operationsGET(), ar);
+        server.operationsGET().addCallback(new FormattableBodyCallback(ar));
     }
 
     /**
@@ -662,16 +661,7 @@ public final class JaxRsRestconf implements ParamConverterProvider {
         MediaTypes.APPLICATION_YANG_DATA_JSON, MediaType.APPLICATION_JSON
     })
     public void operationsGET(@PathParam("operation") final ApiPath operation, @Suspended final AsyncResponse ar) {
-        completeOperationsGet(server.operationsGET(operation), ar);
-    }
-
-    private static void completeOperationsGet(final RestconfFuture<FormattableBody> future, final AsyncResponse ar) {
-        future.addCallback(new JaxRsRestconfCallback<FormattableBody>(ar) {
-            @Override
-            Response transform(final FormattableBody result) {
-                return Response.ok().entity(result).build();
-            }
-        });
+        server.operationsGET(operation).addCallback(new FormattableBodyCallback(ar));
     }
 
     /**
@@ -761,12 +751,7 @@ public final class JaxRsRestconf implements ParamConverterProvider {
         MediaType.TEXT_XML
     })
     public void yangLibraryVersionGET(@Suspended final AsyncResponse ar) {
-        server.yangLibraryVersionGET().addCallback(new JaxRsRestconfCallback<NormalizedNodePayload>(ar) {
-            @Override
-            Response transform(final NormalizedNodePayload result) {
-                return Response.ok().entity(result).build();
-            }
-        });
+        server.yangLibraryVersionGET().addCallback(new FormattableBodyCallback(ar));
     }
 
     // FIXME: References to these resources are generated by our yang-library implementation. That means: