Log exception 09/94909/3
authorParshad Patel <pars.patel@samsung.com>
Wed, 4 Sep 2019 10:03:56 +0000 (19:03 +0900)
committerParshad Patel <pars.patel@samsung.com>
Thu, 5 Sep 2019 05:22:56 +0000 (14:22 +0900)
Either log or rethrow this exception
Use isEmpty() to check whether the collection is empty or not

Issue-ID: SO-1841
Change-Id: Ia964a871497df8a7211260ad1ad8f1efa8ae4d42
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java

index d401522..ce53044 100644 (file)
@@ -7,9 +7,9 @@
  * 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
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,13 +25,15 @@ import java.util.Map;
 import java.util.Optional;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
 import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
 import org.onap.so.client.aai.entities.AAIResultWrapper;
 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AAICreateResources extends AAIResource {
 
+    private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class);
 
     public void createAAIProject(String projectName, String serviceInstance) {
         AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName);
@@ -89,6 +91,7 @@ public class AAICreateResources extends AAIResource {
             Optional<GenericVnf> vnf = aaiResponse.asBean(GenericVnf.class);
             return vnf;
         } catch (Exception ex) {
+            logger.error("Exception in getVnfInstance", ex);
             return Optional.empty();
         }
     }
index 2526ca5..c489ef2 100644 (file)
@@ -7,9 +7,9 @@
  * 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
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,13 +24,19 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
 import org.onap.so.bpmn.common.scripts.ExceptionUtil;
 import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.springframework.stereotype.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 public class AAIDeleteServiceInstance extends AAIResource implements JavaDelegate {
 
+    private static final Logger logger = LoggerFactory.getLogger(AAIDeleteServiceInstance.class);
+
+    private static final String ERROR_MESSAGE =
+            "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI.";
+
     ExceptionUtil exceptionUtil = new ExceptionUtil();
 
     public void execute(DelegateExecution execution) throws Exception {
@@ -41,9 +47,8 @@ public class AAIDeleteServiceInstance extends AAIResource implements JavaDelegat
             getAaiClient().delete(serviceInstanceURI);
             execution.setVariable("GENDS_SuccessIndicator", true);
         } catch (Exception ex) {
-            String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI."
-                    + ex.getMessage();
-            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+            logger.error(ERROR_MESSAGE, ex);
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ERROR_MESSAGE + ex.getMessage());
         }
 
     }
index 493340c..216f426 100644 (file)
@@ -62,6 +62,7 @@ public class CheckAaiForPnfCorrelationIdDelegate implements JavaDelegate {
             logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry);
             execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry);
         } catch (IOException e) {
+            logger.error("Exception in check AAI for pnf_correlation_id execution", e);
             new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage());
         }
     }
index a011346..ee86ca4 100644 (file)
@@ -65,7 +65,7 @@ public class ConfigCheckerDelegate implements JavaDelegate {
             delegateExecution.setVariable(MODEL_UUID, serviceModelUuid);
             List<PnfResourceCustomization> pnfCustomizations =
                     catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid);
-            if (pnfCustomizations != null && pnfCustomizations.size() >= 1) {
+            if (pnfCustomizations != null && !pnfCustomizations.isEmpty()) {
                 PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0);
                 boolean skipPostInstantiationConfiguration = pnfResourceCustomization.isSkipPostInstConf();
                 delegateExecution.setVariable(SKIP_POST_INSTANTIATION_CONFIGURATION,
index 6d73b61..781ee5c 100644 (file)
@@ -48,6 +48,7 @@ public class CreateRelation implements JavaDelegate {
         try {
             pnfManagementImpl.createRelation(serviceInstanceId, pnfName);
         } catch (Exception e) {
+            logger.error("An exception occurred when making service and pnf relation. Exception:", e);
             new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999,
                     "An exception occurred when making service and pnf relation. Exception: " + e.getMessage());
         }