summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsebdet <sd378r@intl.att.com>2018-09-21 17:46:12 +0200
committersebdet <sd378r@intl.att.com>2018-09-21 17:46:12 +0200
commitac3eeb30f40a225372c67cb33fe3396cf44770e4 (patch)
tree56ada2506f9e38776e476b9aab923d30b1e8c151 /src/main/java
parent4aea6da2620cf887fac4cd1158374174f6fc9152 (diff)
Add delete test
Add a test and fix the delete model code that was not working Issue-ID: CLAMP-217 Change-Id: I235200ee0e7dc25ed759b88568333882bfb90c50 Signed-off-by: sebdet <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/camel/CamelProxy.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java28
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java88
3 files changed, 51 insertions, 67 deletions
diff --git a/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java b/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java
index 7abb69286..a74f4c702 100644
--- a/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java
+++ b/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java
@@ -59,7 +59,7 @@ public interface CamelProxy {
* The latest event action in database (like CREATE, SUBMIT, ...)
* @return A string containing the result of the Camel flow execution
*/
- String submit(@ExchangeProperty("actionCd") String actionCommand,
+ String executeAction(@ExchangeProperty("actionCd") String actionCommand,
@ExchangeProperty("modelProp") String modelProperties,
@ExchangeProperty("modelBpmnProp") String modelBpmnProperties,
@ExchangeProperty("modelName") String modelName, @ExchangeProperty("controlName") String controlName,
diff --git a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
index b1243dc22..8dfa190ed 100644
--- a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
@@ -48,22 +48,24 @@ public class CldsEventDelegate {
* Insert event using process variables.
*
* @param camelExchange
- * The Camel Exchange object containing the properties
+ * The Camel Exchange object containing the properties
*/
@Handler
public void execute(Exchange camelExchange) {
String controlName = (String) camelExchange.getProperty("controlName");
String actionCd = (String) camelExchange.getProperty("actionCd");
- String actionStateCd = (String) camelExchange.getProperty("actionStateCd");
- // Flag indicate whether it is triggered by Validation Test button from
- // UI
- boolean isTest = (boolean) camelExchange.getProperty("isTest");
- boolean isInsertTestEvent = (boolean) camelExchange.getProperty("isInsertTestEvent");
- String userid = (String) camelExchange.getProperty("userid");
- // do not insert events for test actions unless flag set to insert them
- if (!isTest || isInsertTestEvent) {
- // won't really have userid here...
- CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, camelExchange.getExchangeId());
- }
+ String actionStateCd = ((String) camelExchange.getProperty("actionStateCd")) != null
+ ? ((String) camelExchange.getProperty("actionStateCd"))
+ : CldsEvent.ACTION_STATE_COMPLETED;
+ // Flag indicate whether it is triggered by Validation Test button from
+ // UI
+ boolean isTest = (boolean) camelExchange.getProperty("isTest");
+ boolean isInsertTestEvent = (boolean) camelExchange.getProperty("isInsertTestEvent");
+ String userid = (String) camelExchange.getProperty("userid");
+ // do not insert events for test actions unless flag set to insert them
+ if (!isTest || isInsertTestEvent) {
+ // won't really have userid here...
+ CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, camelExchange.getExchangeId());
+ }
}
}
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 5e35b8954..8d497cbcc 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -363,8 +363,7 @@ public class CldsService extends SecureServiceBase {
logger.info("PUT deploymentId={}", model.getDeploymentId());
this.fillInCldsModel(model);
// save model to db
- model.setName(modelName);
- updateAndInsertNewEvent(modelName, model.getControlNamePrefix(), model.getEvent(), CldsEvent.ACTION_SUBMIT);
+ updateAndInsertNewEvent(modelName, model.getControlNamePrefix(), model.getEvent(), CldsEvent.ACTION_MODIFY);
model.save(cldsDao, getUserId());
// get vars and format if necessary
String prop = model.getPropText();
@@ -373,73 +372,56 @@ public class CldsService extends SecureServiceBase {
String controlName = model.getControlName();
String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmn);
logger.info("PUT bpmnJson={}", bpmnJson);
- // Flag indicates whether it is triggered by Validation Test button
- // from
- // UI
- boolean isTest = Boolean.parseBoolean(test);
- if (!isTest) {
- String actionTestOverride = refProp.getStringValue("action.test.override");
- if (Boolean.parseBoolean(actionTestOverride)) {
- logger.info("PUT actionTestOverride={}", actionTestOverride);
- logger.info("PUT override test indicator and setting it to true");
- isTest = true;
- }
- }
+ // Test flag coming from UI or from Clamp config
+ boolean isTest = Boolean.parseBoolean(test)
+ || Boolean.parseBoolean(refProp.getStringValue("action.test.override"));
logger.info("PUT isTest={}", isTest);
- String insertTestEvent = refProp.getStringValue("action.insert.test.event");
- boolean isInsertTestEvent = Boolean.parseBoolean(insertTestEvent);
-
+ boolean isInsertTestEvent = Boolean.parseBoolean(refProp.getStringValue("action.insert.test.event"));
logger.info("PUT isInsertTestEvent={}", isInsertTestEvent);
// determine if requested action is permitted
model.validateAction(actionCd);
logger.info("modelProp - " + prop);
logger.info("docText - " + docText);
try {
- String result = camelProxy.submit(actionCd, prop, bpmnJson, modelName, controlName, docText, isTest,
- userId, isInsertTestEvent, model.getEvent().getActionCd());
+ String result = camelProxy.executeAction(actionCd, prop, bpmnJson, modelName, controlName, docText,
+ isTest, userId, isInsertTestEvent, model.getEvent().getActionCd());
logger.info("Starting Camel flow on request, result is: ", result);
} catch (SdcCommunicationException | PolicyClientException | BadRequestException e) {
errorCase = true;
logger.error("Exception occured during invoking Camel process", e);
}
- if (!actionCd.equalsIgnoreCase(CldsEvent.ACTION_DELETE)) {
- // refresh model info from db (get fresh event info)
+ if (actionCd.equalsIgnoreCase(CldsEvent.ACTION_DELETE)) {
+ util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO,
+ ONAPLogConstants.ResponseStatus.COMPLETED);
+ return new ResponseEntity<>("", HttpStatus.OK);
+ } else {
retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
}
- if (retrievedModel != null) {
- if (!isTest && !errorCase
- && (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());
+ if (!isTest && !errorCase
+ && (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());
}
- // audit log
- LoggingUtils.setTimeContext(startTime, new Date());
- auditLogger.info("Process model action completed");
- } else {
- logger.error("CldsModel not found in database with modelName: " + modelName);
- util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(),
- "CldsModel not found in database with modelName " + "modelName", Level.INFO,
- ONAPLogConstants.ResponseStatus.ERROR);
- return new ResponseEntity<String>("CldsModel not found in database with modelName: \" + modelName",
- HttpStatus.INTERNAL_SERVER_ERROR);
+ retrievedModel.save(cldsDao, getUserId());
}
+ // audit log
+ LoggingUtils.setTimeContext(startTime, new Date());
+ auditLogger.info("Process model action completed");
+
} catch (Exception e) {
errorCase = true;
logger.error("Exception occured during putModelAndProcessAction", e);