diff options
author | 2018-10-22 11:06:58 +0800 | |
---|---|---|
committer | 2018-10-22 11:07:09 +0800 | |
commit | f427b03a40aa0cd427ec3ca4fa3c8930adc66a07 (patch) | |
tree | ad170d25387ed0b39e71dfb2e08fb685fba85b09 | |
parent | fbb4c573c53e450086dc622c069ad4ffbb9e983d (diff) |
create Network Service ,nsd/vnf/pnf manager
Change-Id: I7f12b00d00d096281a90309a1cb95dccd27cf083
Issue-ID: USECASEUI-142
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
13 files changed, 968 insertions, 63 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/ServiceBean.java b/server/src/main/java/org/onap/usecaseui/server/bean/ServiceBean.java new file mode 100644 index 00000000..0b54326b --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/bean/ServiceBean.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2018 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.bean; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name="service") +public class ServiceBean { + + @Id + @Column(name = "id") + private String id; + + @Column(name = "serviceInstanceId") + private String serviceInstanceId; + + @Column(name = "customerId") + private String customerId; + + @Column(name = "serviceType") + private String serviceType; + + @Column(name = "serviceDomain") + private String serviceDomain; + + @Column(name = "operationId") + private String operationId; + + @Column(name = "parentServiceInstanceId") + private String parentServiceInstanceId; + + @Column(name = "status") + private String status; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceDomain() { + return serviceDomain; + } + + public void setServiceDomain(String serviceDomain) { + this.serviceDomain = serviceDomain; + } + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + public String getParentServiceInstanceId() { + return parentServiceInstanceId; + } + + public void setParentServiceInstanceId(String parentServiceInstanceId) { + this.parentServiceInstanceId = parentServiceInstanceId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public ServiceBean() { + } + + public ServiceBean(String id, String serviceInstanceId, String customerId, String serviceType, String serviceDomain, + String operationId, String parentServiceInstanceId, String status) { + this.id = id; + this.serviceInstanceId = serviceInstanceId; + this.customerId = customerId; + this.serviceType = serviceType; + this.serviceDomain = serviceDomain; + this.operationId = operationId; + this.parentServiceInstanceId = parentServiceInstanceId; + this.status = status; + } + + @Override + public String toString() { + return "ServiceBean [id=" + id + ", serviceInstanceId=" + serviceInstanceId + ", customerId=" + customerId + + ", serviceType=" + serviceType + ", serviceDomain=" + serviceDomain + ", operationId=" + operationId + + ", parentServiceInstanceId=" + parentServiceInstanceId + ", status=" + status + "]"; + } + +} diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java index 63e91d00..e8b86504 100755 --- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java @@ -20,8 +20,10 @@ import java.text.SimpleDateFormat; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.annotation.Resource;
@@ -97,23 +99,13 @@ public class AlarmController * test commit
*/
@RequestMapping(value = {"/alarm/{currentPage}/{pageSize}",
- "/alarm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"},
+ "/alarm/{currentPage}/{pageSize}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"},
method = RequestMethod.GET , produces = "application/json")
- public String getAlarmData(@PathVariable(required = false) String sourceId,@PathVariable(required = false) String sourceName,
+ public String getAlarmData(@PathVariable(required = false) String sourceName,
@PathVariable(required = false) String priority,@PathVariable(required = false) String startTime,
@PathVariable(required = false) String endTime,@PathVariable(required = false) String vfStatus,
@PathVariable int currentPage, @PathVariable int pageSize) throws JsonProcessingException {
- logger.info("transfer getAlarmData Apis, " +
- "Parameter all follows : [currentPage : {} , pageSize : {} , sourceId : {} , " +
- "sourceName : {} , priority : {} , startTime :{} , endTime : {} , vfStatus : {}]"
- ,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime,vfStatus);
- List<AlarmsHeader> alarmsHeaders = null;
- List<AlarmBo> list = new ArrayList<>();
- Page pa = null;
- if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime
- || null != vfStatus ){
AlarmsHeader alarm = new AlarmsHeader();
- alarm.setSourceId(!"null".equals(sourceId)?sourceId:null);
alarm.setSourceName(!"null".equals(sourceName)?sourceName:null);
alarm.setStatus(!"null".equals(vfStatus)?vfStatus:null);
try {
@@ -122,43 +114,10 @@ public class AlarmController } catch (ParseException e) {
logger.error("Parse date error :"+e.getMessage());
}
- pa = alarmsHeaderService.queryAlarmsHeader(alarm,currentPage,pageSize);
-
- alarmsHeaders = pa.getList();
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
- alarmsHeaders.forEach(a ->{
- AlarmBo abo = new AlarmBo();
- abo.setAlarmsHeader(a);
- AlarmsInformation information = new AlarmsInformation();
- information.setSourceId(a.getSourceId());
- List<AlarmsInformation> informationList = alarmsInformationService.queryAlarmsInformation(information,1,100).getList();
- informationList.forEach( il -> {
- if (il.getValue().equals("")){
- StringBuffer value1 = new StringBuffer();
- alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(il.getName()),1,100).getList()
- .forEach( val -> value1.append(val.getValue()) );
- il.setValue(value1.toString());
- }
- } );
- abo.setAlarmsInformation(informationList);
- list.add(abo);
- });
- }
- }else {
- pa = alarmsHeaderService.queryAlarmsHeader(null, currentPage, pageSize);
- alarmsHeaders = pa.getList();
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
- alarmsHeaders.forEach(a -> {
- AlarmBo abo = new AlarmBo();
- abo.setAlarmsHeader(a);
- abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList());
- list.add(abo);
- });
- }
- }
+ Page pa = alarmsHeaderService.queryAlarmsHeader(alarm,currentPage,pageSize);
try {
Map<String,Object> map = new HashMap<>();
- map.put("alarms",list);
+ map.put("alarms",pa.getList());
map.put("totalRecords",pa.getTotalRecords());
omAlarm.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
return omAlarm.writeValueAsString(map);
@@ -191,11 +150,33 @@ public class AlarmController }
return omAlarm.writeValueAsString(sourceIds);
}
+
+ @RequestMapping(value = {"/alarm/getSourceNames"},method = RequestMethod.GET,produces = "application/json")
+ public String getSourceNames() throws JsonProcessingException{
+ Set<String> sourceNames = new HashSet<>();
+ Page<AlarmsHeader> page = alarmsHeaderService.queryAlarmsHeader(new AlarmsHeader(), 1, Integer.MAX_VALUE);
+ AlarmsHeader alarmsHeader;
+ if(UuiCommonUtil.isNotNullOrEmpty(page)){
+ page = new Page<>();
+ List<AlarmsHeader> list = new ArrayList<>();
+ alarmsHeader = new AlarmsHeader();
+ list.add(alarmsHeader);
+ page.setList(list);
+
+ }
+ for(int a=0;a<page.getList().size();a++){
+ alarmsHeader = (AlarmsHeader)page.getList().get(a);
+ String sourceName = alarmsHeader.getSourceId();
+ sourceNames.add(sourceName);
+ }
+ return omAlarm.writeValueAsString(sourceNames);
+ }
+
@RequestMapping(value = {"/alarm/diagram"},method = RequestMethod.POST,produces = "application/json")
public String diagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String format) {
long timeInterval = 0;
try {
- if("month".equals(format)){
+ if("month".equals(format)){//alarm day month year
formatDate="yyyy-MM";
int maxDay= DateUtils.MonthOfDay(startTime, formatDate);
timeInterval =86400000L*maxDay;
@@ -259,7 +240,6 @@ public class AlarmController public String getStatusCount() throws JsonProcessingException {
List<String> statusCount = new ArrayList<>();
- statusCount.add(alarmsHeaderService.queryStatusCount("0"));
statusCount.add(alarmsHeaderService.queryStatusCount("active"));
statusCount.add(alarmsHeaderService.queryStatusCount("close"));
return omAlarm.writeValueAsString(statusCount);
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java index 4f090538..3486f119 100755 --- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java @@ -19,7 +19,6 @@ package org.onap.usecaseui.server.controller; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -46,7 +45,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.fasterxml.jackson.core.JsonProcessingException; @@ -155,7 +153,7 @@ public class PerformanceController { public String generateDiagram(@RequestParam String sourceId,@RequestParam String startTime,@RequestParam String endTime,@RequestParam String nameParent,@RequestParam String format) { long timeInterval = 0; try { - if("minute".equals(format)){ + if("minute".equals(format)){//performance hour day month formatDate="yyyy-MM-dd HH:mm"; timeInterval =5*60000; }else if("hour".equals(format)){ diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java index 96dae5ad..d3da9a89 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java @@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -@Controller +@RestController @org.springframework.context.annotation.Configuration @EnableAspectJAutoProxy public class PackageDistributionController { @@ -80,4 +80,109 @@ public class PackageDistributionController { public Job deleteVfPackage(@PathVariable("casrId") String casrId){ return packageDistributionService.deleteVfPackage(casrId); } + + @RequestMapping(value = {"/uui-lcm/ns-packages}"}, method = RequestMethod.GET , produces = "application/json") + public String getNsPackages(){ + return packageDistributionService.getNetworkServicePackages(); + } + + @RequestMapping(value = {"/uui-lcm/vnf-packages}"}, method = RequestMethod.GET , produces = "application/json") + public String getVnfPackages(){ + return packageDistributionService.getVnfPackages(); + } + + @RequestMapping(value = {"/uui-lcm/pnf-packages}"}, method = RequestMethod.GET , produces = "application/json") + public String getPnfPackages(){ + return packageDistributionService.getPnfPackages(); + } + + @RequestMapping(value = {"/uui-lcm/createNetworkServiceData}"}, method = RequestMethod.POST , produces = "application/json") + public String createNetworkServiceData(HttpServletRequest request){ + return packageDistributionService.createNetworkServiceData(request); + } + + @RequestMapping(value = {"/uui-lcm/createVnfData}"}, method = RequestMethod.POST , produces = "application/json") + public String createVnfData(HttpServletRequest request){ + return packageDistributionService.createVnfData(request); + } + + @RequestMapping(value = {"/uui-lcm/createPnfData}"}, method = RequestMethod.POST , produces = "application/json") + public String createPnfData(HttpServletRequest request){ + return packageDistributionService.createPnfData(request); + } + + @RequestMapping(value = {"/uui-lcm/getNsdInfo}"}, method = RequestMethod.GET , produces = "application/json") + public String getNsdInfo(@RequestParam String nsdInfoId){ + return packageDistributionService.getNsdInfo(nsdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/getVnfInfo}"}, method = RequestMethod.GET , produces = "application/json") + public String getVnfInfo(@RequestParam String vnfPkgId){ + return packageDistributionService.getVnfInfo(vnfPkgId); + } + + @RequestMapping(value = {"/uui-lcm/getPnfInfo}"}, method = RequestMethod.GET , produces = "application/json") + public String getPnfInfo(@RequestParam String pnfdInfoId){ + return packageDistributionService.getPnfInfo(pnfdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/downLoadNsPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String downLoadNsPackage(@RequestParam String nsdInfoId){ + return packageDistributionService.downLoadNsPackage(nsdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/downLoadPnfPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String downLoadPnfPackage(@RequestParam String pnfdInfoId){ + return packageDistributionService.downLoadPnfPackage(pnfdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/downLoadVnfPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String downLoadVnfPackage(@RequestParam String vnfPkgId){ + return packageDistributionService.downLoadVnfPackage(vnfPkgId); + } + + @RequestMapping(value = {"/uui-lcm/deleteNsdPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String deleteNsdPackage(@RequestParam String nsdInfoId){ + return packageDistributionService.deleteNsdPackage(nsdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/deleteVnfPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String deleteVnfPackage(@RequestParam String vnfPkgId){ + return packageDistributionService.deleteVnfPackage(vnfPkgId); + } + + @RequestMapping(value = {"/uui-lcm/deletePnfPackage}"}, method = RequestMethod.GET , produces = "application/json") + public String deletePnfPackage(@RequestParam String pnfdInfoId){ + return packageDistributionService.deletePnfPackage(pnfdInfoId); + } + + @RequestMapping(value = {"/uui-lcm/getNetworkServiceInfo}"}, method = RequestMethod.GET , produces = "application/json") + public String getNetworkServiceInfo(){ + return packageDistributionService.getNetworkServiceInfo(); + } + + @RequestMapping(value = {"/uui-lcm/getNetworkServiceInfo}"}, method = RequestMethod.POST , produces = "application/json") + public String createNetworkServiceInstance(HttpServletRequest request){ + return packageDistributionService.createNetworkServiceInstance(request); + } + + @RequestMapping(value = {"/uui-lcm/getNetworkServiceInfo}"}, method = RequestMethod.DELETE , produces = "application/json") + public String deleteNetworkServiceInstance(@RequestParam String ns_instance_id){ + return packageDistributionService.deleteNetworkServiceInstance(ns_instance_id); + } + + @RequestMapping(value = {"/uui-lcm/terminateNetworkServiceInstance}"}, method = RequestMethod.POST , produces = "application/json") + public String terminateNetworkServiceInstance(HttpServletRequest request,@RequestParam String ns_instance_id){ + return packageDistributionService.terminateNetworkServiceInstance(request,ns_instance_id); + } + + @RequestMapping(value = {"/uui-lcm/healNetworkServiceInstance}"}, method = RequestMethod.POST , produces = "application/json") + public String healNetworkServiceInstance(HttpServletRequest request,@RequestParam String ns_instance_id){ + return packageDistributionService.healNetworkServiceInstance(request,ns_instance_id); + } + + @RequestMapping(value = {"/uui-lcm/scaleNetworkServiceInstance}"}, method = RequestMethod.POST , produces = "application/json") + public String scaleNetworkServiceInstance(HttpServletRequest request,@RequestParam String ns_instance_id){ + return packageDistributionService.scaleNetworkServiceInstance(request,ns_instance_id); + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java index 715a2acd..b8c86fd3 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java @@ -20,7 +20,9 @@ import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import org.onap.usecaseui.server.bean.ServiceBean; import org.onap.usecaseui.server.service.lcm.ServiceInstanceService; +import org.onap.usecaseui.server.service.lcm.ServiceLcmService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance; import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; @@ -44,21 +46,34 @@ public class ServiceInstanceController { @Resource(name="ServiceInstanceService") private ServiceInstanceService serviceInstanceService; + + @Resource(name="ServiceLcmService") + private ServiceLcmService serviceLcmService; public void setServiceInstanceService(ServiceInstanceService serviceInstanceService) { this.serviceInstanceService = serviceInstanceService; } - @ResponseBody + public void setServiceLcmService(ServiceLcmService serviceLcmService) { + this.serviceLcmService = serviceLcmService; + } + + @ResponseBody @RequestMapping(value = {"/uui-lcm/service-instances"}, method = RequestMethod.GET , produces = "application/json") public List<ServiceInstance> listServiceInstances(HttpServletRequest request){ String customerId = request.getParameter("customerId"); String serviceType = request.getParameter("serviceType"); - logger.info(String.format( - "list service instances with [customerId=%s, serviceType=%s]", - customerId, - serviceType)); - return serviceInstanceService.listServiceInstances(customerId, serviceType); + List<ServiceInstance> list =serviceInstanceService.listServiceInstances(customerId, serviceType); + if(list.size()>0){ + for(ServiceInstance serviceInstance:list){ + ServiceBean serviceBean = serviceLcmService.getServiceBeanByServiceInStanceId(serviceInstance.getServiceInstanceId()); + if(UuiCommonUtil.isNotNullOrEmpty(serviceBean)){ + serviceInstance.setServiceDomain(serviceBean.getServiceDomain()); + } + } + } + System.out.println(list); + return list; } @ResponseBody @RequestMapping(value = {"/uui-lcm/getServiceInstanceById"}, method = RequestMethod.GET , produces = "application/json") diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java index cb919a3d..7f544be5 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java @@ -15,11 +15,13 @@ */ package org.onap.usecaseui.server.controller.lcm; +import org.onap.usecaseui.server.bean.ServiceBean; import org.onap.usecaseui.server.service.lcm.ServiceLcmService; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation; +import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; @@ -49,13 +51,24 @@ public class ServiceLcmController { @ResponseBody @RequestMapping(value = {"/uui-lcm/services"}, method = RequestMethod.POST , produces = "application/json") public ServiceOperation instantiateService(HttpServletRequest request){ - return serviceLcmService.instantiateService(request); + String customerId = request.getParameter("customerId"); + String serviceType = request.getParameter("serviceType"); + String serviceDomain = request.getParameter("serviceDomain"); + String parentServiceInstanceId = request.getParameter("parentServiceInstanceId"); + ServiceBean serviceBean = new ServiceBean(UuiCommonUtil.getUUID(),null,customerId,serviceType,serviceDomain,null,parentServiceInstanceId,null); + ServiceOperation serviceOperation = serviceLcmService.instantiateService(request); + serviceBean.setServiceInstanceId(serviceOperation.getService().getServiceId()); + serviceBean.setOperationId(serviceOperation.getService().getOperationId()); + serviceLcmService.saveOrUpdateServiceBean(serviceBean); + return serviceOperation; } @ResponseBody @RequestMapping(value = {"/uui-lcm/services/{serviceId}/operations/{operationId}"}, method = RequestMethod.GET , produces = "application/json") public OperationProgressInformation queryOperationProgress(@PathVariable(value="serviceId") String serviceId, @PathVariable(value="operationId") String operationId){ - return serviceLcmService.queryOperationProgress(serviceId, operationId); + OperationProgressInformation operationProgressInformation =serviceLcmService.queryOperationProgress(serviceId, operationId); + serviceLcmService.updateServiceInstanceStatusById(operationProgressInformation.getOperationStatus().getResult(), serviceId); + return operationProgressInformation; } @ResponseBody diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java index 4171c5e8..ddea5bf1 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java @@ -15,6 +15,9 @@ */ package org.onap.usecaseui.server.service.lcm; +import javax.servlet.http.HttpServletRequest; + +import org.apache.http.HttpRequest; import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo; import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Csar; import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.DistributionResult; @@ -34,4 +37,46 @@ public interface PackageDistributionService { DistributionResult deleteNsPackage(String csarId); Job deleteVfPackage(String csarId); + + String getVnfPackages(); + + String getNetworkServicePackages(); + + String getPnfPackages(); + + String createNetworkServiceData(HttpServletRequest request); + + String createVnfData(HttpServletRequest request); + + String createPnfData(HttpServletRequest request); + + String getNsdInfo(String nsdInfoId); + + String getVnfInfo(String vnfPkgId); + + String getPnfInfo(String pnfdInfoId); + + String downLoadNsPackage(String nsdInfoId); + + String downLoadPnfPackage(String pnfdInfoId); + + String downLoadVnfPackage(String vnfPkgId); + + String deleteNsdPackage(String nsdInfoId); + + String deleteVnfPackage(String vnfPkgId); + + String deletePnfPackage(String pnfdInfoId); + + String getNetworkServiceInfo(); + + String createNetworkServiceInstance(HttpServletRequest request); + + String deleteNetworkServiceInstance(String nsInstanceId); + + String terminateNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId); + + String healNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId); + + String scaleNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java index f69a33e9..b99a8ed7 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java @@ -15,6 +15,7 @@ */ package org.onap.usecaseui.server.service.lcm; +import org.onap.usecaseui.server.bean.ServiceBean; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; @@ -33,4 +34,10 @@ public interface ServiceLcmService { SaveOrUpdateOperationRsp scaleService(String serviceId,HttpServletRequest request); SaveOrUpdateOperationRsp updateService(String serviceId,HttpServletRequest request); + + void saveOrUpdateServiceBean(ServiceBean serviceBean); + + void updateServiceInstanceStatusById(String status,String serviceInstanceId); + + ServiceBean getServiceBeanByServiceInStanceId(String serviceInstanceId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java index 8239ce46..6ee8979b 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java @@ -35,6 +35,8 @@ public class ServiceInstance { private String serviceInstanceName; private String serviceInstanceLocationId; + + private String serviceDomain; @JsonCreator public ServiceInstance( @@ -88,4 +90,13 @@ public class ServiceInstance { public String getServiceInstanceLocationId() { return serviceInstanceLocationId; } + + public String getServiceDomain() { + return serviceDomain; + } + + public void setServiceDomain(String serviceDomain) { + this.serviceDomain = serviceDomain; + } + } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java index fec91ea3..ea5a80c9 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java @@ -19,6 +19,9 @@ import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Csar; import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.DistributionResult; import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Job; import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.JobStatus; + +import okhttp3.RequestBody; +import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.*; @@ -38,4 +41,67 @@ public interface VfcService { @DELETE("/api/catalog/v1/vnfpackages/{csarId}") Call<Job> deleteVnfPackage(@Path("csarId") String csarId); + + @GET("/api/nslcm/v1/ns") + Call<ResponseBody> getNetworkServiceInfo(); + + @POST("/api/nslcm/v1/ns") + Call<ResponseBody> createNetworkServiceInstance(@Body RequestBody body); + + @DELETE("/api/nslcm/v1/ns/{ns_instance_id}") + Call<ResponseBody> deleteNetworkServiceInstance(@Path("ns_instance_id") String nsInstanceId); + + @POST("/api/nslcm/v1/ns/{ns_instance_id}/terminate") + Call<ResponseBody> terminateNetworkServiceInstance(@Path("ns_instance_id") String nsInstanceId,@Body RequestBody body); + + @POST("/api/nslcm/v1/ns/{ns_instance_id}/heal") + Call<ResponseBody> healNetworkServiceInstance(@Path("ns_instance_id") String nsInstanceId,@Body RequestBody body); + + @POST("/api/nslcm/v1/ns/{ns_instance_id}/scale") + Call<ResponseBody> scaleNetworkServiceInstance(@Path("ns_instance_id") String nsInstanceId,@Body RequestBody body); + + @GET("/api/nsd/v1/ns_descriptors") + Call<ResponseBody> getNetworkServicePackages(); + + @GET("/api/vnfpkgm/v1/vnf_packages") + Call<ResponseBody> getVnfPackages(); + + @GET("/api/nsd/v1/pnf_descriptors") + Call<ResponseBody> getPnfPackages(); + + @POST("/api/nsd/v1/ns_descriptors") + Call<ResponseBody> createNetworkServiceData(@Body RequestBody body); + + @POST("/api/vnfpkgm/v1/vnf_packages") + Call<ResponseBody> createVnfData(@Body RequestBody body); + + @POST("/api/nsd/v1/pnf_descriptors") + Call<ResponseBody> createPnfData(@Body RequestBody body); + + @GET("/api/nsd/v1/ns_descriptors/{nsdInfoId}/nsd_content") + Call<ResponseBody> downLoadNsPackage(@Path("nsdInfoId") String nsdInfoId); + + @GET("/api/nsd/v1/ns_descriptors/{nsdInfoId}") + Call<ResponseBody> getNsdInfo(@Path("nsdInfoId") String nsdInfoId); + + @GET("/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}") + Call<ResponseBody> getVnfInfo(@Path("vnfPkgId") String vnfPkgId); + + @GET("/api/nsd/v1/pnf_descriptors/{pnfdInfoId}") + Call<ResponseBody> getPnfInfo(@Path("pnfdInfoId") String pnfdInfoId); + + @GET("/api/nsd/v1/pnf_descriptors/{pnfdInfoId}/pnfd_content") + Call<ResponseBody> downLoadPnfPackage(@Path("pnfdInfoId") String pnfdInfoId); + + @GET("/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/package_content") + Call<ResponseBody> downLoadVnfPackage(@Path("vnfPkgId") String vnfPkgId); + + @DELETE("/api/nsd/v1/ns_descriptors/{nsdInfoId}") + Call<ResponseBody> deleteNsdPackage(@Path("nsdInfoId") String nsdInfoId); + + @DELETE("/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}") + Call<ResponseBody> deleteVnfdPackage(@Path("vnfPkgId") String vnfPkgId); + + @DELETE("/api/nsd/v1/pnf_descriptors/{pnfdInfoId}") + Call<ResponseBody> deletePnfdPackage(@Path("pnfdInfoId") String pnfdInfoId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java index 991612ab..e440b217 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java @@ -16,6 +16,7 @@ package org.onap.usecaseui.server.service.lcm.impl; import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo; +import org.onap.usecaseui.server.constant.Constant; import org.onap.usecaseui.server.service.lcm.PackageDistributionService; import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; @@ -31,14 +32,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; + +import okhttp3.RequestBody; +import okhttp3.ResponseBody; import retrofit2.Response; import java.io.IOException; import java.util.Collections; import java.util.List; +import javax.servlet.http.HttpServletRequest; + import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.*; import static org.onap.usecaseui.server.util.RestfulServices.create; +import static org.onap.usecaseui.server.util.RestfulServices.extractBody; @Service("PackageDistributionService") @org.springframework.context.annotation.Configuration @@ -165,4 +172,457 @@ public class DefaultPackageDistributionService implements PackageDistributionSer throw new VfcException("VFC service is not available!", e); } } + + @Override + public String getVnfPackages() { + String result=""; + try { + logger.info("vfc getVnfPackages is starting!"); + Response<ResponseBody> response = this.vfcService.getVnfPackages().execute(); + logger.info("vfc getVnfPackages has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getVnfPackages[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getVnfPackages occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + } + + @Override + public String getNetworkServicePackages() { + + String result=""; + try { + logger.info("vfc getNetworkServicePackages is starting!"); + Response<ResponseBody> response = this.vfcService.getNetworkServicePackages().execute(); + logger.info("vfc getNetworkServicePackages has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getNetworkServicePackages[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getNetworkServicePackages occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String getPnfPackages() { + + String result=""; + try { + logger.info("vfc getPnfPackages is starting!"); + Response<ResponseBody> response = this.vfcService.getPnfPackages().execute(); + logger.info("vfc getPnfPackages has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getPnfPackages[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getPnfPackages occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String downLoadNsPackage(String nsdInfoId) { + + String result=""; + try { + logger.info("vfc downLoadNsPackage is starting!"); + Response<ResponseBody> response = this.vfcService.downLoadNsPackage(nsdInfoId).execute(); + logger.info("vfc downLoadNsPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get downLoadNsPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("downLoadNsPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String downLoadPnfPackage(String pnfdInfoId) { + + String result=""; + try { + logger.info("vfc downLoadPnfPackage is starting!"); + Response<ResponseBody> response = this.vfcService.downLoadNsPackage(pnfdInfoId).execute(); + logger.info("vfc downLoadPnfPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get downLoadPnfPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("downLoadPnfPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String downLoadVnfPackage(String vnfPkgId) { + + String result=""; + try { + logger.info("vfc downLoadVnfPackage is starting!"); + Response<ResponseBody> response = this.vfcService.downLoadNsPackage(vnfPkgId).execute(); + logger.info("vfc downLoadVnfPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get downLoadVnfPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("downLoadVnfPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String deleteNsdPackage(String nsdInfoId) { + + String result=""; + try { + logger.info("vfc deleteNsdPackage is starting!"); + Response<ResponseBody> response = this.vfcService.deleteNsdPackage(nsdInfoId).execute(); + logger.info("vfc deleteNsdPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("deleteNsdPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String deleteVnfPackage(String vnfPkgId) { + + String result=""; + try { + logger.info("vfc deleteVnfPackage is starting!"); + Response<ResponseBody> response = this.vfcService.deleteVnfdPackage(vnfPkgId).execute(); + logger.info("vfc deleteVnfPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("deleteVnfPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String deletePnfPackage(String pnfdInfoId) { + + String result=""; + try { + logger.info("vfc deletePnfPackage is starting!"); + Response<ResponseBody> response = this.vfcService.deletePnfdPackage(pnfdInfoId).execute(); + logger.info("vfc deletePnfPackage has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get deletePnfPackage[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("deletePnfPackage occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String getNetworkServiceInfo() { + + String result=""; + try { + logger.info("vfc getNetworkServiceInfo is starting!"); + Response<ResponseBody> response = this.vfcService.getNetworkServiceInfo().execute(); + logger.info("vfc getNetworkServiceInfo has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getNetworkServiceInfo[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getNetworkServiceInfo occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String createNetworkServiceInstance(HttpServletRequest request) { + String result = ""; + try { + logger.info("aai createNetworkServiceInstance is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.createNetworkServiceInstance(requestBody).execute(); + logger.info("aai createNetworkServiceInstance has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not createNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("createNetworkServiceInstance occur exception:"+e); + } + return result; + } + + @Override + public String deleteNetworkServiceInstance(String nsInstanceId) { + + String result=""; + try { + logger.info("vfc deleteNetworkServiceInstance is starting!"); + Response<ResponseBody> response = this.vfcService.deleteNetworkServiceInstance(nsInstanceId).execute(); + logger.info("vfc deleteNetworkServiceInstance has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get deleteNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("deleteNetworkServiceInstance occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String terminateNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) { + String result = ""; + try { + logger.info("aai terminateNetworkServiceInstance is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.terminateNetworkServiceInstance(networkServiceInstanceId,requestBody).execute(); + logger.info("aai terminateNetworkServiceInstance has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not terminateNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("terminateNetworkServiceInstance occur exception:"+e); + } + return result; + } + + @Override + public String healNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) { + String result = ""; + try { + logger.info("aai healNetworkServiceInstance is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.healNetworkServiceInstance(networkServiceInstanceId,requestBody).execute(); + logger.info("aai healNetworkServiceInstance has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not healNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("healNetworkServiceInstance occur exception:"+e); + } + return result; + } + + @Override + public String scaleNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) { + String result = ""; + try { + logger.info("aai scaleNetworkServiceInstance is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.scaleNetworkServiceInstance(networkServiceInstanceId,requestBody).execute(); + logger.info("aai scaleNetworkServiceInstance has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not scaleNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("scaleNetworkServiceInstance occur exception:"+e); + } + return result; + } + + @Override + public String createNetworkServiceData(HttpServletRequest request) { + String result = ""; + try { + logger.info("aai createNetworkServiceData is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.createNetworkServiceData(requestBody).execute(); + logger.info("aai createNetworkServiceData has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not createNetworkServiceData[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("createNetworkServiceData occur exception:"+e); + } + return result; + } + + @Override + public String createVnfData(HttpServletRequest request) { + String result = ""; + try { + logger.info("aai createVnfData is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.createVnfData(requestBody).execute(); + logger.info("aai createVnfData has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not createVnfData[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("createVnfData occur exception:"+e); + } + return result; + } + + @Override + public String createPnfData(HttpServletRequest request) { + String result = ""; + try { + logger.info("aai createPnfData is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = vfcService.createPnfData(requestBody).execute(); + logger.info("aai createPnfData has finished"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not createPnfData[code=%s, message=%s]", response.code(), response.message())); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("createPnfData occur exception:"+e); + } + return result; + } + + @Override + public String getNsdInfo(String nsdInfoId) { + + String result=""; + try { + logger.info("vfc getNsdInfo is starting!"); + Response<ResponseBody> response = this.vfcService.getNsdInfo(nsdInfoId).execute(); + logger.info("vfc getNsdInfo has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get getNsdInfo[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getNsdInfo occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String getVnfInfo(String vnfPkgId) { + + String result=""; + try { + logger.info("vfc getVnfInfo is starting!"); + Response<ResponseBody> response = this.vfcService.getVnfInfo(vnfPkgId).execute(); + logger.info("vfc getVnfInfo has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get getVnfInfo[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getVnfInfo occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } + + @Override + public String getPnfInfo(String pnfdInfoId) { + + String result=""; + try { + logger.info("vfc getPnfInfo is starting!"); + Response<ResponseBody> response = this.vfcService.getPnfInfo(pnfdInfoId).execute(); + logger.info("vfc getPnfInfo has finished!"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + logger.info(String.format("Can not get getPnfInfo[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED;; + } + } catch (IOException e) { + logger.error("getPnfInfo occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java index 498650ab..5a2d86d0 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java @@ -19,9 +19,16 @@ import static org.onap.usecaseui.server.util.RestfulServices.create; import static org.onap.usecaseui.server.util.RestfulServices.extractBody; import java.io.IOException; +import java.util.List; import javax.servlet.http.HttpServletRequest; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.onap.usecaseui.server.bean.AlarmsHeader; +import org.onap.usecaseui.server.bean.ServiceBean; import org.onap.usecaseui.server.service.lcm.ServiceLcmService; import org.onap.usecaseui.server.service.lcm.domain.so.SOService; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; @@ -32,6 +39,7 @@ import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException; import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; @@ -44,7 +52,14 @@ import retrofit2.Response; public class DefaultServiceLcmService implements ServiceLcmService { private static final Logger logger = LoggerFactory.getLogger(DefaultServiceLcmService.class); + + @Autowired + private SessionFactory sessionFactory; + private Session getSession() { + return sessionFactory.openSession(); + } + private SOService soService; public DefaultServiceLcmService() { @@ -142,4 +157,56 @@ public class DefaultServiceLcmService implements ServiceLcmService { throw new SOException("SO Service is not available!", e); } } + + @Override + public void saveOrUpdateServiceBean(ServiceBean serviceBean) { + try(Session session = getSession()){ + if (null == serviceBean) { + logger.error("DefaultServiceLcmService saveOrUpdateServiceBean serviceBean is null!"); + } + Transaction tx = session.beginTransaction(); + session.update(serviceBean); + tx.commit(); + session.flush(); + } catch (Exception e) { + logger.error("exception occurred while performing DefaultServiceLcmService saveOrUpdateServiceBean. Details:" + e.getMessage()); + } + } + + @Override + public void updateServiceInstanceStatusById(String status, String serviceInstanceId) { + try(Session session = getSession()) { + + String string = "update ServiceBean set status=:status where 1=1 and serviceInstanceId=:serviceInstanceId"; + Query q = session.createQuery(string); + q.setString("status",status); + q.setString("serviceInstanceId",serviceInstanceId); + q.executeUpdate(); + session.flush(); + + }catch (Exception e){ + logger.error("exception occurred while performing DefaultServiceLcmService updateServiceInstanceStatusByIdDetail."+e.getMessage()); + } + } + + @Override + public ServiceBean getServiceBeanByServiceInStanceId(String serviceInstanceId) { + ServiceBean serviceBean = null; + try(Session session = getSession()) { + + String string = "from ServiceBean where 1=1 and serviceInstanceId=:serviceInstanceId"; + Query q = session.createQuery(string); + q.setString("serviceInstanceId",serviceInstanceId); + List<ServiceBean> list = q.list(); + session.flush(); + if(list.size()>0){ + serviceBean = list.get(0); + } + }catch (Exception e){ + logger.error("exception occurred while performing DefaultServiceLcmService updateServiceInstanceStatusByIdDetail."+e.getMessage()); + serviceBean = new ServiceBean();; + } + return serviceBean; + + } } diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java index e48197e4..0054ab10 100755 --- a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java @@ -60,8 +60,8 @@ public class AlarmControllerTest { @Test public void testGetAlarmData() throws Exception { try { - controller.getAlarmData("sourceId", "sourceName", "priority", "startTime", "endTime", "vfStatus", 1, 10); - controller.getAlarmData(null, null, null, null, null, null, 1, 10); + controller.getAlarmData("sourceName", "priority", "startTime", "endTime", "vfStatus", 1, 10); + controller.getAlarmData(null, null, null, null, null, 1, 10); } catch (Exception e) { e.printStackTrace(); } |