aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhekeguang <hekeguang@chinamobile.com>2020-02-19 17:13:41 +0800
committerhekeguang <hekeguang@chinamobile.com>2020-02-19 17:13:55 +0800
commitafa1b045ee250bfc5dc918ad7a69c8e5a62b67af (patch)
tree520749f6a5987ee24a735d4a66c7db64a1ab6220
parentee28e9071e114aba6d5d3a2eee4fb5b6f7247f14 (diff)
Add processing code related to slice resource management
Issue-ID: USECASEUI-369 Change-Id: Idc438d3ae83eaa3b4b2cf2e5336a1456ffdf1da6 Signed-off-by: hekeguang <hekeguang@chinamobile.com>
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/nsmf/ResourceMgtService.java51
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceConvert.java594
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceImpl.java863
3 files changed, 1508 insertions, 0 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/nsmf/ResourceMgtService.java b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/ResourceMgtService.java
new file mode 100644
index 00000000..71602247
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/ResourceMgtService.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.service.nsmf;
+
+import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
+
+public interface ResourceMgtService {
+
+ ServiceResult querySlicingBusiness(int pageNo, int pageSize);
+
+ ServiceResult querySlicingBusinessByStatus(String processingStatus, int pageNo, int pageSize);
+
+ ServiceResult querySlicingBusinessDetails(String businessId);
+
+ ServiceResult queryNsiInstances(int pageNo, int pageSize);
+
+ ServiceResult queryNsiInstancesByStatus(String instanceStatus, int pageNo, int pageSize);
+
+ ServiceResult queryNsiDetails(String nsiId);
+
+ ServiceResult queryNsiRelatedNssiInfo(String nsiId);
+
+ ServiceResult queryNssiInstances(int pageNo, int pageSize);
+
+ ServiceResult queryNssiInstancesByStatus(String instanceStatus, int pageNo, int pageSize);
+
+ ServiceResult queryNssiInstancesByEnvironment(String environmentContext, int pageNo, int pageSize);
+
+ ServiceResult queryNssiDetails(String nssiId);
+
+ ServiceResult activateSlicingService(String serviceId);
+
+ ServiceResult deactivateSlicingService(String serviceId);
+
+ ServiceResult terminateSlicingService(String serviceId);
+
+ ServiceResult queryOperationProgress(String serviceId);
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceConvert.java b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceConvert.java
new file mode 100644
index 00000000..df7c2d1b
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceConvert.java
@@ -0,0 +1,594 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.service.nsmf.impl;
+
+import static org.onap.usecaseui.server.util.RestfulServices.create;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.beanutils.BeanUtils;
+import org.onap.usecaseui.server.bean.nsmf.common.PagedResult;
+import org.onap.usecaseui.server.bean.nsmf.resource.HostedBusinessInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.HostedNsiInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.HostedNsiList;
+import org.onap.usecaseui.server.bean.nsmf.resource.IncludedNssiInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiDetailList;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiRelatedNssiInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiServiceInstanceInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiServiceInstanceList;
+import org.onap.usecaseui.server.bean.nsmf.resource.NssiServiceInstanceInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NssiServiceInstanceList;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessDetails;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessList;
+import org.onap.usecaseui.server.bean.nsmf.resource.SubscriberInfo;
+import org.onap.usecaseui.server.bean.nsmf.task.BusinessDemandInfo;
+import org.onap.usecaseui.server.bean.nsmf.task.NstInfo;
+import org.onap.usecaseui.server.constant.nsmf.NsmfParamConstant;
+import org.onap.usecaseui.server.service.slicingdomain.aai.AAISliceService;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIService;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceAndInstance;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceNST;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceProfiles;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceRsp;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.Relationship;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.RelationshipData;
+import org.onap.usecaseui.server.service.slicingdomain.so.SOSliceService;
+import org.onap.usecaseui.server.service.slicingdomain.so.bean.SOOperation;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.onap.usecaseui.server.util.nsmf.NsmfCommonUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import retrofit2.Response;
+
+public class ResourceMgtServiceConvert {
+
+ private static final Logger logger = LoggerFactory.getLogger(ResourceMgtServiceConvert.class);
+ GeneralConvertImpl generalConvert = new GeneralConvertImpl();
+ private SOSliceService soSliceService;
+ private AAISliceService aaiSliceService;
+ Gson gson = new Gson();
+
+ public ResourceMgtServiceConvert() {
+ this(RestfulServices.create(SOSliceService.class), RestfulServices.create(AAISliceService.class));
+ }
+
+ public ResourceMgtServiceConvert(SOSliceService soSliceService, AAISliceService aaiSliceService) {
+ this.soSliceService = soSliceService;
+ this.aaiSliceService = aaiSliceService;
+ }
+
+ void convertSlicingBusinessList(SlicingBusinessList slicingBusinessList, AAIServiceRsp aAIServiceRsp, int pageNo,
+ int pageSize)
+ throws InvocationTargetException, IllegalAccessException, IOException {
+ if (aAIServiceRsp.getaAIService() == null || aAIServiceRsp.getaAIService().size() == 0) {
+ logger.error("convertSlicingBusinessList:aAIServiceRsp.getaAIService() is null or size is 0");
+ return;
+ }
+
+ List<SlicingBusinessInfo> slicingBusinessInfoList = new ArrayList<>();
+ for (AAIService aaiServiceInstance : aAIServiceRsp.getaAIService()) {
+ SlicingBusinessInfo slicingBusinessInfo = new SlicingBusinessInfo();
+ BeanUtils.copyProperties(slicingBusinessInfo, aaiServiceInstance);
+ slicingBusinessInfoList.add(slicingBusinessInfo);
+ }
+ PagedResult pagedOrderList = NsmfCommonUtil.getPagedList(slicingBusinessInfoList, pageNo, pageSize);
+ slicingBusinessList.setSlicingBusinessInfoList(pagedOrderList.getPagedList());
+ slicingBusinessList.setRecordNumber(slicingBusinessInfoList.size());
+ }
+
+ void convertBusinessDetails(String businessId, SlicingBusinessDetails slicingBusinessDetails,
+ AAIServiceAndInstance aaiServiceAndInstance)
+ throws InvocationTargetException, IllegalAccessException, IOException {
+ convertBusinessProfileDetails(businessId, slicingBusinessDetails, aaiServiceAndInstance);
+
+ String nsiId = getNsiIdByBusiness(businessId);
+ NstInfo nstInfo = new NstInfo();
+ getNstInfoByBusiness(nstInfo, nsiId);
+ slicingBusinessDetails.setNstInfo(nstInfo);
+
+ NsiInfo nsiInfo = new NsiInfo();
+ getNsiInfoByBusiness(nsiInfo, nsiId);
+ slicingBusinessDetails.setNsiInfo(nsiInfo);
+
+ }
+
+ void getNsiInfoByBusiness(NsiInfo nsiInfo, String nsiId) {
+ try {
+ // TODO
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceById(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, nsiId)
+ .execute();
+ if (response.isSuccessful()) {
+ logger.info("getNsiInfoByBusiness:listServiceById reponse is:{}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstance = generalConvert.listServiceByIdUtil(object);
+ nsiInfo.setNsiId(aaiServiceAndInstance.getServiceInstanceId());
+ nsiInfo.setNsiName(aaiServiceAndInstance.getServiceInstanceName());
+ nsiInfo.setNsiOrchestrationStatus(aaiServiceAndInstance.getOrchestrationStatus());
+ nsiInfo.setNsiType(aaiServiceAndInstance.getServiceType());
+ } else {
+ logger.error(String
+ .format("getNsiInfoByBusiness: Can not get listServiceById [code={}, message={}]", response.code(),
+ response.message()));
+ return;
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ return;
+ }
+ }
+
+ void getNstInfoByBusiness(NstInfo nstInfo, String nsiId)
+ throws IOException {
+ String modelInvariantId;
+ String modelVersionId;
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.querySerAndSubInsByNSI(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, nsiId).execute();
+ if (response.isSuccessful()) {
+ JSONObject object = response.body();
+ logger.info("getNstInfoByBusiness: querySerAndSubInsByNSI reponse is:{}", response.body());
+ AAIServiceAndInstance aaiNsi = queryNsiDetailsUtils(object);
+ HostedNsiInfo hostedNsiInfo = new HostedNsiInfo();
+ modelInvariantId = aaiNsi.getModelInvariantId();
+ modelVersionId = aaiNsi.getModelVersionId();
+ } else {
+ logger.error(String
+ .format("getNstInfoByBusiness: Can not get listServiceById [code={}, message={}]", response.code(),
+ response.message()));
+ return;
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ return;
+ }
+
+ try {
+ // TODO
+ Response<AAIServiceNST> nstResponse = this.aaiSliceService.queryServiceNST(modelInvariantId, modelVersionId)
+ .execute();
+ if (nstResponse.isSuccessful()) {
+ AAIServiceNST aaiServiceNST = nstResponse.body();
+ logger.info("getNstInfoByBusiness: queryServiceNST reponse is:{}", gson.toJson(aaiServiceNST));
+ nstInfo.setNstId(aaiServiceNST.getModelVersionId());
+ nstInfo.setNstName(aaiServiceNST.getModelName());
+ } else {
+ logger.error(String.format("Can not get queryServiceNST [code={}, message={}]", nstResponse.code(),
+ nstResponse.message()));
+ return;
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ return;
+ }
+ }
+
+ String getNsiIdByBusiness(String businessId)
+ throws IOException {
+ List<AAIServiceAndInstance> aaiServiceAndInstanceList = new ArrayList<>();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.queryAllottedResources(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, businessId).execute();
+ if (response.isSuccessful()) {
+ logger.info("getNsiIdByBusiness: queryAllottedResources response is: {}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstanceList = queryAllottedResourceUtil(object);
+
+ AAIServiceAndInstance aaiServiceAndInstance = aaiServiceAndInstanceList.get(0);
+ Relationship relationship = aaiServiceAndInstance.getRelationshipList().get(0);
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData();
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey()
+ .equals(NsmfParamConstant.SERVICE_INSTANCE_SERVICE_INSTANCE_ID)) {
+ String nsiId = relationshipData.getRelationshipValue();
+ return nsiId;
+ }
+ }
+
+ } else {
+ logger.error(String
+ .format("getNsiIdByBusiness: Can not get queryAllottedResources[code={}, message={}]",
+ response.code(),
+ response.message()));
+ return "";
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ return "";
+ }
+ return "";
+ }
+
+ void convertBusinessProfileDetails(String businessId, SlicingBusinessDetails slicingBusinessDetails,
+ AAIServiceAndInstance aaiServiceAndInstance)
+ throws InvocationTargetException, IllegalAccessException, IOException {
+
+ BusinessDemandInfo businessDemandInfo = new BusinessDemandInfo();
+ businessDemandInfo.setServiceName(aaiServiceAndInstance.getServiceInstanceName());
+ businessDemandInfo.setServiceSnssai(aaiServiceAndInstance.getEnvironmentContext());
+
+ AAIServiceProfiles aaiServiceProfiles = new AAIServiceProfiles();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.getServiceProfiles(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, businessId).execute();
+
+ if (response.isSuccessful()) {
+ logger.info("convertBusinessProfileDetails:getServiceProfiles is:{}", response.body());
+ JSONObject object = response.body();
+ if (object.containsKey("service-profile")) {
+ JSONArray array = object.getJSONArray("service-profile");
+ // return normal result code
+ JSONObject objectProfile = array.getJSONObject(0);
+ aaiServiceProfiles = objectProfile
+ .parseObject(objectProfile.toString(), AAIServiceProfiles.class);
+ } else {
+ logger.error(String
+ .format("convertBusinessProfileDetails:Can not get getServiceProfiles[code={}, message={}]",
+ response.code(),
+ response.message()));
+ }
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+
+ String useInterval = generalConvert.getUseInterval(businessId);
+ businessDemandInfo.setUseInterval(useInterval);
+ BeanUtils.copyProperties(businessDemandInfo, aaiServiceProfiles);
+ List<String> areaInfoList = generalConvert.getAreaTaList(aaiServiceProfiles.getCoverageAreaTAList());
+ businessDemandInfo.setCoverageAreaTaList(areaInfoList);
+ slicingBusinessDetails.setBusinessDemandInfo(businessDemandInfo);
+ }
+
+ void convertHostedNsiList(NsiServiceInstanceList nsiServiceInstanceList, AAIServiceRsp aAIServiceRsp, int pageNo,
+ int pageSize)
+ throws InvocationTargetException, IllegalAccessException {
+
+ if (aAIServiceRsp.getaAIService() == null || aAIServiceRsp.getaAIService().size() == 0) {
+ logger.error("convertHostedNsiList:aAIServiceRsp.getaAIService() is null or size is 0");
+ return;
+ }
+ int i = 0;
+ List<NsiServiceInstanceInfo> nsiServiceInstanceInfoList = new ArrayList<>();
+ for (AAIService aaiServiceInstance : aAIServiceRsp.getaAIService()) {
+ i++;
+ NsiServiceInstanceInfo nsiServiceInstanceInfo = new NsiServiceInstanceInfo();
+ nsiServiceInstanceInfo.setServiceInstanceOrder(String.valueOf(i));
+ nsiServiceInstanceInfo.setOrchestrationStatus(aaiServiceInstance.getOrchestrationStatus());
+ nsiServiceInstanceInfo.setServiceInstanceId(aaiServiceInstance.getServiceInstanceId());
+ nsiServiceInstanceInfo.setServiceInstanceName(aaiServiceInstance.getServiceInstanceName());
+ nsiServiceInstanceInfo.setServiceType(aaiServiceInstance.getServiceType());
+
+ nsiServiceInstanceInfoList.add(nsiServiceInstanceInfo);
+ }
+
+ PagedResult pagedOrderList = NsmfCommonUtil.getPagedList(nsiServiceInstanceInfoList, pageNo, pageSize);
+ nsiServiceInstanceList.setNsiServiceInstanceInfoList(pagedOrderList.getPagedList());
+ nsiServiceInstanceList.setRecordNumber(nsiServiceInstanceInfoList.size());
+ }
+
+ void convertNsiDetailList(NsiDetailList nsiDetailList, AAIServiceAndInstance aaiServiceAndInstance)
+ throws IllegalAccessException, IOException, InvocationTargetException {
+
+ List<String> businessIdList = new ArrayList<>();
+ List<String> nssiIdList = new ArrayList<>();
+ getBusinessAndNssiIds(aaiServiceAndInstance, businessIdList, nssiIdList);
+
+ List<HostedBusinessInfo> hostedBusinessInfoList = new ArrayList<>();
+ getHostedBusinessInfoList(hostedBusinessInfoList, businessIdList);
+ nsiDetailList.setHostedBusinessInfoList(hostedBusinessInfoList);
+
+ List<IncludedNssiInfo> includedNssiInfoList = new ArrayList<>();
+ getIncludedNssiInfoList(includedNssiInfoList, nssiIdList);
+ nsiDetailList.setIncludedNssiInfoList(includedNssiInfoList);
+
+ }
+
+ void getIncludedNssiInfoList(List<IncludedNssiInfo> includedNssiInfoList, List<String> nssiIdList)
+ throws IOException, InvocationTargetException, IllegalAccessException {
+ int i = 0;
+ for (String nssiId : nssiIdList) {
+ i++;
+ try {
+ // TODO
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceById(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, nssiId)
+ .execute();
+ if (response.isSuccessful()) {
+ logger.info("getIncludedNssiInfoList:listServiceById reponse is:{}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstance = generalConvert.listServiceByIdUtil(object);
+ IncludedNssiInfo includedNssiInfo = new IncludedNssiInfo();
+ BeanUtils.copyProperties(includedNssiInfo, aaiServiceAndInstance);
+ includedNssiInfo.setServiceInstanceId(nssiId);
+ includedNssiInfo.setServiceInstanceOrder(String.valueOf(i));
+ includedNssiInfoList.add(includedNssiInfo);
+
+ } else {
+ logger.error(String
+ .format("getIncludedNssiInfoList:Can not get listServiceById [code={}, message={}]",
+ response.code(),
+ response.message()));
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ }
+
+ void getHostedBusinessInfoList(List<HostedBusinessInfo> hostedBusinessInfoList, List<String> businessIdList)
+ throws IOException, InvocationTargetException, IllegalAccessException {
+ for (String businessId : businessIdList) {
+ try {
+ // TODO
+ // 添加给slicingTaskCreationProgress赋值的代码
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceById(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, businessId)
+ .execute();
+ if (response.isSuccessful()) {
+ logger.info("getHostedBusinessInfoList: listServiceById reponse is:{}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstance = generalConvert.listServiceByIdUtil(object);
+ HostedBusinessInfo hostedBusinessInfo = new HostedBusinessInfo();
+ BeanUtils.copyProperties(hostedBusinessInfo, aaiServiceAndInstance);
+ hostedBusinessInfo.setServiceInstanceId(businessId);
+ hostedBusinessInfoList.add(hostedBusinessInfo);
+
+ } else {
+ logger.error(String
+ .format("getHostedBusinessInfoList: Can not get listServiceById [code={}, message={}]",
+ response.code(),
+ response.message()));
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ }
+
+ void getBusinessAndNssiIds(AAIServiceAndInstance aaiServiceAndInstance, List<String> businessIdList,
+ List<String> nssiIdList) {
+ List<Relationship> relationshipList = aaiServiceAndInstance.getRelationshipList();
+ if (relationshipList != null && relationshipList.size() > 0) {
+ for (Relationship relationship : relationshipList) {
+ if (relationship.getRelatedTo().equals(NsmfParamConstant.ALLOTTED_RESOURCE)) {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData();
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey()
+ .equals(NsmfParamConstant.SERVICE_INSTANCE_SERVICE_INSTANCE_ID)) {
+ businessIdList.add(relationshipData.getRelationshipValue());
+ }
+ }
+ }
+ if (relationship.getRelatedTo().equals(NsmfParamConstant.SERVICE_INSTANCE)) {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData();
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey()
+ .equals(NsmfParamConstant.SERVICE_INSTANCE_SERVICE_INSTANCE_ID)) {
+ nssiIdList.add(relationshipData.getRelationshipValue());
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ void convertNsiRelatedNssiInfo(NsiRelatedNssiInfo nsiRelatedNssiInfo, AAIServiceAndInstance aaiServiceAndInstance)
+ throws IllegalAccessException, IOException, InvocationTargetException {
+
+ List<String> nssiIdList = new ArrayList<>();
+ List<String> businessIdList = new ArrayList<>();
+ getBusinessAndNssiIds(aaiServiceAndInstance, businessIdList, nssiIdList);
+ List<IncludedNssiInfo> includedNssiInfoList = new ArrayList<>();
+ getIncludedNssiInfoList(includedNssiInfoList, nssiIdList);
+ getNsiRelatedNssiInfo(nsiRelatedNssiInfo, includedNssiInfoList);
+
+ }
+
+ void getNsiRelatedNssiInfo(NsiRelatedNssiInfo nsiRelatedNssiInfo, List<IncludedNssiInfo> includedNssiInfoList) {
+ for (IncludedNssiInfo includedNssiInfo : includedNssiInfoList) {
+ if (includedNssiInfo.getEnvironmentContext().equals(NsmfParamConstant.AN_NAME)) {
+ nsiRelatedNssiInfo.setAnSuggestNssiId(includedNssiInfo.getServiceInstanceId());
+ nsiRelatedNssiInfo.setAnSuggestNssiName(includedNssiInfo.getServiceInstanceName());
+ }
+
+ if (includedNssiInfo.getEnvironmentContext().equals(NsmfParamConstant.TN_NAME)) {
+ nsiRelatedNssiInfo.setTnSuggestNssiId(includedNssiInfo.getServiceInstanceId());
+ nsiRelatedNssiInfo.setTnSuggestNssiName(includedNssiInfo.getServiceInstanceName());
+ }
+
+ if (includedNssiInfo.getEnvironmentContext().equals(NsmfParamConstant.CN_NAME)) {
+ nsiRelatedNssiInfo.setCnSuggestNssiId(includedNssiInfo.getServiceInstanceId());
+ nsiRelatedNssiInfo.setCnSuggestNssiName(includedNssiInfo.getServiceInstanceName());
+ }
+ }
+ }
+
+ void convertNssiServiceInstanceList(NssiServiceInstanceList nssiServiceInstanceList,
+ AAIServiceRsp aAIServiceRsp,
+ int pageNo, int pageSize)
+ throws InvocationTargetException, IllegalAccessException {
+ if (aAIServiceRsp.getaAIService() == null || aAIServiceRsp.getaAIService().size() == 0) {
+ logger.error("convertNssiServiceInstanceList: aAIServiceRsp.getaAIService() is null or size is 0");
+ return;
+ }
+
+ List<NssiServiceInstanceInfo> nssiServiceInstanceInfoList = new ArrayList<>();
+ int i = 0;
+ for (AAIService aaiService : aAIServiceRsp.getaAIService()) {
+ i++;
+ NssiServiceInstanceInfo nssiServiceInstanceInfo = new NssiServiceInstanceInfo();
+ BeanUtils.copyProperties(nssiServiceInstanceInfo, aaiService);
+ nssiServiceInstanceInfo.setServiceInstanceOrder(String.valueOf(i));
+ nssiServiceInstanceInfoList.add(nssiServiceInstanceInfo);
+ }
+ PagedResult pagedOrderList = NsmfCommonUtil.getPagedList(nssiServiceInstanceInfoList, pageNo, pageSize);
+ nssiServiceInstanceList.setNssiServiceInstanceInfoList(pagedOrderList.getPagedList());
+ nssiServiceInstanceList.setRecordNumber(nssiServiceInstanceInfoList.size());
+ }
+
+ void convertNssiDetails(HostedNsiList hostedNsiList, AAIServiceAndInstance aaiServiceAndInstance)
+ throws InvocationTargetException, IllegalAccessException, IOException {
+
+ List<String> nsiIdList = new ArrayList<>();
+ List<String> emptyList = new ArrayList<>();
+ getBusinessAndNssiIds(aaiServiceAndInstance, emptyList, nsiIdList);
+ List<HostedNsiInfo> hostedNsiInfoList = new ArrayList<>();
+ for (String nsiId : nsiIdList) {
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.querySerAndSubInsByNSI(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, nsiId).execute();
+ if (response.isSuccessful()) {
+ JSONObject object = response.body();
+ logger.info("convertNssiDetails: querySerAndSubInsByNSI reponse is:{}", response.body());
+ AAIServiceAndInstance aaiNssi = queryNsiDetailsUtils(object);
+ HostedNsiInfo hostedNsiInfo = new HostedNsiInfo();
+ hostedNsiInfo.setServiceInstanceId(aaiNssi.getServiceInstanceId());
+ hostedNsiInfo.setServiceInstanceName(aaiNssi.getServiceInstanceName());
+ hostedNsiInfo.setServiceType(aaiNssi.getServiceType());
+ hostedNsiInfo.setOrchestrationStatus(aaiNssi.getOrchestrationStatus());
+ hostedNsiInfoList.add(hostedNsiInfo);
+ } else {
+ logger.error(String.format("convertNssiDetails: Can not get listServiceById [code={}, message={}]",
+ response.code(),
+ response.message()));
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ hostedNsiList.setHostedNsiInfoList(hostedNsiInfoList);
+ hostedNsiList.setRecordNumber(hostedNsiInfoList.size());
+ }
+
+ SubscriberInfo buildSubscriberInfo(String globalSubscriberId, String serviceType) {
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId(globalSubscriberId);
+ subscriberInfo.setServiceType(serviceType);
+ return subscriberInfo;
+ }
+
+ void buildAAIServiceRsp(AAIServiceRsp aAIServiceRsp, JSONArray array) {
+ List<AAIService> aaiserviceList = new ArrayList<AAIService>();
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject object = array.getJSONObject(i);
+ AAIService aaiService = new AAIService();
+ aaiService.setServiceInstanceId(object.getString("service-instance-id"));
+ aaiService.setServiceInstanceName(object.getString("service-instance-name"));
+ aaiService.setServiceType(object.getString("service-type"));
+ aaiService.setEnvironmentContext(object.getString("environment-context"));
+ aaiService.setOrchestrationStatus(object.getString("orchestration-status"));
+ aaiserviceList.add(aaiService);
+ }
+ aAIServiceRsp.setaAIService(aaiserviceList);
+ }
+
+ public AAIServiceAndInstance queryNsiDetailsUtils(JSONObject object) {
+ if (object.containsKey("relationship-list")) {
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ aaiServiceAndInstance.setServiceInstanceId(object.getString("service-instance-id"));
+ aaiServiceAndInstance.setServiceInstanceName(object.getString("service-instance-name"));
+ aaiServiceAndInstance.setModelInvariantId(object.getString("model-invariant-id"));
+ aaiServiceAndInstance.setModelVersionId(object.getString("model-version-id"));
+ aaiServiceAndInstance.setServiceType(object.getString("service-type"));
+ aaiServiceAndInstance.setOrchestrationStatus(object.getString("orchestration-status"));
+
+ JSONArray array = object.getJSONObject("relationship-list").getJSONArray("relationship");
+ List<Relationship> relationshipList = new ArrayList<Relationship>();
+ for (int i = 0; i < array.size(); i++) {
+
+ Relationship relationship = new Relationship();
+ JSONObject objectShip = array.getJSONObject(i);
+ JSONArray arrayData = objectShip.getJSONArray("relationship-data");
+ relationship.setRelatedTo(objectShip.getString("related-to"));
+ List<RelationshipData> RelationshipDataList = new ArrayList<RelationshipData>();
+ for (int j = 0; j < arrayData.size(); j++) {
+ RelationshipData relationshipData = new RelationshipData();
+ JSONObject objectData = arrayData.getJSONObject(j);
+ relationshipData.setRelationshipKey(objectData.getString("relationship-key"));
+ relationshipData.setRelationshipValue(objectData.getString("relationship-value"));
+ RelationshipDataList.add(relationshipData);
+ }
+ relationshipList.add(relationship);
+ relationship.setRelationshipData(RelationshipDataList);
+
+ }
+ aaiServiceAndInstance.setRelationshipList(relationshipList);
+ return aaiServiceAndInstance;
+ } else {
+ return null;
+ }
+ }
+
+ public List<AAIServiceAndInstance> queryAllottedResourceUtil(JSONObject objectResource) {
+ JSONArray arrayResource = objectResource.getJSONArray("allotted-resource");
+ if (arrayResource == null || arrayResource.size() == 0) {
+ logger.error("arrayResource is null or size is 0");
+ return null;
+ }
+
+ List<AAIServiceAndInstance> aaiServiceAndInstanceList = new ArrayList<AAIServiceAndInstance>();
+ for (int i = 0; i < arrayResource.size(); i++) {
+ JSONObject object = arrayResource.getJSONObject(i);
+ if (object.containsKey("relationship-list")) {
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ JSONArray array = object.getJSONObject("relationship-list").getJSONArray("relationship");
+ List<Relationship> relationshipList = new ArrayList<Relationship>();
+ for (int j = 0; j < array.size(); j++) {
+
+ Relationship relationship = new Relationship();
+ JSONObject objectShip = array.getJSONObject(j);
+ JSONArray arrayData = objectShip.getJSONArray("relationship-data");
+ relationship.setRelatedTo(objectShip.getString("related-to"));
+ List<RelationshipData> RelationshipDataList = new ArrayList<RelationshipData>();
+ for (int h = 0; h < arrayData.size(); h++) {
+ RelationshipData relationshipData = new RelationshipData();
+ JSONObject objectData = arrayData.getJSONObject(h);
+ relationshipData.setRelationshipKey(objectData.getString("relationship-key"));
+ relationshipData.setRelationshipValue(objectData.getString("relationship-value"));
+ RelationshipDataList.add(relationshipData);
+ }
+ relationshipList.add(relationship);
+ relationship.setRelationshipData(RelationshipDataList);
+
+ }
+ aaiServiceAndInstance.setRelationshipList(relationshipList);
+ aaiServiceAndInstanceList.add(aaiServiceAndInstance);
+ } else {
+ return null;
+ }
+ }
+ return aaiServiceAndInstanceList;
+ }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceImpl.java
new file mode 100644
index 00000000..abb15a54
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/nsmf/impl/ResourceMgtServiceImpl.java
@@ -0,0 +1,863 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.service.nsmf.impl;
+
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.text.ParseException;
+import java.util.List;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import javax.annotation.Resource;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+import org.onap.usecaseui.server.bean.ServiceInstanceOperations;
+import org.onap.usecaseui.server.bean.nsmf.common.ResultHeader;
+import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
+import org.onap.usecaseui.server.bean.nsmf.resource.HostedNsiList;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiDetailList;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiRelatedNssiInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.NsiServiceInstanceList;
+import org.onap.usecaseui.server.bean.nsmf.resource.NssiServiceInstanceList;
+import org.onap.usecaseui.server.bean.nsmf.resource.ServiceOperationProgress;
+import org.onap.usecaseui.server.bean.nsmf.resource.ServiceOperationResult;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessDetails;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessInfo;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessList;
+import org.onap.usecaseui.server.bean.nsmf.resource.SubscriberInfo;
+import org.onap.usecaseui.server.constant.CommonConstant;
+import org.onap.usecaseui.server.constant.nsmf.NsmfCodeConstant;
+import org.onap.usecaseui.server.constant.nsmf.NsmfParamConstant;
+import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
+import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
+import org.onap.usecaseui.server.service.slicingdomain.aai.AAISliceService;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceAndInstance;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceInstance;
+import org.onap.usecaseui.server.service.slicingdomain.aai.bean.AAIServiceRsp;
+import org.onap.usecaseui.server.service.slicingdomain.so.SOSliceService;
+import org.onap.usecaseui.server.service.slicingdomain.so.bean.ActivateService;
+import org.onap.usecaseui.server.service.slicingdomain.so.bean.SOOperation;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+import retrofit2.Response;
+
+@Service("ResourceMgtService")
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class ResourceMgtServiceImpl implements ResourceMgtService {
+
+ private static final Logger logger = LoggerFactory.getLogger(ResourceMgtServiceImpl.class);
+ @Resource(name = "ServiceLcmService")
+ private ServiceLcmService serviceLcmService;
+
+ private ResourceMgtServiceConvert resourceMgtServiceConvert = new ResourceMgtServiceConvert();
+ GeneralConvertImpl generalConvert = new GeneralConvertImpl();
+
+ private AAISliceService aaiSliceService;
+ private SOSliceService soSliceService;
+ Gson gson = new Gson();
+
+ public ResourceMgtServiceImpl() {
+ this(RestfulServices.create(AAISliceService.class), RestfulServices.create(SOSliceService.class));
+ }
+
+ public ResourceMgtServiceImpl(AAISliceService aaiSliceService, SOSliceService soSliceService) {
+ this.aaiSliceService = aaiSliceService;
+ this.soSliceService = soSliceService;
+ }
+
+ @Override
+ public ServiceResult querySlicingBusiness(int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ SlicingBusinessList slicingBusinessList = new SlicingBusinessList();
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ String resultMsg;
+
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .listService(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G).execute();
+ if (response.isSuccessful()) {
+ logger.info("querySlicingBusiness: listService reponse is:{}", response.body());
+ Type type = new TypeToken<List<AAIServiceInstance>>() {
+ }.getType();
+
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert.convertSlicingBusinessList(slicingBusinessList,
+ aAIServiceRsp, pageNo, pageSize);
+ addBusinessProgress(slicingBusinessList);
+ // return normal result code
+ resultMsg = "5G slicing business instances query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("querySlicingBusiness: Can not get slicingBusinessList[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing task result query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing business instances query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("querySlicingBusiness: 5G slicing business instances query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(slicingBusinessList);
+ return serviceResult;
+ }
+
+ public void addBusinessProgress(SlicingBusinessList slicingBusinessList) {
+ if (slicingBusinessList.getSlicingBusinessInfoList() == null
+ || slicingBusinessList.getSlicingBusinessInfoList().size() == 0) {
+ logger.error(
+ "addBusinessProgress: slicingBusinessList.getSlicingBusinessInfoList() is null or slicingBusinessList.getSlicingBusinessInfoList() size is 0.");
+ return;
+ }
+
+ for (SlicingBusinessInfo slicingBusinessInfo : slicingBusinessList.getSlicingBusinessInfoList()) {
+ String businessId = slicingBusinessInfo.getServiceInstanceId();
+ ServiceInstanceOperations serviceInstanceOperations = serviceLcmService
+ .getServiceInstanceOperationById(businessId);
+ if (null == serviceInstanceOperations || serviceInstanceOperations.getOperationId() == null) {
+ logger.error(
+ "addBusinessProgress: null == serviceInstanceOperations for businessId:{}.",
+ businessId);
+ continue;
+ }
+ String operationId = serviceInstanceOperations.getOperationId();
+ Response<SOOperation> response = null;
+ try {
+ response = this.soSliceService.queryOperationProgress(businessId, operationId)
+ .execute();
+ if (response.isSuccessful()) {
+ SOOperation soOperation = response.body();
+ Gson gson = new Gson();
+ logger.info("addBusinessProgress: queryOperationProgress reponse is:{}",
+ gson.toJson(soOperation).toString());
+ if (soOperation == null || soOperation.getOperation() == null) {
+ logger.error("addBusinessProgress: soOperation is null or getOperation() is null for businessId {}!", businessId);
+ continue;
+ }
+ String operationResult = soOperation.getOperation().getResult();
+ String operationType = soOperation.getOperation().getOperation();
+ int progress = soOperation.getOperation().getProgress();
+ logger.info("addBusinessProgress: operationResult is:{}, operationType is {}, progress is {}",
+ operationResult, operationType, progress);
+ if (operationResult.equals(NsmfCodeConstant.OPERATION_ERROR_STATUS)) {
+ logger.error("addBusinessProgress: progress is ok, but operationResult is error for businessId {}!", businessId);
+ continue;
+ }
+ slicingBusinessInfo.setLastOperationType(operationType);
+ slicingBusinessInfo.setLastOperationProgress(String.valueOf(progress));
+ }
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ logger.error("addBusinessProgress: catch an IOException for businessId {}!", businessId);
+ continue;
+ }
+ }
+ }
+
+ @Override
+ public ServiceResult querySlicingBusinessByStatus(String processingStatus, int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ SlicingBusinessList slicingBusinessList = new SlicingBusinessList();
+ String resultMsg;
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.listServiceByStatus(
+ NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, processingStatus).execute();
+ if (response.isSuccessful()) {
+ logger.info("querySlicingBusinessByStatus: listServiceByStatus reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert.convertSlicingBusinessList(slicingBusinessList,
+ aAIServiceRsp, pageNo, pageSize);
+ addBusinessProgress(slicingBusinessList);
+ // return normal result code
+ resultMsg = "5G slicing business instances query based on status result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("querySlicingBusinessByStatus: Can not get slicingBusinessList[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing task result query based on status failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing business instances query based on status failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info(
+ "querySlicingBusinessByStatus: 5G slicing business instances query based on status has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(slicingBusinessList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult querySlicingBusinessDetails(String businessId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ SlicingBusinessDetails slicingBusinessDetails = new SlicingBusinessDetails();
+ String resultMsg;
+
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceById(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, businessId)
+ .execute();
+ if (response.isSuccessful()) {
+ logger.info("querySlicingBusinessDetails: listServiceById reponse is:{}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstance = generalConvert.listServiceByIdUtil(object);
+ resourceMgtServiceConvert.convertBusinessDetails(businessId,
+ slicingBusinessDetails, aaiServiceAndInstance);
+ resultMsg = "5G slicing business details query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("querySlicingBusinessDetails: Can not get AAIServiceInstance[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing business details query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing business details query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("querySlicingBusinessDetails: 5G slicing business details query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(slicingBusinessDetails);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNsiInstances(int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NsiServiceInstanceList nsiServiceInstanceList = new NsiServiceInstanceList();
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+
+ String resultMsg;
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceNSI(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNsiInstances: listServiceNSI reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert.convertHostedNsiList(nsiServiceInstanceList, aAIServiceRsp,
+ pageNo, pageSize);
+ resultMsg = "5G slicing NSI service instances query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("queryNsiInstances: Can not get AAIServiceInstanceRsp[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing NSI service instances query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing NSI service instances query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("queryNsiInstances: 5G slicing NSI service instances query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nsiServiceInstanceList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNsiInstancesByStatus(String instanceStatus, int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NsiServiceInstanceList nsiServiceInstanceList = new NsiServiceInstanceList();
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ String resultMsg;
+
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.listServiceNSIByStatus(
+ NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, instanceStatus).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNsiInstancesByStatus: listServiceNSIByStatus reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert.convertHostedNsiList(nsiServiceInstanceList, aAIServiceRsp,
+ pageNo, pageSize);
+ resultMsg = "5G slicing NSI service instances based on status result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNsiInstancesByStatus: Can not get AAIServiceInstanceRsp[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing NSI service instances based on status query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing NSI service instances based on status query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info(
+ "queryNsiInstancesByStatus: 5G slicing NSI service instances based on status query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nsiServiceInstanceList);
+ return serviceResult;
+ }
+
+
+ @Override
+ public ServiceResult queryNsiDetails(String serviceInstanceId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NsiDetailList nsiDetailList = new NsiDetailList();
+ String resultMsg;
+
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.querySerAndSubInsByNSI(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, serviceInstanceId).execute();
+ if (response.isSuccessful()) {
+ JSONObject object = response.body();
+ logger.info("queryNsiDetails: querySerAndSubInsByNSI reponse is:{}", response.body());
+ AAIServiceAndInstance aaiServiceAndInstance = resourceMgtServiceConvert.queryNsiDetailsUtils(object);
+ resourceMgtServiceConvert.convertNsiDetailList(nsiDetailList,
+ aaiServiceAndInstance);
+ resultMsg = "5G slicing business details query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNsiDetails: Can not get AAIServiceAndInstance[code={}, message={}]", response.code(),
+ response.message()));
+ resultMsg = "5G slicing business details query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing business details query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("queryNsiDetails: 5G slicing business details query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nsiDetailList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNsiRelatedNssiInfo(String nsiId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NsiRelatedNssiInfo nsiRelatedNssiInfo = new NsiRelatedNssiInfo();
+ String resultMsg;
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .querySerAndSubInsByNSI(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, nsiId)
+ .execute();
+ if (response.isSuccessful()) {
+ JSONObject object = response.body();
+ logger.info("queryNsiRelatedNssiInfo: querySerAndSubInsByNSI reponse is:{}", response.body());
+ AAIServiceAndInstance aaiServiceAndInstance = resourceMgtServiceConvert.queryNsiDetailsUtils(object);
+ resourceMgtServiceConvert.convertNsiRelatedNssiInfo(nsiRelatedNssiInfo,
+ aaiServiceAndInstance);
+ resultMsg = "NSSI associated with NSI result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNsiRelatedNssiInfo: Can not get AAIServiceAndInstance[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "NSSI associated with NSI result query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "NSSI associated with NSI query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("queryNsiRelatedNssiInfo: NSSI associated with NSI query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nsiRelatedNssiInfo);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNssiInstances(int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NssiServiceInstanceList nssiServiceInstanceList = new NssiServiceInstanceList();
+ String resultMsg;
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .listServiceNSSI(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNssiInstances: listServiceNSSI reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert
+ .convertNssiServiceInstanceList(nssiServiceInstanceList, aAIServiceRsp, pageNo, pageSize);
+ resultMsg = "5G slicing NSI service instances query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("queryNssiInstances: Can not get AAIServiceInstanceRsp[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing NSSI service instances result query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+
+ } catch (Exception e) {
+ resultMsg = "5G slicing NSSI service instances query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("queryNssiInstances: 5G slicing NSSI service instances query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nssiServiceInstanceList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNssiInstancesByStatus(String instanceStatus, int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NssiServiceInstanceList nssiServiceInstanceList = new NssiServiceInstanceList();
+ String resultMsg;
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.listServiceNSSIByStatus(
+ NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, instanceStatus).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNssiInstancesByStatus: listServiceNSSIByStatus reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert
+ .convertNssiServiceInstanceList(nssiServiceInstanceList, aAIServiceRsp, pageNo, pageSize);
+ // return normal result code
+ resultMsg = "5G slicing NSSI service instances based on status result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNssiInstancesByStatus: Can not get AAIServiceInstanceRsp[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing NSSI service instances based on status query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing NSSI service instances based on status query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info(
+ "queryNssiInstancesByStatus: 5G slicing NSSI service instances based on status query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nssiServiceInstanceList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNssiInstancesByEnvironment(String environmentContext, int pageNo, int pageSize) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+
+ NssiServiceInstanceList nssiServiceInstanceList = new NssiServiceInstanceList();
+ String resultMsg;
+ AAIServiceRsp aAIServiceRsp = new AAIServiceRsp();
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService.listServiceNSSIByEnv(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G, environmentContext).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNssiInstancesByEnvironment: listServiceNSSIByEnv reponse is:{}", response.body());
+ JSONArray array = response.body().getJSONArray("service-instance");
+ resourceMgtServiceConvert.buildAAIServiceRsp(aAIServiceRsp, array);
+ resourceMgtServiceConvert
+ .convertNssiServiceInstanceList(nssiServiceInstanceList, aAIServiceRsp, pageNo, pageSize);
+ resultMsg = "5G slicing NSSI query based on environment context result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNssiInstancesByEnvironment: Can not get AAIServiceInstanceRsp[code={}, message={}]",
+ response.code(),
+ response.message()));
+ resultMsg = "5G slicing NSSI service instances based on environment query failed!";
+ if (response.code() == NsmfCodeConstant.RESOURCE_NOT_FOUND_CODE){
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }else {
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing NSSI service instances based on environment query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info(
+ "queryNssiInstancesByEnvironment: 5G slicing NSSI service instances based on environment query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(nssiServiceInstanceList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryNssiDetails(String nssiId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ AAIServiceAndInstance aaiServiceAndInstance = new AAIServiceAndInstance();
+ HostedNsiList hostedNsiList = new HostedNsiList();
+ String resultMsg;
+
+ try {
+ // TODO
+ Response<JSONObject> response = this.aaiSliceService
+ .queryNSIByNSSI(NsmfParamConstant.CUSTOM_5G, NsmfParamConstant.SERVICE_TYPE_5G, nssiId).execute();
+ if (response.isSuccessful()) {
+ logger.info("queryNssiDetails: queryNSIByNSSI reponse is:{}", response.body());
+ JSONObject object = response.body();
+ aaiServiceAndInstance = generalConvert.queryServiceUtil(object);
+ resourceMgtServiceConvert.convertNssiDetails(hostedNsiList, aaiServiceAndInstance);
+ resultMsg = "5G slicing service nssi details query result.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String
+ .format("queryNssiDetails: Can not get AAIServiceAndInstance[code={}, message={}]", response.code(),
+ response.message()));
+ resultMsg = "5G slicing service nssi details query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing service nssi details query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("queryNssiDetails: 5G slicing service nssi details query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(hostedNsiList);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult activateSlicingService(String serviceId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ ServiceOperationResult serviceActiveResult = new ServiceOperationResult();
+ String resultMsg;
+
+ try {
+ // TODO
+ SubscriberInfo subscriberInfo = resourceMgtServiceConvert.buildSubscriberInfo(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G);
+ String jsonstr = JSON.toJSONString(subscriberInfo);
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonstr.toString());
+ Response<ActivateService> activeResponse = this.soSliceService.activeService(serviceId, requestBody)
+ .execute();
+
+ if (activeResponse.isSuccessful()) {
+ ActivateService activateService = activeResponse.body();
+ logger.info("activateSlicingService: activeService reponse is:{}",
+ gson.toJson(activateService).toString());
+ String operationId = activateService.getOperationId();
+ serviceActiveResult.setOperationId(operationId);
+ ServiceInstanceOperations serviceOpera = new ServiceInstanceOperations(serviceId, operationId,
+ NsmfCodeConstant.ACTIVATE_TYPE, "0", CommonConstant.IN_PROGRESS_CODE,
+ DateUtils.dateToString(DateUtils.now()), null);
+ serviceLcmService.saveOrUpdateServiceInstanceOperation(serviceOpera);
+ resultMsg = "5G slicing service activated normally.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("activateSlicingService: Can not get ActivateService[code={}, message={}]",
+ activeResponse.code(),
+ activeResponse.message()));
+ resultMsg = "5G slicing service activated failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing service activation failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("activateSlicingService: 5G slicing service activation has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(serviceActiveResult);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult deactivateSlicingService(String serviceId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ ServiceOperationResult serviceDeactivateResult = new ServiceOperationResult();
+ String resultMsg;
+
+ try {
+ // TODO
+ SubscriberInfo subscriberInfo = resourceMgtServiceConvert.buildSubscriberInfo(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G);
+ String jsonstr = JSON.toJSONString(subscriberInfo);
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonstr.toString());
+ Response<ActivateService> activeResponse = this.soSliceService.deactiveService(serviceId, requestBody)
+ .execute();
+
+ if (activeResponse.isSuccessful()) {
+ ActivateService activateService = activeResponse.body();
+ logger.info("deactivateSlicingService: deactiveService reponse is:{}",
+ gson.toJson(activateService).toString());
+ String operationId = activateService.getOperationId();
+ serviceDeactivateResult.setOperationId(operationId);
+ ServiceInstanceOperations serviceOpera = new ServiceInstanceOperations(serviceId, operationId,
+ NsmfCodeConstant.DEACTIVATE_TYPE, "0", CommonConstant.IN_PROGRESS_CODE,
+ DateUtils.dateToString(DateUtils.now()), null);
+ serviceLcmService.saveOrUpdateServiceInstanceOperation(serviceOpera);
+ resultMsg = "5G slicing service deactivated normally.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("deactivateSlicingService: Can not get ActivateService[code={}, message={}]",
+ activeResponse.code(),
+ activeResponse.message()));
+ resultMsg = "5G slicing service deactivation failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing service deactivation failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("deactivateSlicingService: 5G slicing service deactivation has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(serviceDeactivateResult);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult terminateSlicingService(String serviceId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ ServiceOperationResult serviceTerminateResult = new ServiceOperationResult();
+ String resultMsg;
+
+ try {
+ // TODO
+ SubscriberInfo subscriberInfo = resourceMgtServiceConvert.buildSubscriberInfo(NsmfParamConstant.CUSTOM_5G,
+ NsmfParamConstant.SERVICE_TYPE_5G);
+ String jsonstr = JSON.toJSONString(subscriberInfo);
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonstr.toString());
+ Response<ActivateService> activeResponse = this.soSliceService.terminateService(serviceId, requestBody)
+ .execute();
+
+ if (activeResponse.isSuccessful()) {
+ ActivateService activateService = activeResponse.body();
+ logger.info("terminateSlicingService: terminateService reponse is:{}",
+ gson.toJson(activateService).toString());
+ String operationId = activateService.getOperationId();
+ serviceTerminateResult.setOperationId(activateService.getOperationId());
+ ServiceInstanceOperations serviceOpera = new ServiceInstanceOperations(serviceId, operationId,
+ NsmfCodeConstant.DELETE_TYPE, "0", CommonConstant.IN_PROGRESS_CODE,
+ DateUtils.dateToString(DateUtils.now()), null);
+ serviceLcmService.saveOrUpdateServiceInstanceOperation(serviceOpera);
+ resultMsg = "5G slicing service terminated normally.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ } else {
+ logger.error(String.format("terminateSlicingService: Can not get ActivateService[code={}, message={}]",
+ activeResponse.code(),
+ activeResponse.message()));
+ resultMsg = "5G slicing service termination failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } catch (Exception e) {
+ resultMsg = "5G slicing service termination failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("terminateSlicingService: 5G slicing service termination has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(serviceTerminateResult);
+ return serviceResult;
+ }
+
+ @Override
+ public ServiceResult queryOperationProgress(String serviceId) {
+ ServiceResult serviceResult = new ServiceResult();
+ ResultHeader resultHeader = new ResultHeader();
+ ServiceOperationProgress operationProgress = new ServiceOperationProgress();
+ String resultMsg = "";
+
+ try {
+ // TODO
+ ServiceInstanceOperations serviceInstanceOperations = serviceLcmService
+ .getServiceInstanceOperationById(serviceId);
+ if (serviceInstanceOperations != null) {
+ String operationId = serviceInstanceOperations.getOperationId();
+ logger.info("queryOperationProgress: operationId is:{}", operationId);
+ Response<SOOperation> response = this.soSliceService.queryOperationProgress(serviceId, operationId)
+ .execute();
+ if (response.isSuccessful()) {
+ SOOperation soOperation = response.body();
+ Gson gson = new Gson();
+ logger.info("queryOperationProgress: queryOperationProgress reponse is:{}",
+ gson.toJson(soOperation).toString());
+ if (soOperation == null || soOperation.getOperation() == null
+ || soOperation.getOperation().getOperation() == null) {
+ logger.error("queryOperationProgress: soOperation is null or getOperation() is null!");
+ resultMsg = "5G slicing service operation progress query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ } else {
+ String operationResult = soOperation.getOperation().getResult();
+ String operationType = soOperation.getOperation().getOperation();
+ int progress = soOperation.getOperation().getProgress();
+ logger
+ .info("queryOperationProgress: operationResult is:{}, operationType is {}, progress is {}",
+ operationResult, operationType, String.valueOf(progress));
+ if (operationResult.equals(NsmfCodeConstant.OPERATION_ERROR_STATUS)) {
+ logger.error("queryOperationProgress: operationResult is error");
+ resultMsg = "5G slicing service operation progress query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ } else {
+ // return normal result code
+ operationProgress.setOperationType(operationType);
+ operationProgress.setOperationProgress(String.valueOf(progress));
+ resultMsg = "5G slicing service operation progress.";
+ resultHeader.setResult_code(NsmfCodeConstant.SUCCESS_CODE);
+ }
+ }
+ } else {
+ logger.error(String.format("Can not get SOOperation[code={}, message={}]", response.code(),
+ response.message()));
+ resultMsg = "5G slicing service operation progress query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+ } else {
+ logger.error("queryOperationProgress: serviceInstanceOperations is null!");
+ resultMsg = "5G slicing service operation progress query failed!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ }
+
+ } catch (Exception e) {
+ resultMsg = "5G slicing service operation progress query failed. Unknown exception occurred!";
+ resultHeader.setResult_code(NsmfCodeConstant.ERROR_CODE_UNKNOWN);
+ logger.error(e.getMessage());
+ }
+
+ logger.info(resultMsg);
+ logger.info("5G slicing service operation progress query has been finished.");
+ resultHeader.setResult_message(resultMsg);
+ serviceResult.setResult_header(resultHeader);
+ serviceResult.setResult_body(operationProgress);
+ return serviceResult;
+ }
+
+}