Sonar fix: APPC-1717 77/95477/2
authorArundathi Patil <arundpil@in.ibm.com>
Wed, 11 Sep 2019 09:29:19 +0000 (14:59 +0530)
committerTakamune Cho <takamune.cho@att.com>
Tue, 17 Sep 2019 14:58:12 +0000 (14:58 +0000)
Fixed sonar issues across these files

Issue-ID: APPC-1717
Change-Id: I25fc139344e88d389e24b91a7d6796fea6f251c2
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/LookupServer.java

index 4715860..cfd816e 100644 (file)
@@ -8,6 +8,8 @@
  * ================================================================================
  * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
+ * Modification Copyright (C) 2019 IBM
+ * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -359,7 +361,7 @@ public class EvacuateServer extends ProviderServerOperation {
     }
 
     private void setTimeForMetricsLogger() {
-        String timestamp = LoggingUtils.generateTimestampStr(((Date) new Date()).toInstant());
+        String timestamp = LoggingUtils.generateTimestampStr((new Date()).toInstant());
         MDC.put(LoggingConstants.MDCKeys.BEGIN_TIMESTAMP, timestamp);
         MDC.put(LoggingConstants.MDCKeys.END_TIMESTAMP, timestamp);
         MDC.put(LoggingConstants.MDCKeys.ELAPSED_TIME, "0");
index 3fdb767..4ca0365 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
+ * Modification Copyright (C) 2019 IBM
+ * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -51,7 +53,7 @@ public class LookupServer extends ProviderServerOperation {
 
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(EvacuateServer.class);
     private static final Configuration configuration = ConfigurationFactory.getConfiguration();
-
+    private static final String serverFound = "serverFound";
 
     public Server lookupServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
         Server server = null;
@@ -76,14 +78,13 @@ public class LookupServer extends ProviderServerOperation {
             String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vmUrl);
             logger.error(msg);
             doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
-            ctx.setAttribute("serverFound", "failure");
+            ctx.setAttribute(serverFound, "failure");
         }
         return server;
     }
 
     private Server lookupServerNested(Map<String, String> params, Server server, RequestContext rqstCtx, SvcLogicContext ctx,
-            String appName, VMURL vm, String vmUrl)
-            throws APPCException {
+            String appName, VMURL vm, String vmUrl) {
 
         // use try with resource to ensure context is closed (returned to pool)
         try (Context context = resolveContext(rqstCtx, params, appName, vmUrl)) {
@@ -92,7 +93,7 @@ public class LookupServer extends ProviderServerOperation {
                 rqstCtx.reset();
                 server = lookupServer(rqstCtx, context, vm.getServerId());
                 logger.debug(Msg.SERVER_FOUND, vmUrl, context.getTenantName(), server.getStatus().toString());
-                ctx.setAttribute("serverFound", "success");
+                ctx.setAttribute(serverFound, "success");
                 String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "LookupServer", vmUrl);
                 ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
                 doSuccess(rqstCtx);
@@ -102,7 +103,7 @@ public class LookupServer extends ProviderServerOperation {
             String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vmUrl);
             logger.error(msg);
             doFailure(rqstCtx, HttpStatus.NOT_FOUND_404, msg);
-            ctx.setAttribute("serverFound", "failure");
+            ctx.setAttribute(serverFound, "failure");
         } catch (IOException e) {
             // exception closing context
             String msg = EELFResourceManager.format(Msg.CLOSE_CONTEXT_FAILED, e, vmUrl);