Fix minor issues 11/101211/1
authorParshad Patel <pars.patel@samsung.com>
Thu, 6 Feb 2020 03:03:41 +0000 (12:03 +0900)
committerParshad Patel <pars.patel@samsung.com>
Thu, 6 Feb 2020 03:03:48 +0000 (12:03 +0900)
Either log or rethrow this exception
This block of commented-out lines of code should be removed
Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'

Issue-ID: PORTAL-562
Change-Id: I72a7651070462de9bd1e0abb1e83c175d03aa1f3
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java

index d618a6e..c79d6c0 100644 (file)
@@ -77,8 +77,7 @@ public class HttpsBasicClient{
        public static Client getClient() throws Exception {
                String methodName = "getClient";
                ClientConfig config = new ClientConfig();
-               //config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-               //config.getClasses().add(org.onap.aai.util.CustomJacksonJaxBJsonProvider.class);
+
        
                SSLContext ctx = null;
                
@@ -87,17 +86,17 @@ public class HttpsBasicClient{
                        SimpleDateFormat dateFormat = DateUtil.getDateFormat();
                        config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
                        
-                       String truststore_path = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_FILENAME);
+                       String truststorePath = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_FILENAME);
                        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " "
                                + "truststore_path=" +
-                               truststore_path);
-                       String truststore_password = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_PASSWD_X);
+                               truststorePath);
+                       String truststorePassword = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_PASSWD_X);
                        
                        
-                       String decrypted_truststore_password = Password.deobfuscate(truststore_password);
+                       String decryptedTruststorePassword = Password.deobfuscate(truststorePassword);
                        //logger.debug(dateFormat.format(new Date()) + " " + methodName + " decrypted_truststore_password=" + decrypted_truststore_password);
                        
-                       File tr = new File (truststore_path);
+                       File tr = new File (truststorePath);
                        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " absolute "
                                + "truststore path=" + tr.getAbsolutePath());
                        
@@ -105,8 +104,8 @@ public class HttpsBasicClient{
                        //String keystore_password = SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_PASSWD_X);
                        //String decrypted_keystore_password = EncryptedPropValue.decryptTriple(keystore_password);
                        
-                   System.setProperty("javax.net.ssl.trustStore", truststore_path);
-                   System.setProperty("javax.net.ssl.trustStorePassword", decrypted_truststore_password);
+                   System.setProperty("javax.net.ssl.trustStore", truststorePath);
+                   System.setProperty("javax.net.ssl.trustStorePassword", decryptedTruststorePassword);
                        HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
                            public boolean verify(String string,SSLSession ssls) {
                                return true;
@@ -134,9 +133,7 @@ public class HttpsBasicClient{
                        ctx.init(kmf.getKeyManagers(), null, null);
                        */
                        ctx.init(null, null, null);
-                       //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, 
-                       //                                                      new HTTPSProperties( , ctx));
-                       
+
                        return ClientBuilder.newBuilder()
                                .sslContext(ctx)
                                .hostnameVerifier(new HostnameVerifier() {
@@ -148,17 +145,9 @@ public class HttpsBasicClient{
                                .build()
                                .register(CustomJacksonJaxBJsonProvider.class);
                        
-               } catch (Exception e) {
-                       logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting");
-                       //System.out.println("Error setting up config: exiting");
-                       e.printStackTrace();
-                       return null;
-               }
-                       
-               //Client client = ClientBuilder.newClient(config);
-               // uncomment this line to get more logging for the request/response
-               // client.addFilter(new LoggingFilter(System.out));
-               
-               //return client;
-       }
-}  
+        } catch (Exception e) {
+            logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting", e);
+            return null;
+        }
+    }
+}
index 18dabfb..09d7804 100644 (file)
@@ -133,7 +133,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                logger.debug(EELFLoggerDelegate.debugLogger, "http response status=" + status);
                MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(status));
                if (!isHttpSuccess(status)) {
-                       String errMsg = "Failed. Status=" + status + restPath +"; [" + ((ResponseImpl)response).getStatusInfo().getReasonPhrase().toString()
+                       String errMsg = "Failed. Status=" + status + restPath +"; [" + ((ResponseImpl)response).getStatusInfo().getReasonPhrase()
                                        + "]";
                        URL url = null;
                        try {
@@ -255,7 +255,6 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                Response response = getResponse(appId, restPath);
 
                if (response != null) {
-                       //verifyResponse(response);
                        verifyResponse(response,restPath);
                        /* 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 
@@ -278,13 +277,11 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                Response response = getResponse(appId, restPath);
 
                if (response != null) {
-                       //verifyResponse(response);
                        verifyResponse(response,restPath);
                        /* 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;
+                       return ((ResponseImpl)response).readEntity(String.class);
                }
                
                return "";
@@ -308,7 +305,6 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                Response response = getResponse(appId, restPath);
 
                if (response != null) {
-                       //verifyResponse(response);
                        verifyResponse(response,restPath);
                        String str = ((ResponseImpl)response).readEntity(String.class);
                        EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET result =", str);
@@ -316,7 +312,6 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                        try {
                                t = mapper.readValue(str, clazz);
                        } catch (Exception e) {
-                               e.printStackTrace();
                                EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
                        }
                }
@@ -373,16 +368,12 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                }
 
                if (response != null) {
-                       //verifyResponse(response);
                        verifyResponse(response,restPath);
-                       // String contentType = response.getHeaderString("Content-Type");
                        if (clazz != null) {
                                String str = ((ResponseImpl)response).readEntity(String.class);
                                EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str);
                                try {
                                        t = (T) gson.fromJson(str, clazz);
-
-                                       //t = gson.fromJson(str, clazz);
                                } catch (Exception e) {
                                        EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
                                }
@@ -430,7 +421,6 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                }
 
                if (response != null) {
-                       //verifyResponse(response);
                        verifyResponse(response,restPath);
                        String str = ((ResponseImpl)response).readEntity(String.class);
                        EcompPortalUtils.logAndSerializeObject(logger, restPath, "PUT result =", str);
index b41d898..451500d 100644 (file)
@@ -136,7 +136,6 @@ public class MicroserviceServiceImpl implements MicroserviceService {
                        dataAccessService.executeNamedQuery("deleteMicroservice", params, null);
 
                } catch (Exception e) {
-                       e.printStackTrace();
                        logger.error(EELFLoggerDelegate.errorLogger, "deleteMicroservice failed", e);
                        throw e;
                }