Fix the code based on vnaas API docs

Change-Id: I24c6ddfdccd4746dda575628b8e4c300cae06a6f
diff --git a/global/config-samples/ecord-global-config.json b/global/config-samples/ecord-global-config.json
index cd6b082..156c23a 100644
--- a/global/config-samples/ecord-global-config.json
+++ b/global/config-samples/ecord-global-config.json
@@ -5,7 +5,7 @@
         "username" : "xosadmin@opencord.org",
         "password" : "0Ui8QNJNCdXrjjLpF1U6",
         "address" : "127.0.0.1",
-        "resource" : "/xosapi/v1/metronet/usernetworkinterfaces/"
+        "resource" : "/xosapi/v1/vnaas/usernetworkinterfaces/"
       }
     },
     "org.opencord.ce.global.channel.http" : {
diff --git a/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/VirtualDomainDeviceProvider.java b/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/VirtualDomainDeviceProvider.java
index d1bdefb..36daf56 100644
--- a/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/VirtualDomainDeviceProvider.java
+++ b/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/VirtualDomainDeviceProvider.java
@@ -71,6 +71,7 @@
 import static org.onosproject.net.AnnotationKeys.DRIVER;
 import static org.onosproject.net.AnnotationKeys.LATITUDE;
 import static org.onosproject.net.AnnotationKeys.LONGITUDE;
+import static org.opencord.ce.api.services.channel.Symbols.MEF_PORT_TYPE;
 import static org.slf4j.LoggerFactory.getLogger;
 import static org.opencord.ce.api.models.CarrierEthernetNetworkInterface.Type;
 
@@ -87,7 +88,7 @@
     private static final String UNKNOWN = "unknown";
     private static final String NO_LLDP = "no-lldp";
     private static final String DOMAIN_ID = "domainId";
-    private static final String MEF_IF_TYPE = "mefIfType";
+
 
     private ApplicationId appId;
 
@@ -272,19 +273,19 @@
 
     private void notifyXoS(DeviceId deviceId, List<PortDescription> portDescriptions) {
         portDescriptions.forEach(port -> {
-            if (port.annotations().keys().contains(MEF_IF_TYPE)) {
+            if (port.annotations().keys().contains(MEF_PORT_TYPE)) {
                 Type type = Type.valueOf(
-                        port.annotations().value(MEF_IF_TYPE));
+                        port.annotations().value(MEF_PORT_TYPE));
                 ConnectPoint cp = new ConnectPoint(deviceId, port.portNumber());
                 switch (type) {
                     case UNI:
                         ObjectNode body = xoSHttpClient.mapper().createObjectNode();
                         body.put("tenant", port.annotations().value(DOMAIN_ID));
                         body.put("name", "UNI:" + cp.toString());
-                        body.put("latlng", "[" + port.annotations().value(LATITUDE) + "," +
+                        body.put("latlng", "[" + port.annotations().value(LATITUDE) + ", " +
                                 port.annotations().value(LONGITUDE) + "]");
                         body.put("cpe_id", cp.toString());
-                        xoSHttpClient.restPut(body.toString(), cp.toString());
+                        xoSHttpClient.restPost(body.toString());
                         break;
                     case ENNI:
 
@@ -311,9 +312,9 @@
      */
     private void addGlobalMefLtp(DeviceId deviceId, List<PortDescription> portDescriptions) {
         portDescriptions.forEach(port -> {
-            if (port.annotations().keys().contains(MEF_IF_TYPE)) {
+            if (port.annotations().keys().contains(MEF_PORT_TYPE)) {
                 Type type = Type.valueOf(
-                        port.annotations().value(MEF_IF_TYPE));
+                        port.annotations().value(MEF_PORT_TYPE));
                 CarrierEthernetNetworkInterface ni;
                 ConnectPoint cp = new ConnectPoint(deviceId, port.portNumber());
                 switch (type) {
diff --git a/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/XoSHttpClient.java b/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/XoSHttpClient.java
index 1d72b40..fdd8570 100644
--- a/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/XoSHttpClient.java
+++ b/global/virtualprovider/src/main/java/org/opencord/ce/global/virtualdomain/XoSHttpClient.java
@@ -18,6 +18,7 @@
 
 import com.fasterxml.jackson.databind.SerializationFeature;
 import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.onosproject.rest.AbstractWebResource;
 import org.slf4j.Logger;
 
@@ -46,21 +47,29 @@
 
     public XoSHttpClient(XosEndPoint xosEndPoint) {
         this.xosEndPoint = xosEndPoint;
+        // Setup credentials
+        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+                .nonPreemptive()
+                .credentials(xosEndPoint.username(), xosEndPoint.password())
+                .build();
 
+        client.register(feature);
         client.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_TIMEOUT_MS);
         client.property(ClientProperties.READ_TIMEOUT, DEFAULT_TIMEOUT_MS);
         mapper().enable(SerializationFeature.INDENT_OUTPUT);
     }
 
-    public void restPut(String body, String cpeId) {
+    public void restPost(String body) {
         WebTarget webTarget = client.target("http://" + xosEndPoint.ipAddress().toString() +
-                 xosEndPoint.resource() + "/" + cpeId);
+                 xosEndPoint.resource() + "/");
         Response response;
         response = webTarget.request(MediaType.APPLICATION_JSON)
-                .put(Entity.entity(body, MediaType.APPLICATION_JSON));
+                .post(Entity.entity(body, MediaType.APPLICATION_JSON));
         try {
             if (response.getStatus() != HTTP_OK) {
                 log.warn("Failed to put resource {}", xosEndPoint.resource());
+            } else {
+                log.info("Post to XoS successful: {}", response.getStatus());
             }
         } catch (javax.ws.rs.ProcessingException e) {
             log.error("Javax process exception in XoSClientHttp: {}", e.getMessage());