2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2022 Deutsche telekom
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 package org.onap.so.bpmn.moi.tasks;
24 import com.fasterxml.jackson.core.JsonProcessingException;
25 import com.fasterxml.jackson.databind.ObjectMapper;
26 import org.onap.aaiclient.client.aai.AAIRestClientImpl;
27 import org.onap.so.bpmn.common.BuildingBlockExecution;
28 import org.onap.so.bpmn.common.InjectionHelper;
29 import org.onap.so.bpmn.moi.util.AAISliceProfileUtil;
30 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
35 import java.util.ArrayList;
36 import java.util.List;
41 public class DeleteRANNssiBBTask {
42 private static final Logger LOGGER = LoggerFactory.getLogger(DeleteRANNssiBBTask.class);
45 private InjectionHelper injectionHelper;
48 AAISliceProfileUtil aaiSliceProfileUtil;
50 private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
52 private static final ObjectMapper mapper = new ObjectMapper();
55 public void deleteNssi(BuildingBlockExecution execution) throws JsonProcessingException {
56 GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
57 List<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams();
58 String sliceProfileIdFromRequest = mapUserParamsToSliceProfile(sliceProfilesData);
59 aaiSliceProfileUtil.deleteSliceProfile(execution, sliceProfileIdFromRequest);
64 private String mapUserParamsToSliceProfile(List<Map<String, Object>> sliceProfilesData)
65 throws JsonProcessingException {
66 Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
67 List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
68 Map<String, Object> idMap = (Map<String, Object>) list.get(0);
69 String sliceProfileId = (String) idMap.get("sliceProfileId");
70 return sliceProfileId;