aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/templates/archetype-cl-amsterdam/src
diff options
context:
space:
mode:
authorCharles Cole <cc847m@att.com>2017-10-16 12:05:08 -0500
committerCharles Cole <cc847m@att.com>2017-10-18 11:03:38 -0500
commit506267bf7e9d961f1a6b2a989ee8a23ca67b9d61 (patch)
tree7f9079c2a19bb5d01bf4f8a7ab84b7168d9a1cb9 /controlloop/templates/archetype-cl-amsterdam/src
parentb2d602aaedfcc9356e07dd94b6baec70c38815b8 (diff)
Add support for AAI Named Query error handling
Errors from AAI after a Named query now throw an AAIEXception. This is caught in the template to allow the resources to be removed from memory and a final failure to be thrown. Issue-ID: POLICY-314 Change-Id: I319d29ef537b2d01ca288622aac1d9dbbe05f5eb Signed-off-by: Charles Cole <cc847m@att.com>
Diffstat (limited to 'controlloop/templates/archetype-cl-amsterdam/src')
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl22
1 files changed, 19 insertions, 3 deletions
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 3d6d89c69..705bbcd25 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -32,6 +32,7 @@ import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NEW_EVENT_STATUS;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
+import org.onap.policy.aai.util.AAIException;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.CommonHeader;
@@ -507,6 +508,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
$operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
$lock : TargetLock (requestID == $event.requestID)
+ $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -514,9 +516,23 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$params.getClosedLoopControlName(), drools.getRule().getName(),
$event, $manager, $operation, $lock);
- Object request = $operation.startOperation($event);
-
- if (request != null) {
+ Object request = null;
+ boolean caughtException = false;
+ try {
+ request = $operation.startOperation($event);
+ }
+ catch (AAIException e) {
+ //We got an exception, retract everything for this current operation
+ $operation.setOperationHasException(e.getMessage());
+ retract($opTimer);
+ retract($operation);
+ caughtException = true;
+ }
+ //Having the modify statement in the catch clause doesn't work for whatever reason
+ if (caughtException) {
+ modify($manager) {finishOperation($operation)};
+ }
+ else if (request != null) {
logger.debug("{}: {}: starting operation ..",
$params.getClosedLoopControlName(), drools.getRule().getName());
//