- public Loop unDeployLoop(String loopName) throws OperationException {
- util.entering(request, "LoopOperation: Undeploy the closed loop");
- Date startTime = new Date();
- Loop loop = loopService.getLoop(loopName);
-
- if (loop == null) {
- String msg = "Undeploy loop exception: Not able to find closed loop:" + loopName;
- util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO,
- ONAPLogConstants.ResponseStatus.ERROR);
- throw new OperationException(msg);
- }
-
- // verify the current closed loop state
- if (loop.getLastComputedState() != LoopState.DEPLOYED) {
- String msg = "Unploy loop exception: This closed loop is in state:" + loop.getLastComputedState()
- + ". It could be undeployed only when it is in DEPLOYED state.";
- util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO,
- ONAPLogConstants.ResponseStatus.ERROR);
- throw new OperationException(msg);
- }
-
- loop.setDcaeDeploymentStatusUrl(
- dcaeDispatcherServices.deleteExistingDeployment(loop.getDcaeDeploymentId(), loop.getDcaeBlueprintId()));
-
- // clean the deployment ID
- loop.setDcaeDeploymentId(null);
- loop.setLastComputedState(LoopState.SUBMITTED);
-
- // save the updated loop
- loopService.saveOrUpdateLoop (loop);
-
- // audit log
- LoggingUtils.setTimeContext(startTime, new Date());
- auditLogger.info("Undeploy model completed");
- util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
- return loop;
- }
-
- private JsonElement wrapSnakeObject(Object o) {
- //NULL => JsonNull
- if (o == null)
- return JsonNull.INSTANCE;
-
- // Collection => JsonArray
- if (o instanceof Collection) {
- JsonArray array = new JsonArray();
- for (Object childObj : (Collection<?>)o)
- array.add(wrapSnakeObject(childObj));
- return array;
- }
-
- // Array => JsonArray
- if (o.getClass().isArray()) {
- JsonArray array = new JsonArray();