+ private boolean isServiceOperationInformationNotExists(final String serviceInstanceId,
+ final GenericResourceApiServiceOperationInformation input) {
+ final GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = input.getSdncRequestHeader();
+ final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
+ getGenericResourceApiServicemodelinfrastructureService(serviceInstanceId);
+
+ if (optional.isPresent()) {
+ final GenericResourceApiServicemodelinfrastructureService existingService = optional.get();
+ final GenericResourceApiServicestatusServiceStatus serviceStatus = existingService.getServiceStatus();
+ if (serviceStatus != null) {
+ final GenericResourceApiRpcActionEnumeration rpcAction = serviceStatus.getRpcAction();
+ final String svcAction = getSvcAction(requestHeader);
+ if (rpcAction != null && rpcAction.toString().equals(svcAction)) {
+ LOGGER.error("Found Service with id: {} and RpcAction: {} same as SvcAction: {}",
+ serviceInstanceId, rpcAction, svcAction);
+ return false;
+ }
+
+ final Cache cache = getCache(SERVICE_TOPOLOGY_OPERATION_CACHE);
+ LOGGER.info(
+ "Deleting existing GenericResourceApiServiceOperationInformation from cache using key: {} as SvcAction is changed from {} to {}",
+ serviceInstanceId, rpcAction, svcAction);
+ cache.evict(serviceInstanceId);
+ }
+ }
+ return true;
+
+ }
+
+ @Override
+ public Output putVfModuleOperationInformation(
+ GenericResourceApiVfModuleOperationInformation input) {
+
+ final GenericResourceApiServiceinformationServiceInformation serviceInformation = input.getServiceInformation();
+ final GenericResourceApiVnfinformationVnfInformation vnfInformation = input.getVnfInformation();
+ final GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = input.getVfModuleInformation();
+ // Call getVfModule to make a vfList for get the vf-module-information while GET reqest
+ vfModuleList = getVfModule(input);
+
+ final GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = input.getSdncRequestHeader();
+ final String svcRequestId = getSvcRequestId(requestHeader);
+
+ if (serviceInformation != null && isValid(serviceInformation.getServiceInstanceId()) && vnfInformation != null
+ && isValid(vnfInformation.getVnfId()) && vfModuleInformation !=null && isValid(vfModuleInformation.getVfModuleId())) {
+
+
+ final String serviceInstanceId = serviceInformation.getServiceInstanceId();
+ final String vnfId = vnfInformation.getVnfId();
+ final String vfModuleId = vfModuleInformation.getVfModuleId();
+
+ final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
+ getGenericResourceApiServicemodelinfrastructureService(serviceInstanceId);
+ if (optional.isPresent()) {
+ final GenericResourceApiServicemodelinfrastructureService service = optional.get();
+ final GenericResourceApiServicedataServiceData serviceData = service.getServiceData();
+ if (serviceData != null) {
+
+ final GenericResourceApiServicestatusServiceStatus serviceStatus = service.getServiceStatus();
+
+ return new Output().ackFinalIndicator(serviceStatus.getFinalIndicator())
+ .responseCode(serviceStatus.getResponseCode())
+ .responseMessage(serviceStatus.getResponseMessage()).svcRequestId(svcRequestId)
+ .serviceResponseInformation(new GenericResourceApiInstanceReference()
+ .instanceId(serviceInstanceId).objectPath(getObjectPath(serviceInstanceId)))
+ .vnfResponseInformation(new GenericResourceApiInstanceReference().instanceId(vnfId)
+ .objectPath(getObjectPath(serviceInstanceId, vnfId)))
+ .vfModuleResponseInformation(new GenericResourceApiInstanceReference().instanceId(vfModuleId)
+ .objectPath(getObjectPath(vnfId, vfModuleId)));
+ }
+ }
+ LOGGER.error(
+ "Unable to find existing GenericResourceApiServiceModelInfrastructure in cache using service instance id: {}",
+ serviceInstanceId);
+ }
+ LOGGER.error(
+ "Unable to add GenericResourceApiServiceOperationInformation in cache due to invalid input: {}... ",
+ input);
+ return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST)
+ .responseMessage("Unable to add vfModule").svcRequestId(svcRequestId);
+ }
+
+ private List<GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData> getVfModule(GenericResourceApiVfModuleOperationInformation input) {
+
+ final GenericResourceApiVfmoduletopologyVfModuleTopology apiVfModuletopologyVfModuleTopology =
+ new GenericResourceApiVfmoduletopologyVfModuleTopology();
+
+ GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData vfModuleData =
+ new GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData();
+ vfModuleData.setVfModuleInformation(input.getVfModuleInformation());
+ vfModuleData.setVfModuleRequestInput(input.getVfModuleRequestInput());
+
+ GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = new GenericResourceApiVfmoduletopologyVfModuleTopology();
+
+ vfModuleTopology.setSdncGeneratedCloudResources(true);
+ GenericResourceApiParam vfModuleParametersData = new GenericResourceApiParam();
+ List<GenericResourceApiParamParam> params = new ArrayList<GenericResourceApiParamParam>();
+ GenericResourceApiParamParam param = new GenericResourceApiParamParam();
+ param.setName("k8s-rb-profile-name");
+ param.setValue("k8s-rb-profile-value");
+
+ params.add(param);
+ vfModuleParametersData.setParam(params);
+ vfModuleTopology.setVfModuleParameters(vfModuleParametersData);
+
+ vfModuleTopology.setOnapModelInformation(vfModuleData.getVfModuleInformation().getOnapModelInformation());
+ vfModuleTopology.setVfModuleParameters(vfModuleData.getVfModuleRequestInput().getVfModuleInputParameters());
+ vfModuleTopology.setAicClli(vfModuleData.getVfModuleRequestInput().getAicClli());
+ vfModuleTopology.setAicCloudRegion(vfModuleData.getVfModuleRequestInput().getAicCloudRegion());
+ vfModuleTopology.setCloudOwner(vfModuleData.getVfModuleRequestInput().getCloudOwner());
+
+ apiVfModuletopologyVfModuleTopology.vfModuleTopologyIdentifier(getVfModuleTopologyIdentifierStructure(input));
+
+ vfModuleTopology.setVfModuleTopologyIdentifier(apiVfModuletopologyVfModuleTopology.getVfModuleTopologyIdentifier());
+ vfModuleTopology.setTenant(vfModuleData.getVfModuleRequestInput().getTenant());
+
+ genericResourceApiVfModuleTopology.setVfModuleTopology(vfModuleTopology);
+
+ return null;
+
+ }
+
+ public GenericResourceApiVfModuleTopology getGenericResourceApiVfModuleTopology() {
+ return genericResourceApiVfModuleTopology;
+ }
+
+ private GenericResourceApiVfmoduletopologyidentifierVfModuleTopologyIdentifier getVfModuleTopologyIdentifierStructure(
+ @Valid final GenericResourceApiVfModuleOperationInformation input) {
+
+ final GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = input.getVfModuleInformation();
+ return new GenericResourceApiVfmoduletopologyidentifierVfModuleTopologyIdentifier()
+ .vfModuleId(vfModuleInformation.getVfModuleId()).vfModuleType(vfModuleInformation.getVfModuleType()).vfModuleName(input.getVfModuleRequestInput().getVfModuleName());
+ }
+
+ public GenericResourceApiVnfTopology getGenericResourceApiVnfTopology() {
+ return genericResourceApiVnfTopology;
+ }
+
+ public void getVnfsList(List<GenericResourceApiServicedataServicedataVnfsVnf> vnfsList) {
+
+ GenericResourceApiVnftopologyVnfTopology vnfTopology = new GenericResourceApiVnftopologyVnfTopology();
+ LOGGER.info(String.valueOf(vnfsList));
+ vnfTopology.setOnapModelInformation(vnfsList.get(0).getVnfData().getVnfInformation().getOnapModelInformation());
+ vnfTopology.setAicClli(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getAicClli()));
+ vnfTopology.setAicCloudRegion(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getAicCloudRegion()));
+ vnfTopology.setCloudOwner(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getCloudOwner()));
+ vnfTopology.setTenant(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getTenant()));
+ vnfTopology.setVnfResourceAssignments(vnfsList.get(0).getVnfData().getVnfTopology().getVnfResourceAssignments());
+ vnfTopology.setVnfTopologyIdentifierStructure(vnfsList.get(0).getVnfData().getVnfTopology().getVnfTopologyIdentifierStructure());
+ vnfTopology.setVnfParametersData(vnfsList.get(0).getVnfData().getVnfTopology().getVnfParametersData());
+ vnfTopology.setSdncGeneratedCloudResources(vnfsList.get(0).getVnfData().getVnfTopology().getSdncGeneratedCloudResources());
+
+ genericResourceApiVnfTopology.setVnfTopology(vnfTopology);
+ }
+}
\ No newline at end of file