diff options
Diffstat (limited to 'common')
10 files changed, 374 insertions, 20 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java index 2e70c4925a..456f14e5ee 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java @@ -24,8 +24,9 @@ import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel; public enum AAIEdgeLabel implements GraphInventoryEdgeLabel { - BELONGS_TO("org.onap.relationships.inventory.BelongsTo"), USES( - "org.onap.relationships.inventory.Uses"), COMPOSED_OF("org.onap.relationships.inventory.ComposedOf"); + BELONGS_TO("org.onap.relationships.inventory.BelongsTo"), + USES("org.onap.relationships.inventory.Uses"), + COMPOSED_OF("org.onap.relationships.inventory.ComposedOf"); private final String label; diff --git a/common/src/main/java/org/onap/so/client/graphinventory/Format.java b/common/src/main/java/org/onap/so/client/graphinventory/Format.java index b422516e63..c3cb4b9eaf 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/Format.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/Format.java @@ -22,8 +22,14 @@ package org.onap.so.client.graphinventory; public enum Format { - RESOURCE("resource"), RESOURCE_AND_URL("resource_and_url"), SIMPLE("simple"), RAW("raw"), CONSOLE( - "console"), PATHED("pathed"), GRAPHSON("graphson"), ID("id"); + RESOURCE("resource"), + RESOURCE_AND_URL("resource_and_url"), + SIMPLE("simple"), + RAW("raw"), + CONSOLE("console"), + PATHED("pathed"), + GRAPHSON("graphson"), + ID("id"); private final String name; diff --git a/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java b/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java index b00d22dbad..eb95b75593 100644 --- a/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java +++ b/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java @@ -21,11 +21,18 @@ package org.onap.so.client.policy.entities; public enum PolicyServiceType { - GET_CONFIG("getConfig"), SEND_EVENT("sendEvent"), PUSH_POLICY("pushPolicy"), CREATE_POLICY( - "createPolicy"), UPDATE_POLICY("updatePolicy"), GET_DECISION("getDecision"), GET_METRICS( - "getMetrics"), DELETE_POLICY("deletePolicy"), LIST_CONFIG("listConfig"), CREATE_DICTIONARY_ITEM( - "createDictionaryItem"), UPDATE_DICTIONARY_ITEM( - "updateDictionaryItem"), GET_DICTIONARY_ITEMS("getDictionaryItems"); + GET_CONFIG("getConfig"), + SEND_EVENT("sendEvent"), + PUSH_POLICY("pushPolicy"), + CREATE_POLICY("createPolicy"), + UPDATE_POLICY("updatePolicy"), + GET_DECISION("getDecision"), + GET_METRICS("getMetrics"), + DELETE_POLICY("deletePolicy"), + LIST_CONFIG("listConfig"), + CREATE_DICTIONARY_ITEM("createDictionaryItem"), + UPDATE_DICTIONARY_ITEM("updateDictionaryItem"), + GET_DICTIONARY_ITEMS("getDictionaryItems"); private final String name; diff --git a/common/src/main/java/org/onap/so/logger/ErrorCode.java b/common/src/main/java/org/onap/so/logger/ErrorCode.java index 2d6fb791d5..f0a78e9699 100644 --- a/common/src/main/java/org/onap/so/logger/ErrorCode.java +++ b/common/src/main/java/org/onap/so/logger/ErrorCode.java @@ -1,8 +1,12 @@ package org.onap.so.logger; public enum ErrorCode { - PermissionError(100), AvailabilityError(200), DataError(300), SchemaError(400), BusinessProcesssError( - 500), UnknownError(900); + PermissionError(100), + AvailabilityError(200), + DataError(300), + SchemaError(400), + BusinessProcesssError(500), + UnknownError(900); private int value; diff --git a/common/src/main/java/org/onap/so/logger/MessageEnum.java b/common/src/main/java/org/onap/so/logger/MessageEnum.java index e92d50a685..bcf699beaf 100644 --- a/common/src/main/java/org/onap/so/logger/MessageEnum.java +++ b/common/src/main/java/org/onap/so/logger/MessageEnum.java @@ -24,13 +24,200 @@ package org.onap.so.logger; public enum MessageEnum { // Api Handler Messages - APIH_REQUEST_NULL, APIH_QUERY_FOUND, APIH_QUERY_NOT_FOUND, APIH_QUERY_PARAM_WRONG, APIH_DB_ACCESS_EXC, APIH_DB_ACCESS_EXC_REASON, APIH_VALIDATION_ERROR, APIH_REQUEST_VALIDATION_ERROR, APIH_SERVICE_VALIDATION_ERROR, APIH_GENERAL_EXCEPTION_ARG, APIH_GENERAL_EXCEPTION, APIH_GENERAL_WARNING, APIH_AUDIT_EXEC, APIH_GENERAL_METRICS, APIH_DUPLICATE_CHECK_EXC, APIH_DUPLICATE_FOUND, APIH_BAD_ORDER, APIH_DB_ATTRIBUTE_NOT_FOUND, APIH_BPEL_COMMUNICATE_ERROR, APIH_BPEL_RESPONSE_ERROR, APIH_WARP_REQUEST, APIH_ERROR_FROM_BPEL_SERVER, APIH_DB_INSERT_EXC, APIH_DB_UPDATE_EXC, APIH_NO_PROPERTIES, APIH_PROPERTY_LOAD_SUC, APIH_LOAD_PROPERTIES_FAIL, APIH_SDNC_COMMUNICATE_ERROR, APIH_SDNC_RESPONSE_ERROR, APIH_CANNOT_READ_SCHEMA, APIH_HEALTH_CHECK_EXCEPTION, APIH_REQUEST_VALIDATION_ERROR_REASON, APIH_JAXB_MARSH_ERROR, APIH_JAXB_UNMARSH_ERROR, APIH_VNFREQUEST_VALIDATION_ERROR, APIH_DOM2STR_ERROR, APIH_READ_VNFOUTPUT_CLOB_EXCEPTION, APIH_DUPLICATE_CHECK_EXC_ATT, APIH_GENERATED_REQUEST_ID, APIH_GENERATED_SERVICE_INSTANCE_ID, APIH_REPLACE_REQUEST_ID, + APIH_REQUEST_NULL, + APIH_QUERY_FOUND, + APIH_QUERY_NOT_FOUND, + APIH_QUERY_PARAM_WRONG, + APIH_DB_ACCESS_EXC, + APIH_DB_ACCESS_EXC_REASON, + APIH_VALIDATION_ERROR, + APIH_REQUEST_VALIDATION_ERROR, + APIH_SERVICE_VALIDATION_ERROR, + APIH_GENERAL_EXCEPTION_ARG, + APIH_GENERAL_EXCEPTION, + APIH_GENERAL_WARNING, + APIH_AUDIT_EXEC, + APIH_GENERAL_METRICS, + APIH_DUPLICATE_CHECK_EXC, + APIH_DUPLICATE_FOUND, + APIH_BAD_ORDER, + APIH_DB_ATTRIBUTE_NOT_FOUND, + APIH_BPEL_COMMUNICATE_ERROR, + APIH_BPEL_RESPONSE_ERROR, + APIH_WARP_REQUEST, + APIH_ERROR_FROM_BPEL_SERVER, + APIH_DB_INSERT_EXC, + APIH_DB_UPDATE_EXC, + APIH_NO_PROPERTIES, + APIH_PROPERTY_LOAD_SUC, + APIH_LOAD_PROPERTIES_FAIL, + APIH_SDNC_COMMUNICATE_ERROR, + APIH_SDNC_RESPONSE_ERROR, + APIH_CANNOT_READ_SCHEMA, + APIH_HEALTH_CHECK_EXCEPTION, + APIH_REQUEST_VALIDATION_ERROR_REASON, + APIH_JAXB_MARSH_ERROR, + APIH_JAXB_UNMARSH_ERROR, + APIH_VNFREQUEST_VALIDATION_ERROR, + APIH_DOM2STR_ERROR, + APIH_READ_VNFOUTPUT_CLOB_EXCEPTION, + APIH_DUPLICATE_CHECK_EXC_ATT, + APIH_GENERATED_REQUEST_ID, + APIH_GENERATED_SERVICE_INSTANCE_ID, + APIH_REPLACE_REQUEST_ID, // Resource Adapter Messages - RA_GENERAL_EXCEPTION_ARG, RA_GENERAL_EXCEPTION, RA_GENERAL_WARNING, RA_MISSING_PARAM, RA_AUDIT_EXEC, RA_GENERAL_METRICS, RA_CREATE_STACK_TIMEOUT, RA_DELETE_STACK_TIMEOUT, RA_UPDATE_STACK_TIMEOUT, RA_CONNECTION_EXCEPTION, RA_PARSING_ERROR, RA_PROPERTIES_NOT_FOUND, RA_LOAD_PROPERTIES_SUC, RA_NETWORK_ALREADY_EXIST, RA_UPDATE_NETWORK_ERR, RA_CREATE_STACK_ERR, RA_UPDATE_STACK_ERR, RA_CREATE_TENANT_ERR, RA_NETWORK_NOT_FOUND, RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, RA_CREATE_NETWORK_EXC, RA_NS_EXC, RA_PARAM_NOT_FOUND, RA_CONFIG_EXC, RA_UNKOWN_PARAM, RA_VLAN_PARSE, RA_DELETE_NETWORK_EXC, RA_ROLLBACK_NULL, RA_TENANT_NOT_FOUND, RA_QUERY_NETWORK_EXC, RA_CREATE_NETWORK_NOTIF_EXC, RA_ASYNC_ROLLBACK, RA_WSDL_NOT_FOUND, RA_WSDL_URL_CONVENTION_EXC, RA_INIT_NOTIF_EXC, RA_SET_CALLBACK_AUTH_EXC, RA_FAULT_INFO_EXC, RA_MARSHING_ERROR, RA_PARSING_REQUEST_ERROR, RA_SEND_REQUEST_SDNC, RA_RESPONSE_FROM_SDNC, RA_EXCEPTION_COMMUNICATE_SDNC, RA_EVALUATE_XPATH_ERROR, RA_ANALYZE_ERROR_EXC, RA_ERROR_GET_RESPONSE_SDNC, RA_CALLBACK_BPEL, RA_INIT_CALLBACK_WSDL_ERR, RA_CALLBACK_BPEL_EXC, RA_CALLBACK_BPEL_COMPLETE, RA_SDNC_MISS_CONFIG_PARAM, RA_SDNC_INVALID_CONFIG, RA_PRINT_URL, RA_ERROR_CREATE_SDNC_REQUEST, RA_ERROR_CREATE_SDNC_RESPONSE, RA_ERROR_CONVERT_XML2STR, RA_RECEIVE_SDNC_NOTIF, RA_INIT_SDNC_ADAPTER, RA_SEND_REQUEST_APPC_ERR, RA_SEND_REQUEST_SDNC_ERR, RA_RECEIVE_BPEL_REQUEST, RA_TENANT_ALREADY_EXIST, RA_UPDATE_TENANT_ERR, RA_DELETE_TEMAMT_ERR, RA_ROLLBACK_TENANT_ERR, RA_QUERY_VNF_ERR, RA_VNF_ALREADY_EXIST, RA_VNF_UNKNOWN_PARAM, RA_VNF_EXTRA_PARAM, RA_CREATE_VNF_ERR, RA_VNF_NOT_EXIST, RA_UPDATE_VNF_ERR, RA_DELETE_VNF_ERR, RA_ASYNC_CREATE_VNF, RA_SEND_VNF_NOTIF_ERR, RA_ASYNC_CREATE_VNF_COMPLETE, RA_ASYNC_UPDATE_VNF, RA_ASYNC_UPDATE_VNF_COMPLETE, RA_ASYNC_QUERY_VNF, RA_ASYNC_QUERY_VNF_COMPLETE, RA_ASYNC_DELETE_VNF, RA_ASYNC_DELETE_VNF_COMPLETE, RA_ASYNC_ROLLBACK_VNF, RA_ASYNC_ROLLBACK_VNF_COMPLETE, RA_ROLLBACK_VNF_ERR, RA_DB_INVALID_STATUS, RA_CANT_UPDATE_REQUEST, RA_DB_REQUEST_NOT_EXIST, RA_CONFIG_NOT_FOUND, RA_CONFIG_LOAD, RA_RECEIVE_WORKFLOW_MESSAGE, + RA_GENERAL_EXCEPTION_ARG, + RA_GENERAL_EXCEPTION, + RA_GENERAL_WARNING, + RA_MISSING_PARAM, + RA_AUDIT_EXEC, + RA_GENERAL_METRICS, + RA_CREATE_STACK_TIMEOUT, + RA_DELETE_STACK_TIMEOUT, + RA_UPDATE_STACK_TIMEOUT, + RA_CONNECTION_EXCEPTION, + RA_PARSING_ERROR, + RA_PROPERTIES_NOT_FOUND, + RA_LOAD_PROPERTIES_SUC, + RA_NETWORK_ALREADY_EXIST, + RA_UPDATE_NETWORK_ERR, + RA_CREATE_STACK_ERR, + RA_UPDATE_STACK_ERR, + RA_CREATE_TENANT_ERR, + RA_NETWORK_NOT_FOUND, + RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, + RA_CREATE_NETWORK_EXC, + RA_NS_EXC, + RA_PARAM_NOT_FOUND, + RA_CONFIG_EXC, + RA_UNKOWN_PARAM, + RA_VLAN_PARSE, + RA_DELETE_NETWORK_EXC, + RA_ROLLBACK_NULL, + RA_TENANT_NOT_FOUND, + RA_QUERY_NETWORK_EXC, + RA_CREATE_NETWORK_NOTIF_EXC, + RA_ASYNC_ROLLBACK, + RA_WSDL_NOT_FOUND, + RA_WSDL_URL_CONVENTION_EXC, + RA_INIT_NOTIF_EXC, + RA_SET_CALLBACK_AUTH_EXC, + RA_FAULT_INFO_EXC, + RA_MARSHING_ERROR, + RA_PARSING_REQUEST_ERROR, + RA_SEND_REQUEST_SDNC, + RA_RESPONSE_FROM_SDNC, + RA_EXCEPTION_COMMUNICATE_SDNC, + RA_EVALUATE_XPATH_ERROR, + RA_ANALYZE_ERROR_EXC, + RA_ERROR_GET_RESPONSE_SDNC, + RA_CALLBACK_BPEL, + RA_INIT_CALLBACK_WSDL_ERR, + RA_CALLBACK_BPEL_EXC, + RA_CALLBACK_BPEL_COMPLETE, + RA_SDNC_MISS_CONFIG_PARAM, + RA_SDNC_INVALID_CONFIG, + RA_PRINT_URL, + RA_ERROR_CREATE_SDNC_REQUEST, + RA_ERROR_CREATE_SDNC_RESPONSE, + RA_ERROR_CONVERT_XML2STR, + RA_RECEIVE_SDNC_NOTIF, + RA_INIT_SDNC_ADAPTER, + RA_SEND_REQUEST_APPC_ERR, + RA_SEND_REQUEST_SDNC_ERR, + RA_RECEIVE_BPEL_REQUEST, + RA_TENANT_ALREADY_EXIST, + RA_UPDATE_TENANT_ERR, + RA_DELETE_TEMAMT_ERR, + RA_ROLLBACK_TENANT_ERR, + RA_QUERY_VNF_ERR, + RA_VNF_ALREADY_EXIST, + RA_VNF_UNKNOWN_PARAM, + RA_VNF_EXTRA_PARAM, + RA_CREATE_VNF_ERR, + RA_VNF_NOT_EXIST, + RA_UPDATE_VNF_ERR, + RA_DELETE_VNF_ERR, + RA_ASYNC_CREATE_VNF, + RA_SEND_VNF_NOTIF_ERR, + RA_ASYNC_CREATE_VNF_COMPLETE, + RA_ASYNC_UPDATE_VNF, + RA_ASYNC_UPDATE_VNF_COMPLETE, + RA_ASYNC_QUERY_VNF, + RA_ASYNC_QUERY_VNF_COMPLETE, + RA_ASYNC_DELETE_VNF, + RA_ASYNC_DELETE_VNF_COMPLETE, + RA_ASYNC_ROLLBACK_VNF, + RA_ASYNC_ROLLBACK_VNF_COMPLETE, + RA_ROLLBACK_VNF_ERR, + RA_DB_INVALID_STATUS, + RA_CANT_UPDATE_REQUEST, + RA_DB_REQUEST_NOT_EXIST, + RA_CONFIG_NOT_FOUND, + RA_CONFIG_LOAD, + RA_RECEIVE_WORKFLOW_MESSAGE, // BPEL engine Messages - BPMN_GENERAL_INFO, BPMN_GENERAL_EXCEPTION_ARG, BPMN_GENERAL_EXCEPTION, BPMN_GENERAL_WARNING, BPMN_AUDIT_EXEC, BPMN_GENERAL_METRICS, BPMN_URN_MAPPING_FAIL, BPMN_VARIABLE_NULL, BPMN_CALLBACK_EXCEPTION, + BPMN_GENERAL_INFO, + BPMN_GENERAL_EXCEPTION_ARG, + BPMN_GENERAL_EXCEPTION, + BPMN_GENERAL_WARNING, + BPMN_AUDIT_EXEC, + BPMN_GENERAL_METRICS, + BPMN_URN_MAPPING_FAIL, + BPMN_VARIABLE_NULL, + BPMN_CALLBACK_EXCEPTION, // ASDC Messages - ASDC_GENERAL_EXCEPTION_ARG, ASDC_GENERAL_EXCEPTION, ASDC_GENERAL_WARNING, ASDC_GENERAL_INFO, ASDC_AUDIT_EXEC, ASDC_GENERAL_METRICS, ASDC_CREATE_SERVICE, ASDC_ARTIFACT_ALREADY_DEPLOYED, ASDC_CREATE_ARTIFACT, ASDC_ARTIFACT_INSTALL_EXC, ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, ASDC_ARTIFACT_CHECK_EXC, ASDC_INIT_ASDC_CLIENT_EXC, ASDC_INIT_ASDC_CLIENT_SUC, ASDC_LOAD_ASDC_CLIENT_EXC, ASDC_SINGLETON_CHECKT_EXC, ASDC_SHUTDOWN_ASDC_CLIENT_EXC, ASDC_CHECK_HEAT_TEMPLATE, ASDC_START_INSTALL_ARTIFACT, ASDC_ARTIFACT_TYPE_NOT_SUPPORT, ASDC_ARTIFACT_ALREADY_EXIST, ASDC_ARTIFACT_DOWNLOAD_SUC, ASDC_ARTIFACT_DOWNLOAD_FAIL, ASDC_START_DEPLOY_ARTIFACT, ASDC_SEND_NOTIF_ASDC, ASDC_SEND_NOTIF_ASDC_EXEC, ASDC_RECEIVE_CALLBACK_NOTIF, ASDC_RECEIVE_SERVICE_NOTIF, ASDC_ARTIFACT_NULL, ASDC_SERVICE_NOT_SUPPORT, ASDC_ARTIFACT_DEPLOY_SUC, ASDC_PROPERTIES_NOT_FOUND, ASDC_PROPERTIES_LOAD_SUCCESS, + ASDC_GENERAL_EXCEPTION_ARG, + ASDC_GENERAL_EXCEPTION, + ASDC_GENERAL_WARNING, + ASDC_GENERAL_INFO, + ASDC_AUDIT_EXEC, + ASDC_GENERAL_METRICS, + ASDC_CREATE_SERVICE, + ASDC_ARTIFACT_ALREADY_DEPLOYED, + ASDC_CREATE_ARTIFACT, + ASDC_ARTIFACT_INSTALL_EXC, + ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, + ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + ASDC_ARTIFACT_CHECK_EXC, + ASDC_INIT_ASDC_CLIENT_EXC, + ASDC_INIT_ASDC_CLIENT_SUC, + ASDC_LOAD_ASDC_CLIENT_EXC, + ASDC_SINGLETON_CHECKT_EXC, + ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + ASDC_CHECK_HEAT_TEMPLATE, + ASDC_START_INSTALL_ARTIFACT, + ASDC_ARTIFACT_TYPE_NOT_SUPPORT, + ASDC_ARTIFACT_ALREADY_EXIST, + ASDC_ARTIFACT_DOWNLOAD_SUC, + ASDC_ARTIFACT_DOWNLOAD_FAIL, + ASDC_START_DEPLOY_ARTIFACT, + ASDC_SEND_NOTIF_ASDC, + ASDC_SEND_NOTIF_ASDC_EXEC, + ASDC_RECEIVE_CALLBACK_NOTIF, + ASDC_RECEIVE_SERVICE_NOTIF, + ASDC_ARTIFACT_NULL, + ASDC_SERVICE_NOT_SUPPORT, + ASDC_ARTIFACT_DEPLOY_SUC, + ASDC_PROPERTIES_NOT_FOUND, + ASDC_PROPERTIES_LOAD_SUCCESS, // Default Messages, in case Log catalog is not defined - GENERAL_EXCEPTION_ARG, GENERAL_EXCEPTION, GENERAL_WARNING, AUDIT_EXEC, GENERAL_METRICS, LOGGER_SETUP, LOGGER_NOT_FOUND, LOGGER_UPDATE_SUC, LOGGER_UPDATE_DEBUG, LOGGER_UPDATE_DEBUG_SUC, LOAD_PROPERTIES_SUC, NO_PROPERTIES, MADATORY_PARAM_MISSING, LOAD_PROPERTIES_FAIL, INIT_LOGGER, INIT_LOGGER_FAIL, JAXB_EXCEPTION, IDENTITY_SERVICE_NOT_FOUND; + GENERAL_EXCEPTION_ARG, + GENERAL_EXCEPTION, + GENERAL_WARNING, + AUDIT_EXEC, + GENERAL_METRICS, + LOGGER_SETUP, + LOGGER_NOT_FOUND, + LOGGER_UPDATE_SUC, + LOGGER_UPDATE_DEBUG, + LOGGER_UPDATE_DEBUG_SUC, + LOAD_PROPERTIES_SUC, + NO_PROPERTIES, + MADATORY_PARAM_MISSING, + LOAD_PROPERTIES_FAIL, + INIT_LOGGER, + INIT_LOGGER_FAIL, + JAXB_EXCEPTION, + IDENTITY_SERVICE_NOT_FOUND; } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java index 9a184b0a51..34edf91c0c 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java @@ -20,9 +20,75 @@ package org.onap.so.serviceinstancebeans; +import java.lang.reflect.InvocationTargetException; +import com.google.common.base.CaseFormat; + /* * Enum for Model Type values returned by API Handler to BPMN */ public enum ModelType { - service, vnf, vfModule, volumeGroup, network, configuration, connectionPoint, pnf, networkInstanceGroup, instanceGroup + service("serviceInstance"), + vnf("vnf"), + vfModule("vfModule"), + volumeGroup("volumeGroup"), + network("network"), + configuration("configuration"), + connectionPoint("connectionPoint"), + pnf("pnf"), + networkInstanceGroup("networkInstanceGroup"), + instanceGroup("instanceGroup"); + + final String name; + + private ModelType(String name) { + this.name = name; + } + + + public <T> T getId(Object obj) { + return this.get(obj, "Id"); + } + + public <T> T getName(Object obj) { + return this.get(obj, "Name"); + } + + public void setId(Object obj, Object value) { + this.set(obj, "Id", value); + } + + public void setName(Object obj, Object value) { + this.set(obj, "Name", value); + } + + protected <T> T get(Object obj, String field) { + T result = null; + if (obj != null) { + try { + result = (T) obj.getClass().getMethod(String.format("%s%s%s", "get", + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.name), field)).invoke(obj); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { + // silent fail + } + } + + return result; + } + + protected void set(Object obj, String field, Object value) { + if (obj != null) { + try { + obj.getClass() + .getMethod( + String.format("%s%s%s", "set", + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.name), field), + value.getClass()) + .invoke(obj, value); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + // silent fail + } + } + } } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java index fbdb27c0ec..75a6ba8280 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java @@ -22,7 +22,6 @@ package org.onap.so.serviceinstancebeans; import java.util.ArrayList; import java.util.List; -import java.util.Map; import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -36,6 +35,7 @@ public class Request { protected String finishTime; protected String requestScope; protected String requestType; + protected String originalRequestId; protected RequestDetails requestDetails; protected InstanceReferences instanceReferences; protected RequestStatus requestStatus; @@ -124,6 +124,14 @@ public class Request { this.cloudRequestData = cloudRequestData; } + public String getOriginalRequestId() { + return originalRequestId; + } + + public void setOriginalRequestId(String originalRequestId) { + this.originalRequestId = originalRequestId; + } + @Override public String toString() { return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime) @@ -131,6 +139,6 @@ public class Request { .append("requestType", requestType).append("requestDetails", requestDetails) .append("instanceReferences", instanceReferences).append("requestStatus", requestStatus) .append("requestProcessingData", requestProcessingData).append("cloudRequestData", cloudRequestData) - .toString(); + .append("originalRequestId", originalRequestId).toString(); } } diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java index 5f87378b79..0c59887de7 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntity.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -23,7 +23,20 @@ package org.onap.so.utils; import java.util.EnumSet; public enum TargetEntity { - OPENSTACK_ADAPTER, BPMN, GRM, AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER, SNIRO, SDC, EXTERNAL, MULTICLOUD; + OPENSTACK_ADAPTER, + BPMN, + GRM, + AAI, + DMAAP, + POLICY, + CATALOG_DB, + REQUEST_DB, + VNF_ADAPTER, + SDNC_ADAPTER, + SNIRO, + SDC, + EXTERNAL, + MULTICLOUD; private static final String PREFIX = "SO"; diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java new file mode 100644 index 0000000000..e4b694cd15 --- /dev/null +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java @@ -0,0 +1,38 @@ +package org.onap.so.serviceinstancebeans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import org.junit.Test; + +public class ModelTypeTest { + + + + @Test + public void reflectionTest() { + TestServiceInstanceBean a = new TestServiceInstanceBean(); + TestServiceInstanceBean b = new TestServiceInstanceBean(); + + a.setServiceInstanceId("my-id-a"); + a.setServiceInstanceName("my-name-a"); + + b.setServiceInstanceId("my-id-b"); + b.setServiceInstanceName("my-name-b"); + + assertEquals("my-id-a", ModelType.service.getId(a)); + assertEquals("my-name-a", ModelType.service.getName(a)); + ModelType.service.setName(a, ModelType.service.getName(b)); + ModelType.service.setId(a, ModelType.service.getId(b)); + assertEquals("my-name-b", ModelType.service.getName(a)); + assertEquals("my-id-b", ModelType.service.getId(a)); + } + + @Test + public void testSilentFail() { + TestServiceInstanceBean a = new TestServiceInstanceBean(); + + a.setServiceInstanceId("my-id-a"); + a.setServiceInstanceName("my-name-a"); + assertNull(ModelType.service.get(a, "NoField")); + } +} diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java b/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java new file mode 100644 index 0000000000..b8cf6141e3 --- /dev/null +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java @@ -0,0 +1,24 @@ +package org.onap.so.serviceinstancebeans; + +public class TestServiceInstanceBean { + + private String serviceInstanceId; + private String serviceInstanceName; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + +} |