Encode Name parameter passed into client 84/106384/1
authorSmokowski, Steven <steve.smokowski@att.com>
Tue, 21 Apr 2020 19:48:16 +0000 (15:48 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Tue, 21 Apr 2020 19:48:16 +0000 (15:48 -0400)
Encode Name parameter passed into client
Remove un-needed test using file that does not exist

Issue-ID: SO-2823
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I47cab1b9d429552b0a4cdfccf296d0c31952c320

adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java

index 698b605..b98811c 100644 (file)
@@ -26,11 +26,11 @@ import org.onap.so.openstack.exceptions.MsoException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
+import org.springframework.web.util.UriUtils;
 import com.woorea.openstack.base.client.OpenStackRequest;
 import com.woorea.openstack.glance.Glance;
 import com.woorea.openstack.glance.model.Images;
 
-
 @Component
 public class GlanceClientImpl extends MsoCommonUtils {
 
@@ -70,10 +70,14 @@ public class GlanceClientImpl extends MsoCommonUtils {
     public Images queryImages(String cloudSiteId, String tenantId, int limit, String visibility, String marker,
             String name) throws MsoCloudSiteNotFound, GlanceClientException {
         try {
+            String encodedName = null;
+            if (name != null) {
+                encodedName = UriUtils.encodeQueryParam(name, "UTF-8");
+            }
             Glance glanceClient = getGlanceClient(cloudSiteId, tenantId);
             // list is set to false, otherwise an invalid URL is appended
             OpenStackRequest<Images> request = glanceClient.images().list(false).queryParam("visibility", visibility)
-                    .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
+                    .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", encodedName);
             return executeAndRecordOpenstackRequest(request, false);
         } catch (MsoException e) {
             logger.error("Error building Glance Client", e);
index 8f9dbd1..27ff86d 100644 (file)
@@ -26,6 +26,7 @@ import org.onap.so.openstack.exceptions.MsoException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
+import org.springframework.web.util.UriUtils;
 import com.woorea.openstack.base.client.OpenStackRequest;
 import com.woorea.openstack.quantum.Quantum;
 import com.woorea.openstack.quantum.model.Networks;
@@ -73,9 +74,13 @@ public class NeutronClientImpl extends MsoCommonUtils {
     public Networks queryNetworks(String cloudSiteId, String tenantId, int limit, String marker, String name, String id)
             throws MsoCloudSiteNotFound, NeutronClientException {
         try {
+            String encodedName = null;
+            if (name != null) {
+                encodedName = UriUtils.encodeQueryParam(name, "UTF-8");
+            }
             Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
             OpenStackRequest<Networks> request = neutronClient.networks().list().queryParam("id", id)
-                    .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
+                    .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", encodedName);
             return executeAndRecordOpenstackRequest(request, false);
         } catch (MsoException e) {
             logger.error("Error building Neutron Client", e);