2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Modifications Copyright (C) 2018 IBM.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.ccsdk.sli.core.sli.provider.base;
26 import java.util.HashMap;
27 import java.util.Iterator;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor {
40 private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class);
41 private static final String FAILURE= "failure";
44 public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
45 throws SvcLogicException {
47 String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
48 String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
49 String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
50 String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx);
51 String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx);
52 String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
54 boolean force = "true".equalsIgnoreCase(forceStr);
55 boolean localOnly = "true".equalsIgnoreCase(localOnlyStr);
57 Map<String, String> parmMap = getResolvedParameters(node,ctx);
59 String outValue = FAILURE;
61 if (LOG.isDebugEnabled()) {
62 LOG.debug("save node encountered - looking for resource class " + plugin);
67 SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
69 if (resourcePlugin != null) {
72 switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) {
77 outValue = "not-found";
83 } catch (SvcLogicException e) {
84 LOG.error("Caught exception from resource plugin", e);
88 LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
90 return (getNextNode(node, outValue));