package org.onap.appc.dg.common;
import java.util.Map;
-
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
public interface DCAEReporterPlugin extends SvcLogicJavaPlugin {
+
void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
void reportSuccess(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
}
package org.onap.appc.dg.common;
+import java.util.Map;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import java.util.Map;
-
@FunctionalInterface
public interface DgResolverPlugin extends SvcLogicJavaPlugin {
+
void resolveDg(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
}
package org.onap.appc.dg.common;
+import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import java.util.Map;
-
/**
* This interface provides api for sending intermediate messages from DG to initiator
*/
package org.onap.appc.dg.common;
import java.util.Map;
-
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
package org.onap.appc.dg.common;
import java.util.Map;
-
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
public interface LegacyUtil extends SvcLogicJavaPlugin {
void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
package org.onap.appc.dg.common;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
import java.util.Map;
-
import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
@FunctionalInterface
public interface OutputMessagePlugin extends SvcLogicJavaPlugin {
- void outputMessageBuilder(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void outputMessageBuilder(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
}
package org.onap.appc.dg.common;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
import java.util.Map;
-
import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
@FunctionalInterface
public interface VNFCDgResolverPlugin extends SvcLogicJavaPlugin {
+
void resolveVNFCDg(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
}
package org.onap.appc.dg.common;
+import java.util.Map;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
-import java.util.Map;
/**
* DG plugin created for VNF configuration operation to store data in MD-SAL store
**/
package org.onap.appc.dg.common;
+import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import java.util.Map;
-
@FunctionalInterface
public interface VnfExecutionFlow extends SvcLogicJavaPlugin {
- void getVnfExecutionFlowData(Map<String,String> params, SvcLogicContext context);
+
+ void getVnfExecutionFlowData(Map<String, String> params, SvcLogicContext context);
}
package org.onap.appc.dg.common.impl;
-import org.onap.appc.rankingframework.RankedAttributesResolver;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.util.concurrent.locks.ReentrantLock;
+import org.onap.appc.rankingframework.RankedAttributesResolver;
abstract class AbstractResolver {
return dgResolver;
}
- protected abstract FlowKey resolve(final String...args);
+
+ protected abstract FlowKey resolve(final String... args);
}
package org.onap.appc.dg.common.impl;
-import org.onap.appc.dao.util.DBUtils;
-import org.onap.appc.rankingframework.AbstractRankedAttributesResolverFactory;
-import org.onap.appc.rankingframework.ConfigurationEntry;
-import org.onap.appc.rankingframework.ConfigurationSet;
-import org.onap.appc.rankingframework.RankedAttributesResolver;
-
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
+import org.onap.appc.dao.util.DBUtils;
+import org.onap.appc.rankingframework.AbstractRankedAttributesResolverFactory;
+import org.onap.appc.rankingframework.ConfigurationEntry;
+import org.onap.appc.rankingframework.ConfigurationSet;
+import org.onap.appc.rankingframework.RankedAttributesResolver;
abstract class AbstractResolverDataReader {
- private class ConfigurationSetAdaptor implements ConfigurationSet<FlowKey> {
+ private class ConfigurationSetAdaptor implements ConfigurationSet<FlowKey> {
private final ResultSet resultSet;
private class ResultSetIterator implements Iterator<ConfigurationEntry<FlowKey>>, ConfigurationEntry<FlowKey> {
+
@Override
public boolean hasNext() {
try {
@Override
public FlowKey getResult() {
try {
- return new FlowKey(resultSet.getString("dg_name"), resultSet.getString("dg_version"), resultSet.getString("dg_module"));
+ return new FlowKey(resultSet.getString("dg_name"), resultSet.getString("dg_version"),
+ resultSet.getString("dg_module"));
} catch (SQLException e) {
throw new DataReaderException(e);
}
}
protected abstract Collection<String> getAttributeNames();
- protected abstract String getQueryStmt();
+ protected abstract String getQueryStmt();
RankedAttributesResolver<FlowKey> read() {
package org.onap.appc.dg.common.impl;
-
class Constants {
public static final String DG_ERROR_FIELD_NAME = "org.onap.appc.dg.error";
public static final String OUTPUT_PAYLOAD = "output.payload";
//Added for VnfExecution Flow
- public static final String FLOW_STRATEGY = "FlowStrategy" ;
+ public static final String FLOW_STRATEGY = "FlowStrategy";
public static final String DEPENDENCY_TYPE = "DependencyType";
public static final String VNF_TYPE = "vnfType";
public static final String VNF_VERION = "vnfVersion";
- public static final String APPC_INSTANCE_ID= "appc-instance-id";
+ public static final String APPC_INSTANCE_ID = "appc-instance-id";
//Added for Cvaas
public static final String CVAAS_DIRECTORY_PATH = "cvaas-directory-path";
SkipHypervisorCheck("org.onap.appc.skiphypervisorcheck");
private String value;
- LegacyAttributes(String value) {this.value = value;}
- String getValue() {return value;}
- };
+
+ LegacyAttributes(String value) {
+ this.value = value;
+ }
+
+ String getValue() {
+ return value;
+ }
+ }
+
+ ;
enum LCMAttributes {
Action("input.action"),
SkipHypervisorCheck("skip-hypervisor-check");
private String value;
- LCMAttributes(String value) {this.value = value;}
- String getValue() {return value;}
- };
+
+ LCMAttributes(String value) {
+ this.value = value;
+ }
+
+ String getValue() {
+ return value;
+ }
+ }
+
+ ;
// DG Resolver Constants
public static final String IN_PARAM_VNF_TYPE = "vnfType";
public static final String IN_PARAM_API_VERSION = "api-ver";
public static final String OUT_PARAM_DG_NAME = "dg_name";
- public static final String OUT_PARAM_DG_VERSION= "dg_version";
+ public static final String OUT_PARAM_DG_VERSION = "dg_version";
public static final String OUT_PARAM_DG_MODULE = "dg_module";
public static final String TABLE_NAME = "VNFC_DG_MAPPING";
public static final String TABLE_COLUMN_ACTION = "ACTION";
public static final String TABLE_COLUMN_API_VERSION = "API_VERSION";
public static final String TABLE_COLUMN_DG_NAME = "DG_NAME";
- public static final String TABLE_COLUMN_DG_VERSION= "DG_VERSION";
+ public static final String TABLE_COLUMN_DG_VERSION = "DG_VERSION";
public static final String TABLE_COLUMN_DG_MODULE = "DG_MODULE";
}
package org.onap.appc.dg.common.impl;
+import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.onap.appc.adapter.message.EventSender;
import org.onap.appc.adapter.message.MessageDestination;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import java.util.Map;
-
public class DCAEReporterPluginImpl implements DCAEReporterPlugin {
private EventSender eventSender;
@Override
public void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
- String errorDescription,apiVersion,eventId ;
+ String errorDescription, apiVersion, eventId;
- Integer errorCode = readErrorCode(params,ctx);
+ Integer errorCode = readErrorCode(params, ctx);
errorDescription = params.get(Constants.EVENT_MESSAGE);
- if(StringUtils.isEmpty(errorDescription)) {
- reportLegacy(params , ctx);
- }else{
- apiVersion = ctx.getAttribute("input.common-header.api-ver");
- eventId = ctx.getAttribute("input.common-header.request-id");
+ if (StringUtils.isEmpty(errorDescription)) {
+ reportLegacy(params, ctx);
+ } else {
+ apiVersion = ctx.getAttribute("input.common-header.api-ver");
+ eventId = ctx.getAttribute("input.common-header.request-id");
EventMessage eventMessage = new EventMessage(new EventHeader(
- (new java.util.Date()).toString(), apiVersion, eventId),
- new EventStatus(errorCode, errorDescription));
+ (new java.util.Date()).toString(), apiVersion, eventId),
+ new EventStatus(errorCode, errorDescription));
String eventWriteTopic = params.get("event-topic-name");
- if(!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic!=null){
- eventSender.sendEvent(MessageDestination.DCAE, eventMessage,eventWriteTopic);
- }else {
+ if (!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic != null) {
+ eventSender.sendEvent(MessageDestination.DCAE, eventMessage, eventWriteTopic);
+ } else {
eventSender.sendEvent(MessageDestination.DCAE, eventMessage);
}
}
private Integer readErrorCode(Map<String, String> params, SvcLogicContext ctx) {
Integer errorReportCode = 501;
String errorCodeStr = params.get(Constants.DG_ERROR_CODE);
- errorCodeStr = StringUtils.isEmpty(errorCodeStr)?
- ctx.getAttribute(Constants.DG_ERROR_CODE):errorCodeStr;
- try{
- errorReportCode = Integer.parseInt(errorCodeStr);
- }
- catch (NumberFormatException e){
+ errorCodeStr = StringUtils.isEmpty(errorCodeStr) ?
+ ctx.getAttribute(Constants.DG_ERROR_CODE) : errorCodeStr;
+ try {
+ errorReportCode = Integer.parseInt(errorCodeStr);
+ } catch (NumberFormatException e) {
// Ignore Exception
}
return errorReportCode;
String successDescription, apiVersion, eventId;
successDescription = params.get(Constants.EVENT_MESSAGE);
- if(StringUtils.isEmpty(successDescription)) {
+ if (StringUtils.isEmpty(successDescription)) {
successDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
}
successDescription = "Success";
}
EventMessage eventMessage = new EventMessage(new EventHeader(
- (new java.util.Date()).toString(), apiVersion, eventId),
- new EventStatus(successReportCode, successDescription));
+ (new java.util.Date()).toString(), apiVersion, eventId),
+ new EventStatus(successReportCode, successDescription));
String eventWriteTopic = params.get("event-topic-name");
- if(!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic!=null){
- eventSender.sendEvent(MessageDestination.DCAE, eventMessage,eventWriteTopic);
- }else {
+ if (!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic != null) {
+ eventSender.sendEvent(MessageDestination.DCAE, eventMessage, eventWriteTopic);
+ } else {
eventSender.sendEvent(MessageDestination.DCAE, eventMessage);
}
}
private void reportLegacy(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
- String errorDescription,apiVersion,eventId ;
+ String errorDescription, apiVersion, eventId;
- Integer errorCode = readErrorCode(params,ctx);
- errorDescription = getErrorDescriptionAndAddToCtx(params,ctx);
+ Integer errorCode = readErrorCode(params, ctx);
+ errorDescription = getErrorDescriptionAndAddToCtx(params, ctx);
apiVersion = ctx.getAttribute("input.common-header.api-ver");
eventId = ctx.getAttribute("input.common-header.request-id");
EventMessage eventMessage = new EventMessage(new EventHeader(
- (new java.util.Date()).toString(), apiVersion, eventId),
- new EventStatus(errorCode, errorDescription));
+ (new java.util.Date()).toString(), apiVersion, eventId),
+ new EventStatus(errorCode, errorDescription));
String eventWriteTopic = params.get("event-topic-name");
- if(!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic!=null){
- eventSender.sendEvent(MessageDestination.DCAE, eventMessage,eventWriteTopic);
- }else {
+ if (!StringUtils.isEmpty(eventWriteTopic) && eventWriteTopic != null) {
+ eventSender.sendEvent(MessageDestination.DCAE, eventMessage, eventWriteTopic);
+ } else {
eventSender.sendEvent(MessageDestination.DCAE, eventMessage);
}
}
private String getErrorDescriptionAndAddToCtx(Map<String, String> params, SvcLogicContext ctx) {
String errorDescription;
errorDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
- if(StringUtils.isEmpty(errorDescription)) {
+ if (StringUtils.isEmpty(errorDescription)) {
errorDescription = ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE);
}
- if(StringUtils.isEmpty(errorDescription)) {
+ if (StringUtils.isEmpty(errorDescription)) {
errorDescription = "Unknown";
}
- addToContextIfNotContains(errorDescription,ctx);
+ addToContextIfNotContains(errorDescription, ctx);
return errorDescription;
}
private void addToContextIfNotContains(String errorDescription, SvcLogicContext ctx) {
String errorDescriptionFromCtx;
errorDescriptionFromCtx = ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE);
- if(StringUtils.isEmpty(errorDescriptionFromCtx)){
+ if (StringUtils.isEmpty(errorDescriptionFromCtx)) {
errorDescriptionFromCtx = ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE);
}
- if(StringUtils.isEmpty(errorDescriptionFromCtx)){
+ if (StringUtils.isEmpty(errorDescriptionFromCtx)) {
ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorDescription);
- }else if (!errorDescriptionFromCtx.contains(errorDescription)){
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorDescriptionFromCtx+ " | "+ errorDescription);
+ } else if (!errorDescriptionFromCtx.contains(errorDescription)) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorDescriptionFromCtx + " | " + errorDescription);
}
}
package org.onap.appc.dg.common.impl;
-public class DataReaderException extends RuntimeException{
+public class DataReaderException extends RuntimeException {
public DataReaderException(Throwable cause) {
super(cause);
package org.onap.appc.dg.common.impl;
-import org.onap.appc.exceptions.APPCException;
-import org.onap.appc.i18n.Msg;
import com.att.eelf.i18n.EELFResourceManager;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
import java.util.Map;
-
import org.onap.appc.dg.common.DgResolverPlugin;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.i18n.Msg;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class DgResolverPluginImpl implements DgResolverPlugin {
FlowKey flowKey = null;
try {
- if(params.get("DGResolutionType").equalsIgnoreCase("VNFC")) {
- 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));
- }else if(params.get("DGResolutionType").equalsIgnoreCase("VNF")){
- 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));
+ if (params.get("DGResolutionType").equalsIgnoreCase("VNFC")) {
+ 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));
+ } else if (params.get("DGResolutionType").equalsIgnoreCase("VNF")) {
+ 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));
}
if (flowKey != null) {
DGName = flowKey.name();
DGModule = flowKey.module();
ctx.setAttribute(prefix + Constants.OUT_PARAM_DG_MODULE, DGModule);
} else {
- throw new RuntimeException(params.get("DGResolutionType")+ " DG not found for vnf type :" + params.get(Constants.IN_PARAM_VNF_TYPE)
- + " vnfc type : " + params.get(Constants.IN_PARAM_VNFC_TYPE)
- + " action : " + params.get(Constants.IN_PARAM_ACTION)
- + " api version : " + params.get(Constants.IN_PARAM_API_VERSION));
+ throw new RuntimeException(params.get("DGResolutionType") + " DG not found for vnf type :" + params
+ .get(Constants.IN_PARAM_VNF_TYPE)
+ + " vnfc type : " + params.get(Constants.IN_PARAM_VNFC_TYPE)
+ + " action : " + params.get(Constants.IN_PARAM_ACTION)
+ + " api version : " + params.get(Constants.IN_PARAM_API_VERSION));
}
} catch (Exception e) {
- String msg = EELFResourceManager.format(Msg.FAILURE_RETRIEVE_VNFC_DG,params.get(Constants.IN_PARAM_VNFC_TYPE), e.getMessage());
- ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
+ String msg = EELFResourceManager
+ .format(Msg.FAILURE_RETRIEVE_VNFC_DG, params.get(Constants.IN_PARAM_VNFC_TYPE), e.getMessage());
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
throw new RuntimeException(e);
}
}
package org.onap.appc.dg.common.impl;
class FlowKey {
+
private final String name;
private final String version;
private final String module;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.onap.appc.adapter.message.MessageAdapterFactory;
import org.onap.appc.adapter.message.Producer;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
public class IntermediateMessageSenderImpl implements IntermediateMessageSender {
private static final String RESPONSE = "response";
private static final String MSO = "MSO";
- public void init(){
+ public void init() {
configuration = ConfigurationFactory.getConfiguration();
- Properties properties=configuration.getProperties();
+ Properties properties = configuration.getProperties();
String writeTopic = properties.getProperty("appc.LCM.topic.write");
String apiKey = properties.getProperty("appc.LCM.client.key");
String apiSecret = properties.getProperty("appc.LCM.client.secret");
String hostNames = properties.getProperty("appc.LCM.poolMembers");
- logger.debug("Configuration Read : writeTopic = " + writeTopic +", " +
- "hostNames = " + hostNames);
+ logger.debug("Configuration Read : writeTopic = " + writeTopic + ", " +
+ "hostNames = " + hostNames);
Set<String> pool = new HashSet<>();
if (!StringUtils.isEmpty(hostNames)) {
if (ctx != null) {
ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
if (svcRef != null) {
- producer = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopic,apiKey, apiSecret);
+ producer = ((MessageAdapterFactory) ctx.getService(svcRef))
+ .createProducer(pool, writeTopic, apiKey, apiSecret);
}
}
}
@Override
public void sendMessage(Map<String, String> params, SvcLogicContext context) {
String prefix = params.get("prefix");
- prefix = StringUtils.isEmpty(prefix)? "":prefix+".";
- try{
- validateInputs(params,context);
+ prefix = StringUtils.isEmpty(prefix) ? "" : prefix + ".";
+ try {
+ validateInputs(params, context);
String jsonMessage = getJsonMessage(params, context);
logger.debug("Constructed JSON Message : " + jsonMessage);
- producer.post("",jsonMessage);
+ producer.post("", jsonMessage);
context.setAttribute(prefix + STATUS, SUCCESS);
- }
- catch(Exception e){
+ } catch (Exception e) {
String errorMessage = "Error sending intermediate message to initiator " + e.getMessage();
context.setAttribute(prefix + STATUS, FAILURE);
context.setAttribute(prefix + ERROR_MESSAGE, errorMessage);
- logger.error(errorMessage,e);
+ logger.error(errorMessage, e);
}
}
private void validateInputs(Map<String, String> params, SvcLogicContext context) throws APPCException {
String code = params.get("code");
String message = params.get("message");
- if(StringUtils.isEmpty(code) || StringUtils.isEmpty(message)){
+ if (StringUtils.isEmpty(code) || StringUtils.isEmpty(message)) {
throw new APPCException("code or message is empty");
}
String requestId = context.getAttribute("input.common-header.request-id");
- if(StringUtils.isEmpty(requestId)){
+ if (StringUtils.isEmpty(requestId)) {
throw new APPCException("requestId is empty");
}
}
ObjectNode status = getStatus(params);
ObjectNode output = objectMapper.createObjectNode();
- output.put("common-header",commonHeader);
- output.put("status",status);
+ output.put("common-header", commonHeader);
+ output.put("status", status);
- ObjectNode body = objectMapper.createObjectNode();
- body.put("output",output);
+ ObjectNode body = objectMapper.createObjectNode();
+ body.put("output", output);
ObjectNode root = objectMapper.createObjectNode();
root.put("type", RESPONSE);
- root.put("rpc-name",context.getAttribute("input.action"));
+ root.put("rpc-name", context.getAttribute("input.action"));
root.put("cambria.partition", MSO);
- root.put("correlation-id",getCorrelationId(context));
- root.put("body",body);
+ root.put("correlation-id", getCorrelationId(context));
+ root.put("body", body);
return root.toString();
}
private String getCorrelationId(SvcLogicContext context) {
String requestId = context.getAttribute("input.common-header.request-id");
String subRequestId = context.getAttribute("input.common-header.sub-request-id");
- return requestId + (StringUtils.isEmpty(subRequestId)?"":("-"+subRequestId));
+ return requestId + (StringUtils.isEmpty(subRequestId) ? "" : ("-" + subRequestId));
}
- private ObjectNode getStatus(Map<String,String> params) {
+ private ObjectNode getStatus(Map<String, String> params) {
ObjectMapper objectMapper = new ObjectMapper();
- ObjectNode status = objectMapper.createObjectNode();
- status.put("code",params.get("code"));
- status.put("message",params.get("message"));
+ ObjectNode status = objectMapper.createObjectNode();
+ status.put("code", params.get("code"));
+ status.put("message", params.get("message"));
return status;
}
private ObjectNode getCommonHeader(SvcLogicContext context) {
ObjectMapper objectMapper = new ObjectMapper();
- ObjectNode commonHeader = objectMapper.createObjectNode();
- commonHeader.put("api-ver",context.getAttribute("input.common-header.api-ver"));
- commonHeader.put("timestamp",context.getAttribute("input.common-header.timestamp"));
- commonHeader.put("originator-id",context.getAttribute("input.common-header.originator-id"));
- commonHeader.put("request-id",context.getAttribute("input.common-header.request-id"));
- commonHeader.put("sub-request-id",context.getAttribute("input.common-header.sub-request-id"));
+ ObjectNode commonHeader = objectMapper.createObjectNode();
+ commonHeader.put("api-ver", context.getAttribute("input.common-header.api-ver"));
+ commonHeader.put("timestamp", context.getAttribute("input.common-header.timestamp"));
+ commonHeader.put("originator-id", context.getAttribute("input.common-header.originator-id"));
+ commonHeader.put("request-id", context.getAttribute("input.common-header.request-id"));
+ commonHeader.put("sub-request-id", context.getAttribute("input.common-header.sub-request-id"));
return commonHeader;
}
}
package org.onap.appc.dg.common.impl;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Set;
-
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.appc.dg.common.JsonDgUtil;
import org.onap.appc.util.JsonUtil;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
public class JsonDgUtilImpl implements JsonDgUtil {
+
private static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonDgUtilImpl.class);
private static final ThreadLocal<SimpleDateFormat> DATE_TIME_PARSER_THREAD_LOCAL = new ThreadLocal<SimpleDateFormat>() {
public void flatAndAddToContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
if (logger.isTraceEnabled()) {
- logger.trace("Entering to flatAndAddToContext with params = "+ ObjectUtils.toString(params)+", SvcLogicContext = "+ObjectUtils.toString(ctx));
+ logger.trace(
+ "Entering to flatAndAddToContext with params = " + ObjectUtils.toString(params) + ", SvcLogicContext = "
+ + ObjectUtils.toString(ctx));
}
try {
String paramName = Constants.PAYLOAD;
String payload = params.get(paramName);
- if (payload == null || payload.isEmpty())
+ if (payload == null || payload.isEmpty()) {
payload = ctx.getAttribute("input.payload");
+ }
if (!StringUtils.isEmpty(payload)) {
Map<String, String> flatMap = JsonUtil.convertJsonStringToFlatMap(payload);
if (flatMap != null && flatMap.size() > 0) {
}
} catch (Exception e) {
logger.error(e.toString());
- String msg = EELFResourceManager.format(Msg.INPUT_PAYLOAD_PARSING_FAILED,params.get(Constants.PAYLOAD));
+ String msg = EELFResourceManager.format(Msg.INPUT_PAYLOAD_PARSING_FAILED, params.get(Constants.PAYLOAD));
ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
throw new APPCException(e);
}
}
@Override
- public void generateOutputPayloadFromContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException{
+ public void generateOutputPayloadFromContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
if (logger.isTraceEnabled()) {
- logger.trace("Entering to generateOutputPayloadFromContext with SvcLogicContext = "+ObjectUtils.toString(ctx));
+ logger.trace(
+ "Entering to generateOutputPayloadFromContext with SvcLogicContext = " + ObjectUtils.toString(ctx));
}
try {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode JsonNode = objectMapper.createObjectNode();
for (String key : keys) {
- if(key.startsWith(Constants.OUTPUT_PAYLOAD+".")){
- String objkey= key.replaceFirst(Constants.OUTPUT_PAYLOAD + ".", "");
- if(objkey.contains("[") && objkey.contains("]")){
+ if (key.startsWith(Constants.OUTPUT_PAYLOAD + ".")) {
+ String objkey = key.replaceFirst(Constants.OUTPUT_PAYLOAD + ".", "");
+ if (objkey.contains("[") && objkey.contains("]")) {
ArrayNode arrayNode;
- String arrayKey = objkey.substring(0,objkey.indexOf('['));
- int arrayIndex = Integer.parseInt(objkey.substring(objkey.indexOf('[')+1,objkey.indexOf(']')));
- if(JsonNode.has(arrayKey)){
- arrayNode = (ArrayNode)JsonNode.get(arrayKey);
- arrayNode.insert(arrayIndex,ctx.getAttribute(key));
- }else {
+ String arrayKey = objkey.substring(0, objkey.indexOf('['));
+ int arrayIndex = Integer
+ .parseInt(objkey.substring(objkey.indexOf('[') + 1, objkey.indexOf(']')));
+ if (JsonNode.has(arrayKey)) {
+ arrayNode = (ArrayNode) JsonNode.get(arrayKey);
+ arrayNode.insert(arrayIndex, ctx.getAttribute(key));
+ } else {
arrayNode = objectMapper.createArrayNode();
- arrayNode.insert(arrayIndex,ctx.getAttribute(key));
- JsonNode.put(arrayKey,arrayNode);
+ arrayNode.insert(arrayIndex, ctx.getAttribute(key));
+ JsonNode.put(arrayKey, arrayNode);
}
- }else {
+ } else {
JsonNode.put(objkey, ctx.getAttribute(key));
}
}
}
- if(JsonNode.size()>0) {
+ if (JsonNode.size() > 0) {
ctx.setAttribute(Constants.OUTPUT_PAYLOAD, objectMapper.writeValueAsString(JsonNode));
}
} catch (Exception e) {
@Override
public void cvaasFileNameAndFileContentToContext(Map<String, String> params, SvcLogicContext ctx)
- throws APPCException {
+ throws APPCException {
if (logger.isTraceEnabled()) {
logger.trace("Entering to caasFileNameAndFileContentToContext with SvcLogicContext = "
- + ObjectUtils.toString(ctx));
+ + ObjectUtils.toString(ctx));
}
String vnfId = null;
String appcInstanceId = params.get(Constants.APPC_INSTANCE_ID);
/*
- * File name
+ * File name
*/
vnfId = params.get("vnf-id");
long timestampAsLongRepresentingFileCreationTime = System.currentTimeMillis();
ctx.setAttribute(Constants.CVAAS_FILE_NAME, cvassDirectoryPath + File.separator + vnfId + "_"
- + timestampAsLongRepresentingFileCreationTime + "_" + appcInstanceId + ".json");
+ + timestampAsLongRepresentingFileCreationTime + "_" + appcInstanceId + ".json");
/*
* File content
jsonNode.put("CONTENT", ctx.getAttribute("running-config.content"));
ctx.setAttribute(Constants.CVAAS_FILE_CONTENT,
- objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode));
+ objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode));
} catch (Exception e) {
String errorMessage = "Failed to parse create cvass file for vnf with id : " + vnfId;
package org.onap.appc.dg.common.impl;
import java.util.Map;
-
import org.onap.appc.dg.common.LegacyUtil;
import org.onap.appc.dg.common.utils.JSONUtil;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
public class LegacyUtilImpl implements LegacyUtil {
- @Override public void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
- ctx.setAttribute(Constants.LegacyAttributes.Action.getValue(), ctx.getAttribute(Constants.LCMAttributes.Action.getValue()).toLowerCase());
+ @Override
+ public void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ ctx.setAttribute(Constants.LegacyAttributes.Action.getValue(),
+ ctx.getAttribute(Constants.LCMAttributes.Action.getValue()).toLowerCase());
String payloadStr = ctx.getAttribute(Constants.LCMAttributes.Payload.getValue());
- Map<String,String> payloads = JSONUtil.extractPlainValues(payloadStr,
- Constants.LCMAttributes.VMID.getValue(), Constants.LCMAttributes.IdentityURL.getValue(), Constants.LCMAttributes.TenantID.getValue(),
- Constants.LCMAttributes.SkipHypervisorCheck.getValue());
-
- ctx.setAttribute(Constants.LegacyAttributes.VMID.getValue(), payloads.get(Constants.LCMAttributes.VMID.getValue()));
- ctx.setAttribute(Constants.LegacyAttributes.IdentityURL.getValue(), payloads.get(Constants.LCMAttributes.IdentityURL.getValue()));
- ctx.setAttribute(Constants.LegacyAttributes.TenantID.getValue(), payloads.get(Constants.LCMAttributes.TenantID.getValue()));
- ctx.setAttribute(Constants.LegacyAttributes.SkipHypervisorCheck.getValue(), payloads.get(Constants.LCMAttributes.SkipHypervisorCheck.getValue()));
+ Map<String, String> payloads = JSONUtil.extractPlainValues(payloadStr,
+ Constants.LCMAttributes.VMID.getValue(), Constants.LCMAttributes.IdentityURL.getValue(),
+ Constants.LCMAttributes.TenantID.getValue(),
+ Constants.LCMAttributes.SkipHypervisorCheck.getValue());
+
+ ctx.setAttribute(Constants.LegacyAttributes.VMID.getValue(),
+ payloads.get(Constants.LCMAttributes.VMID.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.IdentityURL.getValue(),
+ payloads.get(Constants.LCMAttributes.IdentityURL.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.TenantID.getValue(),
+ payloads.get(Constants.LCMAttributes.TenantID.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.SkipHypervisorCheck.getValue(),
+ payloads.get(Constants.LCMAttributes.SkipHypervisorCheck.getValue()));
}
package org.onap.appc.dg.common.impl;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.Map;
-
import org.onap.appc.dg.common.OutputMessagePlugin;
import org.onap.appc.exceptions.APPCException;
-
-import static org.apache.commons.lang3.StringUtils.isEmpty;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class OutputMessagePluginImpl implements OutputMessagePlugin {
errorDescription = params.get(Constants.ATTRIBUTE_ERROR_MESSAGE);
eventDescription = params.get(Constants.EVENT_MESSAGE);
- addToContextIfNotContains(errorDescription , eventDescription, ctx);
+ addToContextIfNotContains(errorDescription, eventDescription, ctx);
//making event-message
}
}
- public static void addToContextIfNotContains(String errorDescription, String eventDescription, SvcLogicContext ctx) {
- if (!isEmpty(errorDescription)){
+ public static void addToContextIfNotContains(String errorDescription, String eventDescription,
+ SvcLogicContext ctx) {
+ if (!isEmpty(errorDescription)) {
if (isEmpty(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE))) {
ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorDescription);
- }else if (!ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE).contains(errorDescription)) {
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE) + " | " + errorDescription);
+ } else if (!ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE).contains(errorDescription)) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE,
+ ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE) + " | " + errorDescription);
}
}
- if (!isEmpty(eventDescription)){
+ if (!isEmpty(eventDescription)) {
if (isEmpty(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE))) {
ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, eventDescription);
- }else if (!ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE).contains(eventDescription)) {
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE) + " | " + eventDescription);
+ } else if (!ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE).contains(eventDescription)) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE,
+ ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE) + " | " + eventDescription);
}
}
}
import org.onap.appc.configuration.ConfigurationFactory;
public class ResolverDataReaderFactory {
+
private static final Configuration configuration = ConfigurationFactory.getConfiguration();
- private static class ReferenceHolder{
+
+ private static class ReferenceHolder {
+
private static final AbstractResolverDataReader VNFC_RESOLVER_DATA_READER = new VNFCResolverDataReader();
private static final AbstractResolverDataReader VNF_RESOLVER_DATA_READER = new VNFResolverDataReader();
}
- public static AbstractResolverDataReader createResolverDataReader(String resolverType){
- if(resolverType.equalsIgnoreCase("VNF")){
+ public static AbstractResolverDataReader createResolverDataReader(String resolverType) {
+ if (resolverType.equalsIgnoreCase("VNF")) {
return ReferenceHolder.VNF_RESOLVER_DATA_READER;
- }else if(resolverType.equalsIgnoreCase("VNFC")){
+ } else if (resolverType.equalsIgnoreCase("VNFC")) {
return ReferenceHolder.VNFC_RESOLVER_DATA_READER;
- }else {
+ } else {
return null;
}
}
import org.onap.appc.configuration.ConfigurationFactory;
public class ResolverFactory {
+
private static final Configuration configuration = ConfigurationFactory.getConfiguration();
- private static class ReferenceHolder{
- private static final AbstractResolver VNFC_RESOLVER = new VNFCResolver(configuration.getIntegerProperty("org.onap.appc.workflow.resolver.refresh_interval", 300));
- private static final AbstractResolver VNF_RESOLVER = new VNFResolver(configuration.getIntegerProperty("org.onap.appc.workflow.resolver.refresh_interval", 300));
+
+ private static class ReferenceHolder {
+
+ private static final AbstractResolver VNFC_RESOLVER = new VNFCResolver(
+ configuration.getIntegerProperty("org.onap.appc.workflow.resolver.refresh_interval", 300));
+ private static final AbstractResolver VNF_RESOLVER = new VNFResolver(
+ configuration.getIntegerProperty("org.onap.appc.workflow.resolver.refresh_interval", 300));
}
- public static AbstractResolver createResolver(String resolverType){
- if(resolverType.equalsIgnoreCase("VNF")){
+ public static AbstractResolver createResolver(String resolverType) {
+ if (resolverType.equalsIgnoreCase("VNF")) {
return ReferenceHolder.VNF_RESOLVER;
- }else if(resolverType.equalsIgnoreCase("VNFC")){
+ } else if (resolverType.equalsIgnoreCase("VNFC")) {
return ReferenceHolder.VNFC_RESOLVER;
- }else {
+ } else {
return null;
}
}
package org.onap.appc.dg.common.impl;
+import java.util.Map;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import java.util.Map;
-
public class VNFCDgResolverPluginImpl implements org.onap.appc.dg.common.VNFCDgResolverPlugin {
+
@Override
public void resolveVNFCDg(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
DgResolverPluginImpl dgResolverPlugin = new DgResolverPluginImpl();
- params.put("DGResolutionType" , "VNFC");
- dgResolverPlugin.resolveDg(params,ctx);
+ params.put("DGResolutionType", "VNFC");
+ dgResolverPlugin.resolveDg(params, ctx);
}
}
public class VNFCResolver extends AbstractResolver {
+
VNFCResolver(int interval) {
super(interval);
}
@Override
protected FlowKey resolve(String... args) {
- if(args.length !=4){
+ if (args.length != 4) {
throw new IllegalStateException(args.toString());
}
- return resolve(args[0],args[1],args[2],args[3]);
+ return resolve(args[0], args[1], args[2], args[3]);
}
- protected FlowKey resolve(final String action, final String vnfType, final String vnfcType, final String apiVersion) {
+ protected FlowKey resolve(final String action, final String vnfType, final String vnfcType,
+ final String apiVersion) {
RankedAttributesContext context = new RankedAttributesContext() {
@Override
public Object getAttributeValue(String name) {
import java.util.Collection;
public class VNFCResolverDataReader extends AbstractResolverDataReader {
+
@Override
protected Collection<String> getAttributeNames() {
- return Arrays.asList("action","api_version", "vnf_type", "vnfc_type");
+ return Arrays.asList("action", "api_version", "vnf_type", "vnfc_type");
}
@Override
package org.onap.appc.dg.common.impl;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
import org.onap.appc.Constants;
import org.onap.appc.dg.common.VNFConfigurator;
import org.onap.appc.exceptions.APPCException;
import org.onap.appc.mdsal.exception.MDSALStoreException;
import org.onap.appc.mdsal.impl.MDSALStoreFactory;
import org.onap.appc.mdsal.objects.BundleInfo;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.apache.commons.lang3.StringUtils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
public class VNFConfiguratorImpl implements VNFConfigurator {
String configJSON = params.get("configJSON");
String requestId = params.get("requestId");
String prefix = params.get("prefix");
- prefix = StringUtils.isEmpty(prefix)? "":prefix+".";
+ prefix = StringUtils.isEmpty(prefix) ? "" : prefix + ".";
MDSALStore store = MDSALStoreFactory.createMDSALStore();
logger.debug("Inputs Received : uniqueId = " + uniqueId +
- " , yang = " + yang +
- " , configJSON = " + configJSON +
- " , requestId = " + requestId +
- " , prefix = " +prefix);
+ " , yang = " + yang +
+ " , configJSON = " + configJSON +
+ " , requestId = " + requestId +
+ " , prefix = " + prefix);
try {
- if(StringUtils.isEmpty(uniqueId)
- ||StringUtils.isEmpty(yang)
- || StringUtils.isEmpty(configJSON)
- || StringUtils.isEmpty(requestId)){
+ if (StringUtils.isEmpty(uniqueId)
+ || StringUtils.isEmpty(yang)
+ || StringUtils.isEmpty(configJSON)
+ || StringUtils.isEmpty(requestId)) {
throw new APPCException("One or more input parameters are empty : uniqueId = " + uniqueId + " " +
- ", yang = " + yang +
- " , configJSON = " + configJSON +
- " , requestId = " + requestId);
+ ", yang = " + yang +
+ " , configJSON = " + configJSON +
+ " , requestId = " + requestId);
}
Date revision = new SimpleDateFormat(Constants.YANG_REVISION_FORMAT).parse(Constants.YANG_REVISION);
- boolean isYangAlreadyLoaded = store.isModulePresent(uniqueId,revision);
+ boolean isYangAlreadyLoaded = store.isModulePresent(uniqueId, revision);
- if(!isYangAlreadyLoaded){
+ if (!isYangAlreadyLoaded) {
BundleInfo bundleInfo = getBundleInfo(uniqueId);
- store.storeYangModule(yang,bundleInfo);
+ store.storeYangModule(yang, bundleInfo);
}
- store.storeJson(uniqueId, requestId , configJSON);
+ store.storeJson(uniqueId, requestId, configJSON);
context.setAttribute(prefix + STATUS, SUCCESS);
} catch (ParseException e) {
- String errorMessage ="Error parsing the date : " + Constants.YANG_REVISION + " into format " + Constants.YANG_REVISION_FORMAT;
- logger.error(errorMessage,e);
+ String errorMessage = "Error parsing the date : " + Constants.YANG_REVISION + " into format "
+ + Constants.YANG_REVISION_FORMAT;
+ logger.error(errorMessage, e);
context.setAttribute(prefix + STATUS, FAILURE);
context.setAttribute(prefix + ERROR_MESSAGE, errorMessage);
throw new APPCException(e.getMessage());
- }catch (MDSALStoreException e){
+ } catch (MDSALStoreException e) {
String errorMessage = "Error while adding yang to MD-SAL store." + e.getMessage();
- logger.error(errorMessage,e);
- context.setAttribute(prefix + STATUS,FAILURE);
+ logger.error(errorMessage, e);
+ context.setAttribute(prefix + STATUS, FAILURE);
context.setAttribute(prefix + ERROR_MESSAGE, errorMessage);
throw new APPCException(e.getMessage());
}
import org.onap.appc.rankingframework.RankedAttributesContext;
public class VNFResolver extends AbstractResolver {
+
VNFResolver(int interval) {
super(interval);
}
@Override
protected FlowKey resolve(String... args) {
- return resolve(args[0],args[1],args[2],args[3]);
+ return resolve(args[0], args[1], args[2], args[3]);
}
- protected FlowKey resolve(final String action, final String vnfType, final String vnfVersion, final String apiVersion) {
+ protected FlowKey resolve(final String action, final String vnfType, final String vnfVersion,
+ final String apiVersion) {
RankedAttributesContext context = new RankedAttributesContext() {
@Override
public Object getAttributeValue(String name) {
* @since January 19,2017
*/
public class VNFResolverDataReader extends AbstractResolverDataReader {
+
@Override
protected Collection<String> getAttributeNames() {
- return Arrays.asList("action","api_version", "vnf_type", "vnf_version");
+ return Arrays.asList("action", "api_version", "vnf_type", "vnf_version");
}
@Override
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.i18n.EELFResourceManager;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.appc.exceptions.APPCException;
-
-import java.util.*;
-
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.onap.appc.dg.common.VnfExecutionFlow;
import org.onap.appc.dg.dependencymanager.DependencyManager;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
import org.onap.appc.dg.flowbuilder.FlowBuilder;
import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory;
-import org.onap.appc.dg.objects.*;
+import org.onap.appc.dg.objects.DependencyTypes;
+import org.onap.appc.dg.objects.FlowStrategies;
+import org.onap.appc.dg.objects.InventoryModel;
+import org.onap.appc.dg.objects.Node;
+import org.onap.appc.dg.objects.VnfcDependencyModel;
+import org.onap.appc.dg.objects.VnfcFlowModel;
import org.onap.appc.domainmodel.Vnf;
import org.onap.appc.domainmodel.Vnfc;
import org.onap.appc.domainmodel.Vserver;
+import org.onap.appc.exceptions.APPCException;
import org.onap.appc.i18n.Msg;
import org.onap.appc.metadata.objects.DependencyModelIdentifier;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class VnfExecutionFlowImpl implements VnfExecutionFlow {
private final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImpl.class);
- private static final String VNFC_FLOW="vnfcFlow[";
- private static final String VNF_VNFC="vnf.vnfc[";
+ private static final String VNFC_FLOW = "vnfcFlow[";
+ private static final String VNF_VNFC = "vnf.vnfc[";
+
/**
- * Constructor
- * <p>Used through blueprint
+ * Constructor <p>Used through blueprint
*/
- public VnfExecutionFlowImpl(){
+ public VnfExecutionFlowImpl() {
// do nothing
}
if (logger.isTraceEnabled()) {
logger.trace("Input received from DG Node : dependencyType = " + dependencyType +
- " , flowStrategy = " + flowStrategy +
- ", DependencyModelIdentifier = " + modelIdentifier.toString());
+ " , flowStrategy = " + flowStrategy +
+ ", DependencyModelIdentifier = " + modelIdentifier.toString());
}
DependencyManager dependencyManager = DependencyModelFactory.createDependencyManager();
dependencyModel = dependencyManager.getVnfcDependencyModel(
- modelIdentifier, DependencyTypes.findByString(dependencyType));
+ modelIdentifier, DependencyTypes.findByString(dependencyType));
} catch (DependencyModelNotFound e) {
- String msg = EELFResourceManager.format(Msg.DEPENDENCY_MODEL_NOT_FOUND,params.get(Constants.VNF_TYPE), e.getMessage());
+ String msg = EELFResourceManager
+ .format(Msg.DEPENDENCY_MODEL_NOT_FOUND, params.get(Constants.VNF_TYPE), e.getMessage());
logger.error(msg);
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
- context.setAttribute("dependencyModelFound","false");
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ context.setAttribute("dependencyModelFound", "false");
return;
- } catch (InvalidDependencyModelException e){
- String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage());
+ } catch (InvalidDependencyModelException e) {
+ String msg = EELFResourceManager
+ .format(Msg.INVALID_DEPENDENCY_MODEL, params.get(Constants.VNF_TYPE), e.getMessage());
logger.error(msg);
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
- throw new RuntimeException(e.getMessage(),e);
- } catch (APPCException e){
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new RuntimeException(e.getMessage(), e);
+ } catch (APPCException e) {
logger.error(e.getMessage());
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
- throw new RuntimeException(e.getMessage(),e);
- }
- catch (RuntimeException e){
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
+ } catch (RuntimeException e) {
logger.error(e.getMessage());
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, e.getMessage());
throw e;
}
-
- context.setAttribute("dependencyModelFound","true");
- if(logger.isDebugEnabled()){
- logger.debug("Dependency Model = " +dependencyModel);
+ context.setAttribute("dependencyModelFound", "true");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dependency Model = " + dependencyModel);
}
logger.info("Building Inventory Model from DG context");
InventoryModel inventoryModel = null;
try {
- inventoryModel = readInventoryModel(context);
+ inventoryModel = readInventoryModel(context);
} catch (APPCException e) {
logger.error(e.getMessage());
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
- throw new RuntimeException(e.getMessage(),e);
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
- if(logger.isDebugEnabled()){
- logger.debug("Inventory Model = " +inventoryModel);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Inventory Model = " + inventoryModel);
}
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("Validating inventory model with dependency model");
}
try {
validateInventoryModelWithDependencyModel(dependencyModel, inventoryModel);
- }
- catch (APPCException e){
+ } catch (APPCException e) {
logger.error(e.getMessage());
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
- throw new RuntimeException(e.getMessage(),e);
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
logger.info("Creating flow builder");
FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(
- FlowStrategies.findByString(flowStrategy));
+ FlowStrategies.findByString(flowStrategy));
logger.info("Building Vnf flow model");
VnfcFlowModel flowModel;
- try{
- flowModel = flowBuilder.buildFlowModel(dependencyModel,inventoryModel);
- }
- catch (InvalidDependencyModelException e){
- String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage());
+ try {
+ flowModel = flowBuilder.buildFlowModel(dependencyModel, inventoryModel);
+ } catch (InvalidDependencyModelException e) {
+ String msg = EELFResourceManager
+ .format(Msg.INVALID_DEPENDENCY_MODEL, params.get(Constants.VNF_TYPE), e.getMessage());
logger.error(msg);
- context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
- throw new RuntimeException(e.getMessage(),e);
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new RuntimeException(e.getMessage(), e);
}
// remove VNFCs from the flow model where vserver list is empty
reconcileFlowModel(flowModel);
- populateContext(flowModel,context);
- if(logger.isDebugEnabled()){
+ populateContext(flowModel, context);
+ if (logger.isDebugEnabled()) {
logContext(context);
}
- String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetVnfExecutionFlowData","VNF ID " + params.get(Constants.VNF_TYPE));
+ String msg = EELFResourceManager
+ .format(Msg.SUCCESS_EVENT_MESSAGE, "GetVnfExecutionFlowData", "VNF ID " + params.get(Constants.VNF_TYPE));
context.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
}
- private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params) throws APPCException {
+ private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params)
+ throws APPCException {
DependencyTypes dependencyTypes = DependencyTypes.findByString(dependencyType);
- if(dependencyTypes == null){
- throw new APPCException("Dependency type from the input : " + dependencyType +" is invalid.");
+ if (dependencyTypes == null) {
+ throw new APPCException("Dependency type from the input : " + dependencyType + " is invalid.");
}
FlowStrategies flowStrategies = FlowStrategies.findByString(flowStrategy);
- if(flowStrategies == null){
- throw new APPCException("Flow Strategy from the input : " + flowStrategy +" is invalid.");
+ if (flowStrategies == null) {
+ throw new APPCException("Flow Strategy from the input : " + flowStrategy + " is invalid.");
}
String vnfType = params.get(Constants.VNF_TYPE);
- if(vnfType ==null || vnfType.length() ==0){
+ if (vnfType == null || vnfType.length() == 0) {
throw new APPCException("Vnf Type is not passed in the input");
}
String vnfVersion = params.get(Constants.VNF_VERION);
- if(vnfVersion == null || vnfVersion.length() ==0){
+ if (vnfVersion == null || vnfVersion.length() == 0) {
throw new APPCException("Vnf Version not found");
}
}
private void logContext(SvcLogicContext context) {
- for(String key:context.getAttributeKeySet()){
- logger.debug(key + " = " + context.getAttribute(key) + "\n" );
+ for (String key : context.getAttributeKeySet()) {
+ logger.debug(key + " = " + context.getAttribute(key) + "\n");
}
}
private void populateContext(VnfcFlowModel flowModel, SvcLogicContext context) {
- int flowIndex=0;
+ int flowIndex = 0;
Iterator<List<Vnfc>> iterator = flowModel.getModelIterator();
- while (iterator.hasNext()){
- for(Vnfc vnfc:iterator.next()){
- context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcName",vnfc.getVnfcName());
- context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcType",vnfc.getVnfcType());
- context.setAttribute(VNFC_FLOW+flowIndex+"].resilienceType",vnfc.getResilienceType());
- context.setAttribute(VNFC_FLOW+flowIndex+"].vmCount",Integer.toString(vnfc.getVserverList().size()));
- int vmIndex =0;
- for(Vserver vm :vnfc.getVserverList()){
- context.setAttribute(VNFC_FLOW+flowIndex+"].vm["+vmIndex+"].url",vm.getUrl());
+ while (iterator.hasNext()) {
+ for (Vnfc vnfc : iterator.next()) {
+ context.setAttribute(VNFC_FLOW + flowIndex + "].vnfcName", vnfc.getVnfcName());
+ context.setAttribute(VNFC_FLOW + flowIndex + "].vnfcType", vnfc.getVnfcType());
+ context.setAttribute(VNFC_FLOW + flowIndex + "].resilienceType", vnfc.getResilienceType());
+ context
+ .setAttribute(VNFC_FLOW + flowIndex + "].vmCount", Integer.toString(vnfc.getVserverList().size()));
+ int vmIndex = 0;
+ for (Vserver vm : vnfc.getVserverList()) {
+ context.setAttribute(VNFC_FLOW + flowIndex + "].vm[" + vmIndex + "].url", vm.getUrl());
vmIndex++;
}
flowIndex++;
}
}
- context.setAttribute("vnfcFlowCount",Integer.toString(flowIndex));
+ context.setAttribute("vnfcFlowCount", Integer.toString(flowIndex));
}
private InventoryModel readInventoryModel(SvcLogicContext context) throws APPCException {
String vnfcCountStr = context.getAttribute("vnf.vnfcCount");
Integer vnfcCount = Integer.parseInt(vnfcCountStr);
Vnf vnf = createVnf(vnfId, vnfType, vnfVersion);
- for(Integer i=0;i<vnfcCount;i++){
- String vnfcName = context.getAttribute(VNF_VNFC+ i+"].name");
- String vnfcType = context.getAttribute(VNF_VNFC+ i+"].type");
- String vmCountStr = context.getAttribute(VNF_VNFC+ i+"].vm_count");
- if(vnfcType ==null || vnfcType.length() ==0){
- throw new APPCException("Could not retrieve VNFC Type from DG Context for vnf.vnfc["+ i+"].type");
+ for (Integer i = 0; i < vnfcCount; i++) {
+ String vnfcName = context.getAttribute(VNF_VNFC + i + "].name");
+ String vnfcType = context.getAttribute(VNF_VNFC + i + "].type");
+ String vmCountStr = context.getAttribute(VNF_VNFC + i + "].vm_count");
+ if (vnfcType == null || vnfcType.length() == 0) {
+ throw new APPCException("Could not retrieve VNFC Type from DG Context for vnf.vnfc[" + i + "].type");
}
Integer vmCount = Integer.parseInt(vmCountStr);
Vnfc vnfc = createVnfc(vnfcName, vnfcType);
- for(Integer j=0;j<vmCount;j++){
- String vmURL = context.getAttribute(VNF_VNFC+i+"].vm["+j+"].url");
+ for (Integer j = 0; j < vmCount; j++) {
+ String vmURL = context.getAttribute(VNF_VNFC + i + "].vm[" + j + "].url");
Vserver vm = createVserver(vmURL);
vm.setVnfc(vnfc);
vnfc.addVserver(vm);
}
private Vnfc createVnfc(String vnfcName, String vnfcType) {
- Vnfc vnfc =new Vnfc();
+ Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
vnfc.setVnfcType(vnfcType);
return vnfc;
}
private Vnf createVnf(String vnfId, String vnfType, String vnfVersion) {
- Vnf vnf =new Vnf();
+ Vnf vnf = new Vnf();
vnf.setVnfType(vnfType);
vnf.setVnfId(vnfId);
vnf.setVnfVersion(vnfVersion);
private DependencyModelIdentifier readDependencyModelIdentifier(Map<String, String> params) {
String vnfType = params.get(Constants.VNF_TYPE);
String catalogVersion = params.get(Constants.VNF_VERION);
- return new DependencyModelIdentifier(vnfType,catalogVersion);
+ return new DependencyModelIdentifier(vnfType, catalogVersion);
}
- private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException {
+ private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel,
+ InventoryModel inventoryModel) throws APPCException {
Set<String> dependencyModelVnfcSet = new HashSet<>();
Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>();
Set<String> inventoryModelVnfcsSet = new HashSet<>();
Vnfc vnfc = vnfcIterator.next();
if (vnfc.getVserverList().size() == 0) {
if (logger.isDebugEnabled()) {
- logger.debug("No vservers present for Vnfc type: " + vnfc.getVnfcType() + ". Hence, removing it from the flow model.");
+ logger.debug("No vservers present for Vnfc type: " + vnfc.getVnfcType()
+ + ". Hence, removing it from the flow model.");
}
vnfcIterator.remove();
}
package org.onap.appc.dg.common.objects;
-
public class ConnectionDetails {
private String host;