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.onap.ccsdk.sli.core.sli.provider.base;
24 import java.util.HashMap;
25 import java.util.Iterator;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor {
38 private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class);
41 public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
42 throws SvcLogicException {
44 String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
45 String outValue = "failure";
47 if (LOG.isTraceEnabled()) {
48 LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin);
51 Map<String, String> parmMap = new HashMap<String, String>();
53 Set<Map.Entry<String, SvcLogicExpression>> parmSet = node.getParameterSet();
54 boolean hasParms = false;
56 for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet.iterator(); iter.hasNext();) {
58 Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
59 String curName = curEnt.getKey();
60 SvcLogicExpression curExpr = curEnt.getValue();
61 String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
63 if (LOG.isTraceEnabled()) {
64 LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue);
66 parmMap.put(curName, curExprValue);
69 SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
70 if (recorder != null) {
72 recorder.record(parmMap);
73 } catch (SvcLogicException e) {
74 LOG.error("Caught exception from recorder plugin", e);
78 LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin);
80 return (getNextNode(node, outValue));