diff options
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/mso')
12 files changed, 255 insertions, 316 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 index cc3231582..949fdab70 100644 --- 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 @@ -21,10 +21,11 @@ package org.onap.vid.mso; +import java.util.List; +import java.util.UUID; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.changeManagement.WorkflowRequestDetail; import org.onap.vid.controller.OperationalEnvironmentController; -import org.onap.vid.services.ProbeInterface; import org.onap.vid.model.SOWorkflowList; import org.onap.vid.model.SoftDeleteRequest; import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; @@ -33,9 +34,7 @@ import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestD 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; -import java.util.UUID; +import org.onap.vid.services.ProbeInterface; public interface MsoBusinessLogic extends ProbeInterface { @@ -137,9 +136,5 @@ public interface MsoBusinessLogic extends ProbeInterface { RequestDetails buildRequestDetailsForSoftDelete(SoftDeleteRequest softDeleteRequest); - MsoResponseWrapper2 deactivateAndCloudDelete(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, RequestDetails requestDetails); - - MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails); - SOWorkflowList getWorkflowListByModelId(String modelVersionId); } 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 index 4cb495e2f..9146e8f1b 100644 --- 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 @@ -20,6 +20,24 @@ */ package org.onap.vid.mso; +import static com.fasterxml.jackson.module.kotlin.ExtensionsKt.jacksonObjectMapper; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; +import static org.apache.commons.lang.StringUtils.upperCase; +import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest; +import static org.onap.vid.controller.MsoController.CONFIGURATION_ID; +import static org.onap.vid.controller.MsoController.REQUEST_TYPE; +import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID; +import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID; +import static org.onap.vid.controller.MsoController.WORKFLOW_ID; +import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS; +import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE; +import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE; +import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE; +import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS; +import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER; +import static org.onap.vid.utils.Logging.debugRequestDetails; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -27,6 +45,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import io.joshworks.restclient.http.HttpResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.ws.rs.BadRequestException; import org.apache.commons.collections4.ListUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; @@ -35,7 +65,6 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.changeManagement.WorkflowRequestDetail; import org.onap.vid.controller.OperationalEnvironmentController; import org.onap.vid.exceptions.GenericUncheckedException; -import org.onap.vid.model.RequestReferencesContainer; import org.onap.vid.model.SOWorkflowList; import org.onap.vid.model.SoftDeleteRequest; import org.onap.vid.model.probes.ExternalComponentStatus; @@ -58,37 +87,6 @@ import org.onap.vid.mso.rest.TaskList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.togglz.core.manager.FeatureManager; - -import javax.ws.rs.BadRequestException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.toList; -import static org.apache.commons.lang.StringUtils.upperCase; -import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest; -import static org.onap.vid.controller.MsoController.CONFIGURATION_ID; -import static org.onap.vid.controller.MsoController.REQUEST_TYPE; -import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID; -import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID; -import static org.onap.vid.controller.MsoController.WORKFLOW_ID; -import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS; -import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE; -import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE; -import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE; -import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS; -import static org.onap.vid.properties.Features.FLAG_UNASSIGN_SERVICE; -import static org.onap.vid.utils.Logging.debugRequestDetails; public class MsoBusinessLogicImpl implements MsoBusinessLogic { @@ -120,12 +118,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { * This should be replaced with mso client factory. */ private final MsoInterface msoClientInterface; - FeatureManager featureManager; @Autowired - public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) { + public MsoBusinessLogicImpl(MsoInterface msoClientInterface) { this.msoClientInterface = msoClientInterface; - this.featureManager = featureManager; } public static String validateEndpointPath(String endpointEnvVariable) { @@ -168,17 +164,19 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) { logInvocationInDebug("createNwInstance"); - String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + String endpoint; + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); - String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - return msoClientInterface.createNwInstance(requestDetails, nw_endpoint); + String nwEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + return msoClientInterface.createNwInstance(requestDetails, nwEndpoint); } @Override public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { logInvocationInDebug("createVolumeGroupInstance"); - String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + String endpoint; + endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); String vnfEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnfEndpoint = vnfEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -192,10 +190,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); - String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + String partialEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String vfModuleEndpoint = partialEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint); + return msoClientInterface.createVfModuleInstance(requestDetails, vfModuleEndpoint); } @Override @@ -259,19 +257,15 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { logInvocationInDebug("deleteSvcInstance"); String endpoint; - if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)) { - endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE); - if (shouldUnassignService(serviceStatus)) { - logger.debug(EELFLoggerDelegate.debugLogger, "unassign service"); - String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign"; - return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint); - } - } else { - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE); + if (shouldUnassignService(serviceStatus)){ + logger.debug(EELFLoggerDelegate.debugLogger, "unassign service"); + String svcEndpoint = endpoint + "/" + serviceInstanceId + "/unassign"; + return msoClientInterface.unassignSvcInstance(requestDetails, svcEndpoint); } - String svc_endpoint = endpoint + "/" + serviceInstanceId; - return msoClientInterface.deleteSvcInstance(requestDetails, svc_endpoint); + String svcEndpoint = endpoint + "/" + serviceInstanceId; + return msoClientInterface.deleteSvcInstance(requestDetails, svcEndpoint); } private boolean shouldUnassignService(String serviceStatus) { @@ -294,10 +288,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { logInvocationInDebug("deleteVfModule"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); - String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId; + String vfModulesEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + String deleteVfEndpoint = vfModulesEndpoint + '/' + vfModuleId; - return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint); + return msoClientInterface.deleteVfModule(requestDetails, deleteVfEndpoint); } @Override @@ -305,11 +299,11 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { logInvocationInDebug("deleteVolumeGroupInstance"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); - String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - String vnfEndpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - String delete_volume_group_endpoint = vnfEndpoint + "/" + volumeGroupId; + String svcEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String vnfEndpoint = svcEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + String deleteVolumeGroupEndpoint = vnfEndpoint + "/" + volumeGroupId; - return msoClientInterface.deleteVolumeGroupInstance(requestDetails, delete_volume_group_endpoint); + return msoClientInterface.deleteVolumeGroupInstance(requestDetails, deleteVolumeGroupEndpoint); } @Override @@ -317,10 +311,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { logInvocationInDebug("deleteNwInstance"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); - String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId; + String svcEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + String deleteNwEndpoint = svcEndpoint + "/" + networkInstanceId; - return msoClientInterface.deleteNwInstance(requestDetails, delete_nw_endpoint); + return msoClientInterface.deleteNwInstance(requestDetails, deleteNwEndpoint); } @Override @@ -400,7 +394,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) { logInvocationInDebug("deserializeOrchestrationRequestsJson"); - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = jacksonObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true); RequestList requestList; @@ -423,7 +417,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String path = p + "?originalRequestId=" + originalRequestId; RestObject<String> restObjStr = new RestObject<>(); - String str = new String(); + String str = ""; restObjStr.set(str); MsoResponseWrapper msoResponseWrapper = msoClientInterface.getManualTasksByRequestId(str, "", path, restObjStr); @@ -438,9 +432,8 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { private List<Task> deserializeManualTasksJson(String manualTasksJson) { logInvocationInDebug("deserializeManualTasksJson"); - ObjectMapper mapper = new ObjectMapper(); try { - TaskList taskList = mapper.readValue(manualTasksJson, TaskList.class); + TaskList taskList = JACKSON_OBJECT_MAPPER.readValue(manualTasksJson, TaskList.class); return taskList.getTaskList(); } catch (IOException e) { throw new GenericUncheckedException(e); @@ -457,7 +450,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String path = p + "/" + taskId + "/complete"; RestObject<String> restObjStr = new RestObject<>(); - String str = new String(); + String str = ""; restObjStr.set(str); return msoClientInterface.completeManualTask(requestDetails, str, "", path, restObjStr); @@ -561,9 +554,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { requestInfo.setRequestorId(softDeleteRequest.getUserId()); requestDetails.setRequestInfo(requestInfo); - CloudConfiguration cloudConfiguration = new CloudConfiguration(); - cloudConfiguration.setTenantId(softDeleteRequest.getTenantId()); - cloudConfiguration.setLcpCloudRegionId(softDeleteRequest.getLcpCloudRegionId()); + CloudConfiguration cloudConfiguration = new CloudConfiguration(softDeleteRequest.getLcpCloudRegionId(), softDeleteRequest.getTenantId(), null); requestDetails.setCloudConfiguration(cloudConfiguration); ModelInfo modelInfo = new ModelInfo(); @@ -578,18 +569,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override - public MsoResponseWrapper2 deactivateAndCloudDelete(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, RequestDetails requestDetails) { - String path = getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId); - return new MsoResponseWrapper2<>(msoClientInterface.post(path, requestDetails, RequestReferencesContainer.class)); - } - - @Override - public MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails) { - String path = getActivateFabricConfigurationPath(serviceInstanceId); - return new MsoResponseWrapper2<>(msoClientInterface.post(path, requestDetails, RequestReferencesContainer.class)); - } - - @Override public SOWorkflowList getWorkflowListByModelId(String modelVersionId) { logInvocationInDebug("getWorkflowListByModelId"); String pathTemplate = validateEndpointPath(MSO_REST_API_WORKFLOW_SPECIFICATIONS); @@ -634,7 +613,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } Object payloadRaw = requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); try { - return objectMapper.readValue((String) payloadRaw, Map.class); + return JACKSON_OBJECT_MAPPER.readValue((String) payloadRaw, Map.class); } catch (Exception exception) { throw new BadRequestException(message); } @@ -912,7 +891,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } } - enum RequestType { + public enum RequestType { CREATE_INSTANCE("createInstance"), DELETE_INSTANCE("deleteInstance"), 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 index 562182a3c..fcc20fafd 100644 --- 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 @@ -21,15 +21,20 @@ package org.onap.vid.mso; +import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER; + +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.joshworks.restclient.http.HttpResponse; +import java.io.IOException; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; - +import org.onap.vid.exceptions.GenericUncheckedException; public class MsoUtil { - final static ObjectMapper objectMapper = new ObjectMapper(); + static final ObjectMapper objectMapper = new ObjectMapper(); private MsoUtil() { } @@ -48,12 +53,30 @@ public class MsoUtil { T body = httpResponse.getBody(); String entityStr = body instanceof String ? (String) body : objectMapper.writeValueAsString(httpResponse.getBody()); msoResponseWrapper.setEntity(entityStr); - } - catch(JsonProcessingException e) - { + } catch(JsonProcessingException e) { ExceptionUtils.rethrow(e); } } return msoResponseWrapper; } + + public static String formatExceptionAdditionalInfo(int statusCode, String msoResponse) { + String errorMsg = "Http Code:" + statusCode; + if (!StringUtils.isEmpty(msoResponse)) { + String filteredJson; + try { + filteredJson = StringUtils.defaultIfEmpty( + JACKSON_OBJECT_MAPPER.readTree(msoResponse).path("serviceException").toString().replaceAll("[\\{\\}]","") , + msoResponse + ); + } catch (JsonParseException e) { + filteredJson = msoResponse; + } catch (IOException e) { + throw new GenericUncheckedException(e); + } + + errorMsg = errorMsg + ", " + filteredJson; + } + return errorMsg; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java new file mode 100644 index 000000000..f6b8a4241 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 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.model; + +import java.util.List; + +/* +Based on this model: +{ + "requestDetails": { + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{the to be removed/added as member vnf-id}", + "modelInfo": { + "modelType": "vnf" + } + } + } + ] + } +} +*/ + +public class AddOrRemoveInstanceGroupMemberRequestDetails extends BaseResourceInstantiationRequestDetails { + public AddOrRemoveInstanceGroupMemberRequestDetails(RequestInfo requestInfo, List<RelatedInstance> relatedInstanceList) { + super(null, null, requestInfo, null, null, relatedInstanceList, null); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java index c6eb53832..43f5b0070 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java @@ -7,9 +7,9 @@ * 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. @@ -20,15 +20,15 @@ package org.onap.vid.mso.model; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; - import java.util.List; -import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; - @JsonInclude(NON_NULL) public class BaseResourceInstantiationRequestDetails { @@ -83,21 +83,21 @@ public class BaseResourceInstantiationRequestDetails { this.requestParameters = requestParameters; } - public static class RequestInfo { + public static class RequestInfo { - @JsonInclude(NON_NULL) public final String instanceName; - @JsonInclude(NON_NULL) public final String productFamilyId; + @JsonInclude(NON_EMPTY) public final String instanceName; + @JsonInclude(NON_EMPTY) public final String productFamilyId; public final String source; - public final boolean suppressRollback; + @JsonInclude(NON_NULL) public final Boolean suppressRollback; public final String requestorId; - public RequestInfo(String instanceName, String productFamilyId, String source, boolean rollbackOnFailure, String requestorId) { + public RequestInfo(String instanceName, String productFamilyId, String source, Boolean rollbackOnFailure, String requestorId) { this.instanceName = instanceName; this.productFamilyId = productFamilyId; this.source = source; this.requestorId = requestorId; // in the FE we are asking for "RollbackOnFailure" but to MSO we are passing the negative value "suppressRollback" - this.suppressRollback = !rollbackOnFailure; + this.suppressRollback = rollbackOnFailure != null ? (!rollbackOnFailure) : null; } } @@ -120,9 +120,13 @@ public class BaseResourceInstantiationRequestDetails { public static class LineOfBusiness{ public final String lineOfBusinessName; - public LineOfBusiness(String lineOfBusiness) { + private LineOfBusiness(String lineOfBusiness) { this.lineOfBusinessName = lineOfBusiness; } + + public static LineOfBusiness of(String lineOfBusiness) { + return lineOfBusiness==null ? null : new LineOfBusiness(lineOfBusiness); + } } @JsonTypeName("relatedInstance") @@ -150,13 +154,18 @@ public class BaseResourceInstantiationRequestDetails { public static class RequestParameters { public final List<? extends UserParamTypes> userParams; - public RequestParameters(List<? extends UserParamTypes> userParams) { + @JsonInclude(NON_NULL) public final String testApi; + public RequestParameters(List<? extends UserParamTypes> userParams, String testApi) { this.userParams = userParams; + this.testApi = testApi; } public List<? extends UserParamTypes> getUserParams() { return userParams; } + public String getTestApi() { + return testApi; + } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java deleted file mode 100644 index 2e0991755..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 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.model; - -import com.fasterxml.jackson.annotation.*; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - -import java.util.HashMap; -import java.util.Map; - - -/** - * fields communicating the cloud configuration in a standard way - * - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "nodeLocation", - "lcpCloudRegionId", - "tenantId", - "cloudOwner" -}) -public class CloudConfiguration { - - /** - * Location identifier for the node - * - */ - @JsonProperty("nodeLocation") - private String nodeLocation; - /** - * LCP Node Location identifier - * - */ - @JsonProperty("lcpCloudRegionId") - private String lcpCloudRegionId; - /** - * Openstack tenant id - * - */ - @JsonProperty("tenantId") - private String tenantId; - /** - * the cloud owner - * - */ - @JsonProperty("cloudOwner") - private String cloudOwner; - @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<>(); - - /** - * Location identifier for the node - * - * @return - * The nodeLocation - */ - @JsonProperty("nodeLocation") - public String getNodeLocation() { - return nodeLocation; - } - - /** - * Location identifier for the node - * - * @param nodeLocation - * The nodeLocation - */ - @JsonProperty("nodeLocation") - public void setNodeLocation(String nodeLocation) { - this.nodeLocation = nodeLocation; - } - - /** - * LCP Node Location identifier - * - * @return - * The lcpCloudRegionId - */ - @JsonProperty("lcpCloudRegionId") - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - /** - * LCP Node Location identifier - * - * @param lcpCloudRegionId - * The lcpCloudRegionId - */ - @JsonProperty("lcpCloudRegionId") - public void setLcpCloudRegionId(String lcpCloudRegionId) { - this.lcpCloudRegionId = lcpCloudRegionId; - } - - /** - * Openstack tenant id - * - * @return - * The tenantId - */ - @JsonProperty("tenantId") - public String getTenantId() { - return tenantId; - } - - /** - * Openstack tenant id - * - * @param tenantId - * The tenantId - */ - @JsonProperty("tenantId") - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - /** - * the cloud owner - * - * @return - * The cloudOwner - */ - @JsonProperty("cloudOwner") - public String getCloudOwner() { - return cloudOwner; - } - - /** - * the cloud owner - * - * @param cloudOwner - * The cloudOwner - */ - @JsonProperty("cloudOwner") - public void setCloudOwner(String cloudOwner) { - this.cloudOwner = cloudOwner; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - @JsonAnyGetter - public Map<String, Object> getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(nodeLocation).append(lcpCloudRegionId).append(tenantId).append(cloudOwner).append(additionalProperties).toHashCode(); - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - if (!(other instanceof CloudConfiguration)) { - return false; - } - CloudConfiguration rhs = ((CloudConfiguration) other); - return new EqualsBuilder().append(nodeLocation, rhs.nodeLocation).append(lcpCloudRegionId, rhs.lcpCloudRegionId).append(tenantId, rhs.tenantId).append(cloudOwner, rhs.cloudOwner).append(additionalProperties, rhs.additionalProperties).isEquals(); - } - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt new file mode 100644 index 000000000..d603e5b87 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt @@ -0,0 +1,12 @@ +package org.onap.vid.mso.model + +import com.fasterxml.jackson.annotation.JsonInclude + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +//tenantId and might be null for supporting create configuration API (port mirroring) +//cloudOwner might because MSO enable it and it might be used in some flows (default value in MSO "irma-aic") +data class CloudConfiguration @JvmOverloads constructor( + var lcpCloudRegionId: String? = null, + var tenantId:String? = null, + var cloudOwner: String? = null +)
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java new file mode 100644 index 000000000..effc10a08 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 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.model; + +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; +import static org.onap.vid.mso.model.BaseResourceInstantiationRequestDetails.RelatedInstance; + +import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.onap.vid.mso.rest.SubscriberInfo; + +public class ServiceInstantiationPre1806RequestDetails extends ServiceInstantiationRequestDetails { + + @JsonInclude(NON_NULL) + public final CloudConfiguration cloudConfiguration; + @JsonInclude(NON_EMPTY) + public final List<RelatedInstance> relatedInstanceList; + + public ServiceInstantiationPre1806RequestDetails(ModelInfo modelInfo, ServiceInstantiationOwningEntity owningEntity, + SubscriberInfo subscriberInfo, Project project, RequestInfo requestInfo, + RequestParameters requestParameters, CloudConfiguration cloudConfiguration, + List<RelatedInstance> relatedInstanceList) { + super(modelInfo, owningEntity, subscriberInfo, project, requestInfo, requestParameters); + if ((cloudConfiguration != null) && (!StringUtils.isEmpty(cloudConfiguration.getLcpCloudRegionId())) && (!StringUtils.isEmpty(cloudConfiguration.getTenantId()))){ + this.cloudConfiguration = cloudConfiguration; + } else { + this.cloudConfiguration = null; + } + this.relatedInstanceList = relatedInstanceList; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java index 700f43857..8f8dd681a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java @@ -76,8 +76,8 @@ public class ServiceInstantiationRequestDetails { public static class RequestInfo { - @JsonInclude(NON_NULL) public final String instanceName; - @JsonInclude(NON_NULL) public final String productFamilyId; + @JsonInclude(NON_EMPTY) public final String instanceName; + @JsonInclude(NON_EMPTY) public final String productFamilyId; public final String source; public final boolean suppressRollback; public final String requestorId; @@ -150,7 +150,7 @@ public class ServiceInstantiationRequestDetails { private static class ServiceInstantiationServiceInner implements UserParamTypes { public ModelInfo modelInfo = new ModelInfo(); - @JsonInclude(NON_NULL) + @JsonInclude(NON_EMPTY) public String instanceName; public List<Map<String, String>> instanceParams; public ServiceInstantiationVnfList resources; @@ -182,7 +182,7 @@ public class ServiceInstantiationRequestDetails { public final String productFamilyId; public final List<Map<String, String>> instanceParams; @JsonInclude(NON_EMPTY) public final List<VfModuleMacro> vfModules; - @JsonInclude(NON_NULL) public final String instanceName; + @JsonInclude(NON_EMPTY) public final String instanceName; public ServiceInstantiationVnf(ModelInfo modelInfo, CloudConfiguration cloudConfiguration, String platform, String lineOfBusiness, String productFamilyId, List<Map<String, String>> instanceParams, List<VfModuleMacro> vfModules, String instanceName) { this.modelInfo = modelInfo; diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java index 4e6f074c2..3b6cd1d3d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java @@ -7,9 +7,9 @@ * 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. @@ -20,8 +20,10 @@ package org.onap.vid.mso.model; -import com.fasterxml.jackson.annotation.JsonProperty; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -109,14 +111,14 @@ public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiati } public static class RequestParametersVfModule extends BaseResourceInstantiationRequestDetails.RequestParameters { - private final boolean usePreload; + @JsonInclude(NON_NULL) private final Boolean usePreload; - public RequestParametersVfModule(List<? extends UserParamTypes> userParams, boolean usePreload) { - super(userParams); + public RequestParametersVfModule(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi) { + super(userParams, testApi); this.usePreload = usePreload; } - public boolean isUsePreload() { + public Boolean isUsePreload() { return usePreload; } } 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 index 12bf20549..61e0d3af6 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -53,6 +53,7 @@ public class AsyncRequestStatus { public String requestId; public String requestScope; + public String requestType; /** * The instance ids. diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java index 031eaec23..29356aa4d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java @@ -43,6 +43,14 @@ import java.util.Map; }) public class RequestStatus { + public RequestStatus() {} + + public RequestStatus(String requestState, String statusMessage, String timestamp) { + this.requestState = requestState; + this.statusMessage = statusMessage; + this.timestamp = timestamp; + } + /** * percentage complete estimate from 0 to 100 * |