diff options
author | 2018-01-31 17:19:00 +0200 | |
---|---|---|
committer | 2018-01-31 17:19:00 +0200 | |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/main/java/org/onap/vid/mso | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/mso')
25 files changed, 3744 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java new file mode 100644 index 00000000..c197299f --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java @@ -0,0 +1,99 @@ +package org.onap.vid.mso; + +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.controller.OperationalEnvironmentController; +import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; +import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo; +import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails; +import org.onap.vid.mso.rest.Request; +import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.mso.rest.Task; + +import java.util.List; + +public interface MsoBusinessLogic { + + // this function should get params from tosca and send them to instance at mso, then return success response. + MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) throws Exception; + + MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) throws Exception; + + MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId)throws Exception; + + MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) throws Exception; + + MsoResponseWrapper getOrchestrationRequest(String requestId)throws Exception; + + MsoResponseWrapper getOrchestrationRequests(String filterString)throws Exception; + + List<Request> getOrchestrationRequestsForDashboard()throws Exception; + + List<Task> getManualTasksByRequestId(String originalRequestId)throws Exception; + + MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId)throws Exception; + + MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId)throws Exception; + + MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception; + + MsoResponseWrapper deleteConfiguration( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId) throws Exception; + + MsoResponseWrapper setConfigurationActiveStatus( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId, + boolean isActivate) throws Exception; + + MsoResponseWrapper setPortOnConfigurationStatus( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId, + boolean isEnable) throws Exception; + + RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details); + + String getOperationalEnvironmentActivationPath(OperationalEnvironmentActivateInfo details); + + RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentDeactivationRequestDetails(OperationalEnvironmentDeactivateInfo details); + + String getCloudResourcesRequestsStatusPath(String requestId); + + String getOperationalEnvironmentDeactivationPath(OperationalEnvironmentDeactivateInfo details); + + String getOperationalEnvironmentCreationPath(); + + RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId); + + MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception; + + MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate)throws Exception; + + RequestDetailsWrapper generateInPlaceMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception; + + RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception; +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java new file mode 100644 index 00000000..6ad6b5fd --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java @@ -0,0 +1,800 @@ +package org.onap.vid.mso; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.changeManagement.ChangeManagementRequest; +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.controller.OperationalEnvironmentController; +import org.onap.vid.domain.mso.RequestInfo; +import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; +import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo; +import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails; +import org.onap.vid.mso.rest.*; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.ws.rs.BadRequestException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; + +import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest; +import static org.onap.vid.controller.MsoController.*; +import static org.onap.vid.mso.MsoProperties.*; + +public class MsoBusinessLogicImpl implements MsoBusinessLogic { + + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + final static Pattern SOFTWARE_VERSION_PATTERN = Pattern.compile("^[A-Za-z0-9.\\-]+$"); + final static Pattern NUMBER_PATTERN = Pattern.compile("^[0-9]+$"); + private static final String ACTIVATE = "/activate"; + private static final String DEACTIVATE = "/deactivate"; + private static final String ENABLE_PORT = "/enablePort"; + private static final String DISABLE_PORT = "/disablePort"; + private final static String RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT = "operationalEnvironment"; + private final static String SOURCE_OPERATIONAL_ENVIRONMENT = "VID"; + final static private ObjectMapper objectMapper = new ObjectMapper(); + /** + * The Mso REST client + * This should be replaced with mso client factory. + */ + private final MsoInterface msoClientInterface; + /** + * The logger. + */ + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class); + + @Autowired + public MsoBusinessLogicImpl(MsoInterface msoClientInterface) { + this.msoClientInterface = msoClientInterface; + } + + static String validateEndpointPath(String endpointEnvVariable) { + String endpoint = SystemProperties.getProperty(endpointEnvVariable); + if (endpoint == null || endpoint.isEmpty()) { + throw new RuntimeException(endpointEnvVariable + " env variable is not defined"); + } + return endpoint; + } + + // this function should get params from tosca and send them to instance at mso, then return success response. + @Override + public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) throws Exception { + String methodName = "createSvcInstance "; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + return msoClientInterface.createSvcInstance(msoRequest, endpoint); + } + + void validateLineOfBusiness(RequestDetails requestDetails) { + + Object value = requestDetails.getAdditionalProperties(); + + for(String prop: ImmutableList.of("requestDetails", "lineOfBusiness", "lineOfBusinessName")) { + if(value==null ||!(value instanceof Map)) { + value = null; + break; + } + else { + value = ((Map)value).get(prop); + } + } + + if(value == null || value.toString().isEmpty()) { + throw new BadRequestException("lineOfBusiness is required"); + } + + } + + @Override + public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "createVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + return msoClientInterface.createVnf(requestDetails, vnf_endpoint); + } + + @Override + public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "createNwInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + return msoClientInterface.createNwInstance(requestDetails, nw_endpoint); + } + + @Override + public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "createVolumeGroupInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + + return msoClientInterface.createVolumeGroupInstance(requestDetails, vnf_endpoint); + } + + @Override + public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "createVfModuleInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + + return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint); + } + + @Override + public MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "createConfigurationInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS); + endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); + + return msoClientInterface.createConfigurationInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "deleteSvcInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String svc_endpoint = endpoint + "/" + serviceInstanceId; + + return msoClientInterface.deleteSvcInstance(requestDetails, svc_endpoint); + } + + @Override + public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "deleteVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + } catch (Exception exception) { + throw exception; + } + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId; + + return msoClientInterface.deleteVnf(requestDetails, vnf_endpoint); + } + + @Override + public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) throws Exception { + String methodName = "deleteVfModule"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + + String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId; + + return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint); + } + + @Override + public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) throws Exception { + String methodName = "deleteVolumeGroupInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId; + + return msoClientInterface.deleteVolumeGroupInstance(requestDetails, delete_volume_group_endpoint); + } + + @Override + public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) throws Exception { + String methodName = "deleteNwInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + } catch (Exception exception) { + throw exception; + } + + String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId; + + return msoClientInterface.deleteNwInstance(requestDetails, delete_nw_endpoint); + } + + @Override + public MsoResponseWrapper getOrchestrationRequest(String requestId) throws Exception { + String methodName = "getOrchestrationRequest"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + try { + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ); + String path = p + "/" + requestId; + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + + msoClientInterface.getOrchestrationRequest(str, "", path, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper getOrchestrationRequests(String filterString) throws Exception { + String methodName = "getOrchestrationRequest"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + try { + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); + String path = p + filterString; + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + + msoClientInterface.getOrchestrationRequest(str, "", path, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public List<Request> getOrchestrationRequestsForDashboard() throws Exception { + String methodName = "getOrchestrationRequestsForDashboard"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + List<Request> filteredOrchestrationRequests = new ArrayList<>(); + try { + String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); + path += "filter=modelType:EQUALS:vnf"; + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + + MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr); + List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity()); + + ; + for (RequestWrapper currentRequest : allOrchestrationRequests) { + if ((currentRequest.getRequest() != null) && (currentRequest.getRequest().getRequestScope() == Request.RequestScope.VNF) && ((currentRequest.getRequest().getRequestType() == + Request.RequestType.REPLACE_INSTANCE) || (currentRequest.getRequest().getRequestType() == + Request.RequestType.UPDATE_INSTANCE))) { + filteredOrchestrationRequests.add(currentRequest.getRequest()); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + } + return filteredOrchestrationRequests; + + } + + private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) throws Exception { + String methodName = "deserializeOrchestrationRequestsJson"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true); + RequestList requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class); + return requestList.getRequestList(); + } + + + @Override + public List<Task> getManualTasksByRequestId(String originalRequestId) throws Exception { + String methodName = "getManualTasksByRequestId"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); + String path = p + "?originalRequestId=" + originalRequestId; + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + + MsoResponseWrapper msoResponseWrapper = msoClientInterface.getManualTasksByRequestId(str, "", path, restObjStr); + return deserializeManualTasksJson(msoResponseWrapper.getEntity()); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + private List<Task> deserializeManualTasksJson(String manualTasksJson) throws Exception { + String methodName = "deserializeManualTasksJson"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + ObjectMapper mapper = new ObjectMapper(); + TaskList taskList = mapper.readValue(manualTasksJson, TaskList.class); + return taskList.getTaskList(); + } + + + @Override + public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) throws Exception { + String methodName = "completeManualTask"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + try { + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); + String path = p + "/" + taskId + "/complete"; + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + + msoClientInterface.completeManualTask(requestDetails, str, "", path, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "activateServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + try { + String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + "/activate"; + + RestObject<String> restObjStr = new RestObject<>(); + String str = ""; + restObjStr.set(str); + + msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", activateServicePath, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + + @Override + public MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "updateVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + } catch (Exception exception) { + throw exception; + } + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId; + return msoClientInterface.updateVnf(requestDetails, vnf_endpoint); + } + + @Override + public MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "replaceVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint; + try { + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + } catch (Exception exception) { + throw exception; + } + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); + vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, MsoChangeManagementRequest.REPLACE); + return msoClientInterface.replaceVnf(requestDetails, vnf_endpoint); + } + + public RequestDetailsWrapper generateInPlaceMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception { + validateUpdateVnfSoftwarePayload(requestDetails); + RequestDetails inPlaceSoftwareUpdateRequest = new RequestDetails(); + inPlaceSoftwareUpdateRequest.setCloudConfiguration(requestDetails.getCloudConfiguration()); + inPlaceSoftwareUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); + inPlaceSoftwareUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = inPlaceSoftwareUpdateRequest; + return requestDetailsWrapper; + } + + @Override + public RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception { + validateUpdateVnfConfig(requestDetails); + RequestDetails ConfigUpdateRequest = new RequestDetails(); + ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); + ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = ConfigUpdateRequest; + return requestDetailsWrapper; + } + + @Override + public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "updateVnfSoftware"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI + RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails); + return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); + } + + @Override + public MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception { + String methodName = "updateVnfConfig"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails); + String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE); + return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); + } + + private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) { + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); + vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType); + return vnf_endpoint; + } + + private Map getChangeManagementPayload(RequestDetails requestDetails, String message) throws Exception{ + if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){ + throw new BadRequestException(message); + } + Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); + try{ + return objectMapper.readValue((String)payloadRaw,Map.class); + } + catch(Exception exception){ + throw new BadRequestException(message); + } + } + + private void validateUpdateVnfSoftwarePayload(RequestDetails requestDetails) throws Exception { + final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE + " request"; + + Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); + validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "existing-software-version", SOFTWARE_VERSION_PATTERN); + validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "new-software-version", SOFTWARE_VERSION_PATTERN); + + //if "operations-timeout" is not integer, trying to read it as String that represent a number + if (!(payload.get("operations-timeout") instanceof Integer)) { + validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "operations-timeout", NUMBER_PATTERN); + } + + } + + private void validateUpdateVnfSoftwarePayloadProperty(Map payload, String noValidPayloadMsg, String propertyName, Pattern pattern) { + Object forValidation = payload.get(propertyName); + final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid"; + if (!(forValidation instanceof String)) { + throw new BadRequestException(noValidPayloadPropertyMsg); + } + if (!pattern.matcher((String) forValidation).matches()) { + throw new BadRequestException(noValidPayloadPropertyMsg); + } + } + + private void validateUpdateVnfConfig(RequestDetails requestDetails) throws Exception { + final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request"; + + Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters"); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters"); + } + + private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) { + Object forValidation = payload.get(propertyName); + final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid"; + if(!payload.containsKey(propertyName)) { + throw new BadRequestException( noValidPayloadPropertyMsg); + } + } + + @Override + public MsoResponseWrapper deleteConfiguration( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId) throws Exception { + + String methodName = "deleteConfiguration"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); + endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); + endpoint = endpoint.replace(CONFIGURATION_ID, configurationId); + + return msoClientInterface.deleteConfiguration(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper setConfigurationActiveStatus( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId, + boolean isActivate) throws Exception { + + String methodName = "setConfigurationActiveStatus"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); + endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); + endpoint = endpoint.replace(CONFIGURATION_ID, configurationId); + + String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE); + endpoint = endpoint + isActivateState; + + return msoClientInterface.setConfigurationActiveStatus(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate)throws Exception{ + String methodName = "setServiceInstanceStatus"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + try { + String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String endpoint = serviceEndpoint + "/" + serviceInstanceId; + + String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE); + endpoint = endpoint + isActivateState; + + + RestObject<String> restObjStr = new RestObject<>(); + String str = ""; + restObjStr.set(str); + + msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper setPortOnConfigurationStatus( + RequestDetails requestDetails, + String serviceInstanceId, + String configurationId, + boolean isEnable) throws Exception { + String methodName = "setPortOnConfigurationStatus"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); + endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); + endpoint = endpoint.replace(CONFIGURATION_ID, configurationId); + + String isEnablePortStatus = (isEnable ? ENABLE_PORT : DISABLE_PORT); + endpoint = endpoint + isEnablePortStatus; + + return msoClientInterface.setPortOnConfigurationStatus(requestDetails, endpoint); + } + + + @Override + public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) { + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT); + requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT); + requestInfo.setRequestorId(details.getUserId()); + requestDetails.setRequestInfo(requestInfo); + + org.onap.vid.domain.mso.RelatedInstance relatedInstance = new org.onap.vid.domain.mso.RelatedInstance(); + relatedInstance.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT); + relatedInstance.setInstanceId(details.getRelatedInstanceId()); + relatedInstance.setInstanceName(details.getRelatedInstanceName()); + requestDetails.setAdditionalProperty("relatedInstanceList", Collections.singletonList(ImmutableMap.of("relatedInstance", relatedInstance))); + + org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters(); + requestParameters.setUserParams(null); + requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF"); + requestParameters.setAdditionalProperty("workloadContext", details.getWorkloadContext()); + requestParameters.setAdditionalProperty("manifest", details.getManifest()); + requestDetails.setRequestParameters(requestParameters); + + RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails); + + debugRequestDetails(requestDetailsWrapper); + + return requestDetailsWrapper; + } + + @Override + public String getOperationalEnvironmentActivationPath(OperationalEnvironmentActivateInfo details) { + String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE); + path = path.replace("<operational_environment_id>", details.getOperationalEnvironmentId()); + return path; + } + + @Override + public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentDeactivationRequestDetails(OperationalEnvironmentDeactivateInfo details) { + RequestDetails requestDetails = new RequestDetails(); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT); + requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT); + requestInfo.setRequestorId(details.getUserId()); + requestDetails.setRequestInfo(requestInfo); + + org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters(); + requestParameters.setUserParams(null); + requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF"); + requestDetails.setRequestParameters(requestParameters); + RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails); + debugRequestDetails(requestDetailsWrapper); + return requestDetailsWrapper; + } + + @Override + public String getCloudResourcesRequestsStatusPath(String requestId) { + String path = validateEndpointPath(MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS); + path = path.replace("<request_id>", requestId); + return path; + } + + @Override + public String getOperationalEnvironmentDeactivationPath(OperationalEnvironmentDeactivateInfo details) { + String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE); + path = path.replace("<operational_environment_id>", details.getOperationalEnvironmentId()); + return path; + } + + private void debugRequestDetails(Object requestDetails) { + if (logger.isDebugEnabled()) { + String requestDetailsAsString; + try { + requestDetailsAsString = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(requestDetails); + } catch (JsonProcessingException e) { + requestDetailsAsString = "error: cannot stringify RequestDetails"; + } + logger.debug(EELFLoggerDelegate.debugLogger, "requestDetailsAsString: {}", requestDetailsAsString); + } + } + + @Override + public String getOperationalEnvironmentCreationPath() { + String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE); + return path; + } + + @Override + public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) { + OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo( + RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT, + input.getInstanceName(), + SOURCE_OPERATIONAL_ENVIRONMENT, + userId); + + OperationEnvironmentRequestDetails.RelatedInstance relatedInstance = new OperationEnvironmentRequestDetails.RelatedInstance( + RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT, + input.getEcompInstanceId(), + input.getEcompInstanceName()); + + List<OperationEnvironmentRequestDetails.RelatedInstance> relatedInstanceList = Collections.singletonList((relatedInstance)); + + OperationEnvironmentRequestDetails.RequestParameters requestParameters = new OperationEnvironmentRequestDetails.RequestParameters( + input.getOperationalEnvironmentType(), + input.getTenantContext(), + input.getWorkloadContext()); + + OperationEnvironmentRequestDetails requestDetails = new OperationEnvironmentRequestDetails(requestInfo, relatedInstanceList, requestParameters); + RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails); + debugRequestDetails(requestDetailsWrapper); + return requestDetailsWrapper; + } + + @Override + public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "removeRelationshipFromServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships"; + + return msoClientInterface.removeRelationshipFromServiceInstance(requestDetails, removeRelationshipsPath); + } + + @Override + public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception { + String methodName = "addRelationshipToServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships"; + + return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath); + } + + +}
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java new file mode 100644 index 00000000..2d09630f --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java @@ -0,0 +1,85 @@ +package org.onap.vid.mso; + +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.mso.rest.RequestDetails; + +/** + * Created by pickjonathan on 21/06/2017. + */ +public interface MsoInterface { + + /** + * This function will post MSO service with information about how to instantiate the requested service + * @param requestDetails The details about the service as they come from the web. + * @return MsoResponseWrapper containing information about the service instantiation + * --> success : see JSON at resources folder mso_create_instance_response. + * --> failure : would return 200 with failure data. + * @throws Exception + */ + MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + /** + * will create a virtual network function using MSO service. + * @param requestDetails - information about the vnf to create + * @return - the response body recived from MSO + * @throws Exception + */ + MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) throws Exception; + /** + * + * @param requestDetails + * @param path + * @return + * @throws Exception + */ + MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String path) throws Exception; + + /** + * + * @param requestDetails + * @return + * @throws Exception + */ + MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + void getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject) throws Exception; + + MsoResponseWrapper getOrchestrationRequestsForDashboard(String t , String sourceId , String endpoint , RestObject restObject) throws Exception; + + MsoResponseWrapper getManualTasksByRequestId(String t , String sourceId , String endpoint , RestObject restObject) throws Exception; + + MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) throws Exception; + + MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint) throws Exception; + + MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint) throws Exception; + + MsoResponseWrapper deleteConfiguration(RequestDetails requestDetails, String pmc_endpoint) throws Exception; + + MsoResponseWrapper setConfigurationActiveStatus(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails requestDetails, String endpoint) throws Exception; + + void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) throws Exception; + + MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) throws Exception; + + MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) throws Exception; +} + diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java new file mode 100644 index 00000000..607d8419 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +/** + * The Class MsoProperties. + */ +public class MsoProperties extends SystemProperties { + + /** The Constant MSO_SERVER_URL. */ + //VID Properties related to MSO + public static final String MSO_SERVER_URL = "mso.server.url"; + + /** The Constant MSO_DME2_SERVER_URL. */ + public static final String MSO_DME2_SERVER_URL = "mso.dme2.server.url"; + + /** The Constant MSO_DME2_CLIENT_TIMEOUT. */ + public static final String MSO_DME2_CLIENT_TIMEOUT = "mso.dme2.client.timeout"; + + /** The Constant MSO_DME2_CLIENT_READ_TIMEOUT. */ + public static final String MSO_DME2_CLIENT_READ_TIMEOUT = "mso.dme2.client.read.timeout"; + + /** The Constant MSO_SERVER_URL_DEFAULT. */ + public static final String MSO_SERVER_URL_DEFAULT= ""; + + /** The Constant MSO_POLLING_INTERVAL_MSECS. */ + // number of msecs to wait between polling requests + public static final String MSO_POLLING_INTERVAL_MSECS = "mso.polling.interval.msecs"; + + /** The Constant MSO_POLLING_INTERVAL_MSECS_DEFAULT. */ + public static final String MSO_POLLING_INTERVAL_MSECS_DEFAULT = "60000"; + + /** The Constant MSO_DME2_ENABLED. */ + public static final String MSO_DME2_ENABLED = "mso.dme2.enabled"; + + /** The Constant MSO_MAX_POLLS. */ + public static final String MSO_MAX_POLLS = "mso.max.polls"; + + /** The Constant MSO_MAX_POLLS_DEFAULT. */ + public static final String MSO_MAX_POLLS_DEFAULT = "10"; //10 + + /** The Constant MSO_USER_NAME. */ + public static final String MSO_USER_NAME = "mso.user.name"; //m03346 + + /** The Constant MSO_PASSWORD. */ + public static final String MSO_PASSWORD = "mso.password.x"; + + /** The Constant MSO_REST_API_SVC_INSTANCE. */ + public static final String MSO_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance"; // /serviceInstances/v2 + + /** The Constant MSO_REST_API_VNF_INSTANCE. */ + public static final String MSO_REST_API_VNF_INSTANCE = "mso.restapi.vnf.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs + + /** The Constant MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE. */ + public static final String MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE = "mso.restapi.vnf.changemanagement.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs/{request_type} + + /** The Constant MSO_REST_API_NETWORK_INSTANCE. */ + public static final String MSO_REST_API_NETWORK_INSTANCE = "mso.restapi.network.instance"; // /serviceInstances/v2/{serviceInstanceId}/networks + + /** The Constant MSO_REST_API_GET_ORC_REQ. */ + public static final String MSO_REST_API_GET_ORC_REQ = "mso.restapi.get.orc.req"; + + /** The Constant MSO_REST_API_GET_ORC_REQS. */ + public static final String MSO_REST_API_GET_ORC_REQS = "mso.restapi.get.orc.reqs"; + + /** The Constant MSO_REST_API_GET_MAN_TASK. */ + public static final String MSO_REST_API_GET_MAN_TASKS = "mso.restapi.get.man.tasks"; + + /** The Constant MSO_REST_API_VF_MODULE_INSTANCE. */ + public static final String MSO_REST_API_VF_MODULE_INSTANCE = "mso.restapi.vf.module.instance"; + + /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */ + public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; //serviceInstances/v2/{serviceInstanceId}/volumeGroups + + /** The Constant MSO_REST_API_CONFIGURATION_INSTANCE. */ + public static final String MSO_REST_API_CONFIGURATIONS = "mso.restapi.configurations"; //serviceInstances/v5/{serviceInstanceId}/configurations/ + public static final String MSO_REST_API_CONFIGURATION_INSTANCE = "mso.restapi.configuration.instance"; //serviceInstances/v5/{serviceInstanceId}/configurations/{configurationId} + + /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT */ + public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE = "mso.restapi.operationalEnvironment.activate"; + public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE = "mso.restapi.operationalEnvironment.deactivate"; + + /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE */ + public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE = "mso.restapi.operationalEnvironment.create"; + + /** The Constant MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS */ + public static final String MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS = "mso.restapi.operationalEnvironment.cloudResourcesRequests.status"; + + /** The logger. */ + public EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoProperties.class); + + /** The Constant dateFormat. */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java new file mode 100644 index 00000000..b890114b --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import javax.ws.rs.core.Response; + +/** + * This wrapper encapsulates the MSO response in the format expected by the pages. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "status", + "entity" +}) + +public class MsoResponseWrapper implements MsoResponseWrapperInterface { + + + public MsoResponseWrapper() { + } + + public MsoResponseWrapper(Response response) { + setEntity(response.readEntity(String.class)); + setStatus(response.getStatus()); + } + + + /** The status. */ + @JsonProperty("status") + private int status; + + /** The entity. */ + @JsonProperty("entity") + private String entity; + + /** + * Gets the entity. + * + * @return the entity + */ + @Override + @JsonProperty("entity") + public String getEntity() { + return entity; + } + + /** + * Gets the status. + * + * @return the status + */ + @Override + @JsonProperty("status") + public int getStatus() { + return status; + } + + /** + * Sets the status. + * + * @param v the new status + */ + @JsonProperty("status") + public void setStatus(int v) { + this.status = v; + } + + /** + * Sets the entity. + * + * @param v the new entity + */ + @JsonProperty("entity") + public void setEntity(String v) { + this.entity = v; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /** + * Gets the response. + * + * @return the response + */ + @org.codehaus.jackson.annotate.JsonIgnore + @com.fasterxml.jackson.annotation.JsonIgnore + public String getResponse () { + + StringBuilder b = new StringBuilder ("{ \"status\": "); + b.append(getStatus()).append(", \"entity\": " ); + if (this.getEntity() == null || this.getEntity().isEmpty()) { + b.append("\"\""); + } else { + b.append(this.getEntity()); + } + b.append("}"); + return (b.toString()); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java new file mode 100644 index 00000000..5a73a048 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java @@ -0,0 +1,60 @@ +package org.onap.vid.mso; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@JsonPropertyOrder({ + "status", + "entity" +}) + +/* +This is a brother of MsoResponseWrapper. I (Ittay) think it's better. +It is generic, immutable, and has some knowledge about RestObject. +The serialized "entity" field may be either String or nested object. + */ +public class MsoResponseWrapper2<T> implements MsoResponseWrapperInterface { + + final static ObjectMapper objectMapper = new ObjectMapper(); + + private final int status; + private final T entity; + private final String raw; + + public MsoResponseWrapper2(RestObject<T> msoResponse) { + this.status = msoResponse.getStatusCode(); + this.entity = msoResponse.get(); + this.raw = msoResponse.getRaw(); + } + + public MsoResponseWrapper2( + @JsonProperty(value = "status", required = true) int status, + @JsonProperty(value = "entity", required = true) T entity) { + this.status = status; + this.entity = entity; + this.raw = null; + } + + public int getStatus() { + return status; + } + + @Override + @org.codehaus.jackson.annotate.JsonIgnore + @com.fasterxml.jackson.annotation.JsonIgnore + public String getResponse() { + try { + return objectMapper.writeValueAsString(this); + } catch (JsonProcessingException e) { + return getEntity() != null ? getEntity().toString() : null; + } + } + + @JsonProperty + public Object getEntity() { + return entity != null ? entity : raw; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java new file mode 100644 index 00000000..ad251bde --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java @@ -0,0 +1,15 @@ +package org.onap.vid.mso; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public interface MsoResponseWrapperInterface { + @JsonProperty("entity") + Object getEntity(); + + @JsonProperty("status") + int getStatus(); + + @org.codehaus.jackson.annotate.JsonIgnore + @com.fasterxml.jackson.annotation.JsonIgnore + String getResponse(); +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java new file mode 100644 index 00000000..eae705ab --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.glassfish.jersey.client.ClientResponse; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +import static org.onap.vid.utils.Logging.getMethodName; + +/** + * The Class MsoUtil. + */ +public class MsoUtil { + + /** The logger. */ + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoUtil.class); + + /** The Constant dateFormat. */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + + /** + * Wrap response. + * + * @param body the body + * @param statusCode the status code + * @return the mso response wrapper + */ + public static MsoResponseWrapper wrapResponse ( String body, int statusCode ) { + + MsoResponseWrapper w = new MsoResponseWrapper(); + w.setStatus (statusCode); + w.setEntity(body); + + return w; + } + + /** + * Wrap response. + * + * @param cres the cres + * @return the mso response wrapper + */ + public static MsoResponseWrapper wrapResponse (ClientResponse cres) { + String resp_str = ""; + if ( cres != null ) { + resp_str = cres.readEntity(String.class); + } + int statuscode = cres.getStatus(); + MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, statuscode ); + return (w); + } + + /** + * Wrap response. + * + * @param rs the rs + * @return the mso response wrapper + */ + public static MsoResponseWrapper wrapResponse (RestObject<String> rs) { + String resp_str = null; + int status = 0; + if ( rs != null ) { + resp_str = rs.get() != null ? rs.get() : rs.getRaw(); + status = rs.getStatusCode(); + } + MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, status ); + return (w); + } + + /** + * Convert pojo to string. + * + * @param <T> the generic type + * @param t the t + * @return the string + * @throws JsonProcessingException the json processing exception + */ + public static <T> String convertPojoToString ( T t ) { + + String methodName = "convertPojoToString"; + ObjectMapper mapper = new ObjectMapper(); + String r_json_str = ""; + if ( t != null ) { + try { + r_json_str = mapper.writeValueAsString(t); + } + catch ( com.fasterxml.jackson.core.JsonProcessingException j ) { + logger.debug(EELFLoggerDelegate.debugLogger,getMethodName() + " Unable to parse object of type " + t.getClass().getName() + " as json", j); + } + } + return (r_json_str); + } + + /** + * The main method. + * + * @param args the arguments + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java new file mode 100644 index 00000000..8cee23b4 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java @@ -0,0 +1,380 @@ +package org.onap.vid.mso; + +import com.att.eelf.configuration.EELFLogger; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.codec.binary.Base64; +import org.eclipse.jetty.util.security.Password; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.client.HttpBasicClient; +import org.onap.vid.client.HttpsBasicClient; +import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.mso.rest.RestInterface; +import org.onap.vid.utils.Logging; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.Response; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; + +import static org.onap.vid.utils.Logging.*; + +/** + * Created by pickjonathan on 26/06/2017. + */ +public class RestMsoImplementation implements RestInterface { + + /** + * The logger. + */ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMsoImplementation.class); + final private EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("mso"); + + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + + /** The client. */ + private static Client client = null; + + /** The common headers. */ + //private MultivaluedHashMap<String, Object> commonHeaders; + /** + * Instantiates a new mso rest interface. + */ + + @SuppressWarnings("Duplicates") + @Override + public MultivaluedHashMap<String, Object> initMsoClient() + { + final String methodname = "initRestClient()"; + + final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME); + final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD); + final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL); + final String decrypted_password = Password.deobfuscate(password); + + String authString = username + ":" + decrypted_password; + + byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); + String authStringEnc = new String(authEncBytes); + + MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap(); + commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc))); + commonHeaders.put(requestIdHeaderKey, Collections.singletonList(getHttpServletRequest().getHeader(requestIdHeaderKey))); + //Pass calling application identifier to SO + commonHeaders.put("X-FromAppId", Collections.singletonList(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME))); + + boolean use_ssl = true; + if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) { + if ( mso_url.startsWith("https")) { + use_ssl = true; + } + else { + use_ssl = false; + } + } + if (client == null) { + + try { + if ( use_ssl ) { + //logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " getting HttpsBasicClient with username=" + username + // + " password=" + password); + client = HttpsBasicClient.getClient(); + } + else { + //logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " getting HttpsBasicClient with username=" + username + // + " password=" + password); + client = HttpBasicClient.getClient(); + } + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " Unable to get the SSL client"); + } + } + + return commonHeaders; + } + + public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception { + String methodName = "Get"; + + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start"); + + String url=""; + restObject.set(t); + + url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); + final Response cres = client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders) + .get(); + Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres); + int status = cres.getStatus(); + restObject.setStatusCode (status); + + if (status == 200 || status == 202) { + t = (T) cres.readEntity(t.getClass()); + restObject.set(t); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!"); + + } else { + throw new Exception(methodName + " with status="+ status + ", url= " + url ); + } + + logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status ); + + return; + } + + public <T> RestObject<T> GetForObject(String sourceID, String path, Class<T> clazz) throws Exception { + final String methodName = getMethodName(); + logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {})", getMethodCallerName(), methodName, sourceID, path, clazz); + + String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url); + + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); + final Response cres = client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders) + .get(); + Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres); + final RestObject<T> restObject = cresToRestObject(cres, clazz); + int status = cres.getStatus(); + + if (status == 200 || status == 202) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url); + } + + logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status ); + + return restObject; + } + + @Override + public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) { + + String methodName = "Delete"; + String url=""; + Response cres = null; + + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + + url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r); + cres = client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders) + //.entity(r) + .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke(); + Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres); + int status = cres.getStatus(); + restObject.setStatusCode (status); + + if (status == 404) { // resource not found + String msg = "Resource does not exist...: " + cres.getStatus(); + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg); + } else if (status == 200 || status == 204){ + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted"); + } else if (status == 202) { + String msg = "Delete in progress: " + status; + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg); + } + else { + String msg = "Deleting Resource failed: " + status; + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg); + } + + try { + t = (T) cres.readEntity(t.getClass()); + restObject.set(t); + } + catch ( Exception e ) { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e=" + + e.getMessage()); + } + + } + catch (Exception e) + { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString()); + throw e; + + } + } + + public <T> RestObject<T> PostForObject(Object requestDetails, String sourceID, String path, Class<T> clazz) throws RuntimeException { + logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), requestDetails, sourceID, path, clazz); + RestObject<T> restObject = new RestObject<>(); + Post(clazz, requestDetails, sourceID, path, restObject); + return restObject; + } + + @Override + public <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject) throws RuntimeException { + logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), t.getClass(), r, sourceID, path); + Post(t.getClass(), r, sourceID, path, restObject); + } + + public Invocation.Builder prepareClient(String path, String methodName) { + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + + String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url); + // Change the content length + return client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders); + } + + + + public <T> void Post(Class<?> tClass, Object requestDetails, String sourceID, String path, RestObject<T> restObject) throws RuntimeException { + String methodName = "Post"; + String url=""; + + try { + + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + + url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, requestDetails); + // Change the content length + final Response cres = client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders) + .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON)); + Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres); + + final RestObject<T> cresToRestObject = cresToRestObject(cres, tClass); + restObject.set(cresToRestObject.get()); + restObject.setStatusCode(cresToRestObject.getStatusCode()); + restObject.setRaw(cresToRestObject.getRaw()); + + int status = cres.getStatus(); + restObject.setStatusCode (status); + + if ( status >= 200 && status <= 299 ) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + + } else { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url); + } + + } catch (Exception e) + { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString()); + throw e; + + } + + logger.debug(EELFLoggerDelegate.debugLogger, "end {}() => ({}){}", getMethodName(), tClass, restObject); + } + + private <T> RestObject<T> cresToRestObject(Response cres, Class<?> tClass) { + RestObject<T> restObject = new RestObject<>(); + + String rawEntity = null; + try { + cres.bufferEntity(); + rawEntity = cres.readEntity(String.class); + T t = (T) new ObjectMapper().readValue(rawEntity, tClass); + restObject.set(t); + } + catch ( Exception e ) { + try { + restObject.setRaw(rawEntity); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e=" + + e.getMessage() + ", Entity=" + rawEntity); + } catch (Exception e2) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " No response entity, this is probably ok, e=" + + e.getMessage()); + } + } + + int status = cres.getStatus(); + restObject.setStatusCode (status); + + return restObject; + + } + + @Override + public <T> void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject) throws Exception { + + String methodName = "Put"; + String url=""; + + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start"); + +// logRequest (r); + try { + + MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); + + url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r); + // Change the content length + final Response cres = client.target(url) + .request() + .accept("application/json") + .headers(commonHeaders) + //.header("content-length", 201) + //.header("X-FromAppId", sourceID) + .put(Entity.entity(r, MediaType.APPLICATION_JSON)); + + Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres); + + try { + t = (T) cres.readEntity(t.getClass()); + restObject.set(t); + } + catch ( Exception e ) { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e=" + + e.getMessage()); + } + + int status = cres.getStatus(); + restObject.setStatusCode (status); + + if ( status >= 200 && status <= 299 ) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + + } else { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url); + } + + } catch (Exception e) + { + logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString()); + throw e; + + } + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java new file mode 100644 index 00000000..4e2bea05 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.MoreObjects; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +import javax.ws.rs.core.Response; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static org.onap.vid.utils.Logging.getMethodCallerName; + +/** + * The Class RestObject. + * + * @param <T> the generic type + */ +public class RestObject<T> { + + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + + final static ObjectMapper objectMapper = new ObjectMapper(); + + /** + * Generic version of the RestObject class. + * + */ + // T stands for "Type" + private T t; + + // The string source of t, if available + private String rawT; + + /** The status code. */ + private int statusCode= 0; + + public RestObject() { + } + + public RestObject(Response cres, Class<?> tClass, EELFLoggerDelegate logger) { + + String rawEntity = null; + try { + cres.bufferEntity(); + rawEntity = cres.readEntity(String.class); + T t = (T) objectMapper.readValue(rawEntity, tClass); + this.set(t); + } + catch ( Exception e ) { + try { + this.setRaw(rawEntity); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e=" + + e.getMessage() + ", Entity=" + rawEntity); + } catch (Exception e2) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " No response entity, this is probably ok, e=" + + e.getMessage()); + } + } + + int status = cres.getStatus(); + this.setStatusCode (status); + } + + + /** + * Sets the. + * + * @param t the t + */ + public void set(T t) { this.t = t; } + + /** + * Gets the. + * + * @return the t + */ + public T get() { return t; } + + /** + * Sets the status code. + * + * @param v the new status code + */ + public void setStatusCode(int v) { this.statusCode = v; } + + /** + * Gets the status code. + * + * @return the status code + */ + public int getStatusCode() { return this.statusCode; } + + public String getRaw() { + return rawT; + } + + public void setRaw(String rawT) { + this.rawT = rawT; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("t", t) + .add("rawT", rawT) + .add("statusCode", statusCode) + .toString(); + } +} + diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java new file mode 100644 index 00000000..bca643a6 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java @@ -0,0 +1,33 @@ +package org.onap.vid.mso.model; + +import com.google.common.base.MoreObjects; +import org.onap.vid.controller.OperationalEnvironmentController; + +public class OperationalEnvironmentActivateInfo extends OperationalEnvironmentController.OperationalEnvironmentActivateBody { + private final String userId; + private final String operationalEnvironmentId; + + public OperationalEnvironmentActivateInfo(OperationalEnvironmentController.OperationalEnvironmentActivateBody o, String userId, String operationalEnvironmentId) { + super(o.getRelatedInstanceId(), o.getRelatedInstanceName(), o.getWorkloadContext(), o.getManifest()); + + this.userId = userId; + this.operationalEnvironmentId = operationalEnvironmentId; + } + + public String getUserId() { + return userId; + } + + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("operationalEnvironmentId", operationalEnvironmentId) + .add("userId", userId) + .add("super", super.toString()) + .toString(); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java new file mode 100644 index 00000000..1a756eda --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java @@ -0,0 +1,29 @@ +package org.onap.vid.mso.model; + +import com.google.common.base.MoreObjects; + +public class OperationalEnvironmentDeactivateInfo { + private final String userId; + private final String operationalEnvironmentId; + + public OperationalEnvironmentDeactivateInfo(String userId, String operationalEnvironmentId) { + this.userId = userId; + this.operationalEnvironmentId = operationalEnvironmentId; + } + + public String getUserId() { + return userId; + } + + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("operationalEnvironmentId", operationalEnvironmentId) + .add("userId", userId) + .toString(); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java new file mode 100644 index 00000000..f47e16fe --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +//import java.util.HashMap; +//import java.util.Map; +//import javax.annotation.Generated; + +import org.onap.vid.domain.mso.InstanceIds; +import org.onap.vid.domain.mso.RequestStatus; +//import com.fasterxml.jackson.annotation.JsonAnyGetter; +//import com.fasterxml.jackson.annotation.JsonAnySetter; +//import com.fasterxml.jackson.annotation.JsonCreator; +//import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +//import com.fasterxml.jackson.annotation.JsonPropertyOrder; +//import com.fasterxml.jackson.annotation.JsonValue; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * request structure. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) + +public class AsyncRequestStatus extends org.onap.vid.domain.mso.AsyncRequestStatus { + + + /** The instance ids. */ + private InstanceIds instanceIds; + + /** The request status. */ + private RequestStatus requestStatus; + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#getInstanceIds() + */ + public InstanceIds getInstanceIds() { + return instanceIds; + } + + /** + * Sets the instance ids. + * + * @param instanceIds the new instance ids + */ + public void setInstanceIds(InstanceIds instanceIds) { + this.instanceIds = instanceIds; + } + + + /** + * (Required). + * + * @return The requestStatus + */ + @JsonProperty("requestStatus") + public RequestStatus getRequestStatus() { + return requestStatus; + } + + /** + * (Required). + * + * @param requestStatus The requestStatus + */ + @JsonProperty("requestStatus") + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#hashCode() + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(getCorrelator()).append(getFinishTime()).append(instanceIds).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode(); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof AsyncRequestStatus) == false) { + return false; + } + AsyncRequestStatus rhs = ((AsyncRequestStatus) other); + return new EqualsBuilder().append(getCorrelator(), rhs.getCorrelator()).append(getFinishTime(), rhs.getFinishTime()).append(instanceIds, rhs.instanceIds).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals(); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java new file mode 100644 index 00000000..9bb54035 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java @@ -0,0 +1,435 @@ +package org.onap.vid.mso.rest; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.vid.changeManagement.MsoRequestDetails; +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.model.RequestReferencesContainer; +import org.onap.vid.mso.*; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + + +/** + * Created by pickjonathan on 21/06/2017. + */ +public class MsoRestClientNew extends RestMsoImplementation implements MsoInterface { + + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + private final String ORIGINAL_REQUEST_ID = "originalRequestId"; + /** + * The logger. + */ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class); + + @Override + public MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "createSvcInstance "; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) throws Exception { + + String methodName = "createVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) throws Exception { + + String methodName = "createNwInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "createVolumeGroupInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "createVfModuleInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "createConfigurationInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return createInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "deleteSvcInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "deleteVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "deleteVfModule"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "deleteVolumeGroupInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "deleteNwInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, endpoint); + } + + @Override + public void getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject) throws Exception { + Get(t, sourceId, endpoint, restObject); + } + + public void getManualTasks(String t, String sourceId, String endpoint, RestObject restObject) throws Exception { + Get(t, sourceId, endpoint, restObject); + } + + + public MsoResponseWrapper createInstance(RequestDetails request, String path) throws Exception { + String methodName = "createInstance"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + RestObject<String> restObjStr = new RestObject<String>(); + + String str = new String(); + + restObjStr.set(str); + + Post(str, request, "", path, restObjStr); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr); + + return w; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + + /** + * Delete instance. + * + * @param request the request + * @param path the path + * @return the mso response wrapper + * @throws Exception the exception + */ + public MsoResponseWrapper deleteInstance(RequestDetails request, String path) throws Exception { + String methodName = "deleteInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + Delete(str, request, "", path, restObjStr); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + return w; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + + } + + public MsoResponseWrapper getOrchestrationRequestsForDashboard(String t, String sourceId, String endpoint, RestObject restObject) throws Exception { + String methodName = "getOrchestrationRequestsForDashboard"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + getOrchestrationRequest(t, sourceId, endpoint, restObject); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObject); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + + return w; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) throws Exception { + String methodName = "getManualTasksByRequestId"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + getManualTasks(t, sourceId, endpoint, restObject); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObject); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + + return MsoUtil.wrapResponse(restObject); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + + @Override + public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) throws Exception { + String methodName = "completeManualTask"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Complete "); + try { + + Post(t, requestDetails, sourceId, endpoint, restObject); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObject); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + return w; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "replaceVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + return replaceInstance(requestDetails, endpoint); + } + + @Override + public MsoResponseWrapper deleteConfiguration(RequestDetails requestDetails, String pmc_endpoint) + throws Exception { + String methodName = "deleteConfiguration"; + logger.debug(EELFLoggerDelegate.debugLogger, + dateFormat.format(new Date()) + "<== " + methodName + " start"); + + return deleteInstance(requestDetails, pmc_endpoint); + } + + @Override + public MsoResponseWrapper setConfigurationActiveStatus(RequestDetails request, String path) throws Exception { + String methodName = "setConfigurationActiveStatus"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling change configuration active status, path =[" + path + "]"); + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + Post(str, request, "", path, restObjStr); + MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr); + + return msoResponseWrapperObject; + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails request, String path) throws Exception { + String methodName = "setPortOnConfigurationStatus"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling change port configuration status, path =[" + path + "]"); + + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + Post(str, request, "", path, restObjStr); + MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr); + + return msoResponseWrapperObject; + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) throws Exception { + RestObject<RequestReferencesContainer> msoResponse = PostForObject(requestDetails, "", endpoint, RequestReferencesContainer.class); + return new MsoResponseWrapper2<>(msoResponse); + } + + public MsoResponseWrapper replaceInstance(org.onap.vid.changeManagement.RequestDetails request, String path) throws Exception { + String methodName = "replaceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Replace VNF, path =[" + path + "]"); + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = new MsoRequestDetails(request); + + Post(str, requestDetailsWrapper, "", path, restObjStr); + MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr); + int status = msoResponseWrapperObject.getStatus(); + if (status == 202) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + + ",post succeeded, msoResponseWrapperObject response:" + msoResponseWrapperObject.getResponse()); + } else { + logger.error(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + + ": post failed, msoResponseWrapperObject status" + status + ", response:" + msoResponseWrapperObject.getResponse()); + + // TODO + } + return msoResponseWrapperObject; + + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + + } + + @Override + public MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "updateVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + RequestDetailsWrapper wrapper = new RequestDetailsWrapper(); + wrapper.requestDetails = new MsoRequestDetails(requestDetails); + return updateInstance(requestDetails, endpoint); + } + + public MsoResponseWrapper updateInstance(org.onap.vid.changeManagement.RequestDetails request, String path) throws Exception { + String methodName = "updateInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); + RestObject<String> restObjStr = new RestObject<String>(); + String str = new String(); + restObjStr.set(str); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = new MsoRequestDetails(request); + Put(str, requestDetailsWrapper, "", path, restObjStr); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + return w; + + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + + } + + public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) throws Exception { + String methodName = "activateServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start "); + try { + + Post(t, requestDetails, sourceId, endpoint, restObject); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObject); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w =" + w.getResponse()); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) throws Exception { + String methodName = "removeRelationshipFromServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]"); + + RestObject<String> restObjStr = new RestObject<String>(); + String str = ""; + restObjStr.set(str); + Post(str, requestDetails, "", endpoint, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + + @Override + public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) throws Exception { + String methodName = "addRelationshipToServiceInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]"); + + RestObject<String> restObjStr = new RestObject<>(); + restObjStr.set(""); + Post("", requestDetails, "", addRelationshipsPath, restObjStr); + + return MsoUtil.wrapResponse(restObjStr); + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + throw e; + } + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java new file mode 100644 index 00000000..2f6d233c --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java @@ -0,0 +1,120 @@ +package org.onap.vid.mso.rest.OperationalEnvironment; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.List; + +public class OperationEnvironmentRequestDetails { + private final RequestInfo requestInfo; + private final List<RelatedInstance> relatedInstanceList; + private final RequestParameters requestParameters; + + public OperationEnvironmentRequestDetails(@JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo, + @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList, + @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters) { + this.requestInfo = requestInfo; + this.relatedInstanceList = relatedInstanceList; + this.requestParameters = requestParameters; + } + + public RequestInfo getRequestInfo() { + return requestInfo; + } + + public List<RelatedInstance> getRelatedInstanceList() { + return relatedInstanceList; + } + + public RequestParameters getRequestParameters() { + return requestParameters; + } + + public static class RequestInfo { + private final String resourceType; + private final String instanceName; + private final String source; + private final String requestorId; + + public RequestInfo(@JsonProperty(value = "resourceType", required = true) String resourceType, + @JsonProperty(value = "instanceName", required = true) String instanceName, + @JsonProperty(value = "source", required = true) String source, + @JsonProperty(value = "requestorId", required = true) String requestorId) { + this.resourceType = resourceType; + this.instanceName = instanceName; + this.source = source; + this.requestorId = requestorId; + } + + public String getResourceType() { + return resourceType; + } + + public String getInstanceName() { + return instanceName; + } + + public String getSource() { + return source; + } + + public String getRequestorId() { + return requestorId; + } + } + + public static class RequestParameters { + private final String operationalEnvironmentType; + private final String tenantContext; + private final String workloadContext; + + public RequestParameters(@JsonProperty(value = "operationalEnvironmentType", required = true) String operationalEnvironmentType, + @JsonProperty(value = "tenantContext", required = true) String tenantContext, + @JsonProperty(value = "workloadContext", required = true) String workloadContext) { + this.operationalEnvironmentType = operationalEnvironmentType; + this.tenantContext = tenantContext; + this.workloadContext = workloadContext; + } + public String getOperationalEnvironmentType() { + return operationalEnvironmentType; + } + + public String getTenantContext() { + return tenantContext; + } + + public String getWorkloadContext() { + return workloadContext; + } + } + + @JsonTypeName("relatedInstance") + @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) + public static class RelatedInstance { + private final String resourceType; + private final String instanceId; + private final String instanceName; + + public String getResourceType() { + return resourceType; + } + + public String getInstanceId() { + return instanceId; + } + + public String getInstanceName() { + return instanceName; + } + + public RelatedInstance(@JsonProperty(value = "instanceName", required = true) String resourceType, + @JsonProperty(value = "instanceId", required = true) String instanceId, + @JsonProperty(value = "instanceName", required = true) String instanceName) { + this.resourceType = resourceType; + this.instanceId = instanceId; + this.instanceName = instanceName; + } + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java new file mode 100644 index 00000000..b7f12033 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * modelInfo and optional instanceId and instanceName for a model related to the modelInfo being operated on. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ + "instanceName", + "instanceId", + "modelInfo" +}) +public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{ + + + /** The model info. */ + @JsonProperty("modelInfo") + private org.onap.vid.domain.mso.ModelInfo modelInfo; + + /** The additional properties. */ + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + /** + * (Required). + * + * @return The modelInfo + */ + @JsonProperty("modelInfo") + public org.onap.vid.domain.mso.ModelInfo getModelInfo() { + return modelInfo; + } + + /** + * (Required). + * + * @param modelInfo The modelInfo + */ + @JsonProperty("modelInfo") + public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedInstance#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedInstance#getAdditionalProperties() + */ + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedInstance#setAdditionalProperty(java.lang.String, java.lang.Object) + */ + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedInstance#hashCode() + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(getInstanceName()).append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode(); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedInstance#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof RelatedInstance) == false) { + return false; + } + RelatedInstance rhs = ((RelatedInstance) other); + return new EqualsBuilder().append(getInstanceName(), rhs.getInstanceName()).append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.getModelInfo()).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java new file mode 100644 index 00000000..39722e17 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * modelInfo and optional instance id for a model related to the modelInfo being operated on. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "instanceId", + "modelInfo" +}) +public class RelatedModel extends org.onap.vid.domain.mso.RelatedModel { + + /** (Required). */ + @JsonProperty("modelInfo") + private org.onap.vid.domain.mso.ModelInfo modelInfo; + +// /** The related model object instance list. */ +// @JsonProperty("instanceId") +// private org.openecomp.vid.domain.mso.InstanceIds instanceId; + + /** The additional properties. */ + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + /** + * (Required). + * + * @return The modelInfo + */ + @JsonProperty("modelInfo") + public org.onap.vid.domain.mso.ModelInfo getModelInfo() { + return modelInfo; + } + + /** + * (Required). + * + * @param modelInfo The modelInfo + */ + @JsonProperty("modelInfo") + public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedModel#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedModel#getAdditionalProperties() + */ + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedModel#setAdditionalProperty(java.lang.String, java.lang.Object) + */ + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedModel#hashCode() + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode(); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RelatedModel#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof RelatedModel) == false) { + return false; + } + RelatedModel rhs = ((RelatedModel) other); + return new EqualsBuilder().append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.modelInfo).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java new file mode 100644 index 00000000..b1a84ab2 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +//import java.util.HashMap; +//import java.util.Map; +//import javax.annotation.Generated; + +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.vid.domain.mso.InstanceIds; +import org.onap.vid.domain.mso.RequestStatus; +//import com.fasterxml.jackson.annotation.JsonAnyGetter; +//import com.fasterxml.jackson.annotation.JsonAnySetter; +//import com.fasterxml.jackson.annotation.JsonCreator; +//import com.fasterxml.jackson.annotation.JsonIgnore; +//import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +//import com.fasterxml.jackson.annotation.JsonPropertyOrder; +//import com.fasterxml.jackson.annotation.JsonValue; +import org.apache.commons.lang.builder.EqualsBuilder; +//import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * request structure. + */ +public class Request extends org.onap.vid.domain.mso.Request { + + + /** The instance ids. */ + private InstanceIds instanceIds; + + /** The request details. */ + private RequestDetails requestDetails; + + /** The request status. */ + private RequestStatus requestStatus; + + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.Request#getInstanceIds() + */ + @JsonProperty("instanceIds") + public InstanceIds getInstanceIds() { + return instanceIds; + } + + /** + * Sets the instance ids. + * + * @param instanceIds The instanceIds + */ + @JsonProperty("instanceIds") + public void setInstanceIds(InstanceIds instanceIds) { + this.instanceIds = instanceIds; + } + + /** + * (Required). + * + * @return The requestDetails + */ + @JsonProperty("requestDetails") + public RequestDetails getRequestDetails() { + return requestDetails; + } + + /** + * (Required). + * + * @param requestDetails The requestDetails + */ + @JsonProperty("requestDetails") + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + + /** + * Gets the request status. + * + * @return The requestStatus + */ + @JsonProperty("requestStatus") + public RequestStatus getRequestStatus() { + return requestStatus; + } + + /** + * Sets the request status. + * + * @param requestStatus The requestStatus + */ + @JsonProperty("requestStatus") + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.Request#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.Request#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof Request) == false) { + return false; + } + Request rhs = ((Request) other); + return new EqualsBuilder().append(getFinishTime(), rhs.getFinishTime()).append(getInstanceIds(), rhs.getInstanceIds()).append(getRequestDetails(), rhs.getRequestDetails()).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37).append(getFinishTime()).append(getInstanceIds()).append(getRequestDetails()).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode(); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java new file mode 100644 index 00000000..1e059896 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +import java.util.HashMap; +import java.util.Map; +import java.util.List; + +import org.onap.vid.domain.mso.*; +import org.onap.vid.domain.mso.SubscriberInfo; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * aggregates the context, configuraiton and detailed parameters associated with the request into a single structure. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "cloudConfiguration", + "modelInfo", + "relatedModelList", + "requestInfo", + "subscriberInfo", + "requestParameters" +}) +public class RequestDetails{ + + /** The cloud configuration. */ + @JsonProperty("cloudConfiguration") + private CloudConfiguration cloudConfiguration; + + /** The model info. */ + @JsonProperty("modelInfo") + private ModelInfo modelInfo; + + /** The related model list. */ + @JsonProperty("relatedModelList") + private List<RelatedModel> relatedInstanceList; + + /** The request info. */ + @JsonProperty("requestInfo") + private RequestInfo requestInfo; + + /** The subscriber info. */ + @JsonProperty("subscriberInfo") + private SubscriberInfo subscriberInfo; + + /** The request parameters. */ + @JsonProperty("requestParameters") + private RequestParameters requestParameters; + + /** The additional properties. */ + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + /** + * Gets the cloud configuration. + * + * @return The cloudConfiguration + */ + @JsonProperty("cloudConfiguration") + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + /** + * Sets the cloud configuration. + * + * @param cloudConfiguration The cloudConfiguration + */ + @JsonProperty("cloudConfiguration") + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + /** + * Gets the model info. + * + * @return The modelInfo + */ + @JsonProperty("modelInfo") + public ModelInfo getModelInfo() { + return modelInfo; + } + + /** + * Sets the model info. + * + * @param modelInfo The modelInfo + */ + @JsonProperty("modelInfo") + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + /** + * Gets the related instance list. + * + * @return The relatedInstanceList + */ + @JsonProperty("relatedInstanceList") + public List<RelatedModel> getRelatedInstanceList() { + return relatedInstanceList; + } + + /** + * Sets the related model list. + * + * @param relatedInstanceList The relatedInstanceList + */ + @JsonProperty("relatedInstanceList") + public void setRelatedInstanceList( List<RelatedModel> relatedInstanceList) { + this.relatedInstanceList = relatedInstanceList; + } + + /** + * Gets the request info. + * + * @return The requestInfo + */ + @JsonProperty("requestInfo") + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the request info. + * + * @param requestInfo The requestInfo + */ + @JsonProperty("requestInfo") + public void setRequestInfo(RequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + + /** + * Gets the subscriber info. + * + * @return The subscriberInfo + */ + @JsonProperty("subscriberInfo") + public SubscriberInfo getSubscriberInfo() { + return subscriberInfo; + } + + /** + * Sets the subscriber info. + * + * @param subscriberInfo The subscriberInfo + */ + @JsonProperty("subscriberInfo") + public void setSubscriberInfo(SubscriberInfo subscriberInfo) { + this.subscriberInfo = subscriberInfo; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RequestDetails#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RequestDetails#getAdditionalProperties() + */ + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RequestDetails#setAdditionalProperty(java.lang.String, java.lang.Object) + */ + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RequestDetails#hashCode() + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(cloudConfiguration).append(modelInfo).append(relatedInstanceList).append(requestInfo).append(getRequestParameters()).append(subscriberInfo).append(additionalProperties).toHashCode(); + } + + /* (non-Javadoc) + * @see org.openecomp.vid.domain.mso.RequestDetails#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof RequestDetails) == false) { + return false; + } + RequestDetails rhs = ((RequestDetails) other); + return new EqualsBuilder().append(cloudConfiguration, rhs.cloudConfiguration).append(modelInfo, rhs.modelInfo).append(relatedInstanceList, rhs.relatedInstanceList).append(requestInfo, rhs.requestInfo).append(getRequestParameters(), rhs.getRequestParameters()).append(subscriberInfo, rhs.subscriberInfo).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + + public RequestParameters getRequestParameters() { + return requestParameters; + } + + public void setRequestParameters(RequestParameters requestParameters) { + this.requestParameters = requestParameters; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java new file mode 100644 index 00000000..8f8272c0 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest; + +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +//import com.fasterxml.jackson.annotation.JsonInclude; +//import com.fasterxml.jackson.annotation.JsonProperty; +//import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import java.util.List; + +/** + * List of relatedModel structures that are related to a modelInfo being operated on. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ + "finishTime", + "instanceIds", + "requestDetails", + "requestId", + "requestScope", + "requestStatus", + "requestType", + "startTime" +}) + +public class RequestList { + + /** The request list. */ + private List<RequestWrapper> requestList; + + /** The additional properties. */ + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + /** + * (Required). + * + * @return The RelatedModel List + */ + public List<RequestWrapper> getRequestList() { + return requestList; + } + + /** + * Sets the request list. + * + * @param l the new request list + */ + public void setRequestList(List<RequestWrapper> l) { + this.requestList = l; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + /** + * Gets the additional properties. + * + * @return the additional properties + */ + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Sets the additional property. + * + * @param name the name + * @param value the value + */ + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(getRequestList()).append(additionalProperties).toHashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof RequestList) == false) { + return false; + } + RequestList rhs = ((RequestList) other); + return new EqualsBuilder().append(getRequestList(), rhs.getRequestList()).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java new file mode 100644 index 00000000..c93d0e56 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java @@ -0,0 +1,35 @@ +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * request wrapper structure. + */ +public class RequestWrapper { + + + /** The request. */ + private Request request; + + + /** + * Gets the request. + * + * @return The requestDetails + */ + @JsonProperty("request") + public Request getRequest() { + return request; + } + + /** + * Sets the request. + * + * @param request The request + */ + @JsonProperty + public void setRequest(Request request) { + this.request = request; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java new file mode 100644 index 00000000..ee074f38 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java @@ -0,0 +1,54 @@ +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Response { + + /** The status. */ + private int status; + + /** The entity. */ + private RequestList entity; + + /** + * Gets the status. + * + * @return The status + */ + @JsonProperty("status") + public int getStatus() { + return status; + } + + /** + * Sets the status. + * + * @param status The status + */ + @JsonProperty("status") + public void setStatus(int status) { + this.status = status; + } + + /** + * Gets the entity. + * + * @return The entity + */ + @JsonProperty("entity") + public RequestList getEntity() { + return entity; + } + + /** + * Sets the entity. + * + * @param entity The entity + */ + @JsonProperty("entity") + public void setEntity(RequestList entity) { + this.entity = entity; + } + + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java new file mode 100644 index 00000000..9fc95fce --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java @@ -0,0 +1,68 @@ +package org.onap.vid.mso.rest; + +import org.onap.vid.mso.RestObject; + +import javax.ws.rs.core.MultivaluedHashMap; + +/** + * Created by pickjonathan on 26/06/2017. + */ +public interface RestInterface { + + /** + * Inits the rest client. + */ + MultivaluedHashMap<String, Object> initMsoClient(); + + /** + * Gets the. + * + * @param <T> the generic type + * @param t the t + * @param sourceId the source id + * @param path the path + * @param restObject the rest object + * @throws Exception the exception + */ + <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception; + + /** + * Delete. + * + * @param <T> the generic type + * @param t the t + * @param r the r + * @param sourceID the source ID + * @param path the path + * @param restObject the rest object + * @throws Exception the exception + */ + <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) throws Exception; + + /** + * Post. + * + * @param <T> the generic type + * @param t the t + * @param r the r + * @param sourceID the source ID + * @param path the path + * @param restObject the rest object + * @throws Exception the exception + */ + <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject) throws Exception; + + /** + * Put. + * + * @param <T> the generic type + * @param t the t + * @param r the r + * @param sourceID the source ID + * @param path the path + * @param restObject the rest object + * @throws Exception the exception + */ + <T> void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject) throws Exception; + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java new file mode 100644 index 00000000..79aaaea5 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java @@ -0,0 +1,119 @@ +package org.onap.vid.mso.rest; + +import java.util.List; + +public class Task { + + private String taskId; + private String type; + private String nfRole; + private String subscriptionServiceType; + private String originalRequestId; + private String originalRequestorId; + private String errorSource; + private String errorCode; + private String errorMessage; + private String buildingBlockName; + private String buildingBlockStep; + private List<String> validResponses; + + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getNfRole() { + return nfRole; + } + + public void setNfRole(String nfRole) { + this.nfRole = nfRole; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getOriginalRequestId() { + return originalRequestId; + } + + public void setOriginalRequestId(String originalRequestId) { + this.originalRequestId = originalRequestId; + } + + public String getOriginalRequestorId() { + return originalRequestorId; + } + + public void setOriginalRequestorId(String originalRequestorId) { + this.originalRequestorId = originalRequestorId; + } + + public String getErrorSource() { + return errorSource; + } + + public void setErrorSource(String errorSource) { + this.errorSource = errorSource; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getBuildingBlockName() { + return buildingBlockName; + } + + public void setBuildingBlockName(String buildingBlockName) { + this.buildingBlockName = buildingBlockName; + } + + public String getBuildingBlockStep() { + return buildingBlockStep; + } + + public void setBuildingBlockStep(String buildingBlockStep) { + this.buildingBlockStep = buildingBlockStep; + } + + public List<String> getValidResponses() { + return validResponses; + } + + public void setValidResponses(List<String> validResponses) { + this.validResponses = validResponses; + } + + + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java new file mode 100644 index 00000000..bbff333a --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java @@ -0,0 +1,16 @@ +package org.onap.vid.mso.rest; + +import java.util.List; + +public class TaskList { + + public List<Task> getTaskList() { + return taskList; + } + + public void setTaskList(List<Task> taskList) { + this.taskList = taskList; + } + + private List<Task> taskList; +} |