2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 ONAP
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.sli.core.sli.provider;
23 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
25 import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class BlockNodeExecutor extends SvcLogicNodeExecutor {
32 private static final Logger LOG = LoggerFactory
33 .getLogger(BlockNodeExecutor.class);
36 public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
37 throws SvcLogicException {
39 SvcLogicExpression atomicExpr = node.getAttribute("atomic");
40 String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx);
41 boolean isAtomic = "true".equalsIgnoreCase(atomicStr);
43 // Initialize status to success so that at least one outcome will execute
44 ctx.setStatus("success");
46 int numOutcomes = node.getNumOutcomes();
48 for (int i = 0; i < numOutcomes; i++) {
49 if ("failure".equals(ctx.getStatus()) && isAtomic) {
50 LOG.info("Block - stopped executing nodes due to failure status");
54 SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1));
55 if (nextNode != null) {
56 if (LOG.isDebugEnabled()) {
57 LOG.debug("Block - executing outcome " + (i + 1));
59 while (nextNode != null)
61 nextNode = svc.executeNode(nextNode, ctx);
64 if (LOG.isDebugEnabled()) {
65 LOG.debug("Block - done: no outcome " + (i + 1));