Merge "add junit coverage for SvnfmService"
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / bpmn / servicedecomposition / tasks / ExecuteBuildingBlockRainyDay.java
index fd2054c..be53e50 100644 (file)
@@ -104,6 +104,7 @@ public class ExecuteBuildingBlockRainyDay {
                     }
                 } catch (Exception ex) {
                     // keep default serviceType value
+                    logger.error("Exception in serviceType retrivel", ex);
                 }
                 String vnfType = ASTERISK;
                 try {
@@ -115,6 +116,7 @@ public class ExecuteBuildingBlockRainyDay {
                     }
                 } catch (Exception ex) {
                     // keep default vnfType value
+                    logger.error("Exception in vnfType retrivel", ex);
                 }
 
                 String errorCode = ASTERISK;
@@ -122,12 +124,14 @@ public class ExecuteBuildingBlockRainyDay {
                     errorCode = "" + workflowException.getErrorCode();
                 } catch (Exception ex) {
                     // keep default errorCode value
+                    logger.error("Exception in errorCode retrivel", ex);
                 }
 
                 try {
                     errorCode = "" + (String) execution.getVariable("WorkflowExceptionCode");
                 } catch (Exception ex) {
                     // keep default errorCode value
+                    logger.error("Exception in errorCode retrivel", ex);
                 }
 
                 String workStep = ASTERISK;
@@ -135,6 +139,7 @@ public class ExecuteBuildingBlockRainyDay {
                     workStep = workflowException.getWorkStep();
                 } catch (Exception ex) {
                     // keep default workStep value
+                    logger.error("Exception in workStep retrivel", ex);
                 }
 
                 String errorMessage = ASTERISK;
@@ -142,11 +147,23 @@ public class ExecuteBuildingBlockRainyDay {
                     errorMessage = workflowException.getErrorMessage();
                 } catch (Exception ex) {
                     // keep default workStep value
+                    logger.error("Exception in errorMessage retrivel", ex);
+                }
+
+                String serviceRole = ASTERISK;
+                try {
+                    serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0)
+                            .getModelInfoServiceInstance().getServiceRole();
+                    if (serviceRole == null || serviceRole.isEmpty()) {
+                        serviceRole = ASTERISK;
+                    }
+                } catch (Exception ex) {
+                    // keep default serviceRole value
                 }
 
                 RainyDayHandlerStatus rainyDayHandlerStatus;
                 rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatus(bbName, serviceType, vnfType,
-                        errorCode, workStep, errorMessage);
+                        errorCode, workStep, errorMessage, serviceRole);
 
                 if (rainyDayHandlerStatus == null) {
                     handlingCode = "Abort";
@@ -166,14 +183,14 @@ public class ExecuteBuildingBlockRainyDay {
                         logger.error("Failed to update Request Db Infra Active Requests with Retry Status", ex);
                     }
                 }
-                if (handlingCode.equals("RollbackToAssigned") && !aLaCarte) {
+                if ("RollbackToAssigned".equals(handlingCode) && !aLaCarte) {
                     handlingCode = "Rollback";
                 }
                 if (handlingCode.startsWith("Rollback")) {
                     String targetState = "";
-                    if (handlingCode.equalsIgnoreCase("RollbackToAssigned")) {
+                    if ("RollbackToAssigned".equalsIgnoreCase(handlingCode)) {
                         targetState = Status.ROLLED_BACK_TO_ASSIGNED.toString();
-                    } else if (handlingCode.equalsIgnoreCase("RollbackToCreated")) {
+                    } else if ("RollbackToCreated".equalsIgnoreCase(handlingCode)) {
                         targetState = Status.ROLLED_BACK_TO_CREATED.toString();
                     } else {
                         targetState = Status.ROLLED_BACK.toString();
@@ -193,7 +210,7 @@ public class ExecuteBuildingBlockRainyDay {
             int envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
             execution.setVariable("maxRetries", envMaxRetries);
         } catch (Exception ex) {
-            logger.error("Could not read maxRetries from config file. Setting max to 5 retries");
+            logger.error("Could not read maxRetries from config file. Setting max to 5 retries", ex);
             execution.setVariable("maxRetries", 5);
         }
     }
@@ -236,8 +253,7 @@ public class ExecuteBuildingBlockRainyDay {
             request.setLastModifiedBy("CamundaBPMN");
             requestDbclient.updateInfraActiveRequests(request);
         } catch (Exception e) {
-            logger.error("Failed to update Request db with extSystemErrorSource or rollbackExtSystemErrorSource: "
-                    + e.getMessage());
+            logger.error("Failed to update Request db with extSystemErrorSource or rollbackExtSystemErrorSource: ", e);
         }
     }