2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.dg.common.impl;
25 import org.openecomp.appc.exceptions.APPCException;
26 import org.openecomp.appc.i18n.Msg;
27 import com.att.eelf.i18n.EELFResourceManager;
28 import org.openecomp.sdnc.sli.SvcLogicContext;
32 import org.openecomp.appc.dg.common.DgResolverPlugin;
34 public class DgResolverPluginImpl implements DgResolverPlugin {
37 public void resolveDg(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
39 String DGName, DGVersion, DGModule = null;
40 String prefix = params.containsKey("prefix") ? params.get("prefix") + "." : "";
41 AbstractResolver resolver = ResolverFactory.createResolver(params.get("DGResolutionType"));
42 FlowKey flowKey = null;
45 if(params.get("DGResolutionType").equalsIgnoreCase("VNFC")) {
46 flowKey = resolver.resolve(params.get(Constants.IN_PARAM_ACTION), params.get(Constants.IN_PARAM_VNF_TYPE), params.get(Constants.IN_PARAM_VNFC_TYPE), params.get(Constants.IN_PARAM_API_VERSION));
47 }else if(params.get("DGResolutionType").equalsIgnoreCase("VNF")){
48 flowKey = resolver.resolve(params.get(Constants.IN_PARAM_ACTION), params.get(Constants.IN_PARAM_VNF_TYPE), params.get("vnfVersion"), params.get(Constants.IN_PARAM_API_VERSION));
50 if (flowKey != null) {
51 DGName = flowKey.name();
52 ctx.setAttribute(prefix + Constants.OUT_PARAM_DG_NAME, DGName);
53 DGVersion = flowKey.version();
54 ctx.setAttribute(prefix + Constants.OUT_PARAM_DG_VERSION, DGVersion);
55 DGModule = flowKey.module();
56 ctx.setAttribute(prefix + Constants.OUT_PARAM_DG_MODULE, DGModule);
58 throw new RuntimeException(params.get("DGResolutionType")+ " DG not found for vnf type :" + params.get(Constants.IN_PARAM_VNF_TYPE)
59 + " vnfc type : " + params.get(Constants.IN_PARAM_VNFC_TYPE)
60 + " action : " + params.get(Constants.IN_PARAM_ACTION)
61 + " api version : " + params.get(Constants.IN_PARAM_API_VERSION));
63 } catch (Exception e) {
64 String msg = EELFResourceManager.format(Msg.FAILURE_RETRIEVE_VNFC_DG,params.get(Constants.IN_PARAM_VNFC_TYPE), e.getMessage());
65 ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
66 throw new RuntimeException(e);