Sonar fix: APPC-1717
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / main / java / org / onap / appc / adapter / iaas / provider / operation / impl / LookupServer.java
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);