Get Roles on Users page for ext app
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / service / ApplicationsRestClientServiceImpl.java
index 1871720..cfe5557 100644 (file)
@@ -52,8 +52,8 @@ import javax.ws.rs.core.Response;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.impl.ResponseImpl;
 import org.apache.cxf.transport.http.HTTPException;
-import org.onap.portalapp.portal.service.AppsCacheService;
 import org.onap.portalapp.portal.domain.EPApp;
 import org.onap.portalapp.portal.logging.aop.EPAuditLog;
 import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
@@ -222,7 +222,12 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                if (response != null) {
                        verifyResponse(response);
-                       String str = response.readEntity(String.class);
+                       
+                       /* It is not recommendable to use the implementation class org.apache.cxf.jaxrs.impl.ResponseImpl in the code, 
+                       but had to force this in-order to prevent conflict with the ResponseImpl class of Jersey Client which 
+                       doesn't work as expected. Created Portal-253 for tracking */
+                       String str = ((ResponseImpl)response).readEntity(String.class);
+                       
                        EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET result =", str);
                        try {
                                t = gson.fromJson(str, clazz);
@@ -240,7 +245,11 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                if (response != null) {
                        verifyResponse(response);
-                       String incomingJson = response.readEntity(String.class);
+                       
+                       /* It is not recommendable to use the implementation class org.apache.cxf.jaxrs.impl.ResponseImpl in the code, 
+                       but had to force this in-order to prevent conflict with the ResponseImpl class of Jersey Client which 
+                       doesn't work as expected. Created Portal-253 for tracking */
+                       String incomingJson = ((ResponseImpl)response).readEntity(String.class);
                        return incomingJson;
                }
                
@@ -252,7 +261,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
         * (non-Javadoc)
         * 
         * @see
-        * org.openecomp.portalapp.portal.service.ApplicationsRestClientService#get(
+        * org.onap.portalapp.portal.service.ApplicationsRestClientService#get(
         * java.lang.Class, long, java.lang.String, boolean)
         */
        @Override
@@ -266,7 +275,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                if (response != null) {
                        verifyResponse(response);
-                       String str = response.readEntity(String.class);
+                       String str = ((ResponseImpl)response).readEntity(String.class);
                        EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET result =", str);
 
                        try {
@@ -332,7 +341,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                        // String contentType = response.getHeaderString("Content-Type");
                        if (clazz != null) {
-                               String str = response.readEntity(String.class);
+                               String str = ((ResponseImpl)response).readEntity(String.class);
                                EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str);
                                try {
                                        t = gson.fromJson(str, clazz);
@@ -354,13 +363,15 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                WebClient client = null;
                Response response = null;
                T t = null;
-
+               logger.debug(EELFLoggerDelegate.debugLogger, "Entering to createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
                client = createClientForApp(appId, restPath);
                EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST request =", payload);
-
+               logger.debug(EELFLoggerDelegate.debugLogger, "Finished createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
                try {
                        if (client != null) {
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Entering to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
                                response = client.post(payload);
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Finished to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
                        } else {
                                logger.error(EELFLoggerDelegate.errorLogger,
                                                "Unable to create the Webclient to make the '" + restPath + "' API call.");
@@ -377,7 +388,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                        // String contentType = response.getHeaderString("Content-Type");
                        if (clazz != null) {
-                               String str = response.readEntity(String.class);
+                               String str = ((ResponseImpl)response).readEntity(String.class);
                                EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str);
                                try {
                                        t = gson.fromJson(str, clazz);
@@ -396,12 +407,21 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                Response response = null;
                T t = null;
 
+               logger.debug(EELFLoggerDelegate.debugLogger, "Entering to createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
+
                client = createClientForApp(appId, restPath);
                EcompPortalUtils.logAndSerializeObject(logger, restPath, "PUT request =", payload);
+               
+               logger.debug(EELFLoggerDelegate.debugLogger, "Finished createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
 
                try {
                        if (client != null) {
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Entering to PUT for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
+
                                response = client.put(payload);
+                               
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Finished to PUT for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
+
                        } else {
                                logger.error(EELFLoggerDelegate.errorLogger,
                                                "Unable to create the Webclient to make the '" + restPath + "' API call.");
@@ -415,7 +435,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
 
                if (response != null) {
                        verifyResponse(response);
-                       String str = response.readEntity(String.class);
+                       String str = ((ResponseImpl)response).readEntity(String.class);
                        EcompPortalUtils.logAndSerializeObject(logger, restPath, "PUT result =", str);
                        try {
                                t = gson.fromJson(str, clazz);