summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristophe Closset <cc697w@intl.att.com>2018-07-06 12:03:20 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-06 12:03:20 +0000
commit92f3a667717a816cefbc0c6392b48a0f8a781e88 (patch)
tree33b8912289004d4af6de167cef9f7d90aebca197 /src/main/java
parent48cd2b60a3fc36ecb396e85537d4af4b9555ad63 (diff)
parent0e8cc67db4f27dceb73e2f4b652c2b37ce8bd725 (diff)
Merge "Fix sonar issue"
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index c0ff83cbb..a63d02185 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -468,30 +468,35 @@ public class CldsService extends SecureServiceBase {
// refresh model info from db (get fresh event info)
retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
}
- if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
- || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
- || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
- if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
- // SDC artifact case
- logger.info("Skipping DCAE inventory call as closed loop has been created from SDC notification");
- DcaeEvent dcaeEvent = new DcaeEvent();
- dcaeEvent.setArtifactName(retrievedModel.getControlName() + ".yml");
- dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
- CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
- CldsEvent.ACTION_STATE_RECEIVED, null);
- } else {
- // This should be done only when the call to DCAE
- // has not yet been done. When CL comes from SDC
- // this is not required as the DCAE inventory call is done
- // during the CL deployment.
- dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
+ if (retrievedModel != null) {
+ if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
+ || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
+ || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
+ if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
+ // SDC artifact case
+ logger.info("Skipping DCAE inventory call as closed loop has been created from SDC notification");
+ DcaeEvent dcaeEvent = new DcaeEvent();
+ dcaeEvent.setArtifactName(retrievedModel.getControlName() + ".yml");
+ dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
+ CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
+ CldsEvent.ACTION_STATE_RECEIVED, null);
+ } else {
+ // This should be done only when the call to DCAE
+ // has not yet been done. When CL comes from SDC
+ // this is not required as the DCAE inventory call is done
+ // during the CL deployment.
+ dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
+ }
+ retrievedModel.save(cldsDao, getUserId());
}
- retrievedModel.save(cldsDao, getUserId());
+ // audit log
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "Process model action success", this.getClass().getName());
+ auditLogger.info("Process model action completed");
+ } else {
+ logger.error("CldsModel not found in database with modelName: " + modelName);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("CldsModel not found in database with modelName: \" + modelName").build();
}
- // audit log
- LoggingUtils.setTimeContext(startTime, new Date());
- LoggingUtils.setResponseContext("0", "Process model action success", this.getClass().getName());
- auditLogger.info("Process model action completed");
} catch (Exception e) {
errorCase = true;
logger.error("Exception occured during putModelAndProcessAction", e);