First part of onap rename
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / main / java / org / openecomp / appc / adapter / iaas / provider / operation / impl / base / ProviderStackOperation.java
index 46c98d9..cbf6202 100644 (file)
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.appc.adapter.iaas.provider.operation.impl.base;
+package org.onap.appc.adapter.iaas.provider.operation.impl.base;
 
-import org.openecomp.appc.Constants;
-import org.openecomp.appc.adapter.iaas.impl.RequestContext;
-import org.openecomp.appc.adapter.iaas.impl.RequestFailedException;
-import org.openecomp.appc.adapter.openstack.heat.StackResource;
-import org.openecomp.appc.i18n.Msg;
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.iaas.impl.RequestContext;
+import org.onap.appc.adapter.iaas.impl.RequestFailedException;
+import org.onap.appc.adapter.openstack.heat.StackResource;
+import org.onap.appc.i18n.Msg;
 import com.att.cdp.exceptions.ContextConnectionException;
 import com.att.cdp.exceptions.ResourceNotFoundException;
 import com.att.cdp.exceptions.TimeoutException;
@@ -42,16 +42,12 @@ import com.att.cdp.zones.spi.RequestState;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import com.att.eelf.i18n.EELFResourceManager;
-import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import com.woorea.openstack.base.client.OpenStackBaseException;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.util.List;
 
-/**
- * @since September 29, 2016
- */
-public abstract class ProviderStackOperation extends ProviderOperation{
+public abstract class ProviderStackOperation extends ProviderOperation {
 
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderStackOperation.class);
 
@@ -59,7 +55,8 @@ public abstract class ProviderStackOperation extends ProviderOperation{
     protected void trackRequest(Context context, AbstractService.State... states) {
         RequestState.clear();
 
-        if (null == states) return;
+        if (null == states)
+            return;
         for (AbstractService.State state : states) {
             RequestState.put(state.getName(), state.getValue());
         }
@@ -71,7 +68,7 @@ public abstract class ProviderStackOperation extends ProviderOperation{
             StackTraceElement element;
             for (; index < stack.length; index++) {
                 element = stack[index];
-                if ("trackRequest".equals(element.getMethodName())) {  //$NON-NLS-1$
+                if ("trackRequest".equals(element.getMethodName())) { //$NON-NLS-1$
                     break;
                 }
             }
@@ -90,7 +87,10 @@ public abstract class ProviderStackOperation extends ProviderOperation{
         }
     }
 
-    private boolean checkStatus(String expectedStatus, int pollInterval, String actualStatus) {
+    /*
+     * Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument
+     */
+    private boolean checkStatus(String expectedStatus, long pollInterval, String actualStatus) {
         if (actualStatus.toUpperCase().equals(expectedStatus)) {
             return true;
         } else {
@@ -111,8 +111,10 @@ public abstract class ProviderStackOperation extends ProviderOperation{
         while (System.currentTimeMillis() < maxTimeToWait) {
             String stackStatus = stackResource.show(stack.getName(), stack.getId()).execute().getStackStatus();
             logger.debug("Stack status : " + stackStatus);
-            if (stackStatus.toUpperCase().contains("FAILED")) return false;
-            if(checkStatus(expectedStatus, pollInterval, stackStatus)) return true;
+            if (stackStatus.toUpperCase().contains("FAILED"))
+                return false;
+            if (checkStatus(expectedStatus, pollInterval, stackStatus))
+                return true;
         }
         throw new TimeoutException("Timeout waiting for stack status change");
     }
@@ -157,12 +159,15 @@ public abstract class ProviderStackOperation extends ProviderOperation{
     }
 
 
-    protected boolean waitForStackStatus(RequestContext rc, Stack stack, Stack.Status expectedStatus) throws ZoneException, RequestFailedException {
+    protected boolean waitForStackStatus(RequestContext rc, Stack stack, Stack.Status expectedStatus)
+            throws ZoneException, RequestFailedException {
         SvcLogicContext ctx = rc.getSvcLogicContext();
         Context context = stack.getContext();
         StackService stackService = context.getStackService();
-
-        int pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
+        /*
+         * Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument
+         */
+        long pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
         int timeout = configuration.getIntegerProperty(Constants.PROPERTY_STACK_STATE_CHANGE_TIMEOUT);
         long maxTimeToWait = System.currentTimeMillis() + (long) timeout * 1000;
         Stack.Status stackStatus;