2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.sdnc.sli.provider;
24 import org.openecomp.sdnc.sli.SvcLogicContext;
25 import org.openecomp.sdnc.sli.SvcLogicException;
26 import org.openecomp.sdnc.sli.SvcLogicNode;
27 import org.openecomp.sdnc.sli.SvcLogicResource;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 public class ExistsNodeExecutor extends SvcLogicNodeExecutor {
33 private static final Logger LOG = LoggerFactory
34 .getLogger(ExistsNodeExecutor.class);
36 public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
37 SvcLogicContext ctx) throws SvcLogicException {
39 String plugin = SvcLogicExpressionResolver.evaluate(
40 node.getAttribute("plugin"), node, ctx);
41 String resourceType = SvcLogicExpressionResolver.evaluate(
42 node.getAttribute("resource"), node, ctx);
43 String key = SvcLogicExpressionResolver.evaluateAsKey(
44 node.getAttribute("key"), node, ctx);
45 String pfx = SvcLogicExpressionResolver.evaluate(
46 node.getAttribute("pfx"), node, ctx);
48 String outValue = "failure";
50 if (LOG.isDebugEnabled()) {
51 LOG.debug("exists node encountered - looking for resource class "
57 SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
59 if (resourcePlugin != null) {
63 switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) {
74 } catch (SvcLogicException e) {
75 LOG.error("Caught exception from resource plugin", e);
79 LOG.warn("Could not find SvcLogicResource object for plugin "
83 SvcLogicNode nextNode = node.getOutcomeValue(outValue);
84 if (nextNode != null) {
85 if (LOG.isDebugEnabled()) {
86 LOG.debug("about to execute " + outValue + " branch");
91 nextNode = node.getOutcomeValue("Other");
92 if (nextNode != null) {
93 if (LOG.isDebugEnabled()) {
94 LOG.debug("about to execute Other branch");
97 if (LOG.isDebugEnabled()) {
99 LOG.debug("no "+outValue+" or Other branch found");