From e585e291a7d1fc27541471d8bebb6fe36a72b9e7 Mon Sep 17 00:00:00 2001 From: "victor.gao" Date: Wed, 16 Aug 2017 16:45:43 +0800 Subject: Update directory according groupid Update openo to onap according groupid org.onap.vfc.nfvo.res. Change-Id: I3e32d445b8e5f2bfe8caa813052a8a7ae7e128a8 Issue-Id:VFC-86 Signed-off-by: victor.gao --- .../org/onap/vfc/nfvo/res/common/ResourceUtil.java | 43 +++ .../java/org/onap/vfc/nfvo/res/common/VimUtil.java | 141 ++++++++ .../vfc/nfvo/res/common/constant/Constant.java | 93 ++++++ .../vfc/nfvo/res/common/constant/HttpConstant.java | 79 +++++ .../nfvo/res/common/constant/ParamConstant.java | 370 ++++++++++++++++++++ .../nfvo/res/common/constant/ResponseConstant.java | 60 ++++ .../vfc/nfvo/res/common/constant/UrlConstant.java | 258 ++++++++++++++ .../onap/vfc/nfvo/res/common/util/JsonUtil.java | 290 ++++++++++++++++ .../onap/vfc/nfvo/res/common/util/RestfulUtil.java | 371 +++++++++++++++++++++ .../onap/vfc/nfvo/res/common/util/StringUtil.java | 215 ++++++++++++ .../nfvo/res/common/util/request/RequestUtil.java | 129 +++++++ .../res/common/util/response/ResponseUtil.java | 133 ++++++++ .../res/common/util/response/RoaResponseUtil.java | 113 +++++++ .../activator/ROAResmgrServicePostProcessor.java | 60 ++++ .../adapter/impl/ResmgrAdapter2MSBManager.java | 111 ++++++ .../adapter/impl/ResmgrAdapterMgrService.java | 185 ++++++++++ .../adapter/inf/IResmgrAdapter2MSBManager.java | 52 +++ .../adapter/inf/IResmgrAdapterMgrService.java | 39 +++ .../res/service/base/openstack/impl/HostImpl.java | 80 +++++ .../service/base/openstack/impl/LocationImpl.java | 186 +++++++++++ .../service/base/openstack/impl/NetworkImpl.java | 101 ++++++ .../res/service/base/openstack/impl/PortImpl.java | 103 ++++++ .../res/service/base/openstack/impl/SitesImpl.java | 231 +++++++++++++ .../res/service/base/openstack/impl/VimImpl.java | 82 +++++ .../nfvo/res/service/base/openstack/inf/Host.java | 66 ++++ .../base/openstack/inf/InterfaceResManagement.java | 40 +++ .../res/service/base/openstack/inf/Location.java | 104 ++++++ .../res/service/base/openstack/inf/Network.java | 69 ++++ .../nfvo/res/service/base/openstack/inf/Port.java | 76 +++++ .../service/base/openstack/inf/ResManagement.java | 66 ++++ .../nfvo/res/service/base/openstack/inf/Sites.java | 95 ++++++ .../nfvo/res/service/base/openstack/inf/Vim.java | 76 +++++ .../service/business/impl/HostBusinessImpl.java | 162 +++++++++ .../service/business/impl/LimitsBusinessImpl.java | 93 ++++++ .../business/impl/LocationBusinessImpl.java | 242 ++++++++++++++ .../service/business/impl/NetworkBusinessImpl.java | 153 +++++++++ .../service/business/impl/PortBusinessImpl.java | 161 +++++++++ .../service/business/impl/SitesBusinessImpl.java | 200 +++++++++++ .../res/service/business/impl/VimBusinessImpl.java | 99 ++++++ .../res/service/business/inf/HostBusiness.java | 131 ++++++++ .../res/service/business/inf/LimitsBusiness.java | 42 +++ .../res/service/business/inf/LocationBusiness.java | 134 ++++++++ .../res/service/business/inf/NetworkBusiness.java | 133 ++++++++ .../res/service/business/inf/PortBusiness.java | 131 ++++++++ .../res/service/business/inf/SitesBusiness.java | 124 +++++++ .../nfvo/res/service/business/inf/VimBusiness.java | 72 ++++ .../vfc/nfvo/res/service/dao/impl/AbstractDao.java | 57 ++++ .../vfc/nfvo/res/service/dao/impl/HostDaoImpl.java | 83 +++++ .../nfvo/res/service/dao/impl/LocationDaoImpl.java | 83 +++++ .../nfvo/res/service/dao/impl/NetworkDaoImpl.java | 83 +++++ .../vfc/nfvo/res/service/dao/impl/PortDaoImpl.java | 83 +++++ .../nfvo/res/service/dao/impl/SitesDaoImpl.java | 77 +++++ .../vfc/nfvo/res/service/dao/impl/VimDaoImpl.java | 55 +++ .../res/service/dao/impl/VirtualLinkDaoImpl.java | 84 +++++ .../vfc/nfvo/res/service/dao/impl/VmDaoImpl.java | 108 ++++++ .../vfc/nfvo/res/service/dao/impl/VnfDaoImpl.java | 84 +++++ .../nfvo/res/service/dao/impl/VnfInfoDaoImpl.java | 96 ++++++ .../res/service/dao/impl/VnfStatusDaoImpl.java | 96 ++++++ .../onap/vfc/nfvo/res/service/dao/inf/HostDao.java | 114 +++++++ .../vfc/nfvo/res/service/dao/inf/LocationDao.java | 123 +++++++ .../vfc/nfvo/res/service/dao/inf/NetworkDao.java | 125 +++++++ .../onap/vfc/nfvo/res/service/dao/inf/PortDao.java | 114 +++++++ .../vfc/nfvo/res/service/dao/inf/SitesDao.java | 105 ++++++ .../onap/vfc/nfvo/res/service/dao/inf/VimDao.java | 68 ++++ .../nfvo/res/service/dao/inf/VirtualLinkDao.java | 69 ++++ .../onap/vfc/nfvo/res/service/dao/inf/VmDao.java | 45 +++ .../onap/vfc/nfvo/res/service/dao/inf/VnfDao.java | 69 ++++ .../vfc/nfvo/res/service/dao/inf/VnfInfoDao.java | 43 +++ .../vfc/nfvo/res/service/dao/inf/VnfStatusDao.java | 43 +++ .../vfc/nfvo/res/service/entity/HostEntity.java | 179 ++++++++++ .../nfvo/res/service/entity/LocationEntity.java | 236 +++++++++++++ .../vfc/nfvo/res/service/entity/NetworkEntity.java | 271 +++++++++++++++ .../vfc/nfvo/res/service/entity/PortEntity.java | 179 ++++++++++ .../vfc/nfvo/res/service/entity/SitesEntity.java | 309 +++++++++++++++++ .../vfc/nfvo/res/service/entity/VimEntity.java | 106 ++++++ .../nfvo/res/service/entity/VirtualLinkEntity.java | 285 ++++++++++++++++ .../onap/vfc/nfvo/res/service/entity/VmEntity.java | 96 ++++++ .../vfc/nfvo/res/service/entity/VnfEntity.java | 337 +++++++++++++++++++ .../vfc/nfvo/res/service/entity/VnfInfoEntity.java | 83 +++++ .../nfvo/res/service/entity/VnfStatusEntity.java | 213 ++++++++++++ .../service/group/impl/GrantResServiceImpl.java | 206 ++++++++++++ .../group/impl/IResourceAddServiceImpl.java | 159 +++++++++ .../group/impl/IResourceDelServiceImpl.java | 75 +++++ .../group/impl/IResourceUpdateServiceImpl.java | 120 +++++++ .../service/group/impl/ResOperateServiceImpl.java | 257 ++++++++++++++ .../service/group/impl/VirtualLinkServiceImpl.java | 123 +++++++ .../nfvo/res/service/group/impl/VmServiceImpl.java | 177 ++++++++++ .../res/service/group/impl/VnfInfoServiceImpl.java | 150 +++++++++ .../res/service/group/impl/VnfServiceImpl.java | 141 ++++++++ .../service/group/impl/VnfStatusServiceImpl.java | 117 +++++++ .../res/service/group/inf/GrantResService.java | 44 +++ .../res/service/group/inf/ResOperateService.java | 82 +++++ .../res/service/group/inf/VirtualLinkService.java | 64 ++++ .../vfc/nfvo/res/service/group/inf/VmService.java | 44 +++ .../nfvo/res/service/group/inf/VnfInfoService.java | 42 +++ .../vfc/nfvo/res/service/group/inf/VnfService.java | 66 ++++ .../res/service/group/inf/VnfStatusService.java | 42 +++ .../vfc/nfvo/res/service/mapper/HostMapper.java | 114 +++++++ .../nfvo/res/service/mapper/LocationMapper.java | 123 +++++++ .../vfc/nfvo/res/service/mapper/NetworkMapper.java | 125 +++++++ .../vfc/nfvo/res/service/mapper/PortMapper.java | 114 +++++++ .../vfc/nfvo/res/service/mapper/SitesMapper.java | 111 ++++++ .../vfc/nfvo/res/service/mapper/VimMapper.java | 68 ++++ .../nfvo/res/service/mapper/VirtualLinkMapper.java | 39 +++ .../onap/vfc/nfvo/res/service/mapper/VmMapper.java | 41 +++ .../vfc/nfvo/res/service/mapper/VnfInfoMapper.java | 39 +++ .../vfc/nfvo/res/service/mapper/VnfMapper.java | 39 +++ .../nfvo/res/service/mapper/VnfStatusMapper.java | 39 +++ .../nfvo/res/service/rest/GrantResourseRoa.java | 94 ++++++ .../onap/vfc/nfvo/res/service/rest/HostRoa.java | 183 ++++++++++ .../onap/vfc/nfvo/res/service/rest/LimitsRoa.java | 73 ++++ .../vfc/nfvo/res/service/rest/LocationRoa.java | 316 ++++++++++++++++++ .../onap/vfc/nfvo/res/service/rest/NetworkRoa.java | 189 +++++++++++ .../onap/vfc/nfvo/res/service/rest/PortRoa.java | 183 ++++++++++ .../vfc/nfvo/res/service/rest/ResOperateRoa.java | 151 +++++++++ .../onap/vfc/nfvo/res/service/rest/SitesRoa.java | 224 +++++++++++++ .../onap/vfc/nfvo/res/service/rest/SwaggerRoa.java | 49 +++ .../vfc/nfvo/res/service/rest/VirtualLinkRoa.java | 129 +++++++ .../org/onap/vfc/nfvo/res/service/rest/VmRoa.java | 127 +++++++ .../onap/vfc/nfvo/res/service/rest/VnfInfoRoa.java | 129 +++++++ .../org/onap/vfc/nfvo/res/service/rest/VnfRoa.java | 128 +++++++ .../vfc/nfvo/res/service/rest/VnfStatusRoa.java | 129 +++++++ .../rest/exceptionmapper/ExceptionMessage.java | 64 ++++ .../exceptionmapper/GenericExceptionMapper.java | 41 +++ .../exceptionmapper/ServiceExceptionMapper.java | 45 +++ .../nfvo/resmanagement/common/ResourceUtil.java | 43 --- .../openo/nfvo/resmanagement/common/VimUtil.java | 141 -------- .../resmanagement/common/constant/Constant.java | 93 ------ .../common/constant/HttpConstant.java | 79 ----- .../common/constant/ParamConstant.java | 370 -------------------- .../common/constant/ResponseConstant.java | 60 ---- .../resmanagement/common/constant/UrlConstant.java | 258 -------------- .../nfvo/resmanagement/common/util/JsonUtil.java | 290 ---------------- .../resmanagement/common/util/RestfulUtil.java | 371 --------------------- .../nfvo/resmanagement/common/util/StringUtil.java | 215 ------------ .../common/util/request/RequestUtil.java | 129 ------- .../common/util/response/ResponseUtil.java | 133 -------- .../common/util/response/RoaResponseUtil.java | 113 ------- .../activator/ROAResmgrServicePostProcessor.java | 60 ---- .../adapter/impl/ResmgrAdapter2MSBManager.java | 111 ------ .../adapter/impl/ResmgrAdapterMgrService.java | 185 ---------- .../adapter/inf/IResmgrAdapter2MSBManager.java | 52 --- .../adapter/inf/IResmgrAdapterMgrService.java | 39 --- .../service/base/openstack/impl/HostImpl.java | 80 ----- .../service/base/openstack/impl/LocationImpl.java | 186 ----------- .../service/base/openstack/impl/NetworkImpl.java | 101 ------ .../service/base/openstack/impl/PortImpl.java | 103 ------ .../service/base/openstack/impl/SitesImpl.java | 231 ------------- .../service/base/openstack/impl/VimImpl.java | 82 ----- .../service/base/openstack/inf/Host.java | 66 ---- .../base/openstack/inf/InterfaceResManagement.java | 40 --- .../service/base/openstack/inf/Location.java | 104 ------ .../service/base/openstack/inf/Network.java | 69 ---- .../service/base/openstack/inf/Port.java | 76 ----- .../service/base/openstack/inf/ResManagement.java | 66 ---- .../service/base/openstack/inf/Sites.java | 95 ------ .../service/base/openstack/inf/Vim.java | 76 ----- .../service/business/impl/HostBusinessImpl.java | 162 --------- .../service/business/impl/LimitsBusinessImpl.java | 93 ------ .../business/impl/LocationBusinessImpl.java | 242 -------------- .../service/business/impl/NetworkBusinessImpl.java | 153 --------- .../service/business/impl/PortBusinessImpl.java | 161 --------- .../service/business/impl/SitesBusinessImpl.java | 200 ----------- .../service/business/impl/VimBusinessImpl.java | 99 ------ .../service/business/inf/HostBusiness.java | 131 -------- .../service/business/inf/LimitsBusiness.java | 42 --- .../service/business/inf/LocationBusiness.java | 134 -------- .../service/business/inf/NetworkBusiness.java | 133 -------- .../service/business/inf/PortBusiness.java | 131 -------- .../service/business/inf/SitesBusiness.java | 124 ------- .../service/business/inf/VimBusiness.java | 72 ---- .../service/dao/impl/AbstractDao.java | 57 ---- .../service/dao/impl/HostDaoImpl.java | 83 ----- .../service/dao/impl/LocationDaoImpl.java | 83 ----- .../service/dao/impl/NetworkDaoImpl.java | 83 ----- .../service/dao/impl/PortDaoImpl.java | 83 ----- .../service/dao/impl/SitesDaoImpl.java | 77 ----- .../resmanagement/service/dao/impl/VimDaoImpl.java | 55 --- .../service/dao/impl/VirtualLinkDaoImpl.java | 84 ----- .../resmanagement/service/dao/impl/VmDaoImpl.java | 108 ------ .../resmanagement/service/dao/impl/VnfDaoImpl.java | 84 ----- .../service/dao/impl/VnfInfoDaoImpl.java | 96 ------ .../service/dao/impl/VnfStatusDaoImpl.java | 96 ------ .../resmanagement/service/dao/inf/HostDao.java | 114 ------- .../resmanagement/service/dao/inf/LocationDao.java | 123 ------- .../resmanagement/service/dao/inf/NetworkDao.java | 125 ------- .../resmanagement/service/dao/inf/PortDao.java | 114 ------- .../resmanagement/service/dao/inf/SitesDao.java | 105 ------ .../nfvo/resmanagement/service/dao/inf/VimDao.java | 68 ---- .../service/dao/inf/VirtualLinkDao.java | 69 ---- .../nfvo/resmanagement/service/dao/inf/VmDao.java | 45 --- .../nfvo/resmanagement/service/dao/inf/VnfDao.java | 69 ---- .../resmanagement/service/dao/inf/VnfInfoDao.java | 43 --- .../service/dao/inf/VnfStatusDao.java | 43 --- .../resmanagement/service/entity/HostEntity.java | 179 ---------- .../service/entity/LocationEntity.java | 236 ------------- .../service/entity/NetworkEntity.java | 271 --------------- .../resmanagement/service/entity/PortEntity.java | 179 ---------- .../resmanagement/service/entity/SitesEntity.java | 309 ----------------- .../resmanagement/service/entity/VimEntity.java | 106 ------ .../service/entity/VirtualLinkEntity.java | 285 ---------------- .../resmanagement/service/entity/VmEntity.java | 96 ------ .../resmanagement/service/entity/VnfEntity.java | 337 ------------------- .../service/entity/VnfInfoEntity.java | 83 ----- .../service/entity/VnfStatusEntity.java | 213 ------------ .../service/group/impl/GrantResServiceImpl.java | 206 ------------ .../group/impl/IResourceAddServiceImpl.java | 159 --------- .../group/impl/IResourceDelServiceImpl.java | 75 ----- .../group/impl/IResourceUpdateServiceImpl.java | 120 ------- .../service/group/impl/ResOperateServiceImpl.java | 257 -------------- .../service/group/impl/VirtualLinkServiceImpl.java | 123 ------- .../service/group/impl/VmServiceImpl.java | 177 ---------- .../service/group/impl/VnfInfoServiceImpl.java | 150 --------- .../service/group/impl/VnfServiceImpl.java | 141 -------- .../service/group/impl/VnfStatusServiceImpl.java | 117 ------- .../service/group/inf/GrantResService.java | 44 --- .../service/group/inf/ResOperateService.java | 82 ----- .../service/group/inf/VirtualLinkService.java | 64 ---- .../resmanagement/service/group/inf/VmService.java | 44 --- .../service/group/inf/VnfInfoService.java | 42 --- .../service/group/inf/VnfService.java | 66 ---- .../service/group/inf/VnfStatusService.java | 42 --- .../resmanagement/service/mapper/HostMapper.java | 114 ------- .../service/mapper/LocationMapper.java | 123 ------- .../service/mapper/NetworkMapper.java | 125 ------- .../resmanagement/service/mapper/PortMapper.java | 114 ------- .../resmanagement/service/mapper/SitesMapper.java | 111 ------ .../resmanagement/service/mapper/VimMapper.java | 68 ---- .../service/mapper/VirtualLinkMapper.java | 39 --- .../resmanagement/service/mapper/VmMapper.java | 41 --- .../service/mapper/VnfInfoMapper.java | 39 --- .../resmanagement/service/mapper/VnfMapper.java | 39 --- .../service/mapper/VnfStatusMapper.java | 39 --- .../service/rest/GrantResourseRoa.java | 94 ------ .../nfvo/resmanagement/service/rest/HostRoa.java | 183 ---------- .../nfvo/resmanagement/service/rest/LimitsRoa.java | 73 ---- .../resmanagement/service/rest/LocationRoa.java | 316 ------------------ .../resmanagement/service/rest/NetworkRoa.java | 189 ----------- .../nfvo/resmanagement/service/rest/PortRoa.java | 183 ---------- .../resmanagement/service/rest/ResOperateRoa.java | 151 --------- .../nfvo/resmanagement/service/rest/SitesRoa.java | 224 ------------- .../resmanagement/service/rest/SwaggerRoa.java | 49 --- .../resmanagement/service/rest/VirtualLinkRoa.java | 129 ------- .../nfvo/resmanagement/service/rest/VmRoa.java | 127 ------- .../resmanagement/service/rest/VnfInfoRoa.java | 129 ------- .../nfvo/resmanagement/service/rest/VnfRoa.java | 128 ------- .../resmanagement/service/rest/VnfStatusRoa.java | 129 ------- .../rest/exceptionmapper/ExceptionMessage.java | 64 ---- .../exceptionmapper/GenericExceptionMapper.java | 41 --- .../exceptionmapper/ServiceExceptionMapper.java | 45 --- .../main/resources/mybatis/mysql/HostMapper.xml | 14 +- .../resources/mybatis/mysql/LocationMapper.xml | 12 +- .../main/resources/mybatis/mysql/NetworkMapper.xml | 14 +- .../main/resources/mybatis/mysql/PortMapper.xml | 14 +- .../main/resources/mybatis/mysql/SitesMapper.xml | 14 +- .../src/main/resources/mybatis/mysql/VimMapper.xml | 6 +- .../resources/mybatis/mysql/VirtualLinkMapper.xml | 12 +- .../src/main/resources/mybatis/mysql/VmMapper.xml | 12 +- .../main/resources/mybatis/mysql/VnfInfoMapper.xml | 12 +- .../src/main/resources/mybatis/mysql/VnfMapper.xml | 12 +- .../resources/mybatis/mysql/VnfStatusMapper.xml | 12 +- .../resources/spring/Resmanagement/services.xml | 100 +++--- .../spring/Resmanagement/svc_register.xml | 4 +- 263 files changed, 15329 insertions(+), 15329 deletions(-) create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/ResourceUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/VimUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/Constant.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/HttpConstant.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ParamConstant.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ResponseConstant.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/UrlConstant.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/JsonUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/RestfulUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/StringUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/request/RequestUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/ResponseUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/RoaResponseUtil.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/activator/ROAResmgrServicePostProcessor.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapter2MSBManager.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapterMgrService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapter2MSBManager.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapterMgrService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/HostImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/LocationImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/NetworkImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/PortImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/SitesImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/VimImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Host.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/InterfaceResManagement.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Location.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Network.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Port.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/ResManagement.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Sites.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Vim.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/HostBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LimitsBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LocationBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/NetworkBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/PortBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/SitesBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/VimBusinessImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/HostBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LimitsBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LocationBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/NetworkBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/PortBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/SitesBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/VimBusiness.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/AbstractDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/HostDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/LocationDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/NetworkDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/PortDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/SitesDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VimDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VirtualLinkDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VmDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfInfoDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfStatusDaoImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/HostDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/LocationDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/NetworkDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/PortDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/SitesDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VimDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VirtualLinkDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VmDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfInfoDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfStatusDao.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/HostEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/LocationEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/NetworkEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/PortEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/SitesEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VimEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VirtualLinkEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VmEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfInfoEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfStatusEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/GrantResServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceAddServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceDelServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceUpdateServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/ResOperateServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VirtualLinkServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VmServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfInfoServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfStatusServiceImpl.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/GrantResService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/ResOperateService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VirtualLinkService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VmService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfInfoService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfStatusService.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/HostMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/LocationMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/NetworkMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/PortMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/SitesMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VimMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VirtualLinkMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VmMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfInfoMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfStatusMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/GrantResourseRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/HostRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LimitsRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LocationRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/NetworkRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/PortRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/ResOperateRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SitesRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SwaggerRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VirtualLinkRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VmRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfInfoRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfStatusRoa.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ExceptionMessage.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/GenericExceptionMapper.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ServiceExceptionMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java delete mode 100644 ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java (limited to 'ResmanagementService/service/src/main') diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/ResourceUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/ResourceUtil.java new file mode 100644 index 0000000..d38459a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/ResourceUtil.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class ResourceUtil { + + private ResourceUtil() { + + } + + /** + * It is used to get Message
+ * + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getMessage(String key) { + return key; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/VimUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/VimUtil.java new file mode 100644 index 0000000..6dc3121 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/VimUtil.java @@ -0,0 +1,141 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common; + +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 30, 2016 + */ +public class VimUtil { + + private static final Logger LOG = LoggerFactory.getLogger(VimUtil.class); + + private VimUtil() { + + } + + /** + * Get VIMs. + * + * @return + */ + public static JSONArray getVims() { + String esrResponse = + RestfulUtil.getResponseContent(UrlConstant.ESR_GET_VIMS_URL, new RestfulParametes(), "get"); + LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); + if(null == esrResponse) { + LOG.error("ESR return fail."); + return null; + } else { + return JSONArray.fromObject(esrResponse); + } + + } + + /** + * Get vimId by vimName. + * + * @return + */ + public static String getVimIdByName(String name) { + JSONArray vims = getVims(); + for(int i = 0; i < vims.size(); i++) { + JSONObject vim = vims.getJSONObject(i); + LOG.info("vimInfo: " + vim); + String vimName = vim.getString("name"); + String vimId = vim.getString("vimId"); + LOG.info("name:" + name + ", vimName:" + vimName + ", vimId:" + vimId); + if(name.trim().equalsIgnoreCase(vimName)) { + return vimId; + } + } + LOG.error("No vim with this vimName"); + return ""; + + } + + /** + * Get VIM. + * + * @param vimId + * @return + */ + public static JSONObject getVimById(String vimId) { + if(vimId == null || "".equals(vimId.trim())) { + LOG.error("Get vim ERROR, VimId is null. "); + return null; + } + JSONObject esrResponse = RestfulUtil.getResponseObj(String.format(UrlConstant.ESR_GET_VIM_URL, vimId), "get"); + LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); + if(null == esrResponse) { + LOG.error("ESR return fail."); + return null; + } else { + return esrResponse; + } + } + + /** + * Get tenants. + * + * @param vimId + * @return + */ + public static JSONArray getTenants(String vimId) { + String url = String.format(UrlConstant.GET_TENANT_URL, vimId); + JSONObject resultObj = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); + JSONArray tenants = resultObj.getJSONArray("tenants"); + LOG.info("Get tenants from multivim! tenants:{}", tenants); + return tenants; + } + + /** + *
+ * + * @param tenant + * @param vimId + * @return + * @since NFVO 0.5 + */ + public static String getTenantIdByName(String tenant, String vimId) { + JSONArray tenants = VimUtil.getTenants(vimId); + String tenantId = ""; + for(int i = 0; i < tenants.size(); i++) { + JSONObject obj = tenants.getJSONObject(i); + String name = obj.getString("name"); + if(name.equalsIgnoreCase(tenant)) { + tenantId = obj.getString("id"); + } + } + LOG.info("GetTenantIdByName tenantId:{}", tenantId); + return tenantId; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/Constant.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/Constant.java new file mode 100644 index 0000000..d26c63e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/Constant.java @@ -0,0 +1,93 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.constant; + +/** + * HTTP constants
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class Constant { + + public static final String RES_MANAGEMENT_DB = "resmanagementdb"; + + /** + * Database Delete/Modify/Add fail. + */ + public static final int ERROR_CODE = -1; + + /** + * Database Delete/Modify/Add success. + */ + public static final int OK_CODE = 1; + + /** + * Lack of resource. + */ + public static final int RES_NOT_ENOUGH_CODE = -2; + + /** + * Module name. + */ + public static final String MODULE_NAME = "Resmanagement"; + + public static final String RESPONSE_CONTENT = "responseContent"; + + public static final String STATUS_CODE = "statusCode"; + + /** + * Format Time + */ + public static final String DATE_FORMATE = "yyyy-MM-dd HH:mm:ss"; + + public static final String DATE_UTC_FORMATE = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + public static final String UTC_FORMATE = "UTC"; + + public static final String DATE_DAY_FORMATE = "yyyy-MM-dd 00:00:00"; + + /** + * IAM + */ + + public static final String HTTP_CONTENT_TYPE = "Content-Type"; + + public static final String HTTP_CONTENT_TYPE_VALUE = "application/json;charset=UTF-8"; + + public static final String X_TENANT_ID = "X-Tenant-Id"; + + public static final String IAM_TOKEN = "x-auth-token"; + + public static final String IAM_AUTH_TOKEN = "X-Auth-Token"; + + public static final String IAM_USER_ID = "X-User-Id"; + + public static final String IAM_USER_NAME = "X-User-Name"; + + public static final String IAM_DOMAIN_NAME = "X-Domain-Name"; + + public static final String HEADER_SUBJECT_TOKEN = "X-Subject-Token"; + + public static final int REPEAT_REG_TIME = 60 * 1000; + + private Constant() { + // private constants + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/HttpConstant.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/HttpConstant.java new file mode 100644 index 0000000..a81dff5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/HttpConstant.java @@ -0,0 +1,79 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.constant; + +/** + * + * Http constant class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HttpConstant { + + public static final int ERROR_CODE = -1; + + public static final int OK_CODE = 1; + + public static final int HTTP_OK = 200; + + public static final int HTTP_CREATED = 201; + + public static final int HTTP_ACCEPTED = 202; + + public static final int HTTP_NOCONTENT = 204; + + public static final int HTTP_UNAUTHORIZED = 401; + + public static final int HTTP_BAD_REQUEST = 400; + + public static final int HTTP_NOTFOUND_CODE = 404; + + public static final int HTTP_CONFLICT_CODE = 409; + + public static final int HTTP_INVALID_PARAMETERS = 415; + + public static final int HTTP_INNERERROR_CODE = 500; + + public static final int INTERNAL_EXCEPTION_CODE = 600; + + public static final int TOKEN_HEAD_NULL_CODE = 601; + + public static final int TOKEN_USER_NULL_CODE = 602; + + public static final int SERVICE_URL_ERROR_CODE = 603; + + public static final int ACCESS_OBJ_NULL_CODE = 604; + + public static final int CONNECT_NOT_FOUND_CODE = 605; + + public static final int VCENTER_PARA_ERROR_CODE = 606; + + public static final int TYPE_PARA_ERROR_CODE = 607; + + public static final int CONNECT_FAIL_CODE = 608; + + public static final int DIS_CONNECT_FAIL_CODE = 609; + + public static final int HANDSHAKE_FAIL_CODE = 610; + + private HttpConstant() { + //private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ParamConstant.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ParamConstant.java new file mode 100644 index 0000000..870e4a7 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ParamConstant.java @@ -0,0 +1,370 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.constant; + +/** + *
+ *

+ * Contstant for System interactive. + *

+ * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class ParamConstant { + + /** + * param key: vimId. + */ + public static final String PARAM_VIMID = "vimId"; + + /** + * param key: vimName + */ + public static final String PARAM_VIMNAME = "vimName"; + + /** + * param key: tenantId. + */ + public static final String PARAM_TENANTID = "tenantId"; + + public static final String TOTAL_CPU = "totalCPU"; + + public static final String USED_CPU = "usedCPU"; + + public static final String TOTAL_MEMORY = "totalMemory"; + + public static final String USED_MEMORY = "usedMemory"; + + public static final String TOTAL_DISK = "totalDisk"; + + public static final String USED_DISK = "usedDisk"; + + /** + * param key: data. + */ + public static final String PARAM_DATA = "data"; + + /** + * param key: id. + */ + public static final String PARAM_ID = "id"; + + /** + * param key: vimId + */ + public static final String PARAM_IP = "ip"; + + /** + * param key: role. + */ + public static final String PARAM_ROLE = "role"; + + /** + * param key: roleId. + */ + public static final String PARAM_ROLEID = "roleId"; + + /** + * param key: total. + */ + public static final String PARAM_TOTAL = "total"; + + /** + * param key: used. + */ + public static final String PARAM_USED = "used"; + + /** + * param key: vcpus. + */ + public static final String PARAM_VCPUS = "vcpus"; + + /** + * param key: disk. + */ + public static final String PARAM_DISK = "disk"; + + /** + * param key: cpumhz. + */ + public static final String PARAM_CPUMHZ = "cpumhz"; + + /** + * param key: countyr + */ + public static final String PARAM_COUNTRY = "country"; + + /** + * param key: vendorId + */ + public static final String PARAM_VENDORID = "vendorId"; + + /** + * param key: vendorName + */ + public static final String PARAM_VENDORNAME = "vendorName"; + + /** + * param key: memory. + */ + public static final String PARAM_MEMORY = "memory"; + + /** + * param key: name. + */ + public static final String PARAM_NAME = "name"; + + /** + * param key: status. + */ + public static final String PARAM_STATUS = "status"; + + /** + * param key: parent. + */ + public static final String PARAM_PARENT = "parent"; + + /** + * param key: location. + */ + public static final String PARAM_LOCATION = "location"; + + /** + * param key: siteName. + */ + public static final String PARAM_SITENAME = "siteName"; + + /** + * param key: vendor. + */ + public static final String PARAM_VENDOR = "vendor"; + + /** + * param key: vendors. + */ + public static final String PARAM_VENDORS = "vendors"; + + /** + * param key: tenantSites. + */ + public static final String PARAM_TENANTSITES = "tenantSites"; + + /** + * param key: siteId. + */ + public static final String PARAM_SITEID = "siteId"; + + /** + * param key: resArbitration. + */ + public static final String PARAM_RESARBITRATION = "resArbitration"; + + /** + * param key: userRole. + */ + public static final String PARAM_USERROLE = "userRole"; + + /** + * param key: admin. + */ + public static final String PARAM_ADMIN = "admin"; + + /** + * param key: tenant. + */ + public static final String PARAM_TENANT = "tenant"; + + /** + * param key: type. + */ + public static final String PARAM_TYPE = "type"; + + /** + * param key: action. + */ + public static final String PARAM_ACTION = "action"; + + /** + * param key: offline. + */ + public static final String PARAM_OFFLINE = "offline"; + + /** + * param key: online. + */ + public static final String PARAM_ONLINE = "online"; + + /** + * param key: drexecute. + */ + public static final String PARAM_DREXECUTE = "drexecute"; + + /** + * param key: drRollBack. + */ + public static final String PARAM_DRROLLBACK = "drrollback"; + + /** + * param key: scaleOut. + */ + public static final String PARAM_SCALEOUT = "scaleout"; + + /** + * param key: scaleIn. + */ + public static final String PARAM_SCALEIN = "scalein"; + + /** + * param key: network. + */ + public static final String PARAM_NETWORK = "networks"; + + /** + * param key: host. + */ + public static final String PARAM_HOST = "hosts"; + + /** + * param key: network. + */ + public static final String PARAM_PORT = "ports"; + + /** + * param key: providernetworks. + */ + public static final String PARAM_PROVIDERNETWORKS = "providernetworks"; + + /** + * param key: vims. + */ + public static final String PARAM_VIMS = "vims"; + + /** + * param key: vms. + */ + public static final String PARAM_VMS = "vms"; + + /** + * param key: vapps. + */ + public static final String PARAM_VAPPS = "vapps"; + + /** + * param key: vapp. + */ + public static final String PARAM_VAPP = "vapp"; + + /** + * param key: sites. + */ + public static final String PARAM_SITES = "sites"; + + /** + * param key: vduId. + */ + public static final String PARAM_VDUID = "vduId"; + + /** + * param key: vappId. + */ + public static final String PARAM_VAPPID = "vappId"; + + /** + * param key: hostId. + */ + public static final String PARAM_HOSTID = "hostId"; + + /** + * param key: projectId. + */ + public static final String PARAM_PROJECTID = "projectId"; + + /** + * param key: vnfmId. + */ + public static final String PARAM_VNFMID = "vnfmId"; + + /** + * param key: params. + */ + public static final String PARAM_PARAMS = "params"; + + /** + * param key: url. + */ + public static final String PARAM_URL = "url"; + + /** + * param key: post. + */ + public static final String PARAM_POST = "post"; + + /** + * param key: put. + */ + public static final String PARAM_PUT = "put"; + + /** + * param key: del. + */ + public static final String PARAM_DEL = "del"; + + /** + * param key: get. + */ + public static final String PARAM_GET = "get"; + + /** + * param key: retCode. + */ + public static final String PARAM_RETCODE = "retCode"; + + /** + * param key: ADD. + */ + public static final String PARAM_ADD = "add"; + + /** + * param key: active. + */ + public static final String PARAM_ACTIVE = "active"; + + /** + * param key: deleted. + */ + public static final String PARAM_DELETED = "deleted"; + + /** + * param key: deleting. + */ + public static final String PARAM_DELETING = "deleting"; + + /** + * param key: response + */ + public static final String PARAM_RESPONSE = "response"; + + /** + * param key: info + */ + public static final String PARAM_INFO = "info"; + + private ParamConstant() { + // private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ResponseConstant.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ResponseConstant.java new file mode 100644 index 0000000..5e7126c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/ResponseConstant.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.constant; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; + +/** + * Response constants.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class ResponseConstant { + + public static final String ADD_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.success"); + + public static final String ADD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.error"); + + public static final String DEL_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.success"); + + public static final String DEL_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.error"); + + public static final String MOD_SUCESS_MSG = + ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.success"); + + public static final String MOD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.error"); + + public static final String QUERY_SUCESS_MSG = + ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.success"); + + public static final String QUERY_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.error"); + + public static final String DELSODORES_FAIL_MSG = "delete sodores error"; + + public static final String DELVNFMINFO_FAIL_MSG = "delete vnfm error"; + + public static final String RES_VERIFY_SUCESS_MSG = "nsdata verify sucessfully"; + + public static final String RES_VERIFY_FAIL_MSG = "res verify failed"; + + private ResponseConstant() { + // private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/UrlConstant.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/UrlConstant.java new file mode 100644 index 0000000..572bff3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/constant/UrlConstant.java @@ -0,0 +1,258 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.constant; + +/** + *
+ *

+ * Constant for REST URL. + *

+ * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class UrlConstant { + + /** + * networks target. + */ + public static final String LOCATION_TARGET = "location"; + + /** + * MSB register url. + */ + public static final String REST_MSB_REGISTER = "/openoapi/microservices/v1/services"; + + public static final String ESR_GET_VIM_URL = "/openoapi/extsys/v1/vims/%s"; + + public static final String ESR_GET_VIMS_URL = "/openoapi/extsys/v1/vims"; + + /** + * send resource info to monitor url + */ + public static final String SEND_MSG_MONITOR = "/openoapi/umc/v1/resinfo"; + + /** + * networks url. + */ + public static final String LOCATION_URL = "/v1/locations"; + + /** + * port url. + */ + public static final String PORT_URL = "/v1/ports"; + + /** + * host url. + */ + public static final String HOST_URL = "/v1/hosts"; + + /** + * vl url. + */ + public static final String VL_URL = "/v1/vl"; + + /** + * vnf url. + */ + public static final String VNF_URL = "/v1/vnf"; + + /** + * vnfinfo url. + */ + public static final String VNFINFO_URL = "/v1/vnfinfo"; + + /** + * vnfstatus url. + */ + public static final String VNFSTATUS_URL = "/v1/vnfstatus"; + + /** + * grant resource url. + */ + public static final String GRANTRES_URL = "/v1/resource/grant"; + + /** + * vm url. + */ + public static final String VM_URL = "/v1/vm"; + + /** + * sites target. + */ + public static final String SITES_TARGET = "sites"; + + /** + * sites url. + */ + public static final String SITES_URL = "/v1/datacenters"; + + /** + * networks target. + */ + public static final String NETWORKS_TARGET = "networks"; + + /** + * networks url. + */ + public static final String NETWORKS_URL = "/v1/networks"; + + /** + * updateres. + */ + public static final String MODRES_URL = "/updateres"; + + /** + * resoperate target. + */ + public static final String RESOPERATE_TARGET = "resoperate"; + + /** + * APPLICATION_TYPE. + */ + public static final String APPLICATION_TYPE = "application/json"; + + /** + * ADDRES. + */ + public static final String ADDRES_URL = "/resmgr/vims"; + + /** + * updatebytenant. + */ + public static final String UPDATE_BY_TENANT = "updatebytenant"; + + /** + * updatebyvapp. + */ + public static final String UPDATE_BY_VAPP = "updatebyvapp"; + + /** + * getNetworkURL. + */ + public static final String GET_NETWORK_URL = "/openoapi/multivim/v1/%s/%s/networks"; + + /** + * getTenantURL. + */ + public static final String GET_TENANT_URL = "/openoapi/multivim/v1/%s/tenants"; + + /** + * getHostURL. + */ + public static final String GET_HOST_URL = "/openoapi/multivim/v1/%s/%s/hosts"; + + /** + * getHostDetailURL. + */ + public static final String GET_HOSTDETAIL_URL = "/openoapi/multivim/v1/%s/%s/hosts/%s"; + + /** + * getNetworkURL. + */ + public static final String GET_PORT_URL = "/openoapi/multivim/v1/%s/%s/ports"; + + /** + * getLimitsURL. + */ + public static final String GET_LIMITS_URL = "/openoapi/multivim/v1/%s/%s/limits"; + + /** + * template notify M url. + */ + public static final String TEMPLATE_NOTIFY_M_URL = ""; + + /** + * tenantsite allot url. + */ + public static final String TENANTSITE_ALLOT_URL = "/v1/resmanage/tenantsite/allot"; + + /** + * tenantsite allot target. + */ + public static final String TENANTSITE_ALLOT_TARGET = "tenantsite/allot"; + + /** + * tenant url. + */ + public static final String TENANT_URL = "/v1/resmanage/tenant"; + + /** + * tenant target. + */ + public static final String TENANT_TARGET = "tenant"; + + /** + * rollback url. + */ + public static final String ROLLBACK_URL = "/v1/resmanage/rollback"; + + /** + * rollback target. + */ + public static final String ROLLBACK_TARGET = "rollback"; + + /** + * vms target. + */ + public static final String VIM_TARGET = "vim"; + + /** + * vms url. + */ + public static final String VIM_URL = "/v1/resmanage/vim"; + + /** + * https + */ + public static final String GET_HTTPS = "https://"; + + /** + * get token + */ + public static final String GET_IAM_TOKEN = "/v3/auth/tokens"; + + /** + * rest. + */ + public static final String REST = "/rest"; + + /** + * donsdata url. + */ + public static final String INSTALL_URL = "install"; + + /** + * donsdata url. + */ + public static final String UNINSTALL_URL = "uninstall"; + + /** + * respool url. + */ + public static final String RESOPERATE_URL = "/v1/resoperate"; + + /** + * limits url. + */ + public static final String LIMITS_URL = "/v1/limits"; + + private UrlConstant() { + // private constructor + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/JsonUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/JsonUtil.java new file mode 100644 index 0000000..2b6e905 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/JsonUtil.java @@ -0,0 +1,290 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util; + +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + * + * Json Utility Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class JsonUtil { + + private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class); + + private static final int TYPE_STRING = 0; + + private static final int TYPE_INT = 1; + + private static final int TYPE_JSONA = 2; + + private static final int TYPE_JSONO = 3; + + private static final int TYPE_LONG = 4; + + private JsonUtil() { + } + + /** + * + * Get Json Field String.
+ * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static String getJsonFieldStr(JSONObject jsonObj, String fieldName) { + return (String)getJsonFieldObject(jsonObj, fieldName, TYPE_STRING); + } + + /** + * + * Get Json Field Integer.
+ * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) { + return (Integer)getJsonFieldObject(jsonObj, fieldName, TYPE_INT); + } + + /** + * + * Get Json Field array.
+ * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static JSONArray getJsonFieldArr(JSONObject jsonObj, String fieldName) { + return (JSONArray)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONA); + } + + /** + * + * Get Json Field Json.
+ * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static JSONObject getJsonFieldJson(JSONObject jsonObj, String fieldName) { + return (JSONObject)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONO); + } + + /** + * + * Get Json Field Long.
+ * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static Long getJsonFieldLong(JSONObject jsonObj, String fieldName) { + return (Long)getJsonFieldObject(jsonObj, fieldName, TYPE_LONG); + } + + /** + * + * Get Json Field Object.
+ * + * @param jsonObj + * @param fieldName + * @param classType + * @return + * @since NFVO 0.5 + */ + private static Object getJsonFieldObject(JSONObject jsonObj, String fieldName, int classType) { + try { + if(null != jsonObj && jsonObj.has(fieldName)) { + Object result = new Object(); + switch(classType) { + case TYPE_STRING: + result = "null".equals(jsonObj.getString(fieldName)) ? "" : jsonObj.getString(fieldName); + break; + case TYPE_INT: + result = jsonObj.getInt(fieldName); + break; + case TYPE_JSONA: + result = jsonObj.getJSONArray(fieldName); + break; + case TYPE_JSONO: + result = jsonObj.getJSONObject(fieldName); + break; + case TYPE_LONG: + result = jsonObj.getLong(fieldName); + break; + default: + result = null; + break; + } + return result; + } + } catch(JSONException e) { + LOG.error("function=getJsonFieldLong, exception: {} ", e); + return null; + } + return null; + } + + /** + * + * Check whether the Json Object is empty.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static boolean isNullJson(JSONObject jsonObject) { + if(null == jsonObject || jsonObject.isEmpty()) { + return true; + } + return false; + } + + /** + * + * Get String value by Json.
+ * + * @param json + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getStrValueByjson(JSONObject json, String key) { + JSONArray names = json.names(); + String result = null; + for(int i = 0; i < names.size(); i++) { + String nodeName = names.getString(i); + if(json.optJSONObject(nodeName) != null) { + result = getStrValueByjson(json.getJSONObject(nodeName), key); + } + if(json.optJSONArray(nodeName) != null) { + result = getStrValueByJArray(json.getJSONArray(nodeName), key); + } + if(nodeName.equals(key)) { + result = json.getString(nodeName); + break; + } + } + return result; + } + + private static String getStrValueByJArray(JSONArray json, String key) { + String result = null; + for(int i = 0; i < json.size(); i++) { + if(json.optJSONObject(i) != null) { + result = getStrValueByjson(json.getJSONObject(i), key); + } + if(json.optJSONArray(i) != null) { + result = getStrValueByJArray(json.getJSONArray(i), key); + } + } + return result; + } + + /** + * + * Get Json Value by Json object.
+ * + * @param json + * @param key + * @return + * @since NFVO 0.5 + */ + public static JSONObject getJsonValueByjson(JSONObject json, String key) { + JSONObject resultJson = new JSONObject(); + String result = getStrValueByjson(json, key); + if(null == result) { + return null; + } + resultJson.element(key, result); + return resultJson; + + } + + /** + * + * Get String Value by Json object.
+ * + * @param json + * @param parentKey + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getStrValueByJson(JSONObject json, String parentKey, String key) { + if(parentKey.isEmpty()) { + return getStrValueByjson(json, key); + } + JSONObject parentJson = getJsonValueByjson(json, parentKey); + if(isNullJson(parentJson)) { + return null; + } + return getStrValueByjson(parentJson, key); + + } + + /** + * + * Get response Data.
+ * + * @param obj + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseData(JSONObject obj) { + JSONObject result = new JSONObject(); + + Integer retCode = getJsonFieldInt(obj, ParamConstant.PARAM_RETCODE); + if(null == retCode || retCode == -1) { + return null; + } + + if(obj.optJSONObject(ParamConstant.PARAM_DATA) != null) { + result = obj.getJSONObject(ParamConstant.PARAM_DATA); + } else if(obj.optJSONArray(ParamConstant.PARAM_DATA) != null) { + result = obj.getJSONArray(ParamConstant.PARAM_DATA).getJSONObject(0); + } + if(result.isEmpty()) { + return null; + } + + if(result.containsKey(ParamConstant.PARAM_RETCODE)) { + result = getResponseData(result); + } + return result; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/RestfulUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/RestfulUtil.java new file mode 100644 index 0000000..5d7d334 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/RestfulUtil.java @@ -0,0 +1,371 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.Constant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.Restful; +import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; +import org.openo.baseservice.roa.util.restclient.RestfulFactory; +import org.openo.baseservice.roa.util.restclient.RestfulOptions; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + * Restful Utility Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class RestfulUtil { + + public static final String TYPE_GET = "get"; + + public static final String TYPE_PUT = "put"; + + public static final String TYPE_POST = "post"; + + public static final String TYPE_DEL = "delete"; + + public static final String CONTENT_TYPE = "Content-type"; + + public static final String APPLICATION = "application/json"; + + private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class); + + private static final Restful REST_CLIENT = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); + + private RestfulUtil() { + } + + /** + * Get response object.
+ * + * @param url + * @param type + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseObj(String url, String type) { + return getResponseObj(url, new RestfulParametes(), type); + } + + /** + * Get response object.
+ * + * @param url + * @param parametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseObj(String url, RestfulParametes parametes, String type) { + try { + String content = RestfulUtil.getResponseContent(url, parametes, null, type); + LOGGER.error("function=getResponseObj, content : {}", content); + if(StringUtils.isEmpty(content)) { + return null; + } + return JSONObject.fromObject(content); + } catch(JSONException e) { + LOGGER.error("function=getResponseObj, exception : {}", e); + return null; + } + } + + /** + * Get response content.
+ * + * @param url + * @param restParametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static String getResponseContent(String url, RestfulParametes restParametes, String type) { + return getResponseContent(url, restParametes, null, type); + } + + /** + * Get response map.
+ * + * @param url + * @param restParametes + * @param opt + * @param type + * @return + * @since NFVO 0.5 + */ + public static Map getResponseMap(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + RestfulResponse response = restfulResponse(url, restParametes, opt, type); + return getResponseMap(response); + } + + /** + * Get response content map.
+ * + * @param url + * @param type + * @return + * @since NFVO 0.5 + */ + public static Map getResponseContentMap(String url, String type) { + RestfulResponse response = restfulResponse(url, new RestfulParametes(), null, type); + return getResponseMap(response); + } + + private static Map getResponseMap(RestfulResponse response) { + Map resMap = new HashMap<>(10); + if(null != response) { + resMap.put(Constant.RESPONSE_CONTENT, response.getResponseContent()); + resMap.put(Constant.STATUS_CODE, response.getStatus()); + } + return resMap; + } + + /** + * Get response content.
+ * + * @param url + * @param restParametes + * @param opt + * @param type + * @return + * @since NFVO 0.5 + */ + public static String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + String responseContent = null; + RestfulResponse rsp = restfulResponse(url, restParametes, opt, type); + if(rsp != null) { + int httpStatus = rsp.getStatus(); + LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus); + if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) { + responseContent = rsp.getResponseContent(); + LOGGER.warn("function=getResponseContent, get response data success!responseContent={}", + responseContent); + } + } + return responseContent; + } + + /** + * Get restful response.
+ * + * @param url + * @param restParametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRestfulResponse(String url, RestfulParametes restParametes, String type) { + return restfulResponse(url, restParametes, null, type); + } + + private static RestfulResponse restfulResponse(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + RestfulResponse rsp = new RestfulResponse(); + try { + + if(REST_CLIENT != null) { + if(TYPE_GET.equals(type)) { + rsp = REST_CLIENT.get(url, restParametes, opt); + } else if(TYPE_POST.equals(type)) { + rsp = REST_CLIENT.post(url, restParametes, opt); + } else if(TYPE_PUT.equals(type)) { + rsp = REST_CLIENT.put(url, restParametes, opt); + } else if(TYPE_DEL.equals(type)) { + rsp = REST_CLIENT.delete(url, restParametes, opt); + } + } + } catch(ServiceException e) { + LOGGER.error("function=restfulResponse, get restful response catch exception {} ", e); + } + LOGGER.warn("function=restfulResponse, response status is {} ", rsp.getStatus()); + return rsp; + } + + /** + * encapsulate the java reflect exception.
+ * + * @param methodName, Restful's method. + * @param objects, method param array. + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRestRes(String methodName, Object... objects) { + try { + if(objects == null || REST_CLIENT == null) { + return null; + } + + Class[] classes = new Class[objects.length]; + for(int i = 0; i < objects.length; i++) { + classes[i] = objects[i].getClass(); + } + if(methodName.startsWith("async")) { + classes[classes.length - 1] = RestfulAsyncCallback.class; + } + + Class rtType = methodName.startsWith("async") ? void.class : RestfulResponse.class; + MethodType mt = MethodType.methodType(rtType, classes); + Object result = MethodHandles.lookup().findVirtual(REST_CLIENT.getClass(), methodName, mt) + .bindTo(REST_CLIENT).invokeWithArguments(objects); + if(result != null) { + return (RestfulResponse)result; + } + LOGGER.warn("function=getRestRes, msg: invoke Restful async {} method which return type is Void.", + methodName); + return null; + } catch(ReflectiveOperationException e) { + LOGGER.error("function=getRestRes, msg=error occurs, e={}.", e); + } catch(Throwable e) {// NOSONAR + LOGGER.error("function=getRestRes, msg=Throwable, e={}.", e); + try { + throw (ServiceException)new ServiceException().initCause(e.getCause()); + } catch(ServiceException se) { + LOGGER.error("function=getRestRes, msg=ServiceException occurs, e={}.", se); + } + } + return null; + } + + /** + * Get response.
+ * + * @param restParametes + * @param url + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public static JSONArray getResponseRes(RestfulParametes restParametes, String url) throws ServiceException { + String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); + if(null == result || result.isEmpty()) { + LOGGER.error("result from url:" + url + " result:" + result); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + + JSONArray rsArray = null; + try { + JSONObject rsJson = JSONObject.fromObject(result); + rsArray = rsJson.getJSONArray(ParamConstant.PARAM_DATA); + } catch(JSONException e) { + LOGGER.error("getResources error:" + e); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + return rsArray; + } + + /** + * Get response.
+ * + * @param restParametes + * @param url + * @param iResName + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public static JSONArray getResponseRes(RestfulParametes restParametes, String url, String iResName) + throws ServiceException { + String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); + if(null == result || result.isEmpty()) { + LOGGER.error("result from url:" + url + " result:" + result); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + + JSONArray rsArray = null; + try { + JSONObject rsJson = JSONObject.fromObject(result); + rsArray = rsJson.getJSONArray(iResName); + String vimId = rsJson.getString(ParamConstant.PARAM_VIMID); + String vimName = rsJson.getString(ParamConstant.PARAM_VIMNAME); + for(int i = 0; i < rsArray.size(); i++) { + JSONObject jsonObj = rsArray.getJSONObject(i); + jsonObj.put(ParamConstant.PARAM_VIMID, vimId); + jsonObj.put(ParamConstant.PARAM_VIMNAME, vimName); + } + } catch(JSONException e) { + LOGGER.error("getResources error:" + e); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + return rsArray; + } + + /** + *
+ * + * @param paramsMap + * @param params + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRemoteResponse(Map paramsMap, String params) { + String url = paramsMap.get("url"); + String methodType = paramsMap.get("methodType"); + + RestfulResponse rsp = null; + Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); + try { + + RestfulParametes restfulParametes = new RestfulParametes(); + Map headerMap = new HashMap<>(3); + headerMap.put(CONTENT_TYPE, APPLICATION); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(params); + + if(rest != null) { + if(TYPE_GET.equalsIgnoreCase(methodType)) { + rsp = rest.get(url, restfulParametes); + } else if(TYPE_POST.equalsIgnoreCase(methodType)) { + rsp = rest.post(url, restfulParametes); + } else if(TYPE_PUT.equalsIgnoreCase(methodType)) { + rsp = rest.put(url, restfulParametes); + } else if(TYPE_DEL.equalsIgnoreCase(methodType)) { + rsp = rest.delete(url, restfulParametes); + } + } + } catch(ServiceException e) { + LOGGER.error("function=getRemoteResponse, get restful response catch exception {}", e); + } + return rsp; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/StringUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/StringUtil.java new file mode 100644 index 0000000..2d4b1c7 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/StringUtil.java @@ -0,0 +1,215 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util; + +import java.math.BigDecimal; +import java.text.DecimalFormat; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * String Utility Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class StringUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class); + + private StringUtil() { + } + + /** + * + * Check whether thestring is valid.
+ * + * @param str + * @return + * @since NFVO 0.5 + */ + public static boolean isValidString(String str) { + if(null == str || str.isEmpty()) { + return false; + } + return true; + } + + /** + * + * Check whether the value is larger than zero.
+ * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isAnyLargeThanZero(String... strs) { + for(String str : strs) { + if(!StringUtils.isEmpty(str) && Float.parseFloat(str) > 0) { + LOGGER.info("isAnyLargeThanZero : {} is > 0", str); + return true; + } + } + return false; + } + + /** + * + * Check whether the value is Integer.
+ * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isInteger(String... strs) { + try { + for(String str : strs) { + if(!StringUtils.isEmpty(str)) { + int value = Integer.parseInt(str); + if(value < 0) { + return false; + } + } + } + } catch(NumberFormatException e) { + return false; + } + return true; + } + + /** + * + * Check whether the input is Numeric.
+ * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isNumeric(String... strs) { + try { + for(String str : strs) { + if(!StringUtils.isEmpty(str)) { + float value = Float.parseFloat(str); + if(value < 0) { + return false; + } + } + } + } catch(NumberFormatException e) { + return false; + } + return true; + } + + /** + * + * Compare zero by float.
+ * + * @param tatol + * @param used + * @param drTotal + * @return + * @since NFVO 0.5 + */ + public static boolean compareZeroByFloat(String tatol, String used, String drTotal) { + Float ftotal = (float)0; + Float fused = (float)0; + Float fdrTotal = (float)0; + if(!StringUtils.isEmpty(tatol)) { + ftotal = new Float(tatol); + } + if(!StringUtils.isEmpty(used)) { + fused = new Float(used); + } + if(!StringUtils.isEmpty(drTotal)) { + fdrTotal = new Float(drTotal); + } + if(ftotal < fused + fdrTotal) { + return false; + } + + return true; + } + + /** + * + * Compare zero by integer.
+ * + * @param tatol + * @param used + * @param drTotal + * @return + * @since NFVO 0.5 + */ + public static boolean compareZeroByInteger(String tatol, String used, String drTotal) { + Integer ftotal = (int)0; + Integer fused = (int)0; + Integer fdrTotal = (int)0; + if(!StringUtils.isEmpty(tatol)) { + ftotal = Integer.valueOf(tatol); + } + if(!StringUtils.isEmpty(used)) { + fused = Integer.valueOf(used); + } + if(!StringUtils.isEmpty(drTotal)) { + fdrTotal = Integer.valueOf(drTotal); + } + if(ftotal < fused + fdrTotal) { + return false; + } + return true; + } + + /** + * + * Number format.
+ * + * @param data + * @return + * @since NFVO 0.5 + */ + public static String numFormat(String data) { + if(null != data && !("".equals(data))) { + BigDecimal var = new BigDecimal(data); + DecimalFormat formatWithoutFraction = new DecimalFormat("############"); + DecimalFormat formatWithFraction = new DecimalFormat("############.############"); + if(new BigDecimal(var.intValue()).compareTo(var) == 0) { + return formatWithoutFraction.format(var); + } + return formatWithFraction.format(var); + } + return null; + } + + /** + * + *
+ * + * @param inputStr + * @return + * @since NFVO 0.5 + */ + public static boolean checkXss(String inputStr) { + return inputStr.matches("[A-Za-z0-9_.']+"); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/request/RequestUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/request/RequestUtil.java new file mode 100644 index 0000000..bbc28a3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/request/RequestUtil.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util.request; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + *
+ *

+ * Utility used for request + *

+ * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public final class RequestUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(RequestUtil.class); + + /** + * Constructor
+ *

+ *

+ * + * @since NFVO 0.5 + */ + private RequestUtil() { + } + + /** + * Get context string from http context + * + * @param context + * http context + * @return the needed string in http context + */ + public static String getStringRequestBody(HttpServletRequest context) { + try { + InputStream input = context.getInputStream(); + return IOUtils.toString(input); + } catch(IOException e) { + LOGGER.error("function=getStringRequestBody, get httpservletrequest body exception: {}", e); + return null; + } + } + + /** + * Get json parameter from http context + * + * @param context + * http context + * @return JSONObject + */ + public static JSONObject getJsonRequestBody(HttpServletRequest context) { + try { + String bodyStr = getStringRequestBody(context); + return JSONObject.fromObject(bodyStr); + } catch(JSONException e) { + LOGGER.error("function=getJsonRequestBody, maybe request param is not a jsonobject exception: {}", e); + return null; + } + } + + /** + * Get the body of all request in json format
+ * + * @param context + * The http context + * @return JSONObject The body of all request in json format + * @since NFVO 0.5 + */ + public static JSONObject getAllJsonRequestBody(HttpServletRequest context) { + JSONObject requestBody = getJsonRequestBody(context); + if(null == requestBody) { + LOGGER.error("get httpservletrequest body exception"); + requestBody = new JSONObject(); + } + LOGGER.warn("function=getAllJsonRequestBody; msg=get request data is:[{}]", requestBody.toString()); + requestBody.put("header", getContextHeader(context)); + return requestBody; + } + + /** + * Get the context header
+ * + * @param context + * The http context + * @return Map context header + * @since NFVO 0.5 + */ + @SuppressWarnings("unchecked") + private static Map getContextHeader(HttpServletRequest context) { + Map header = new HashMap(); + Enumeration headerNames = context.getHeaderNames(); + while(headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + String value = context.getHeader(headerName); + header.put(headerName, value); + } + return header; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/ResponseUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/ResponseUtil.java new file mode 100644 index 0000000..28ee1b0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/ResponseUtil.java @@ -0,0 +1,133 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util.response; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import javax.servlet.http.HttpServletRequest; + +import net.sf.json.JSONObject; + +/** + * + * Response utility class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class ResponseUtil { + + private ResponseUtil() { + } + + /** + * Roa request common return function, default return code 200
+ * + * @param retCode + * The request return code + * @param msg + * The request message + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(int retCode, String msg) { + return genHttpResponse(null, createCodeMap(-1, retCode), msg, null); + } + + /** + * Roa request common return function, default return code 200
+ * + * @param retCode + * The request return code + * @param msg + * The request message + * @param map + * Other request info of this request + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(int retCode, String msg, Map map) { + return genHttpResponse(null, createCodeMap(-1, retCode), msg, map); + } + + /** + * Roa request common return method
+ * + * @param context + * The http request context + * @param httpStatusCode + * The http response code + * @param retCode + * The http request return code + * @param msg + * The message of request + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(HttpServletRequest context, int httpStatusCode, int retCode, String msg) { + return genHttpResponse(context, createCodeMap(httpStatusCode, retCode), msg, null); + } + + /** + * + * Roa request common return method.
+ * + * @param context, The http request context + * @param codeMap + * @param msg, The message of request + * @param map, Other message of request + * @return + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(HttpServletRequest context, Map codeMap, String msg, + Map map) { + JSONObject object = new JSONObject(); + + object.put("msg", msg); + if(null != map) { + Iterator> ite = map.entrySet().iterator(); + if(ite.hasNext()) { + Map.Entry entry = ite.next(); + object.put(entry.getKey(), entry.getValue().toString()); + } + } + return object; + } + + /** + * Create code map to maintenance the relationship between return code and + * http status code
+ * + * @param httpStatusCode + * The http response code + * @param retCode + * The http request return code + * @return Map + * @since NFVO 0.5 + */ + private static Map createCodeMap(int httpStatusCode, int retCode) { + Map codeMap = new HashMap<>(5); + codeMap.put("httpStatusCode", httpStatusCode); + codeMap.put("retCode", retCode); + return codeMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/RoaResponseUtil.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/RoaResponseUtil.java new file mode 100644 index 0000000..1043e7a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/common/util/response/RoaResponseUtil.java @@ -0,0 +1,113 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.common.util.response; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.ResponseConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ * Utility for generate Roa get/add/update/delete method status + *

+ * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public final class RoaResponseUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(RoaResponseUtil.class); + + private RoaResponseUtil() { + + } + + /** + * Generate get method response
+ * + * @param list + * The basic response for get method + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject get(List list) { + Map map = new HashMap(10); + map.put(ParamConstant.PARAM_DATA, list); + LOGGER.info("function=get; msg=get map:{}", map.toString()); + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.QUERY_SUCESS_MSG, map); + } + + /** + * Generate different response by different parameter for add method
+ * + * @param result + * The result + * @return JSONObject + * @since NFVO 0.5 + */ + public static JSONObject add(int result) { + LOGGER.info("function=add; msg=add result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.ADD_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.ADD_SUCESS_MSG); + } + } + + /** + * Generate different response by different parameter for update method
+ * + * @param result + * The result + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject update(int result) { + LOGGER.info("function=update; msg=update result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.MOD_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.MOD_SUCESS_MSG); + } + } + + /** + * Generate different response by different parameter for delete method
+ * + * @param result + * The result + * @return delete JSONObject of the response for http request + * @since NFVO 0.5 + */ + public static JSONObject delete(int result) { + LOGGER.info("function=delete; msg=delete result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.DEL_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.DEL_SUCESS_MSG); + } + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/activator/ROAResmgrServicePostProcessor.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/activator/ROAResmgrServicePostProcessor.java new file mode 100644 index 0000000..6c217c2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/activator/ROAResmgrServicePostProcessor.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.activator; + +import org.onap.vfc.nfvo.res.service.adapter.inf.IResmgrAdapterMgrService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public class ROAResmgrServicePostProcessor implements DestructionAwareBeanPostProcessor { + + private static final Logger LOG = LoggerFactory.getLogger(ROAResmgrServicePostProcessor.class); + + @Override + public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { + if(bean instanceof IResmgrAdapterMgrService) { + LOG.warn("Register to Microservice BUS!"); + IResmgrAdapterMgrService resmgrAdapterSvc = (IResmgrAdapterMgrService)bean; + resmgrAdapterSvc.register(); + } + + return bean; + } + + @Override + public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { + // TODO Auto-generated method stub + return bean; + } + + @Override + public void postProcessBeforeDestruction(Object bean, String name) throws BeansException { + // TODO Auto-generated method stub + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapter2MSBManager.java new file mode 100644 index 0000000..f9ccbed --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapter2MSBManager.java @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.adapter.impl; + +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.constant.Constant; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.service.adapter.inf.IResmgrAdapter2MSBManager; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public class ResmgrAdapter2MSBManager implements IResmgrAdapter2MSBManager { + + private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapter2MSBManager.class); + + @Override + public JSONObject registerResmgr(Map paramsMap, JSONObject driverInfo) { + JSONObject resultObj = new JSONObject(); + + RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); + if(null == rsp) { + LOG.error("function=registerResmgr, RestfulResponse is null"); + resultObj.put("reason", "RestfulResponse is null."); + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + LOG.warn("function=registerResmgr, status={}, content={}.", rsp.getStatus(), rsp.getResponseContent()); + String resultCreate = rsp.getResponseContent(); + + if(rsp.getStatus() == HttpConstant.HTTP_CREATED) { + LOG.warn("function=registerResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); + resultObj = JSONObject.fromObject(resultCreate); + resultObj.put("retCode", HttpConstant.HTTP_CREATED); + return resultObj; + } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { + LOG.error("function=registerResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,invalid parameters."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { + LOG.error("function=registerResmgr, msg=MSB return fail,internal system error,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,internal system error."); + } + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + + @Override + public JSONObject unregisterResmgr(Map paramsMap) { + JSONObject resultObj = new JSONObject(); + + RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, ""); + if(null == rsp) { + LOG.error("function=unregisterResmgr, RestfulResponse is null"); + resultObj.put("reason", "RestfulResponse is null."); + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + String resultCreate = rsp.getResponseContent(); + + if(rsp.getStatus() == HttpConstant.HTTP_NOCONTENT) { + LOG.warn("function=unregisterResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); + resultObj = JSONObject.fromObject(resultCreate); + resultObj.put("retCode", HttpConstant.HTTP_NOCONTENT); + return resultObj; + } else if(rsp.getStatus() == HttpConstant.HTTP_NOTFOUND_CODE) { + LOG.error( + "function=unregisterResmgr, msg=MSB return fail,can't find the service instance.status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,can't find the service instance."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { + LOG.error("function=unregisterResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,invalid parameters."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { + LOG.error("function=unregisterResmgr, msg=MSB return fail,internal system error,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,internal system error."); + } + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapterMgrService.java new file mode 100644 index 0000000..8b1d905 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/impl/ResmgrAdapterMgrService.java @@ -0,0 +1,185 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.adapter.impl; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Executors; + +import org.onap.vfc.nfvo.res.common.constant.Constant; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.service.adapter.inf.IResmgrAdapter2MSBManager; +import org.onap.vfc.nfvo.res.service.adapter.inf.IResmgrAdapterMgrService; +import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +@Service +public class ResmgrAdapterMgrService implements IResmgrAdapterMgrService { + + private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapterMgrService.class); + + public static final String RESMGRADAPTERINFO = "resmgradapterinfo.json"; + + @Override + public void register() { + // set BUS URL and mothedtype + Map paramsMap = new HashMap<>(); + paramsMap.put("url", UrlConstant.REST_MSB_REGISTER); + paramsMap.put("methodType", ParamConstant.PARAM_POST); + + // get resmgr info and raise registration + try { + String resmgrInfo = readVimAdapterInfoFromJson(); + if(!"".equals(resmgrInfo)) { + JSONObject adapterObject = JSONObject.fromObject(resmgrInfo); + RegisterResmgrThread resmgrThread = new RegisterResmgrThread(paramsMap, adapterObject); + Executors.newSingleThreadExecutor().submit(resmgrThread); + } else { + LOG.error("Resmgr info is null,please check!"); + } + + } catch(IOException e) { + LOG.error("Failed to read Resmgr info! " + e.getMessage(), e); + } + + } + + /** + * Retrieve VIM driver information. + * + * @return + * @throws IOException + */ + public static String readVimAdapterInfoFromJson() throws IOException { + InputStream ins = null; + BufferedInputStream bins = null; + String fileContent = ""; + + String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator") + + "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator") + + RESMGRADAPTERINFO; + + try { + ins = new FileInputStream(fileName); + bins = new BufferedInputStream(ins); + + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); + + if(num > 0) { + fileContent = new String(contentByte); + } + } catch(FileNotFoundException e) { + LOG.error(fileName + "is not found!", e); + } finally { + if(ins != null) { + ins.close(); + } + if(bins != null) { + bins.close(); + } + } + + return fileContent; + } + + private static class RegisterResmgrThread implements Runnable { + + // Thread lock Object + private final Object lockObject = new Object(); + + private IResmgrAdapter2MSBManager adapter2MSBMgr = new ResmgrAdapter2MSBManager(); + + // url and mothedtype + private Map paramsMap; + + // driver body + private JSONObject adapterInfo; + + public RegisterResmgrThread(Map paramsMap, JSONObject adapterInfo) { + this.paramsMap = paramsMap; + this.adapterInfo = adapterInfo; + } + + @Override + public void run() { + LOG.info("start register resmgr", RegisterResmgrThread.class); + + if(paramsMap == null || adapterInfo == null) { + LOG.error("parameter is null,please check!", RegisterResmgrThread.class); + return; + } + + // catch Runtime Exception + try { + sendRequest(paramsMap, adapterInfo); + } catch(RuntimeException e) { + LOG.error(e.getMessage(), e); + } + + } + + private void sendRequest(Map paramsMap, JSONObject driverInfo) { + JSONObject resultObj = adapter2MSBMgr.registerResmgr(paramsMap, driverInfo); + + if(Integer.valueOf(resultObj.get("retCode").toString()) == HttpConstant.HTTP_CREATED) { + LOG.info("Resmgr has now Successfully Registered to the Microservice BUS!"); + } else { + LOG.error("Resmgr failed to Register to the Microservice BUS! Reason:" + + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); + + // if registration fails,wait one minute and try again + try { + synchronized(lockObject) { + lockObject.wait(Constant.REPEAT_REG_TIME); + } + } catch(InterruptedException e) { + LOG.error(e.getMessage(), e); + } + + sendRequest(this.paramsMap, this.adapterInfo); + } + + } + + } + + @Override + public void unregister() { + // unregister + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapter2MSBManager.java new file mode 100644 index 0000000..5981f59 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapter2MSBManager.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.adapter.inf; + +import java.util.Map; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public interface IResmgrAdapter2MSBManager { + + /** + *
+ * + * @param paramsMap + * @param driverInfo + * @return + * @since NFVO 0.5 + */ + JSONObject registerResmgr(Map paramsMap, JSONObject driverInfo); + + /** + *
+ * + * @param paramsMap + * @return + * @since NFVO 0.5 + */ + JSONObject unregisterResmgr(Map paramsMap); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapterMgrService.java new file mode 100644 index 0000000..3bce8af --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/adapter/inf/IResmgrAdapterMgrService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.adapter.inf; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public interface IResmgrAdapterMgrService { + + /** + * Resmgr register interface. + */ + void register(); + + /** + * Resmgr unregister interface. + */ + void unregister(); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/HostImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/HostImpl.java new file mode 100644 index 0000000..1dbaf51 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/HostImpl.java @@ -0,0 +1,80 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Host; +import org.onap.vfc.nfvo.res.service.business.inf.HostBusiness; +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * + * Host implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostImpl implements Host { + + private HostBusiness hostBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return hostBusiness.addHost(HostEntity.toEntity(jsonObject)); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return hostBusiness.updateHostSelective(HostEntity.toEntity(jsonObject)); + } + + @Override + public int update(HostEntity portEntity) throws ServiceException { + return hostBusiness.updateHostSelective(portEntity); + } + + @Override + public int delete(String id) throws ServiceException { + return hostBusiness.deleteHost(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return hostBusiness.updateHostByVimId(HostEntity.toEntity(jsonObject)); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return hostBusiness.deleteHostByVimId(vimId); + } + + @Override + public List getList(Map condition) throws ServiceException { + return hostBusiness.getHosts(condition); + } + + public void setHostBusiness(HostBusiness hostBusiness) { + this.hostBusiness = hostBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/LocationImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/LocationImpl.java new file mode 100644 index 0000000..422fa06 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/LocationImpl.java @@ -0,0 +1,186 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Location; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.business.inf.LocationBusiness; +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Location Implementation Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationImpl implements Location { + + private LocationBusiness locationBusiness; + + private Sites sites; + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationImpl.class); + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return locationBusiness.addLocation(LocationEntity.toEntity(jsonObject)); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return locationBusiness.updateLocationSelective(LocationEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String location) throws ServiceException { + return locationBusiness.deleteLocation(location); + } + + @Override + public Map get(String id) throws ServiceException { + Map map = new HashMap<>(); + map.put(ParamConstant.PARAM_ID, id); + List sodores = locationBusiness.getLocations(map); + map.clear(); + map.put(ParamConstant.PARAM_DATA, sodores); + return map; + } + + @Override + public List get(Map condition) throws ServiceException { + return locationBusiness.getLocations(condition); + } + + @Override + public List getCountry() throws ServiceException { + return locationBusiness.getCountry(); + } + + @Override + public List getCloudservice() throws ServiceException { + LOGGER.info("get cloud service from external system"); + JSONArray vims = VimUtil.getVims(); + LOGGER.info("vims: " + vims.toString()); + List cloudService = new ArrayList<>(); + for(int i = 0; i < vims.size(); i++) { + String vimName = vims.getJSONObject(i).getString("name"); + cloudService.add(vimName); + } + return cloudService; + } + + @Override + public List getLocationByCountry(Map condition) throws ServiceException { + return locationBusiness.getLocationByCountry(condition); + } + + @Override + public LocationEntity getLocation(Map condition) throws ServiceException { + List locationlist = locationBusiness.getLocations(condition); + if(null == locationlist || locationlist.isEmpty()) { + return null; + } + return locationlist.get(0); + } + + @Override + public List getLocationInfo(List locationInfo) throws ServiceException { + ArrayList newSites = new ArrayList<>(); + Map condition = new HashMap<>(); + for(int i = 0; i < locationInfo.size(); i++) { + LocationEntity locationEntity = locationInfo.get(i); + String latitude = locationEntity.getLatitude(); + String longitude = locationEntity.getLongitude(); + String locatSite = locationEntity.getLocation(); + condition.put(ParamConstant.PARAM_LOCATION, locatSite); + LOGGER.info("LocationRoa::getLocation condition:{}", condition); + List sitesEntity = sites.getList(condition); + LOGGER.info("LocationRoa::getLocation sitesEntity:{}", sitesEntity); + if(null != sitesEntity && !sitesEntity.isEmpty()) { + for(SitesEntity entity : sitesEntity) { + JSONObject site = JSONObject.fromObject(entity.toString()); + JSONObject resTotalJo = site.getJSONObject("total"); + JSONObject resUsedlJo = site.getJSONObject("used"); + JSONObject ressiteJo = computingSite(resTotalJo, resUsedlJo); + site.element("latitude", latitude); + site.element("longitude", longitude); + site.element("siteDetail", ressiteJo); + LOGGER.info("LocationRoa::getLocation latitude:{}, longitude:{}", latitude, longitude); + LOGGER.info("LocationRoa::getLocation site:{}", site); + newSites.add(site); + } + } + } + return newSites; + } + + /** + * Computing site.
+ * + * @param total + * @param used + * @return + * @since NFVO 0.5 + */ + public JSONObject computingSite(JSONObject total, JSONObject used) { + String vcpus = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_VCPUS); + String memorys = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_MEMORY); + String disks = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_DISK); + String vcpusused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_VCPUS); + String memoryused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_MEMORY); + String diskused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_DISK); + float cpu = Float.parseFloat(vcpusused) / Float.parseFloat(vcpus); + float memory = Float.parseFloat(memoryused) / Integer.parseInt(memorys); + float disk = Float.parseFloat(diskused) / Float.parseFloat(disks); + JSONObject resTotalJo = new JSONObject(); + resTotalJo.put(ParamConstant.PARAM_VCPUS, String.valueOf(Math.round(cpu * 100)) + "%"); + resTotalJo.put(ParamConstant.PARAM_MEMORY, String.valueOf(Math.round(memory * 100)) + "%"); + resTotalJo.put(ParamConstant.PARAM_DISK, String.valueOf(Math.round(disk * 100)) + "%"); + + return resTotalJo; + } + + public LocationBusiness getLocationBusiness() { + return locationBusiness; + } + + public void setLocationBusiness(LocationBusiness locationBusiness) { + this.locationBusiness = locationBusiness; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/NetworkImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/NetworkImpl.java new file mode 100644 index 0000000..9bfcf74 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/NetworkImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Network; +import org.onap.vfc.nfvo.res.service.business.inf.NetworkBusiness; +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Network implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkImpl implements Network { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkImpl.class); + + private NetworkBusiness networkBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.warn("function=addPort; jsonObject={}", jsonObject); + JSONObject networkObj = dataParse(jsonObject); + return networkBusiness.addNetwork(NetworkEntity.toEntity(networkObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) { + JSONObject portObj = new JSONObject(); + portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); + portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); + portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); + portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); + portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + portObj.put("physicalNetwork", JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); + portObj.put("networkType", JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + portObj.put("segmentationId", JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); + return portObj; + } + + @Override + public int add(NetworkEntity entity) throws ServiceException { + return networkBusiness.addNetwork(entity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return networkBusiness.updateNetworkSelective(NetworkEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String id) throws ServiceException { + return networkBusiness.deleteNetwork(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return networkBusiness.updateNetworkByVimId(NetworkEntity.toEntity(jsonObject)); + } + + @Override + public List getList(Map condition) throws ServiceException { + return networkBusiness.getNetworks(condition); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return networkBusiness.deleteNetworkByVimId(vimId); + } + + public void setNetworkBusiness(NetworkBusiness networkBusiness) { + this.networkBusiness = networkBusiness; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/PortImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/PortImpl.java new file mode 100644 index 0000000..36b6cd1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/PortImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Port; +import org.onap.vfc.nfvo.res.service.business.inf.PortBusiness; +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Port implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortImpl implements Port { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortImpl.class); + + private PortBusiness portBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.warn("function=addPort; jsonObject={}", jsonObject); + JSONObject portObj = dataParse(jsonObject); + return portBusiness.addPort(PortEntity.toEntity(portObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) { + JSONObject portObj = new JSONObject(); + portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); + portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); + portObj.put("networkId", JsonUtil.getJsonFieldStr(jsonObject, "networkId")); + portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); + portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); + portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return portObj; + } + + @Override + public int add(PortEntity portEntity) throws ServiceException { + return portBusiness.addPort(portEntity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return portBusiness.updatePortSelective(PortEntity.toEntity(jsonObject)); + } + + @Override + public int update(PortEntity portEntity) throws ServiceException { + return portBusiness.updatePortSelective(portEntity); + } + + @Override + public int delete(String id) throws ServiceException { + return portBusiness.deletePort(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return portBusiness.updatePortByVimId(PortEntity.toEntity(jsonObject)); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return portBusiness.deletePortByVimId(vimId); + } + + @Override + public List getList(Map condition) throws ServiceException { + return portBusiness.getPorts(condition); + } + + public void setPortBusiness(PortBusiness portBusiness) { + this.portBusiness = portBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/SitesImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/SitesImpl.java new file mode 100644 index 0000000..3238f50 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/SitesImpl.java @@ -0,0 +1,231 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.business.inf.LimitsBusiness; +import org.onap.vfc.nfvo.res.service.business.inf.SitesBusiness; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.onap.vfc.nfvo.res.service.group.inf.ResOperateService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * DC info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class SitesImpl implements Sites { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesImpl.class); + + private SitesBusiness sitesBusiness; + + private LimitsBusiness limitsBusiness; + + private ResOperateService resOperateService; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.info("Add datacenter jsonObject: {}", jsonObject); + SitesEntity sitesEntity = SitesEntity.toEntity(jsonObject); + sitesEntity.setStatus(ParamConstant.PARAM_ACTIVE); + String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); + String vimId = VimUtil.getVimIdByName(vimName); + sitesEntity.setVimId(vimId); + JSONObject resource = limitsBusiness.getLimits(vimId); + sitesEntity.setVimName(resource.getString(ParamConstant.PARAM_VIMNAME)); + sitesEntity.setTotalCPU(resource.getString(ParamConstant.TOTAL_CPU)); + sitesEntity.setUsedCPU(resource.getString(ParamConstant.USED_CPU)); + sitesEntity.setTotalMemory(resource.getString(ParamConstant.TOTAL_MEMORY)); + sitesEntity.setUsedMemory(resource.getString(ParamConstant.USED_MEMORY)); + sitesEntity.setTotalDisk(resource.getString(ParamConstant.TOTAL_DISK)); + sitesEntity.setUsedDisk(resource.getString(ParamConstant.USED_DISK)); + if(StringUtils.isEmpty(sitesEntity.getId())) { + sitesEntity.setId(UUID.randomUUID().toString()); + jsonObject.put(ParamConstant.PARAM_ID, sitesEntity.getId()); + } + LOGGER.info("Add datacenter sitesEntity: {}", sitesEntity.toString()); + return sitesBusiness.addSite(sitesEntity); + } + + /** + *
+ * + * @param json + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public void sendToMonitor(JSONObject jsonObject) throws ServiceException { + LOGGER.info("SitesImpl sendToMonitor jsonObject: {}", jsonObject); + String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); + String vimId = VimUtil.getVimIdByName(vimName); + JSONObject vimInfo = VimUtil.getVimById(vimId); + LOGGER.info("SitesImpl sendToMonitor vimInfo: {}", vimInfo); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + JSONObject json = new JSONObject(); + json.put("header", null); + LOGGER.info("tenantId:{}, vimId:{}", tenantId, vimId); + resOperateService.addIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("create", vimId); + } + + @Override + public int update(SitesEntity sitesEntity) throws ServiceException { + return sitesBusiness.updateSiteSelective(sitesEntity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + LOGGER.info("grantResource jsonObject: {}", jsonObject); + JSONObject sitesObj = dataParse(jsonObject); + return sitesBusiness.updateSiteSelective(SitesEntity.toEntity(sitesObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) throws ServiceException { + String vimId = jsonObject.getString(ParamConstant.PARAM_VIMID); + Map condition = new HashMap<>(); + condition.put("vimId", vimId); + SitesEntity sitesEntity = get(condition); + if(null == sitesEntity) { + LOGGER.error("Get sites null, vimId={}", vimId); + return null; + } + return computeSiteUsed(jsonObject, sitesEntity); + } + + private JSONObject computeSiteUsed(JSONObject jsonObject, SitesEntity sitesEntity) throws ServiceException { + String action = JsonUtil.getJsonFieldStr(jsonObject, "action"); + String usedCpu = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_CPU); + String usedMemory = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_MEMORY); + String usedDisk = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_DISK); + String oldCpu = sitesEntity.getUsedCPU(); + String oldMemory = sitesEntity.getUsedMemory(); + String oldDisk = sitesEntity.getUsedDisk(); + String newCpu = accumOrFreeRes(usedCpu, oldCpu, action, sitesEntity.getTotalCPU(), "cpu"); + String newMemory = accumOrFreeRes(usedMemory, oldMemory, action, sitesEntity.getTotalMemory(), "memory"); + String newDisk = accumOrFreeRes(usedDisk, oldDisk, action, sitesEntity.getTotalDisk(), "disk"); + + JSONObject resUsed = new JSONObject(); + resUsed.put(ParamConstant.USED_CPU, newCpu); + resUsed.put(ParamConstant.USED_MEMORY, newMemory); + resUsed.put(ParamConstant.USED_DISK, newDisk); + resUsed.put("id", sitesEntity.getId()); + resUsed.put("name", sitesEntity.getName()); + resUsed.put("status", sitesEntity.getStatus()); + resUsed.put("location", sitesEntity.getLocation()); + resUsed.put("country", sitesEntity.getCountry()); + resUsed.put(ParamConstant.PARAM_VIMID, sitesEntity.getVimId()); + resUsed.put(ParamConstant.PARAM_VIMNAME, sitesEntity.getVimName()); + resUsed.put(ParamConstant.TOTAL_CPU, sitesEntity.getTotalCPU()); + resUsed.put(ParamConstant.TOTAL_MEMORY, sitesEntity.getTotalMemory()); + resUsed.put(ParamConstant.TOTAL_DISK, sitesEntity.getTotalDisk()); + return resUsed; + } + + private String accumOrFreeRes(String resUsed, String resOld, String action, String total, String type) + throws ServiceException { + BigDecimal iResUsed = new BigDecimal(resUsed); + BigDecimal iResOld = new BigDecimal(resOld); + BigDecimal itotal = new BigDecimal(total); + if("online".equals(action)) { + if(iResOld.add(iResUsed).compareTo(itotal) > 0) { + throw new ServiceException("Grant resource fail! The " + type + " resource not enough."); + } + return String.valueOf(iResOld.add(iResUsed)); + } else { + if(iResOld.subtract(iResUsed).compareTo(BigDecimal.ZERO) < 0) { + throw new ServiceException("Grant resource fail! The " + type + " resource used below zero."); + } + return String.valueOf(iResOld.subtract(iResUsed)); + } + } + + @Override + public int updateResource(JSONObject jsonObject) throws ServiceException { + return sitesBusiness.updateSiteResource(SitesEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String id) throws ServiceException { + Map map = new HashMap(10); + map.put(ParamConstant.PARAM_ID, id); + List datacenters = getList(map); + SitesEntity site = datacenters.get(0); + LOGGER.info("site: {}", site); + String vimId = site.getVimId(); + LOGGER.info("vimId: {}", vimId); + resOperateService.sendMsgMonitor("delete", vimId); + resOperateService.deleteIRes(vimId); + return sitesBusiness.deleteSite(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return sitesBusiness.updateSiteByVimId(SitesEntity.toEntity(jsonObject)); + } + + @Override + public List getList(Map condition) throws ServiceException { + return sitesBusiness.getSites(condition); + } + + @Override + public SitesEntity get(Map condition) throws ServiceException { + List siteList = sitesBusiness.getSites(condition); + if(null == siteList || siteList.isEmpty()) { + return null; + } + return siteList.get(0); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return 0; + } + + public void setSitesBusiness(SitesBusiness sitesBusiness) { + this.sitesBusiness = sitesBusiness; + } + + public void setLimitsBusiness(LimitsBusiness limitsBusiness) { + this.limitsBusiness = limitsBusiness; + } + + public void setResOperateService(ResOperateService resOperateService) { + this.resOperateService = resOperateService; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/VimImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/VimImpl.java new file mode 100644 index 0000000..99c1e96 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/impl/VimImpl.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Vim; +import org.onap.vfc.nfvo.res.service.business.inf.VimBusiness; +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * Vim info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class VimImpl implements Vim { + + private VimBusiness vimBusiness; + + @Override + public int add(String id) throws ServiceException { + return vimBusiness.addVim(id); + } + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return add(jsonObject.getString("id")); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return 0; + } + + @Override + public int delete(String id) throws ServiceException { + return vimBusiness.deleteVim(id); + } + + @Override + public VimEntity getVim(String id) throws ServiceException { + return vimBusiness.getVim(id); + } + + @Override + public List getList() throws ServiceException { + return vimBusiness.getVims(); + } + + @Override + public List getVimInfo(Map condition) throws ServiceException { + // get vim from vimadapter + return new ArrayList(); + } + + public void setVimBusiness(VimBusiness vimBusiness) { + this.vimBusiness = vimBusiness; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Host.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Host.java new file mode 100644 index 0000000..068762b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Host.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Host extends InterfaceResManagement { + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + *
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList(Map condition) throws ServiceException; + + /** + *
+ * + * @param resPoolEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(HostEntity resPoolEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/InterfaceResManagement.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/InterfaceResManagement.java new file mode 100644 index 0000000..167c617 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/InterfaceResManagement.java @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface InterfaceResManagement extends ResManagement { + + /** + *
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteResByVimId(String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Location.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Location.java new file mode 100644 index 0000000..a3a0c15 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Location.java @@ -0,0 +1,104 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * Location details class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface Location extends ResManagement { + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + Map get(String id) throws ServiceException; + + /** + * Get list of locations.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List get(Map condition) throws ServiceException; + + /** + * Get location details.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + LocationEntity getLocation(Map condition) throws ServiceException; + + /** + * Get location info.
+ * + * @param locationInfo + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getLocationInfo(List locationInfo) throws ServiceException; + + /** + * Get Country.
+ * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getCountry() throws ServiceException; + + /** + * Get location by country.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getLocationByCountry(Map condition) throws ServiceException; + + /** + * Get cloud services.
+ * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getCloudservice() throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Network.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Network.java new file mode 100644 index 0000000..398d8a9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Network.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * + * Network class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface Network extends InterfaceResManagement { + + /** + * + * Update status by VIM Id.
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + * + * Get list of networks.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList(Map condition) throws ServiceException; + + /** + *
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int add(NetworkEntity entity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Port.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Port.java new file mode 100644 index 0000000..9fc7f77 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Port.java @@ -0,0 +1,76 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Port extends InterfaceResManagement { + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + *
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList(Map condition) throws ServiceException; + + /** + *
+ * + * @param resPoolEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(PortEntity resPoolEntity) throws ServiceException; + + /** + *
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(PortEntity portEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/ResManagement.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/ResManagement.java new file mode 100644 index 0000000..225f095 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/ResManagement.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface ResManagement { + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(JSONObject jsonObject) throws ServiceException; + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(JSONObject jsonObject) throws ServiceException; + + /* + * key : parameter key value : parameter value + */ + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Sites.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Sites.java new file mode 100644 index 0000000..c6c622a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Sites.java @@ -0,0 +1,95 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Sites extends InterfaceResManagement { + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + *
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList(Map condition) throws ServiceException; + + /** + *
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + SitesEntity get(Map condition) throws ServiceException; + + /** + *
+ * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateResource(JSONObject jsonObject) throws ServiceException; + + /** + *
+ * + * @param sitesEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(SitesEntity sitesEntity) throws ServiceException; + + /** + *
+ * + * @param json + * @throws ServiceException + * @since NFVO 0.5 + */ + void sendToMonitor(JSONObject json) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Vim.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Vim.java new file mode 100644 index 0000000..4d3e278 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/base/openstack/inf/Vim.java @@ -0,0 +1,76 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * Virtualised Infrastructure Manager.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Vim extends ResManagement { + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + VimEntity getVim(String id) throws ServiceException; + + /** + *
+ * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList() throws ServiceException; + + /** + * + * Get VIM information.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getVimInfo(Map condition) throws ServiceException; + + /** + *
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/HostBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/HostBusinessImpl.java new file mode 100644 index 0000000..f7be74f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/HostBusinessImpl.java @@ -0,0 +1,162 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.service.business.inf.HostBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.HostDao; +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * Host business implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostBusinessImpl implements HostBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(HostBusinessImpl.class); + + private HostDao hostDao; + + @Override + public HostEntity getHost(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getHost; msg=get error, because id is empty."); + return null; + } + return hostDao.getHost(id); + } + + @Override + public List getHosts(Map condition) { + return hostDao.getHosts(condition); + } + + @Override + public int deleteHost(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteHost; msg=delete error, because id is empty."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.id.null")); + } + HostEntity rp = hostDao.getHost(id); + if(null == rp) { + return hostDao.deleteHost(id); + } + + return hostDao.deleteHost(id); + } + + @Override + public int addHost(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=addHost; msg=add error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); + } + + if(!checkId(hostEntity.getId())) { + LOGGER.error("function=addHost; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); + } + if(StringUtils.isEmpty(hostEntity.getId())) { + hostEntity.setId(UUID.randomUUID().toString()); + } + return hostDao.addHost(hostEntity); + } + + @Override + public int addHostSelective(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=addHostSelective; msg=add error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); + } + if(!checkId(hostEntity.getId())) { + LOGGER.error("function=addHostSelective; msg=add error, because id is allready exist."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); + } + + if(StringUtils.isEmpty(hostEntity.getId())) { + hostEntity.setId(UUID.randomUUID().toString()); + } + return hostDao.addHostSelective(hostEntity); + } + + private boolean checkId(String id) { + HostEntity respool = hostDao.getHost(id); + if(null == respool) { + return true; + } + return false; + } + + @Override + public int updateHostSelective(HostEntity hostEntity) throws ServiceException { + if(!checkId(hostEntity.getId())) { + return hostDao.updateHostSelective(hostEntity); + } else { + return addHostSelective(hostEntity); + } + } + + @Override + public int updateHost(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=updateHost; msg=update error, because hostEntity is null."); + throw new ServiceException("update error, because hostEntity is null."); + } + + return hostDao.updateHost(hostEntity); + } + + @Override + public int updateHostByVimId(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=updateHostByVimId; msg=update error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.update.entity.null")); + } + return hostDao.updateHostByVimId(hostEntity); + } + + @Override + public int deleteHostByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteHostByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.vimid.check")); + } + return hostDao.deleteHostByVimId(vimId); + } + + public void setHostDao(HostDao hostDao) { + this.hostDao = hostDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LimitsBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LimitsBusinessImpl.java new file mode 100644 index 0000000..8a2be18 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LimitsBusinessImpl.java @@ -0,0 +1,93 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.service.business.inf.LimitsBusiness; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LimitsBusinessImpl implements LimitsBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(LimitsBusinessImpl.class); + + /** + *
+ * + * @param vimId + * @param tenantId + * @return + * @since NFVO 0.5 + */ + private JSONObject getResponse(String vimId, String tenantId) { + LOGGER.info("function=getResponse; vimId={}, tenantId={}", vimId, tenantId); + String url = String.format(UrlConstant.GET_LIMITS_URL, vimId, tenantId); + JSONObject result = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); + LOGGER.warn("function=getResponse; result={}", result); + if(null == result) { + JSONObject obj = new JSONObject(); + obj.put("msg", "getLimits fail!"); + return obj; + } + return result; + } + + @Override + public JSONObject getLimits(String vimId) throws ServiceException { + JSONObject vimInfo = VimUtil.getVimById(vimId); + LOGGER.info("GetLimits vimInfo: {}", vimInfo); + String vimName = vimInfo.getString("name"); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + + JSONObject limits = getResponse(vimId, tenantId); + + String totalCPU = String.valueOf(limits.get("maxTotalCores")); + String totalMemory = String.valueOf(limits.get("maxTotalRAMSize")); + String totalDisk = String.valueOf(limits.get("maxTotalVolumeGigabytes")); + String usedCPU = String.valueOf(limits.get("totalCoresUsed")); + String usedMemory = String.valueOf(limits.get("totalRAMUsed")); + String usedDisk = String.valueOf(limits.get("totalGigabytesUsed")); + + JSONObject result = new JSONObject(); + result.put("vimId", vimId); + result.put("vimName", vimName); + result.put("totalCPU", totalCPU); + result.put("totalMemory", totalMemory); + result.put("totalDisk", totalDisk); + result.put("usedCPU", usedCPU); + result.put("usedMemory", usedMemory); + result.put("usedDisk", usedDisk); + LOGGER.info("getLimits result:{}", result); + return result; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LocationBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LocationBusinessImpl.java new file mode 100644 index 0000000..f1da586 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/LocationBusinessImpl.java @@ -0,0 +1,242 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.util.StringUtil; +import org.onap.vfc.nfvo.res.service.business.inf.LocationBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.LocationDao; +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * Location Business implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationBusinessImpl implements LocationBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationBusinessImpl.class); + + private LocationDao locationDao; + + /** + * + * Check location.
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public boolean checkLocation(LocationEntity locationEntity) throws ServiceException { + String location = locationEntity.getLocation(); + Map map = new HashMap<>(); + map.put(ParamConstant.PARAM_LOCATION, location); + List locationList = getLocations(map); + if(locationList == null || locationList.isEmpty()) { + return false; + } + return true; + } + + /** + * + * Check Latitude.;
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public boolean checkLatitude(LocationEntity locationEntity) throws ServiceException { + String latitu = locationEntity.getLatitude(); + String longitu = locationEntity.getLongitude(); + if("-0".equals(locationEntity.getLatitude())) { + locationEntity.setLatitude("0"); + } + if("-0".equals(locationEntity.getLongitude())) { + locationEntity.setLongitude("0"); + } + float latitude = Float.parseFloat(latitu); + float longitude = Float.parseFloat(longitu); + if((latitude >= -90 && latitude <= 90) && (longitude >= -180 && longitude <= 180)) { + return true; + } + return false; + } + + private boolean checkModified(LocationEntity locationEntity) { + String newCountry = locationEntity.getCountry(); + String newLocation = locationEntity.getLocation(); + String id = locationEntity.getId(); + LocationEntity selectLocation = locationDao.getLocation(id); + if(null == selectLocation) { + return false; + } + String oldCountry = selectLocation.getCountry(); + String oldLocation = selectLocation.getLocation(); + if(newCountry.equals(oldCountry) && newLocation.equals(oldLocation)) { + return true; + } + return false; + } + + @Override + public LocationEntity getLocation(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getLocation; msg=get error, because id is empty."); + return null; + } + return locationDao.getLocation(id); + } + + @Override + public List getCountry() throws ServiceException { + return locationDao.getCountry(); + } + + @Override + public List getLocationByCountry(Map condition) throws ServiceException { + return locationDao.getLocationByCountry(condition); + } + + @Override + public List getLocations(Map condition) throws ServiceException { + return locationDao.getLocations(condition); + } + + @Override + public int deleteLocation(String location) throws ServiceException { + if(StringUtils.isEmpty(location)) { + LOGGER.error("function=deleteLocation; msg=delete error, because location is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.base.entity.check")); + } + return locationDao.deleteLocation(location); + } + + @Override + public int addLocation(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=addLocation; msg=add error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); + } + if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) + || !StringUtil.checkXss(locationEntity.getLatitude()) + || !StringUtil.checkXss(locationEntity.getLongitude())) { + LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + } + if(checkLocation(locationEntity)) { + LOGGER.error("function=addLocation; msg=add Location error, because location exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.check")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=addLocation; msg=add Location error, because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.latitude.check")); + } + if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { + locationEntity.setId(UUID.randomUUID().toString()); + } + LOGGER.error("function=addLocation; msg=add DO success, : " + locationEntity); + return locationDao.addLocation(locationEntity); + + } + + @Override + public int addLocationSelective(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=addLocationSelective; msg=add error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); + } + if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) + || !StringUtil.checkXss(locationEntity.getLatitude()) + || !StringUtil.checkXss(locationEntity.getLongitude())) { + LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + } + if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { + locationEntity.setId(UUID.randomUUID().toString()); + } + return locationDao.addLocationSelective(locationEntity); + } + + @Override + public int updateLocationSelective(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=updateLocationSelective; msg=update error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.check")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=updateLocationSelective; msg=update Location error, " + + "because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); + } + if(!checkModified(locationEntity)) { + LOGGER.error("function=updateLocationSelective; msg=update Location error, " + + "because country or location be modified."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.modified.check")); + } + return locationDao.updateLocationSelective(locationEntity); + } + + @Override + public int updateLocation(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=updateLocation; msg=update error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.null")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=updateLocation; msg=update Location error, because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); + } + return locationDao.updateLocation(locationEntity); + } + + public LocationDao getLocationDao() { + return locationDao; + } + + public void setLocationDao(LocationDao locationDao) { + this.locationDao = locationDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/NetworkBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/NetworkBusinessImpl.java new file mode 100644 index 0000000..e14f9ca --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/NetworkBusinessImpl.java @@ -0,0 +1,153 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.service.business.inf.NetworkBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.NetworkDao; +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Network business implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkBusinessImpl implements NetworkBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkBusinessImpl.class); + + private NetworkDao networkDao; + + @Override + public NetworkEntity getNetwork(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getNetwork; msg=get error, because id is empty."); + return null; + } + return networkDao.getNetwork(id); + } + + @Override + public List getNetworks(Map condition) { + return networkDao.getNetworks(condition); + } + + @Override + public int deleteNetwork(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteNetwork; msg=delete error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.delete.id.null")); + } + return networkDao.deleteNetwork(id); + } + + @Override + public int addNetwork(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=addNetwork; msg=add error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); + } + if(!checkId(networkEntity.getId())) { + return networkDao.updateNetworkSelective(networkEntity); + } + if(StringUtils.isEmpty(networkEntity.getId())) { + networkEntity.setId(UUID.randomUUID().toString()); + } + return networkDao.addNetwork(networkEntity); + } + + @Override + public int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=addNetworkSelective; msg=add error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); + } + if(!checkId(networkEntity.getId())) { + return networkDao.updateNetworkSelective(networkEntity); + } + if(StringUtils.isEmpty(networkEntity.getId())) { + networkEntity.setId(UUID.randomUUID().toString()); + } + return networkDao.addNetworkSelective(networkEntity); + } + + private boolean checkId(String id) { + NetworkEntity network = networkDao.getNetwork(id); + if(null == network) { + return true; + } + return false; + } + + @Override + public int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetworkSelective; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetworkSelective(networkEntity); + } + + @Override + public int updateNetwork(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetwork; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetwork(networkEntity); + } + + @Override + public int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetworkByVimId; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetworkByVimId(networkEntity); + } + + @Override + public int deleteNetworkByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteNetworkByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException(ResourceUtil.getMessage("")); + } + return networkDao.deleteNetworkByVimId(vimId); + } + + public void setNetworkDao(NetworkDao networkDao) { + this.networkDao = networkDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/PortBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/PortBusinessImpl.java new file mode 100644 index 0000000..8b11b82 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/PortBusinessImpl.java @@ -0,0 +1,161 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.service.business.inf.PortBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.PortDao; +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Port business implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortBusinessImpl implements PortBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortBusinessImpl.class); + + private PortDao portDao; + + @Override + public PortEntity getPort(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getPort; msg=get error, because id is empty."); + return null; + } + return portDao.getPort(id); + } + + @Override + public List getPorts(Map condition) { + return portDao.getPorts(condition); + } + + @Override + public int deletePort(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deletePort; msg=delete error, because id is empty."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.id.null")); + } + PortEntity rp = portDao.getPort(id); + if(null == rp) { + return portDao.deletePort(id); + } + + return portDao.deletePort(id); + } + + @Override + public int addPort(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=addPort; msg=add error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); + } + + if(!checkId(portEntity.getId())) { + return portDao.updatePortSelective(portEntity); + } + if(StringUtils.isEmpty(portEntity.getId())) { + portEntity.setId(UUID.randomUUID().toString()); + } + return portDao.addPort(portEntity); + } + + @Override + public int addPortSelective(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=addPortSelective; msg=add error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); + } + if(!checkId(portEntity.getId())) { + return portDao.updatePortSelective(portEntity); + } + + if(StringUtils.isEmpty(portEntity.getId())) { + portEntity.setId(UUID.randomUUID().toString()); + } + return portDao.addPortSelective(portEntity); + } + + private boolean checkId(String id) { + PortEntity respool = portDao.getPort(id); + if(null == respool) { + return true; + } + return false; + } + + @Override + public int updatePortSelective(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePortSelective; msg=update error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); + } + + return portDao.updatePortSelective(portEntity); + } + + @Override + public int updatePort(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePort; msg=update error, because portEntity is null."); + throw new ServiceException("update error, because portEntity is null."); + } + + return portDao.updatePort(portEntity); + } + + @Override + public int updatePortByVimId(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePortByVimId; msg=update error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); + } + return portDao.updatePortByVimId(portEntity); + } + + @Override + public int deletePortByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deletePortByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.vimid.check")); + } + return portDao.deletePortByVimId(vimId); + } + + public void setPortDao(PortDao portDao) { + this.portDao = portDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/SitesBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/SitesBusinessImpl.java new file mode 100644 index 0000000..4b724b0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/SitesBusinessImpl.java @@ -0,0 +1,200 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.service.business.inf.SitesBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.SitesDao; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Sites info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class SitesBusinessImpl implements SitesBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesBusinessImpl.class); + + private SitesDao sitesDao; + + private static final String TYPE_ADD = "add"; + + private static final String TYPE_UPDATE = "update"; + + private static final String TYPE_DELETE = "delete"; + + @Override + public SitesEntity getSite(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getSite; msg=get error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.null")); + } + return sitesDao.getSite(id); + } + + @Override + public List getSites(Map condition) { + return sitesDao.getSites(condition); + } + + @Override + public int deleteSite(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteSite; msg=delete error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.delete.id.null")); + } + + return sitesDao.deleteSite(id); + } + + @Override + public int addSite(SitesEntity sitesEntity) throws ServiceException { + LOGGER.info("addSite sitesEntity"); + if(null == sitesEntity) { + LOGGER.error("function=addSite; msg=add error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); + } + // if(!StringUtil.checkXss(sitesEntity.getName()) || + // !StringUtil.checkXss(sitesEntity.getCountry()) + // || !StringUtil.checkXss(sitesEntity.getLocation())) { + // LOGGER.error("function=addLocation; msg=add site error, because XSS injection."); + // throw new ServiceException( + // ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + // } + LOGGER.info("sitesEntity: " + sitesEntity.toString()); + this.checkSite(sitesEntity, TYPE_ADD); + SitesEntity.dataFramat(sitesEntity); + LOGGER.info("Add datacenter data into DB."); + return sitesDao.addSite(sitesEntity); + } + + private void checkSite(SitesEntity sitesEntity, String type) throws ServiceException { + if(TYPE_ADD.equals(type)) { + checkId(sitesEntity.getId()); + checkSiteName(sitesEntity.getName()); + if(!SitesEntity.checkResource(sitesEntity)) { + LOGGER.error("function=checkRespool; msg=site{} resource error", sitesEntity.toString()); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.resource.check")); + } + } + } + + private void checkSiteName(String siteName) throws ServiceException { + Map siteMap = new HashMap<>(10); + siteMap.put(ParamConstant.PARAM_NAME, siteName); + List siteList = sitesDao.getSites(siteMap); + if(null != siteList && !siteList.isEmpty()) { + LOGGER.error("function=checkSiteName; msg=site: {} has already exist.", siteName); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.name.check")); + } + } + + private void checkId(String id) throws ServiceException { + SitesEntity site = sitesDao.getSite(id); + if(null != site) { + LOGGER.error("function=checkId; msg=add error, because id is already exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.check")); + } + } + + @Override + public int addSiteSelective(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=addSiteSelective; msg=add error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); + } + this.checkSite(sitesEntity, TYPE_ADD); + + if(StringUtils.isEmpty(sitesEntity.getId())) { + sitesEntity.setId(UUID.randomUUID().toString()); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.addSiteSelective(sitesEntity); + } + + @Override + public int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteSelective; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + + this.checkSite(sitesEntity, TYPE_UPDATE); + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteSelective(sitesEntity); + } + + @Override + public int updateSite(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSite; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + this.checkSite(sitesEntity, TYPE_UPDATE); + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSite(sitesEntity); + } + + @Override + public int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteByVimId; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteByVimId(sitesEntity); + } + + @Override + public int updateSiteResource(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteResource; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteSelective(sitesEntity); + } + + public void setSitesDao(SitesDao sitesDao) { + this.sitesDao = sitesDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/VimBusinessImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/VimBusinessImpl.java new file mode 100644 index 0000000..48ecd1f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/impl/VimBusinessImpl.java @@ -0,0 +1,99 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.impl; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.util.StringUtil; +import org.onap.vfc.nfvo.res.service.business.inf.VimBusiness; +import org.onap.vfc.nfvo.res.service.dao.inf.VimDao; +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Vim info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class VimBusinessImpl implements VimBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(VimBusinessImpl.class); + + private VimDao vimDao; + + @Override + public VimEntity getVim(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getVim; msg=get error, because id is empty."); + return null; + } + return vimDao.getVim(id); + } + + @Override + public List getVims() { + return vimDao.getVims(); + } + + @Override + public int deleteVim(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteVim; msg=deleteVim error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.del.id.check")); + } + return vimDao.deleteVim(id); + } + + @Override + public int addVim(String id) throws ServiceException { + if(!StringUtil.isValidString(id)) { + LOGGER.error("function=addVim; msg=add error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.null")); + } + if(!checkId(id)) { + LOGGER.error("function=addVim; msg=add error, because id is already exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.check")); + } + + VimEntity vimEntity = new VimEntity(); + vimEntity.setId(id); + return vimDao.addVim(vimEntity); + } + + private boolean checkId(String id) { + VimEntity vim = vimDao.getVim(id); + if(null == vim) { + return true; + } + return false; + } + + public void setVimDao(VimDao vimDao) { + this.vimDao = vimDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/HostBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/HostBusiness.java new file mode 100644 index 0000000..d8a95f3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/HostBusiness.java @@ -0,0 +1,131 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * Host Buisiness Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public interface HostBusiness { + + /** + * + * Get host.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * + * Get details of hosts.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getHosts(Map condition); + + /** + * + * Delete host.
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteHost(String id) throws ServiceException; + + /** + * + * Delete host by VIM Id.
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId) throws ServiceException; + + /** + * + * Add host.
+ * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity) throws ServiceException; + + /** + * + * Add selective host.
+ * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update selective host.
+ * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update host.
+ * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update host by VIM Id.
+ * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LimitsBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LimitsBusiness.java new file mode 100644 index 0000000..661406a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LimitsBusiness.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LimitsBusiness { + + /** + *
+ * + * @param paramJson + * @return + * @since NFVO 0.5 + */ + JSONObject getLimits(String vimId) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LocationBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LocationBusiness.java new file mode 100644 index 0000000..f132a6d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/LocationBusiness.java @@ -0,0 +1,134 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * + * Location Business Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationBusiness { + + /** + * + * Get Location.
+ * + * @param location + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + LocationEntity getLocation(String location) throws ServiceException; + + /** + * + * Get Locations.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getLocations(Map condition) throws ServiceException; + + /** + * + * Delete Location.
+ * + * @param location + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteLocation(String location) throws ServiceException; + + /** + * + * Add Location.
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addLocation(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Add Selective Location.
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Update Selective Location.
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Update Location.
+ * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Get Country.
+ * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getCountry() throws ServiceException; + + /** + * + * Get Location By Country.
+ * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getLocationByCountry(Map condition) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/NetworkBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/NetworkBusiness.java new file mode 100644 index 0000000..f75d2ae --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/NetworkBusiness.java @@ -0,0 +1,133 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * + * Network Business class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkBusiness { + + /** + * + * Get network details.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of available networks.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getNetworks(Map condition); + + /** + * + * Delete Network.
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteNetwork(String id) throws ServiceException; + + /** + * + * Delete network by Virtual Infrastructure Manager ID.
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId) throws ServiceException; + + /** + * + * Add Network.
+ * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Add Selective Network.
+ * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update Selective Network.
+ * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update Network.
+ * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update network by Virtual Infrastructure Manager ID.
+ * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/PortBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/PortBusiness.java new file mode 100644 index 0000000..4c19408 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/PortBusiness.java @@ -0,0 +1,131 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * Port Buisiness Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public interface PortBusiness { + + /** + * + * Get Port.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * + * Get details of ports.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getPorts(Map condition); + + /** + * + * Delete Port.
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deletePort(String id) throws ServiceException; + + /** + * + * Delete port by VIM ID.
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId) throws ServiceException; + + /** + * + * Add port.
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity) throws ServiceException; + + /** + * + * Add selective port.
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity) throws ServiceException; + + /** + * + * Update selective port.
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity) throws ServiceException; + + /** + * + * Update port.
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity) throws ServiceException; + + /** + * + * Update port by VIM Id.
+ * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/SitesBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/SitesBusiness.java new file mode 100644 index 0000000..574e745 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/SitesBusiness.java @@ -0,0 +1,124 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * DC info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesBusiness { + + /** + * It is used to get Site info.
+ * + * @param id + * @return The get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + SitesEntity getSite(String id) throws ServiceException; + + /** + * It is used to get Sites info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getSites(Map condition); + + /** + * It is used to delete Site info.
+ * + * @param id + * @return The delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + int deleteSite(String id) throws ServiceException; + + /** + * It is used to add Site info.
+ * + * @param sitesEntity + * @return The add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addSite(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to add Site info.
+ * + * @param sitesEntity + * @return The add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.
+ * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to create update Site info.
+ * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSite(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.
+ * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.
+ * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteResource(SitesEntity sitesEntity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/VimBusiness.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/VimBusiness.java new file mode 100644 index 0000000..f29f257 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/business/inf/VimBusiness.java @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.business.inf; + +import java.util.List; + +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * Vim info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimBusiness { + + /** + * It is used to get Vim info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vim info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + List getVims(); + + /** + * It is used to delete Vim info.
+ * + * @param id + * @return the delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + int deleteVim(String id) throws ServiceException; + + /** + * It is used to add Vim info.
+ * + * @param id + * @return the add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addVim(String id) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/AbstractDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/AbstractDao.java new file mode 100644 index 0000000..b31c5bc --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/AbstractDao.java @@ -0,0 +1,57 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import org.apache.ibatis.session.SqlSession; + +/** + *
+ *

+ * Database abstract class to get the MapperManager + *

+ * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class AbstractDao { + + private SqlSession session; + + protected AbstractDao() { + //added this private costructor to fix static errors. + } + + public SqlSession getSession() { + return session; + } + + public void setSession(SqlSession session) { + this.session = session; + } + + /** + * get Mybatis Mapper
+ * + * @param type + * The type of Class + * @return Mapper + * @since NFVO 0.5 + */ + public T getMapperManager(Class type) { + return (T)getSession().getMapper(type); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/HostDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/HostDaoImpl.java new file mode 100644 index 0000000..7dae83c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/HostDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.HostDao; +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.onap.vfc.nfvo.res.service.mapper.HostMapper; + +/** + * + * Host DAO implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostDaoImpl extends AbstractDao implements HostDao { + + @Override + public HostEntity getHost(String id) { + return getMapperManager(HostMapper.class).getHost(id); + } + + @Override + public List getHosts(Map condition) { + return getMapperManager(HostMapper.class).getHosts(condition); + } + + @Override + public int deleteHost(String id) { + return getMapperManager(HostMapper.class).deleteHost(id); + } + + @Override + public int deleteHostByVimId(String vimId) { + return getMapperManager(HostMapper.class).deleteHostByVimId(vimId); + } + + @Override + public int addHost(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).addHost(hostEntity); + } + + @Override + public int addHostSelective(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).addHostSelective(hostEntity); + } + + @Override + public int updateHostSelective(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHostSelective(hostEntity); + } + + @Override + public int updateHost(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHost(hostEntity); + } + + @Override + public int updateHostByVimId(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHostByVimId(hostEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/LocationDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/LocationDaoImpl.java new file mode 100644 index 0000000..b6af978 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/LocationDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.LocationDao; +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.onap.vfc.nfvo.res.service.mapper.LocationMapper; + +/** + * + * Location DAO implemetation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationDaoImpl extends AbstractDao implements LocationDao { + + @Override + public LocationEntity getLocation(String id) { + return getMapperManager(LocationMapper.class).getLocation(id); + } + + @Override + public List getCountry() { + return getMapperManager(LocationMapper.class).getCountry(); + } + + @Override + public List getLocationByCountry(Map condition) { + return getMapperManager(LocationMapper.class).getLocationByCountry(condition); + } + + @Override + public List getLocations(Map condition) { + return getMapperManager(LocationMapper.class).getLocations(condition); + } + + @Override + public int deleteLocation(String id) { + return getMapperManager(LocationMapper.class).deleteLocation(id); + } + + @Override + public int addLocation(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).addLocation(locationEntity); + } + + @Override + public int addLocationSelective(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).addLocationSelective(locationEntity); + } + + @Override + public int updateLocationSelective(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).updateLocationSelective(locationEntity); + } + + @Override + public int updateLocation(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).updateLocation(locationEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/NetworkDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/NetworkDaoImpl.java new file mode 100644 index 0000000..a63e094 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/NetworkDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.NetworkDao; +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.onap.vfc.nfvo.res.service.mapper.NetworkMapper; + +/** + * + * Network DAO implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkDaoImpl extends AbstractDao implements NetworkDao { + + @Override + public NetworkEntity getNetwork(String id) { + return getMapperManager(NetworkMapper.class).getNetwork(id); + } + + @Override + public List getNetworks(Map condition) { + return getMapperManager(NetworkMapper.class).getNetworks(condition); + } + + @Override + public int deleteNetwork(String id) { + return getMapperManager(NetworkMapper.class).deleteNetwork(id); + } + + @Override + public int deleteNetworkByVimId(String vimId) { + return getMapperManager(NetworkMapper.class).deleteNetworkByVimId(vimId); + } + + @Override + public int addNetwork(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).addNetwork(networkEntity); + } + + @Override + public int addNetworkSelective(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).addNetworkSelective(networkEntity); + } + + @Override + public int updateNetworkSelective(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetworkSelective(networkEntity); + } + + @Override + public int updateNetwork(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetwork(networkEntity); + } + + @Override + public int updateNetworkByVimId(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetworkByVimId(networkEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/PortDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/PortDaoImpl.java new file mode 100644 index 0000000..d4ec76d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/PortDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.PortDao; +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.onap.vfc.nfvo.res.service.mapper.PortMapper; + +/** + * + * Port DAO implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortDaoImpl extends AbstractDao implements PortDao { + + @Override + public PortEntity getPort(String id) { + return getMapperManager(PortMapper.class).getPort(id); + } + + @Override + public List getPorts(Map condition) { + return getMapperManager(PortMapper.class).getPorts(condition); + } + + @Override + public int deletePort(String id) { + return getMapperManager(PortMapper.class).deletePort(id); + } + + @Override + public int deletePortByVimId(String vimId) { + return getMapperManager(PortMapper.class).deletePortByVimId(vimId); + } + + @Override + public int addPort(PortEntity portEntity) { + return getMapperManager(PortMapper.class).addPort(portEntity); + } + + @Override + public int addPortSelective(PortEntity portEntity) { + return getMapperManager(PortMapper.class).addPortSelective(portEntity); + } + + @Override + public int updatePortSelective(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePortSelective(portEntity); + } + + @Override + public int updatePort(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePort(portEntity); + } + + @Override + public int updatePortByVimId(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePortByVimId(portEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/SitesDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/SitesDaoImpl.java new file mode 100644 index 0000000..f35963e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/SitesDaoImpl.java @@ -0,0 +1,77 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.SitesDao; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.onap.vfc.nfvo.res.service.mapper.SitesMapper; + +/** + * DC interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class SitesDaoImpl extends AbstractDao implements SitesDao { + + @Override + public SitesEntity getSite(String id) { + return getMapperManager(SitesMapper.class).getSite(id); + } + + @Override + public List getSites(Map condition) { + return getMapperManager(SitesMapper.class).getSites(condition); + } + + @Override + public int deleteSite(String id) { + return getMapperManager(SitesMapper.class).deleteSite(id); + } + + @Override + public int addSite(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).addSite(sitesEntity); + } + + @Override + public int addSiteSelective(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).addSiteSelective(sitesEntity); + } + + @Override + public int updateSiteSelective(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSiteSelective(sitesEntity); + } + + @Override + public int updateSite(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSite(sitesEntity); + } + + @Override + public int updateSiteByVimId(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSiteByVimId(sitesEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VimDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VimDaoImpl.java new file mode 100644 index 0000000..e8c7374 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VimDaoImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; + +import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao; +import org.onap.vfc.nfvo.res.service.dao.inf.VimDao; +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.onap.vfc.nfvo.res.service.mapper.VimMapper; + +/** + * Vim interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class VimDaoImpl extends AbstractDao implements VimDao { + + @Override + public VimEntity getVim(String id) { + return getMapperManager(VimMapper.class).getVim(id); + } + + @Override + public List getVims() { + return getMapperManager(VimMapper.class).getVims(); + } + + @Override + public int deleteVim(String id) { + return getMapperManager(VimMapper.class).deleteVim(id); + } + + @Override + public int addVim(VimEntity vimEntity) { + return getMapperManager(VimMapper.class).addVim(vimEntity); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VirtualLinkDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VirtualLinkDaoImpl.java new file mode 100644 index 0000000..bfe0345 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VirtualLinkDaoImpl.java @@ -0,0 +1,84 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VirtualLinkDao; +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; +import org.onap.vfc.nfvo.res.service.mapper.VirtualLinkMapper; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VirtualLinkDaoImpl extends AbstractDao implements VirtualLinkDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VirtualLinkEntity getVl(String id) { + return getMapperManager(VirtualLinkMapper.class).selectByPrimaryKey(id); + } + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List getVls(Map condition) { + return getMapperManager(VirtualLinkMapper.class).getVls(condition); + } + + /** + *
+ * + * @param virtualLinkEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVl(VirtualLinkEntity virtualLinkEntity) { + return getMapperManager(VirtualLinkMapper.class).insert(virtualLinkEntity); + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVlById(String id) { + return getMapperManager(VirtualLinkMapper.class).deleteByPrimaryKey(id); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VmDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VmDaoImpl.java new file mode 100644 index 0000000..ec174e2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VmDaoImpl.java @@ -0,0 +1,108 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VmDao; +import org.onap.vfc.nfvo.res.service.entity.VmEntity; +import org.onap.vfc.nfvo.res.service.mapper.VmMapper; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VmDaoImpl extends AbstractDao implements VmDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VmEntity getVm(String id) { + return getMapperManager(VmMapper.class).selectByPrimaryKey(id); + } + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List getVms(Map condition) { + return getMapperManager(VmMapper.class).getVms(condition); + } + + /** + *
+ * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVm(VmEntity vmEntity) { + return getMapperManager(VmMapper.class).insert(vmEntity); + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVmById(String id) { + return getMapperManager(VmMapper.class).deleteByPrimaryKey(id); + } + + /** + *
+ * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVm(VmEntity vmEntity) { + return getMapperManager(VmMapper.class).updateByPrimaryKeySelective(vmEntity); + } + + /** + *
+ * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVmByVnfId(String vnfInstanceId) { + return getMapperManager(VmMapper.class).deleteByVnfId(vnfInstanceId); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfDaoImpl.java new file mode 100644 index 0000000..de1b293 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfDaoImpl.java @@ -0,0 +1,84 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VnfDao; +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; +import org.onap.vfc.nfvo.res.service.mapper.VnfMapper; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfDaoImpl extends AbstractDao implements VnfDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfEntity getVnf(String id) { + return getMapperManager(VnfMapper.class).selectByPrimaryKey(id); + } + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List getVnfs(Map condition) { + return getMapperManager(VnfMapper.class).getVnfs(condition); + } + + /** + *
+ * + * @param vnfEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnf(VnfEntity vnfEntity) { + return getMapperManager(VnfMapper.class).insert(vnfEntity); + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfById(String id) { + return getMapperManager(VnfMapper.class).deleteByPrimaryKey(id); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfInfoDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfInfoDaoImpl.java new file mode 100644 index 0000000..a01e01d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfInfoDaoImpl.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VnfInfoDao; +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; +import org.onap.vfc.nfvo.res.service.mapper.VnfInfoMapper; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfInfoDaoImpl extends AbstractDao implements VnfInfoDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfInfoEntity getVnfInfo(String id) { + return getMapperManager(VnfInfoMapper.class).selectByPrimaryKey(id); + } + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List getVnfInfos(Map condition) { + return getMapperManager(VnfInfoMapper.class).getVnfInfos(condition); + } + + /** + *
+ * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnfInfo(VnfInfoEntity vnfInfoEntity) { + return getMapperManager(VnfInfoMapper.class).insert(vnfInfoEntity); + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfInfoById(String id) { + return getMapperManager(VnfInfoMapper.class).deleteByPrimaryKey(id); + } + + /** + *
+ * + * @param vnfInfoEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVnfInfo(VnfInfoEntity vnfInfoEntity) { + return getMapperManager(VnfInfoMapper.class).updateByPrimaryKeySelective(vnfInfoEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfStatusDaoImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfStatusDaoImpl.java new file mode 100644 index 0000000..6570664 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/impl/VnfStatusDaoImpl.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VnfStatusDao; +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; +import org.onap.vfc.nfvo.res.service.mapper.VnfStatusMapper; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VnfStatusDaoImpl extends AbstractDao implements VnfStatusDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfStatusEntity getVnfStatus(String id) { + return getMapperManager(VnfStatusMapper.class).selectByPrimaryKey(id); + } + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List getVnfStatuss(Map condition) { + return getMapperManager(VnfStatusMapper.class).getVnfStatuss(condition); + } + + /** + *
+ * + * @param vnfStatusEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnfStatus(VnfStatusEntity vnfStatusEntity) { + return getMapperManager(VnfStatusMapper.class).insert(vnfStatusEntity); + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfStatusById(String id) { + return getMapperManager(VnfStatusMapper.class).deleteByPrimaryKey(id); + } + + /** + *
+ * + * @param vnfStatusEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVnfStatus(VnfStatusEntity vnfStatusEntity) { + return getMapperManager(VnfStatusMapper.class).updateByPrimaryKeySelective(vnfStatusEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/HostDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/HostDao.java new file mode 100644 index 0000000..0f0c825 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/HostDao.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.HostEntity; + +/** + * Host info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface HostDao { + + /** + * It is used to get Host info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * It is used to get Hosts info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getHosts(Map condition); + + /** + * It is used to delete Hosts info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHost(String id); + + /** + * It is used to delete Hosts info.
+ * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId); + + /** + * It is used to add Hosts info.
+ * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity); + + /** + * It is used to add Hosts info.
+ * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/LocationDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/LocationDao.java new file mode 100644 index 0000000..4266b6a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/LocationDao.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; + +/** + * + * Location DAO Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationDao { + + /** + * + * Get Location.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + LocationEntity getLocation(String id); + + /** + * + * Get Locations.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getLocations(Map condition); + + /** + * + * Delete Location.
+ * + * @param location + * @return + * @since NFVO 0.5 + */ + int deleteLocation(String location); + + /** + * + * Add Location.
+ * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int addLocation(LocationEntity sodoResEntity); + + /** + * + * Add Selective Location.
+ * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity sodoResEntity); + + /** + * + * Update selective location.
+ * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity sodoResEntity); + + /** + * + * Update Location.
+ * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity sodoResEntity); + + /** + * + * Get Country.
+ * + * @return + * @since NFVO 0.5 + */ + List getCountry(); + + /** + * + * Get Location by Country.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getLocationByCountry(Map condition); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/NetworkDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/NetworkDao.java new file mode 100644 index 0000000..1c9b319 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/NetworkDao.java @@ -0,0 +1,125 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; + +/** + * + * Network DOA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkDao { + + /** + * + * Get Network Details.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of available networks.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getNetworks(Map condition); + + /** + * + * Delete Network.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteNetwork(String id); + + /** + * + * Delete network by VIM ID.
+ * + * @param vimId + * @return + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId); + + /** + * + * Add Network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity); + + /** + * + * Add selective network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update selective network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity); + + /** + * + * Update network by VIM ID.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/PortDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/PortDao.java new file mode 100644 index 0000000..555e507 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/PortDao.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.PortEntity; + +/** + * Port info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface PortDao { + + /** + * It is used to get Port info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * It is used to get Ports info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getPorts(Map condition); + + /** + * It is used to delete Ports info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deletePort(String id); + + /** + * It is used to delete Ports info.
+ * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId); + + /** + * It is used to add Ports info.
+ * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity); + + /** + * It is used to add Ports info.
+ * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/SitesDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/SitesDao.java new file mode 100644 index 0000000..c179d40 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/SitesDao.java @@ -0,0 +1,105 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; + +/** + * Sites info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesDao { + + /** + * It is used to get Sites info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + SitesEntity getSite(String id); + + /** + * It is used to get Sites info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getSites(Map condition); + + /** + * It is used to get Sites info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + int deleteSite(String id); + + /** + * It is used to delete Sites info.
+ * + * @param sitesEntity + * @return The delete result + * @since NFVO 0.5 + */ + int addSite(SitesEntity sitesEntity); + + /** + * It is used to add Sites info.
+ * + * @param sitesEntity + * @return The add result + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity sitesEntity); + + /** + * It is used to add Sites info.
+ * + * @param sitesEntity + * @return The add result + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity sitesEntity); + + /** + * It is used to update Sites info.
+ * + * @param sitesEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateSite(SitesEntity sitesEntity); + + /** + * It is used to update Sites info.
+ * + * @param sitesEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity sitesEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VimDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VimDao.java new file mode 100644 index 0000000..38f1dda --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VimDao.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; + +import org.onap.vfc.nfvo.res.service.entity.VimEntity; + +/** + * Vim info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimDao { + + /** + * It is used to get Vim info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vims info.
+ * + * @return The get result + * @since NFVO 0.5 + */ + List getVims(); + + /** + * It is used to delete Vim info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteVim(String id); + + /** + * It is used to add Vim info.
+ * + * @param vimEntity + * @return The add result + * @since NFVO 0.5 + */ + int addVim(VimEntity vimEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VirtualLinkDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VirtualLinkDao.java new file mode 100644 index 0000000..4b12169 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VirtualLinkDao.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VirtualLinkDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + VirtualLinkEntity getVl(String id); + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getVls(Map condition); + + /** + *
+ * + * @param virtualLinkEntity + * @return + * @since NFVO 0.5 + */ + int addVl(VirtualLinkEntity virtualLinkEntity); + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteVlById(String id); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VmDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VmDao.java new file mode 100644 index 0000000..3b88b5c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VmDao.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VmEntity; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VmDao { + + VmEntity getVm(String id); + + List getVms(Map condition); + + int addVm(VmEntity vmEntity); + + int deleteVmById(String id); + + int updateVm(VmEntity vmEntity); + + int deleteVmByVnfId(String vnfInstanceId); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfDao.java new file mode 100644 index 0000000..03b7ff4 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfDao.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfDao { + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + VnfEntity getVnf(String id); + + /** + *
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getVnfs(Map condition); + + /** + *
+ * + * @param vnfEntity + * @return + * @since NFVO 0.5 + */ + int addVnf(VnfEntity vnfEntity); + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteVnfById(String id); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfInfoDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfInfoDao.java new file mode 100644 index 0000000..6ea65cb --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfInfoDao.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfInfoDao { + + VnfInfoEntity getVnfInfo(String id); + + List getVnfInfos(Map condition); + + int addVnfInfo(VnfInfoEntity vnfInfoEntity); + + int deleteVnfInfoById(String id); + + int updateVnfInfo(VnfInfoEntity vnfInfoEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfStatusDao.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfStatusDao.java new file mode 100644 index 0000000..ee6f0f1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/dao/inf/VnfStatusDao.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VnfStatusDao { + + VnfStatusEntity getVnfStatus(String id); + + List getVnfStatuss(Map condition); + + int addVnfStatus(VnfStatusEntity vnfStatusEntity); + + int deleteVnfStatusById(String id); + + int updateVnfStatus(VnfStatusEntity vnfStatusEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/HostEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/HostEntity.java new file mode 100644 index 0000000..6c5a20f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/HostEntity.java @@ -0,0 +1,179 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * Host entity class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public class HostEntity { + + private String id; + + private String name; + + private String cpu; + + private String memory; + + private String disk; + + private String vimId; + + private String vimName; + + /** + * @return Returns the id. + */ + public String getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return Returns the cpu. + */ + public String getCpu() { + return cpu; + } + + /** + * @param cpu The cpu to set. + */ + public void setCpu(String cpu) { + this.cpu = cpu; + } + + /** + * @return Returns the memory. + */ + public String getMemory() { + return memory; + } + + /** + * @param memory The memory to set. + */ + public void setMemory(String memory) { + this.memory = memory; + } + + /** + * @return Returns the disk. + */ + public String getDisk() { + return disk; + } + + /** + * @param disk The disk to set. + */ + public void setDisk(String disk) { + this.disk = disk; + } + + /** + * @return Returns the vimId. + */ + public String getVimId() { + return vimId; + } + + /** + * @param vimId The vimId to set. + */ + public void setVimId(String vimId) { + this.vimId = vimId; + } + + /** + * @return Returns the vimName. + */ + public String getVimName() { + return vimName; + } + + /** + * @param vimName The vimName to set. + */ + public void setVimName(String vimName) { + this.vimName = vimName; + } + + /** + * + * To entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static HostEntity toEntity(JSONObject jsonObject) { + HostEntity hostEntity = new HostEntity(); + hostEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + hostEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + hostEntity.setCpu(JsonUtil.getJsonFieldStr(jsonObject, "cpu")); + hostEntity.setMemory(JsonUtil.getJsonFieldStr(jsonObject, "memory")); + hostEntity.setDisk(JsonUtil.getJsonFieldStr(jsonObject, "disk")); + hostEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + hostEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return hostEntity; + } + + @Override + public String toString() { + JSONObject hostResJson = new JSONObject(); + hostResJson.put("id", StringUtils.trimToEmpty(this.getId())); + hostResJson.put("name", StringUtils.trimToEmpty(this.getName())); + hostResJson.put("cpu", StringUtils.trimToEmpty(this.getCpu())); + hostResJson.put("memory", StringUtils.trimToEmpty(this.getMemory())); + hostResJson.put("disk", StringUtils.trimToEmpty(this.getDisk())); + hostResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + hostResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + return hostResJson.toString(); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/LocationEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/LocationEntity.java new file mode 100644 index 0000000..95d5fad --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/LocationEntity.java @@ -0,0 +1,236 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Location entity class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationEntity { + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.ID + * + * @mbggenerated + */ + private String id; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.COUNTRY + * + * @mbggenerated + */ + private String country; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LOCATION + * + * @mbggenerated + */ + private String location; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LATITUDE + * + * @mbggenerated + */ + private String latitude; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LONGITUDE + * + * @mbggenerated + */ + private String longitude; + + private String description; + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.ID + * + * @return the value of location.ID + * @mbggenerated + */ + public String getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.ID + * + * @param id + * the value for location.ID + * @mbggenerated + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.COUNTRY + * + * @return the value of location.COUNTRY + * @mbggenerated + */ + public String getCountry() { + return country; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.COUNTRY + * + * @param country + * the value for location.COUNTRY + * @mbggenerated + */ + public void setCountry(String country) { + this.country = country == null ? null : country.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LOCATION + * + * @return the value of location.LOCATION + * @mbggenerated + */ + public String getLocation() { + return location; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LOCATION + * + * @param location + * the value for location.LOCATION + * @mbggenerated + */ + public void setLocation(String location) { + this.location = location == null ? null : location.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LATITUDE + * + * @return the value of location.LATITUDE + * @mbggenerated + */ + public String getLatitude() { + return latitude; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LATITUDE + * + * @param latitude + * the value for location.LATITUDE + * @mbggenerated + */ + public void setLatitude(String latitude) { + this.latitude = latitude == null ? null : latitude.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LONGITUDE + * + * @return the value of location.LONGITUDE + * @mbggenerated + */ + public String getLongitude() { + return longitude; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LONGITUDE + * + * @param longitude + * the value for location.LONGITUDE + * @mbggenerated + */ + public void setLongitude(String longitude) { + this.longitude = longitude == null ? null : longitude.trim(); + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description == null ? null : description.trim(); + } + + /** + * + * To Entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static LocationEntity toEntity(JSONObject jsonObject) { + LocationEntity sodoresesEntity = new LocationEntity(); + sodoresesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sodoresesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); + sodoresesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); + sodoresesEntity.setLatitude(JsonUtil.getJsonFieldStr(jsonObject, "latitude")); + sodoresesEntity.setLongitude(JsonUtil.getJsonFieldStr(jsonObject, "longitude")); + sodoresesEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); + return sodoresesEntity; + } + + @Override + public String toString() { + JSONObject locationJson = new JSONObject(); + locationJson.put("id", StringUtils.trimToEmpty(this.getId())); + locationJson.put("country", StringUtils.trimToEmpty(this.getCountry())); + locationJson.put("location", StringUtils.trimToEmpty(this.getLocation())); + locationJson.put("latitude", StringUtils.trimToEmpty(this.getLatitude())); + locationJson.put("longitude", StringUtils.trimToEmpty(this.getLongitude())); + locationJson.put("description", StringUtils.trimToEmpty(this.getDescription())); + return locationJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/NetworkEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/NetworkEntity.java new file mode 100644 index 0000000..7f1a7e5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/NetworkEntity.java @@ -0,0 +1,271 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Network entity class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkEntity { + + /** + * This field corresponds to the database column network.ID + */ + private String id; + + /** + * This field corresponds to the database column network.NAME + */ + private String name; + + /** + * This field corresponds to the database column network.TENANT_ID + */ + private String tenantId; + + /** + * This field corresponds to the database column network.VIM_ID + */ + private String vimId; + + /** + * This field corresponds to the database column ivm.VIM_NAME + */ + private String vimName; + + /** + * This field corresponds to the database column network.STATUS + */ + private String status; + + /** + * This field corresponds to the database column network.PHYSICAL_NETWORK + */ + + private String physicalNetwork; + + /** + * This field corresponds to the database column network.NETWORK_TYPE + */ + private String networkType; + + /** + * This field corresponds to the database column network.SEGMENTATION_ID + */ + private String segmentationId; + + /** + * return the value of network.ID + */ + public String getId() { + return id; + } + + /** + * This method sets the value of the database column network.ID + * + * @param id + * the value for network.ID + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * return the value of network.NAME + */ + public String getName() { + return name; + } + + /** + * This method sets the value of the database column network.NAME + * + * @param name + * the value for network.NAME + */ + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + /** + * return the value of network.TENANT_ID + */ + public String getTenantId() { + return tenantId; + } + + /** + * This method sets the value of the database column network.TENANT_ID + * + * @param tenantId + * the value for network.TENANT_ID + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId == null ? null : tenantId.trim(); + } + + /** + * return the value of network.VIM_ID + */ + public String getVimId() { + return vimId; + } + + /** + * This method sets the value of the database column network.VIM_ID + * + * @param networkVimId + * the value for network.VIM_ID + */ + public void setVimId(String networkVimId) { + this.vimId = networkVimId == null ? null : networkVimId.trim(); + } + + /** + * return the value of ivm.VIM_NAME + */ + public String getVimName() { + return vimName; + } + + /** + * This method sets the value of the database column ivm.VIM_NAME + * + * @param networkVimName + * the value for ivm.VIM_NAME + */ + public void setVimName(String networkVimName) { + this.vimName = networkVimName == null ? null : networkVimName.trim(); + } + + /** + * return the value of network.STATUS + */ + public String getStatus() { + return status; + } + + /** + * This method sets the value of the database column network.STATUS + * + * @param networkStatus + * the value for network.STATUS + */ + public void setStatus(String networkStatus) { + this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase(); + } + + /** + * return the value of network.PHYSICAL_NETWORK + */ + public String getPhysicalNetwork() { + return physicalNetwork; + } + + /** + * This method sets the value of the database column + * network.PHYSICAL_NETWORK + * + * @param physicalNetwork + * the value for network.PHYSICAL_NETWORK + */ + public void setPhysicalNetwork(String physicalNetwork) { + this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim(); + } + + /** + * return the value of network.NETWORK_TYPE + */ + public String getNetworkType() { + return networkType; + } + + /** + * This method sets the value of the database column network.NETWORK_TYPE + * + * @param networkType + * the value for network.NETWORK_TYPE + */ + public void setNetworkType(String networkType) { + this.networkType = networkType == null ? null : networkType.trim(); + } + + /** + * return the value of network.SEGMENTATION_ID + */ + public String getSegmentationId() { + return segmentationId; + } + + /** + * This method sets the value of the database column network.SEGMENTATION_ID + * + * @param segmentationId + * the value for network.SEGMENTATION_ID + */ + public void setSegmentationId(String segmentationId) { + this.segmentationId = segmentationId == null ? null : segmentationId.trim(); + } + + /** + * + * To Entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static NetworkEntity toEntity(JSONObject jsonObject) { + NetworkEntity sitesEntity = new NetworkEntity(); + sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + sitesEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); + sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + sitesEntity.setPhysicalNetwork(JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); + sitesEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + sitesEntity.setSegmentationId(JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); + return sitesEntity; + } + + @Override + public String toString() { + JSONObject networkJson = new JSONObject(); + networkJson.put("id", StringUtils.trimToEmpty(this.getId())); + networkJson.put("name", StringUtils.trimToEmpty(this.getName())); + networkJson.put("tenant_id", StringUtils.trimToEmpty(this.getTenantId())); + networkJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + networkJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + networkJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + networkJson.put("provider:physical_network", StringUtils.trimToEmpty(this.getPhysicalNetwork())); + networkJson.put("provider:network_type", StringUtils.trimToEmpty(this.getNetworkType())); + networkJson.put("provider:segmentation_id", StringUtils.trimToEmpty(this.getSegmentationId())); + return networkJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/PortEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/PortEntity.java new file mode 100644 index 0000000..2249726 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/PortEntity.java @@ -0,0 +1,179 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * Port Entity Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public class PortEntity { + + private String id; + + private String name; + + private String networkId; + + private String status; + + private String tenantId; + + private String vimId; + + private String vimName; + + /** + * @return Returns the id. + */ + public String getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return Returns the networkId. + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param networkId The networkId to set. + */ + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + /** + * @return Returns the status. + */ + public String getStatus() { + return status; + } + + /** + * @param status The status to set. + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return Returns the tenantId. + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId The tenantId to set. + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + /** + * @return Returns the vimId. + */ + public String getVimId() { + return vimId; + } + + /** + * @param vimId The vimId to set. + */ + public void setVimId(String vimId) { + this.vimId = vimId; + } + + /** + * @return Returns the vimName. + */ + public String getVimName() { + return vimName; + } + + /** + * @param vimName The vimName to set. + */ + public void setVimName(String vimName) { + this.vimName = vimName; + } + + /** + * + * To Entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static PortEntity toEntity(JSONObject jsonObject) { + PortEntity portEntity = new PortEntity(); + portEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + portEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + portEntity.setNetworkId(JsonUtil.getJsonFieldStr(jsonObject, "networkId")); + portEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + portEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); + portEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return portEntity; + } + + @Override + public String toString() { + JSONObject portResJson = new JSONObject(); + portResJson.put("id", StringUtils.trimToEmpty(this.getId())); + portResJson.put("name", StringUtils.trimToEmpty(this.getName())); + portResJson.put("networkId", StringUtils.trimToEmpty(this.getNetworkId())); + portResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + portResJson.put("tenantId", StringUtils.trimToEmpty(this.getTenantId())); + portResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + portResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + return portResJson.toString(); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/SitesEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/SitesEntity.java new file mode 100644 index 0000000..c2940d6 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/SitesEntity.java @@ -0,0 +1,309 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.common.util.StringUtil; + +import net.sf.json.JSONObject; + +/** + * + * Sites entity class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class SitesEntity { + + private String id; + + private String name; + + private String location; + + private String country; + + private String vimId; + + private String vimName; + + private String status; + + private String totalCPU = "0"; + + private String totalMemory = "0"; + + private String totalDisk = "0"; + + private String usedCPU = "0"; + + private String usedMemory = "0"; + + private String usedDisk = "0"; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location == null ? null : location.trim(); + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country == null ? null : country.trim(); + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String siteVimId) { + this.vimId = siteVimId == null ? null : siteVimId.trim(); + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String siteVimName) { + this.vimName = siteVimName == null ? null : siteVimName.trim(); + } + + public String getStatus() { + return status; + } + + public void setStatus(String siteStatus) { + this.status = siteStatus == null ? null : siteStatus.trim().toLowerCase(); + } + + /** + * @return Returns the totalCPU. + */ + public String getTotalCPU() { + return totalCPU; + } + + /** + * @param totalCPU The totalCPU to set. + */ + public void setTotalCPU(String totalCPU) { + this.totalCPU = totalCPU == null ? null : totalCPU.trim(); + } + + /** + * @return Returns the totalMemory. + */ + public String getTotalMemory() { + return totalMemory; + } + + /** + * @param totalMemory The totalMemory to set. + */ + public void setTotalMemory(String totalMemory) { + this.totalMemory = totalMemory == null ? null : totalMemory.trim(); + } + + /** + * @return Returns the totalDisk. + */ + public String getTotalDisk() { + return totalDisk; + } + + /** + * @param totalDisk The totalDisk to set. + */ + public void setTotalDisk(String totalDisk) { + this.totalDisk = totalDisk == null ? null : totalDisk.trim(); + } + + /** + * @return Returns the usedCPU. + */ + public String getUsedCPU() { + return usedCPU; + } + + /** + * @param usedCPU The usedCPU to set. + */ + public void setUsedCPU(String usedCPU) { + this.usedCPU = usedCPU == null ? null : usedCPU.trim(); + } + + /** + * @return Returns the usedMemory. + */ + public String getUsedMemory() { + return usedMemory; + } + + /** + * @param usedMemory The usedMemory to set. + */ + public void setUsedMemory(String usedMemory) { + this.usedMemory = usedMemory == null ? null : usedMemory.trim(); + } + + /** + * @return Returns the usedDisk. + */ + public String getUsedDisk() { + return usedDisk; + } + + /** + * @param usedDisk The usedDisk to set. + */ + public void setUsedDisk(String usedDisk) { + this.usedDisk = usedDisk == null ? null : usedDisk.trim(); + } + + /** + * + * To Entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static SitesEntity toEntity(JSONObject jsonObject) { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + sitesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); + sitesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); + sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + sitesEntity.setTotalCPU(JsonUtil.getJsonFieldStr(jsonObject, "totalCPU")); + sitesEntity.setTotalMemory(JsonUtil.getJsonFieldStr(jsonObject, "totalMemory")); + sitesEntity.setTotalDisk(JsonUtil.getJsonFieldStr(jsonObject, "totalDisk")); + sitesEntity.setUsedCPU(JsonUtil.getJsonFieldStr(jsonObject, "usedCPU")); + sitesEntity.setUsedMemory(JsonUtil.getJsonFieldStr(jsonObject, "usedMemory")); + sitesEntity.setUsedDisk(JsonUtil.getJsonFieldStr(jsonObject, "usedDisk")); + return sitesEntity; + } + + @Override + public String toString() { + JSONObject siteResJson = new JSONObject(); + siteResJson.put("id", StringUtils.trimToEmpty(this.getId())); + siteResJson.put("name", StringUtils.trimToEmpty(this.getName())); + siteResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + siteResJson.put("location", StringUtils.trimToEmpty(this.getLocation())); + siteResJson.put("country", StringUtils.trimToEmpty(this.getCountry())); + siteResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + siteResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + siteResJson.put("totalCPU", StringUtils.trimToEmpty(this.getTotalCPU())); + siteResJson.put("totalMemory", StringUtils.trimToEmpty(this.getTotalMemory())); + siteResJson.put("totalDisk", StringUtils.trimToEmpty(this.getTotalDisk())); + siteResJson.put("usedCPU", StringUtils.trimToEmpty(this.getUsedCPU())); + siteResJson.put("usedMemory", StringUtils.trimToEmpty(this.getUsedMemory())); + siteResJson.put("usedDisk", StringUtils.trimToEmpty(this.getUsedDisk())); + + return siteResJson.toString(); + } + + /** + * + * Check whther the resource is zero.
+ * + * @param siteEntity + * @return + * @since NFVO 0.5 + */ + public static boolean checkResourceIsZero(SitesEntity siteEntity) { + + if(StringUtil.isAnyLargeThanZero(siteEntity.getUsedCPU(), siteEntity.getUsedMemory(), + siteEntity.getUsedDisk())) { + return false; + } + + return true; + } + + /** + * + * Check resource.
+ * + * @param siteEntity + * @return + * @since NFVO 0.5 + */ + public static boolean checkResource(SitesEntity siteEntity) { + String cpu = siteEntity.getTotalCPU(); + String memory = siteEntity.getTotalMemory(); + String disk = siteEntity.getTotalDisk(); + String cpuUsed = siteEntity.getUsedCPU(); + String memoryUsed = siteEntity.getUsedMemory(); + String diskUsed = siteEntity.getUsedDisk(); + + if(!StringUtil.isInteger(cpu, cpuUsed)) { + return false; + } + + if(!StringUtil.isNumeric(memory, disk, memoryUsed, diskUsed)) { + return false; + } + return true; + } + + /** + * + * Format data.
+ * + * @param siteEntity + * @since NFVO 0.5 + */ + public static void dataFramat(SitesEntity siteEntity) { + siteEntity.setTotalCPU(StringUtil.numFormat(siteEntity.getTotalCPU())); + siteEntity.setTotalMemory(StringUtil.numFormat(siteEntity.getTotalMemory())); + siteEntity.setTotalDisk(StringUtil.numFormat(siteEntity.getTotalDisk())); + siteEntity.setUsedCPU(StringUtil.numFormat(siteEntity.getUsedCPU())); + siteEntity.setUsedMemory(StringUtil.numFormat(siteEntity.getUsedMemory())); + siteEntity.setUsedDisk(StringUtil.numFormat(siteEntity.getUsedDisk())); + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VimEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VimEntity.java new file mode 100644 index 0000000..b1b52de --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VimEntity.java @@ -0,0 +1,106 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Virtualised infrastructure manager entity class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class VimEntity { + + /** + * This field corresponds to the database column vim.ID + * + * @mbggenerated + */ + private String id; + + /** + * This field corresponds to the database column vim.ID + * + * @mbggenerated + */ + private String name; + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column vim.ID + * + * @return the value of vim.ID + */ + public String getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column vim.ID + * + * @param id + * the value for vim.ID + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * + * To Entity.
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VimEntity toEntity(JSONObject jsonObject) { + VimEntity vimEntity = new VimEntity(); + vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + return vimEntity; + } + + /** + * + * To String.
+ * + * @return + * @since NFVO 0.5 + */ + public String toString() { + JSONObject resJson = new JSONObject(); + resJson.put("id", StringUtils.trimToEmpty(this.getId())); + resJson.put("name", StringUtils.trimToEmpty(this.getName())); + return resJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VirtualLinkEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VirtualLinkEntity.java new file mode 100644 index 0000000..d4408e8 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VirtualLinkEntity.java @@ -0,0 +1,285 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-27 + */ +public class VirtualLinkEntity implements Serializable { + + /** */ + private String id; + + /** */ + private String name; + + /** */ + private String backendId; + + /** */ + private String isPublic; + + /** */ + private String dcName; + + /** */ + private String vimId; + + /** */ + private String vimName; + + /** */ + private String physicialNet; + + /** */ + private String nsId; + + /** */ + private String nsName; + + /** */ + private String description; + + /** */ + private String networkType; + + /** */ + private String segmentation; + + /** */ + private String mtu; + + /** */ + private String vlanTransparent; + + /** */ + private String routerExternal; + + /** */ + private String resourceProviderType; + + /** */ + private String resourceProviderId; + + private static final long serialVersionUID = 1L; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBackendId() { + return backendId; + } + + public void setBackendId(String backendId) { + this.backendId = backendId; + } + + public String getIsPublic() { + return isPublic; + } + + public void setIsPublic(String isPublic) { + this.isPublic = isPublic; + } + + public String getDcName() { + return dcName; + } + + public void setDcName(String dcName) { + this.dcName = dcName; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String vimName) { + this.vimName = vimName; + } + + public String getPhysicialNet() { + return physicialNet; + } + + public void setPhysicialNet(String physicialNet) { + this.physicialNet = physicialNet; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getNsName() { + return nsName; + } + + public void setNsName(String nsName) { + this.nsName = nsName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public String getSegmentation() { + return segmentation; + } + + public void setSegmentation(String segmentation) { + this.segmentation = segmentation; + } + + public String getMtu() { + return mtu; + } + + public void setMtu(String mtu) { + this.mtu = mtu; + } + + public String getVlanTransparent() { + return vlanTransparent; + } + + public void setVlanTransparent(String vlanTransparent) { + this.vlanTransparent = vlanTransparent; + } + + public String getRouterExternal() { + return routerExternal; + } + + public void setRouterExternal(String routerExternal) { + this.routerExternal = routerExternal; + } + + public String getResourceProviderType() { + return resourceProviderType; + } + + public void setResourceProviderType(String resourceProviderType) { + this.resourceProviderType = resourceProviderType; + } + + public String getResourceProviderId() { + return resourceProviderId; + } + + public void setResourceProviderId(String resourceProviderId) { + this.resourceProviderId = resourceProviderId; + } + + /** + *
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VirtualLinkEntity toEntity(JSONObject jsonObject) { + VirtualLinkEntity virtualLinkEntity = new VirtualLinkEntity(); + virtualLinkEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "vlInstanceId")); + virtualLinkEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + virtualLinkEntity.setBackendId(JsonUtil.getJsonFieldStr(jsonObject, "backendId")); + virtualLinkEntity.setIsPublic(JsonUtil.getJsonFieldStr(jsonObject, "isPublic")); + virtualLinkEntity.setDcName(JsonUtil.getJsonFieldStr(jsonObject, "dcName")); + virtualLinkEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + virtualLinkEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + virtualLinkEntity.setPhysicialNet(JsonUtil.getJsonFieldStr(jsonObject, "physicialNet")); + virtualLinkEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + virtualLinkEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); + virtualLinkEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); + virtualLinkEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + virtualLinkEntity.setSegmentation(JsonUtil.getJsonFieldStr(jsonObject, "segmentation")); + virtualLinkEntity.setMtu(JsonUtil.getJsonFieldStr(jsonObject, "mtu")); + virtualLinkEntity.setVlanTransparent(JsonUtil.getJsonFieldStr(jsonObject, "vlanTransparent")); + virtualLinkEntity.setRouterExternal(JsonUtil.getJsonFieldStr(jsonObject, "routerExternal")); + virtualLinkEntity.setResourceProviderId(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderId")); + virtualLinkEntity.setResourceProviderType(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderType")); + return virtualLinkEntity; + } + + @Override + public String toString() { + JSONObject virtualLinkResJson = new JSONObject(); + virtualLinkResJson.put("id", StringUtils.trimToEmpty(this.getId())); + virtualLinkResJson.put("name", StringUtils.trimToEmpty(this.getName())); + virtualLinkResJson.put("backendId", StringUtils.trimToEmpty(this.getBackendId())); + virtualLinkResJson.put("isPublic", StringUtils.trimToEmpty(this.getIsPublic())); + virtualLinkResJson.put("dcName", StringUtils.trimToEmpty(this.getDcName())); + virtualLinkResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + virtualLinkResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + virtualLinkResJson.put("physicialNet", StringUtils.trimToEmpty(this.getPhysicialNet())); + virtualLinkResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + virtualLinkResJson.put("nsName", StringUtils.trimToEmpty(this.getNsName())); + virtualLinkResJson.put("description", StringUtils.trimToEmpty(this.getDescription())); + virtualLinkResJson.put("networkType", StringUtils.trimToEmpty(this.getNetworkType())); + virtualLinkResJson.put("segmentation", StringUtils.trimToEmpty(this.getSegmentation())); + virtualLinkResJson.put("mtu", StringUtils.trimToEmpty(this.getMtu())); + virtualLinkResJson.put("vlanTransparent", StringUtils.trimToEmpty(this.getVlanTransparent())); + virtualLinkResJson.put("routerExternal", StringUtils.trimToEmpty(this.getRouterExternal())); + virtualLinkResJson.put("resourceProviderId", StringUtils.trimToEmpty(this.getResourceProviderId())); + virtualLinkResJson.put("resourceProviderType", StringUtils.trimToEmpty(this.getResourceProviderType())); + return virtualLinkResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VmEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VmEntity.java new file mode 100644 index 0000000..d46633e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VmEntity.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VmEntity implements Serializable { + + /** */ + private String vmId; + + /** */ + private String vmName; + + /** */ + private String vmStatus; + + /** */ + private String vnfInstanceId; + + private static final long serialVersionUID = 1L; + + public String getVmId() { + return vmId; + } + + public void setVmId(String vmId) { + this.vmId = vmId; + } + + public String getVmName() { + return vmName; + } + + public void setVmName(String vmName) { + this.vmName = vmName; + } + + public String getVmStatus() { + return vmStatus; + } + + public void setVmStatus(String vmStatus) { + this.vmStatus = vmStatus; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public static VmEntity toEntity(JSONObject jsonObject) { + VmEntity vmEntity = new VmEntity(); + vmEntity.setVmId(JsonUtil.getJsonFieldStr(jsonObject, "vmId")); + vmEntity.setVmName(JsonUtil.getJsonFieldStr(jsonObject, "vmName")); + vmEntity.setVmStatus(JsonUtil.getJsonFieldStr(jsonObject, "vmStatus")); + vmEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + return vmEntity; + } + + @Override + public String toString() { + JSONObject vmResJson = new JSONObject(); + vmResJson.put("vmId", StringUtils.trimToEmpty(this.getVmId())); + vmResJson.put("vmName", StringUtils.trimToEmpty(this.getVmName())); + vmResJson.put("vmStatus", StringUtils.trimToEmpty(this.getVmStatus())); + vmResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + return vmResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfEntity.java new file mode 100644 index 0000000..4028c89 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfEntity.java @@ -0,0 +1,337 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VnfEntity implements Serializable { + + /** */ + private String id; + + /** */ + private String vnfInstanceId; + + /** */ + private String vnfInstanceName; + + /** */ + private String nsId; + + /** */ + private String nsName; + + /** */ + private String vnfmId; + + /** */ + private String vnfmName; + + /** */ + private String vnfPackageName; + + /** */ + private String vnfDescriptorName; + + /** */ + private String vimId; + + /** */ + private String vimName; + + /** */ + private String vimTenant; + + /** */ + private String jobId; + + /** */ + private String vnfStatus; + + /** */ + private String vnfType; + + /** */ + private Integer maxVm; + + /** */ + private Integer maxCpu; + + /** */ + private Integer maxDisk; + + /** */ + private Integer maxRam; + + /** */ + private Integer maxShd; + + /** */ + private Integer maxNet; + + /** */ + private String name; + + private static final long serialVersionUID = 1L; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfInstanceName() { + return vnfInstanceName; + } + + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getNsName() { + return nsName; + } + + public void setNsName(String nsName) { + this.nsName = nsName; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getVnfmName() { + return vnfmName; + } + + public void setVnfmName(String vnfmName) { + this.vnfmName = vnfmName; + } + + public String getVnfPackageName() { + return vnfPackageName; + } + + public void setVnfPackageName(String vnfPackageName) { + this.vnfPackageName = vnfPackageName; + } + + public String getVnfDescriptorName() { + return vnfDescriptorName; + } + + public void setVnfDescriptorName(String vnfDescriptorName) { + this.vnfDescriptorName = vnfDescriptorName; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String vimName) { + this.vimName = vimName; + } + + public String getVimTenant() { + return vimTenant; + } + + public void setVimTenant(String vimTenant) { + this.vimTenant = vimTenant; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getVnfStatus() { + return vnfStatus; + } + + public void setVnfStatus(String vnfStatus) { + this.vnfStatus = vnfStatus; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public Integer getMaxVm() { + return maxVm; + } + + public void setMaxVm(Integer maxVm) { + this.maxVm = maxVm; + } + + public Integer getMaxCpu() { + return maxCpu; + } + + public void setMaxCpu(Integer maxCpu) { + this.maxCpu = maxCpu; + } + + public Integer getMaxDisk() { + return maxDisk; + } + + public void setMaxDisk(Integer maxDisk) { + this.maxDisk = maxDisk; + } + + public Integer getMaxRam() { + return maxRam; + } + + public void setMaxRam(Integer maxRam) { + this.maxRam = maxRam; + } + + public Integer getMaxShd() { + return maxShd; + } + + public void setMaxShd(Integer maxShd) { + this.maxShd = maxShd; + } + + public Integer getMaxNet() { + return maxNet; + } + + public void setMaxNet(Integer maxNet) { + this.maxNet = maxNet; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + *
+ * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VnfEntity toEntity(JSONObject jsonObject) { + VnfEntity vnfEntity = new VnfEntity(); + vnfEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + vnfEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + vnfEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfEntity.setVnfInstanceName(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceName")); + vnfEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); + vnfEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + vnfEntity.setVnfmName(JsonUtil.getJsonFieldStr(jsonObject, "vnfmName")); + vnfEntity.setVnfPackageName(JsonUtil.getJsonFieldStr(jsonObject, "vnfPackageName")); + vnfEntity.setVnfDescriptorName(JsonUtil.getJsonFieldStr(jsonObject, "vnfDescriptorName")); + vnfEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + vnfEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + vnfEntity.setVimTenant(JsonUtil.getJsonFieldStr(jsonObject, "vimTenant")); + vnfEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); + vnfEntity.setVnfStatus(JsonUtil.getJsonFieldStr(jsonObject, "vnfStatus")); + vnfEntity.setVnfType(JsonUtil.getJsonFieldStr(jsonObject, "vnfType")); + vnfEntity.setMaxVm(JsonUtil.getJsonFieldInt(jsonObject, "maxVm")); + vnfEntity.setMaxCpu(JsonUtil.getJsonFieldInt(jsonObject, "maxCpu")); + vnfEntity.setMaxDisk(JsonUtil.getJsonFieldInt(jsonObject, "maxDisk")); + vnfEntity.setMaxRam(JsonUtil.getJsonFieldInt(jsonObject, "maxRam")); + vnfEntity.setMaxShd(JsonUtil.getJsonFieldInt(jsonObject, "maxShd")); + vnfEntity.setMaxNet(JsonUtil.getJsonFieldInt(jsonObject, "maxNet")); + return vnfEntity; + } + + @Override + public String toString() { + JSONObject vnfResJson = new JSONObject(); + vnfResJson.put("id", StringUtils.trimToEmpty(this.getId())); + vnfResJson.put("name", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfInstanceName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("nsId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("nsName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfmId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfmName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfPackageName", StringUtils.trimToEmpty(this.getId())); + vnfResJson.put("vnfDescriptorName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimTenant", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("jobId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfStatus", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfType", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxVm", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxCpu", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxDisk", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxRam", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxShd", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxNet", StringUtils.trimToEmpty(this.getName())); + return vnfResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfInfoEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfInfoEntity.java new file mode 100644 index 0000000..f993d9c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfInfoEntity.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VnfInfoEntity implements Serializable { + + /** */ + private String vnfInstanceId; + + /** */ + private String nsId; + + /** */ + private String vnfmId; + + private static final long serialVersionUID = 1L; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public static VnfInfoEntity toEntity(JSONObject jsonObject) { + VnfInfoEntity vnfInfoEntity = new VnfInfoEntity(); + vnfInfoEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfInfoEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfInfoEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + return vnfInfoEntity; + } + + @Override + public String toString() { + JSONObject vnfInfoResJson = new JSONObject(); + vnfInfoResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + vnfInfoResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + vnfInfoResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); + return vnfInfoResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfStatusEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfStatusEntity.java new file mode 100644 index 0000000..78ad1b8 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/entity/VnfStatusEntity.java @@ -0,0 +1,213 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-29 + */ +public class VnfStatusEntity implements Serializable { + + /** */ + private String vnfInstanceId; + + /** */ + private String jobId; + + /** */ + private String nsId; + + /** */ + private String vnfmId; + + /** */ + private String responseDescriptor; + + /** */ + private String status; + + /** */ + private String progress; + + /** */ + private String statusDescription; + + /** */ + private String errorCode; + + /** */ + private String responseId; + + /** */ + private String responseHistoryList; + + /** */ + private String addVm; + + /** */ + private String delVm; + + private static final long serialVersionUID = 1L; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getResponseDescriptor() { + return responseDescriptor; + } + + public void setResponseDescriptor(String responseDescriptor) { + this.responseDescriptor = responseDescriptor; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getProgress() { + return progress; + } + + public void setProgress(String progress) { + this.progress = progress; + } + + public String getStatusDescription() { + return statusDescription; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public String getResponseHistoryList() { + return responseHistoryList; + } + + public void setResponseHistoryList(String responseHistoryList) { + this.responseHistoryList = responseHistoryList; + } + + public String getAddVm() { + return addVm; + } + + public void setAddVm(String addVm) { + this.addVm = addVm; + } + + public String getDelVm() { + return delVm; + } + + public void setDelVm(String delVm) { + this.delVm = delVm; + } + + public static VnfStatusEntity toEntity(JSONObject jsonObject) { + VnfStatusEntity vnfStatusEntity = new VnfStatusEntity(); + vnfStatusEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfStatusEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); + vnfStatusEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfStatusEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + vnfStatusEntity.setResponseDescriptor(JsonUtil.getJsonFieldStr(jsonObject, "responseDescriptor")); + vnfStatusEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + vnfStatusEntity.setProgress(JsonUtil.getJsonFieldStr(jsonObject, "progress")); + vnfStatusEntity.setStatusDescription(JsonUtil.getJsonFieldStr(jsonObject, "statusDescription")); + vnfStatusEntity.setErrorCode(JsonUtil.getJsonFieldStr(jsonObject, "errorCode")); + vnfStatusEntity.setResponseId(JsonUtil.getJsonFieldStr(jsonObject, "responseId")); + vnfStatusEntity.setResponseHistoryList(JsonUtil.getJsonFieldStr(jsonObject, "responseHistoryList")); + vnfStatusEntity.setAddVm(JsonUtil.getJsonFieldStr(jsonObject, "addVm")); + vnfStatusEntity.setDelVm(JsonUtil.getJsonFieldStr(jsonObject, "delVm")); + return vnfStatusEntity; + } + + @Override + public String toString() { + JSONObject vnfStatusResJson = new JSONObject(); + vnfStatusResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + vnfStatusResJson.put("jobId", StringUtils.trimToEmpty(this.getJobId())); + vnfStatusResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + vnfStatusResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); + vnfStatusResJson.put("responseDescriptor", StringUtils.trimToEmpty(this.getResponseDescriptor())); + vnfStatusResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + vnfStatusResJson.put("progress", StringUtils.trimToEmpty(this.getProgress())); + vnfStatusResJson.put("statusDescription", StringUtils.trimToEmpty(this.getStatusDescription())); + vnfStatusResJson.put("errorCode", StringUtils.trimToEmpty(this.getErrorCode())); + vnfStatusResJson.put("responseId", StringUtils.trimToEmpty(this.getResponseId())); + vnfStatusResJson.put("responseHistoryList", StringUtils.trimToEmpty(this.getResponseHistoryList())); + vnfStatusResJson.put("addVm", StringUtils.trimToEmpty(this.getAddVm())); + vnfStatusResJson.put("delVm", StringUtils.trimToEmpty(this.getDelVm())); + return vnfStatusResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/GrantResServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/GrantResServiceImpl.java new file mode 100644 index 0000000..2eea6d0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/GrantResServiceImpl.java @@ -0,0 +1,206 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.group.inf.GrantResService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class GrantResServiceImpl implements GrantResService { + + private static final Logger LOGGER = LoggerFactory.getLogger(GrantResServiceImpl.class); + + private Sites sites; + + /** + *
+ * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject grantResource(JSONObject object) throws ServiceException { + LOGGER.info("function=grantResource; object: {}", object.toString()); + JSONObject additionalparam = object.getJSONObject("additionalParam"); + String vimId = additionalparam.getString("vimid"); + JSONObject vimJson = VimUtil.getVimById(vimId); + String tenant = vimJson.getString("tenant"); + JSONObject accessinfo = new JSONObject(); + accessinfo.put("tenant", tenant); + JSONObject vim = new JSONObject(); + vim.put("vimid", vimId); + vim.put("accessinfo", accessinfo); + LOGGER.info("function=grantResource; vim: {}", vim.toString()); + JSONObject result = new JSONObject(); + result.put("vim", vim); + return result; + } + + @Override + public JSONObject grantResourceReal(JSONObject object) throws ServiceException { + LOGGER.info("function=grantResource; object: {}", object.toString()); + String vimId = object.getString("vimId"); + JSONObject vimJson = VimUtil.getVimById(vimId); + JSONObject vim = parseVim(vimJson); + String resType = ""; + JSONArray resArr = new JSONArray(); + if(object.containsKey("addResource")) { + resType = "addResource"; + resArr = parseResource(object, resType); + } else if(object.containsKey("removeResource")) { + resType = "removeResource"; + resArr = parseResource(object, resType); + } + JSONObject resInfo = getResInfo(object, resType); + resInfo.put("vimId", vimId); + sites.update(resInfo); + + JSONObject result = new JSONObject(); + result.put("vim", vim); + result.put("zone", ""); + result.put("zoneGroup", ""); + result.put(resType, resArr); + result.put("tempResource", ""); + result.put("updateResource", ""); + result.put("vimAssets", new JSONObject()); + result.put("additionalParam", ""); + LOGGER.info("function=grantResource; result: {}", result.toString()); + return result; + } + + private JSONObject getResInfo(JSONObject object, String type) { + JSONArray arr = object.getJSONArray(type); + LOGGER.info("function=getResInfo; arr: {}, type: {}", arr, type); + JSONObject resourceObj = new JSONObject(); + if("addResource".equals(type)) { + resourceObj = getGrantResource(arr); + resourceObj.put("action", "online"); + } else if("removeResource".equals(type)) { + resourceObj = getGrantResource(arr); + resourceObj.put("action", "offline"); + } + LOGGER.info("function=getResInfo; resutl: {}", resourceObj.toString()); + return resourceObj; + } + + /** + *
+ * + * @param addResource + * @return + * @since NFVO 0.5 + */ + private JSONObject getGrantResource(JSONArray resource) { + int cpuNum = 0; + int memNum = 0; + int diskNum = 0; + for(int i = 0; i < resource.size(); i++) { + JSONObject res = resource.getJSONObject(i); + JSONObject vCpu = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") + .getJSONObject("virtualCpu"); + int vCpuNum = vCpu.getInt("numVirtualCpu"); + JSONObject vMem = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") + .getJSONObject("virtualMemory"); + int vMemNum = vMem.getInt("virtualMemSize"); + JSONObject vDisk = res.getJSONObject("resourceTemplate").getJSONObject("virtualStorageDescriptor"); + int vDiskNum = vDisk.getInt("sizeOfStorage"); + cpuNum = cpuNum + vCpuNum; + memNum = memNum + vMemNum; + diskNum = diskNum + vDiskNum; + } + JSONObject obj = new JSONObject(); + obj.put("usedCPU", String.valueOf(cpuNum)); + obj.put("usedMemory", String.valueOf(memNum)); + obj.put("usedDisk", String.valueOf(diskNum)); + return obj; + } + + /** + *
+ * + * @param object + * @return + * @since NFVO 0.5 + */ + private JSONArray parseResource(JSONObject object, String key) { + JSONArray newResources = new JSONArray(); + JSONArray oldResource = object.getJSONArray(key); + LOGGER.info("function=parseResource; Resource: {}", oldResource.toString()); + for(int i = 0; i < oldResource.size(); i++) { + JSONObject res = oldResource.getJSONObject(i); + JSONObject obj = new JSONObject(); + obj.put("reservationId", ""); + obj.put("resourceProviderId", ""); + obj.put("zoneId", ""); + obj.put("vimId", object.getString("vimId")); + obj.put("resourceDefinitionId", res.getString("resourceDefinitionId")); + newResources.add(obj); + } + LOGGER.info("function=parseResource; Parse Resource result: {}", newResources.toString()); + return newResources; + } + + /** + *
+ * + * @param vimJson + * @return + * @since NFVO 0.5 + */ + private JSONObject parseVim(JSONObject vimJson) { + LOGGER.info("function=grantResource; vimJson: {}", vimJson.toString()); + JSONObject interfaceInfo = new JSONObject(); + interfaceInfo.put("vimType", vimJson.getString("type")); + interfaceInfo.put("apiVersion", "v2"); + interfaceInfo.put("protocolType", "http"); + JSONObject accessInfo = new JSONObject(); + accessInfo.put("tenant", vimJson.getString("tenant")); + accessInfo.put("username", vimJson.getString("userName")); + accessInfo.put("password", vimJson.getString("password")); + JSONObject vim = new JSONObject(); + vim.put("vimInfoId", vimJson.getString("vimId")); + vim.put("vimId", vimJson.getString("vimId")); + vim.put("interfaceInfo", interfaceInfo); + vim.put("accessInfo", accessInfo); + vim.put("interfaceEndpoint", vimJson.getString("url")); + return vim; + } + + /** + * @param sites The sites to set. + */ + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceAddServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceAddServiceImpl.java new file mode 100644 index 0000000..6c7bad9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceAddServiceImpl.java @@ -0,0 +1,159 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.InterfaceResManagement; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * iResource add service implementation.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceAddServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceAddServiceImpl.class); + + /** + * Add iResource.
+ * + * @param restParametes + * @param iResMap + * @throws ServiceException + * @since NFVO 0.5 + */ + @Transactional(rollbackFor = ServiceException.class) + public void addIRes(RestfulParametes restParametes, Map iResMap) + throws ServiceException { + addIResources(iResMap, createResUrlMap(), restParametes); + } + + private void addIResources(Map iResMap, HashMap urlMap, + RestfulParametes restParametes) throws ServiceException { + for(String iResName : iResMap.keySet()) { + if(ParamConstant.PARAM_HOST.equals(iResName)) { + addHostResource(iResMap, restParametes, String.format(urlMap.get(iResName), + restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), + iResName); + } else { + String url = String.format(urlMap.get(iResName), restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID)); + JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=addIResources; iResArray={}", iResArray); + for(Object object : iResArray) { + JSONObject iRes = JSONObject.fromObject(object); + int result = iResMap.get(iResName).add(iRes); + LOGGER.warn("function=addIResources; msg=iRes name is [{}],result is [{}]", iResName, result); + } + } + } + } + + /** + * Add Host Resource.
+ * + * @param iResMap + * @param restParametes + * @param url + * @param iResName + * @throws ServiceException + * @since NFVO 0.5 + */ + public static void addHostResource(Map iResMap, RestfulParametes restParametes, + String url, String iResName) throws ServiceException { + JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=addHostResource; hostResArray={}", hostResArray); + for(Object object : hostResArray) { + JSONObject hostRes = JSONObject.fromObject(object); + String hostZone = hostRes.getString("zone"); + if("internal".equals(hostZone)) { + continue; + } + String hostName = hostRes.getString("name"); + String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID), hostName); + + String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); + if(result == null) { + continue; + } + JSONObject hostObj = JSONObject.fromObject(result); + JSONObject host = hostDataParse(hostObj, hostName); + int res = iResMap.get(iResName).add(host); + LOGGER.warn("function=addHostResource; result={}, res={}", result, res); + if(res < 0) { + LOGGER.error("function=addHostResource; add into DB fail!"); + } + + } + } + + /** + *
+ * + * @param hostObj + * @param hostName + * @return + * @since NFVO 0.5 + */ + public static JSONObject hostDataParse(JSONObject hostObj, String hostName) { + LOGGER.warn("function=hostDataParse; hostObj={}, hostName={}", hostObj, hostName); + JSONArray hostArray = hostObj.getJSONArray("host"); + for(Object object : hostArray) { + JSONObject hostObject = JSONObject.fromObject(object); + if(hostObject.getString("project").contains("total")) { + String vimId = JsonUtil.getJsonFieldStr(hostObj, "vimId"); + String hostId = vimId + hostName; + JSONObject host = new JSONObject(); + host.put("id", hostId); + host.put("name", hostName); + host.put("cpu", JsonUtil.getJsonFieldStr(hostObject, "cpu")); + host.put("memory", JsonUtil.getJsonFieldStr(hostObject, "memory_mb")); + host.put("disk", JsonUtil.getJsonFieldStr(hostObject, "disk_gb")); + host.put("vimId", JsonUtil.getJsonFieldStr(hostObj, "vimId")); + host.put("vimName", JsonUtil.getJsonFieldStr(hostObj, "vimName")); + return host; + } + } + return new JSONObject(); + } + + private HashMap createResUrlMap() { + HashMap urlMap = new HashMap(10); + urlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); + urlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); + urlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); + return urlMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceDelServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceDelServiceImpl.java new file mode 100644 index 0000000..8dbcaf0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceDelServiceImpl.java @@ -0,0 +1,75 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.InterfaceResManagement; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Vim; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * iResource delete service implementation.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceDelServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceDelServiceImpl.class); + + /** + * + * Delete iResource.
+ * + * @param vimId + * @param iResMap + * @param vim + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public int deleteIRes(String vimId, Map iResMap, Vim vim) throws ServiceException { + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_VIMID, vimId); + + checkIResDelResult(vimId, iResMap); + return vim.delete(vimId); + } + + private void checkIResDelResult(String vimId, Map iResMap) throws ServiceException { + for(String keyName : iResMap.keySet()) { + if(iResMap.get(keyName).deleteResByVimId(vimId) < 0) { + LOGGER.error("function=checkIResDelResult; msg=delete {} failed,", keyName); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.delete.fail") + + keyName); + } + LOGGER.warn("function=checkIResDelResult; msg=delete {} success", keyName); + } + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceUpdateServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceUpdateServiceImpl.java new file mode 100644 index 0000000..f26fedf --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/IResourceUpdateServiceImpl.java @@ -0,0 +1,120 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.InterfaceResManagement; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * iResource update service implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceUpdateServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceUpdateServiceImpl.class); + + /** + * Update iResource.
+ * + * @param vimId + * @param restParametes + * @param iResMap + * @param sites + * @throws ServiceException + * @since NFVO 0.5 + */ + @Transactional(rollbackFor = ServiceException.class) + public void updateIRes(String vimId, RestfulParametes restParametes, Map iResMap) + throws ServiceException { + + updateIResByName(iResMap, createResUrlMap(), restParametes, vimId); + } + + private void updateIResByName(Map iResMap, HashMap updateUrlMap, + RestfulParametes restParametes, String vimId) throws ServiceException { + for(String resName : updateUrlMap.keySet()) { + if(ParamConstant.PARAM_HOST.equals(resName)) { + updateHostResource(iResMap, restParametes, String.format(updateUrlMap.get(resName), + restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), + resName); + } else if(iResMap.get(resName).deleteResByVimId(vimId) >= 0) { + String url = String.format(updateUrlMap.get(resName), restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID)); + JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, resName); + LOGGER.warn("function=addIResources; iResArray={}", iResArray); + for(Object object : iResArray) { + JSONObject iRes = JSONObject.fromObject(object); + int result = iResMap.get(resName).add(iRes); + LOGGER.warn("function=updateIResByName; msg=iRes name is [{}],result is [{}]", resName, result); + + } + } + } + } + + private void updateHostResource(Map iResMap, RestfulParametes restParametes, + String url, String iResName) throws ServiceException { + + JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=updateHostResource; hostResArray={}", hostResArray); + for(Object object : hostResArray) { + JSONObject hostRes = JSONObject.fromObject(object); + String hostZone = hostRes.getString("zone"); + if("internal".equals(hostZone)) { + continue; + } + String hostName = hostRes.getString("name"); + String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID), hostName); + + String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); + JSONObject hostObj = JSONObject.fromObject(result); + JSONObject host = IResourceAddServiceImpl.hostDataParse(hostObj, hostName); + int res = iResMap.get(ParamConstant.PARAM_HOST).update(host); + LOGGER.warn("function=updateHostResource; result={}, res={}", result, res); + if(res < 0) { + LOGGER.error("function=updateHostResource; add into DB fail!"); + } + + } + } + + private HashMap createResUrlMap() { + HashMap updateUrlMap = new HashMap(10); + updateUrlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); + updateUrlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); + updateUrlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); + return updateUrlMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/ResOperateServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/ResOperateServiceImpl.java new file mode 100644 index 0000000..66686e7 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/ResOperateServiceImpl.java @@ -0,0 +1,257 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.Constant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.common.util.StringUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Host; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.InterfaceResManagement; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Network; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Port; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Vim; +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.onap.vfc.nfvo.res.service.entity.VimEntity; +import org.onap.vfc.nfvo.res.service.group.inf.ResOperateService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Resource operation service implementation class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class ResOperateServiceImpl implements ResOperateService { + + private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateServiceImpl.class); + + private Sites sites; + + private Network network; + + private Host host; + + private Port port; + + private Vim vim; + + private IResourceAddServiceImpl iResourceAddServiceImpl; + + private IResourceUpdateServiceImpl iResourceUpdateServiceImpl; + + private IResourceDelServiceImpl iResourceDelServiceImpl; + + @Override + @Transactional(rollbackFor = ServiceException.class) + public void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { + LOGGER.warn("function=addIRes; msg=add IResource by vimId:[{}], tenantId:[{}]", vimId, tenantId); + if(!StringUtil.isValidString(vimId) || !StringUtil.isValidString(tenantId)) { + LOGGER.warn("function=addIRes; msg=vimId[{}] is valid", vimId); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.vimId")); + } + + RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); + HashMap iResMap = createMap(); + + if(vim.add(vimId) <= 0) { + LOGGER.error("VimId exists"); + throw new ServiceException("VimId exists"); + } + + iResourceAddServiceImpl.addIRes(restParametes, iResMap); + } + + @Override + @Transactional(rollbackFor = ServiceException.class) + public void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { + if(!StringUtil.isValidString(vimId)) { + LOGGER.error("function=updateIRes; msg=vimId is not exist"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); + } + + RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); + HashMap iResMap = createMap(); + iResourceUpdateServiceImpl.updateIRes(vimId, restParametes, iResMap); + } + + @Override + public void updateAllIRes() throws ServiceException { + LOGGER.warn("function=updateAllIRes; msg=update all IResource"); + List vims = vim.getList(); + if(vims.isEmpty()) { + LOGGER.error("function=updateAllIRes; msg=vimId is not exist"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); + } + for(VimEntity vimEntity : vims) { + String vimId = vimEntity.getId(); + LOGGER.warn("function=updateAllIRes; msg=start update vimId:{}", vimId); + updateIRes(null, vimId, new JSONObject()); + } + } + + @Override + @Transactional(rollbackFor = ServiceException.class) + public int deleteIRes(String vimId) throws ServiceException { + LOGGER.warn("function=deleteAllRes; msg=deleteResPool vimId: {}", vimId); + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteAllRes; msg=vimId is null"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.res.no.vimId")); + } + + return iResourceDelServiceImpl.deleteIRes(vimId, createMap(), vim); + } + + private RestfulParametes createRestfulParametes(String tenantId, String vimId, JSONObject header) { + RestfulParametes restParametes = new RestfulParametes(); + restParametes.put("vimId", vimId); + restParametes.put("tenantId", tenantId); + restParametes.putHttpContextHeader("Content-Type", "application/json"); + JSONObject headers = JsonUtil.getJsonFieldJson(header, "header"); + if(null == headers || !headers.has("x-auth-token")) { + String token = "TestToken"; + LOGGER.warn("function=createRestfulParametes; msg=create token."); + restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, token); + return restParametes; + } + restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, + JsonUtil.getJsonFieldStr(headers, Constant.IAM_AUTH_TOKEN)); + return restParametes; + } + + private HashMap createMap() { + HashMap iResMap = new HashMap(10); + iResMap.put(ParamConstant.PARAM_NETWORK, network); + iResMap.put(ParamConstant.PARAM_HOST, host); + iResMap.put(ParamConstant.PARAM_PORT, port); + return iResMap; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + + public void setNetwork(Network network) { + this.network = network; + } + + public void setHost(Host host) { + this.host = host; + } + + public void setPort(Port port) { + this.port = port; + } + + public void setVim(Vim vim) { + this.vim = vim; + } + + /** + * Set iResource Add service implemtation.
+ * + * @param iResourceAddServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceAddServiceImpl(IResourceAddServiceImpl iResourceAddServiceImpl) { + this.iResourceAddServiceImpl = iResourceAddServiceImpl; + } + + /** + * Set iResource update service implementation.
+ * + * @param iResourceUpdateServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceUpdateServiceImpl(IResourceUpdateServiceImpl iResourceUpdateServiceImpl) { + this.iResourceUpdateServiceImpl = iResourceUpdateServiceImpl; + } + + /** + * Set iresource delete service implementation.
+ * + * @param iResourceDelServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceDelServiceImpl(IResourceDelServiceImpl iResourceDelServiceImpl) { + this.iResourceDelServiceImpl = iResourceDelServiceImpl; + } + + /** + *
+ * + * @param string + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public void sendMsgMonitor(String operateType, String vimId) throws ServiceException { + LOGGER.info("Enter sendMsgMonitor!"); + Map map = new HashMap<>(10); + map.put("vimId", vimId); + List hosts = host.getList(map); + for(HostEntity entity : hosts) { + JSONObject msgObj = new JSONObject(); + msgObj.put("operationType", operateType); + msgObj.put("resourceType", "HOST"); + msgObj.put("label", entity.getName()); + if("delete".equals(operateType)) { + JSONArray deleteIds = new JSONArray(); + deleteIds.add(entity.getId()); + msgObj.put("deleteIds", deleteIds); + } else { + JSONArray data = new JSONArray(); + JSONObject obj = JSONObject.fromObject(entity); + obj.put("oid", entity.getId()); + obj.put("moc", "nfv.host.linux"); + data.add(obj); + msgObj.put("data", data); + } + RestfulParametes restfulParametes = new RestfulParametes(); + Map headerMap = new HashMap<>(3); + headerMap.put("Content-Type", "application/json"); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(msgObj.toString()); + LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); + String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, + ParamConstant.PARAM_POST); + LOGGER.warn(result); + } + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VirtualLinkServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VirtualLinkServiceImpl.java new file mode 100644 index 0000000..287f636 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VirtualLinkServiceImpl.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.service.dao.inf.VirtualLinkDao; +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VirtualLinkService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +public class VirtualLinkServiceImpl implements VirtualLinkService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkServiceImpl.class); + + private VirtualLinkDao virtualLinkDao; + + /** + *
+ * + * @param virtualLinkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException { + if(!checkId(virtualLinkEntity.getId())) { + LOGGER.error("function=addVl; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil + .getMessage("org.onap.vfc.nfvo.res.service.group.impl.VirtualLinkServiceImpl.add.id.check")); + } + if(StringUtils.isEmpty(virtualLinkEntity.getId())) { + virtualLinkEntity.setId(UUID.randomUUID().toString()); + } + int result = virtualLinkDao.addVl(virtualLinkEntity); + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", virtualLinkEntity.getId()); + restJson.put("name", virtualLinkEntity.getName()); + } else { + LOGGER.error("function=addVl; msg=add vl into DB error."); + restJson.put("message", "Add Vl into DB error."); + } + return restJson; + + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String id) { + VirtualLinkEntity vl = virtualLinkDao.getVl(id); + if(null == vl) { + return true; + } + return false; + } + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List getList(Map map) throws ServiceException { + return virtualLinkDao.getVls(map); + } + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return virtualLinkDao.deleteVlById(id); + } + + public void setVirtualLinkDao(VirtualLinkDao virtualLinkDao) { + this.virtualLinkDao = virtualLinkDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VmServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VmServiceImpl.java new file mode 100644 index 0000000..fef97b2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VmServiceImpl.java @@ -0,0 +1,177 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.RestfulUtil; +import org.onap.vfc.nfvo.res.service.dao.inf.VmDao; +import org.onap.vfc.nfvo.res.service.entity.VmEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VmService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VmServiceImpl implements VmService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VmServiceImpl.class); + + private VmDao vmDao; + + /** + *
+ * + * @param vmEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVm(VmEntity vmEntity) throws ServiceException { + int result; + if(!checkId(vmEntity.getVmId())) { + result = vmDao.updateVm(vmEntity); + sendMsgMonitor("create", vmEntity); + } else { + if(StringUtils.isEmpty(vmEntity.getVmId())) { + vmEntity.setVmId(UUID.randomUUID().toString()); + } + result = vmDao.addVm(vmEntity); + sendMsgMonitor("update", vmEntity); + } + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", vmEntity.getVmId()); + restJson.put("name", vmEntity.getVmName()); + } else { + LOGGER.error("function=addVm; msg=add vm into DB error."); + restJson.put("message", "Add vm into DB error."); + } + return restJson; + } + + /** + *
+ * + * @param vmId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vmId) { + VmEntity vm = vmDao.getVm(vmId); + if(null == vm) { + return true; + } + return false; + } + + public void sendMsgMonitor(String operateType, VmEntity vmEntity) throws ServiceException { + JSONObject msgObj = new JSONObject(); + msgObj.put("operationType", operateType); + msgObj.put("resourceType", "VDU"); + msgObj.put("label", vmEntity.getVmName()); + if("delete".equals(operateType)) { + JSONArray deleteIds = new JSONArray(); + deleteIds.add(vmEntity.getVmId()); + msgObj.put("deleteIds", deleteIds); + } else { + JSONArray data = new JSONArray(); + JSONObject obj = JSONObject.fromObject(vmEntity); + obj.put("oid", vmEntity.getVmId()); + obj.put("moc", "nfv.vdu.linux"); + data.add(obj); + msgObj.put("data", data); + } + LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); + RestfulParametes restfulParametes = new RestfulParametes(); + Map headerMap = new HashMap<>(3); + headerMap.put("Content-Type", "application/json"); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(msgObj.toString()); + String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, + ParamConstant.PARAM_POST); + LOGGER.warn(result); + + } + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List getList(Map map) throws ServiceException { + return vmDao.getVms(map); + } + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return vmDao.deleteVmById(id); + } + + public void setVmDao(VmDao vmDao) { + this.vmDao = vmDao; + } + + /** + *
+ * + * @param vnfInstanceId + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int deleteByVnfId(String vnfInstanceId) throws ServiceException { + Map map = new HashMap<>(10); + map.put("vnfInstanceId", vnfInstanceId); + List vms = vmDao.getVms(map); + for(int i = 0; i < vms.size(); i++) { + VmEntity vm = vms.get(i); + sendMsgMonitor("delete", vm); + } + return vmDao.deleteVmByVnfId(vnfInstanceId); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfInfoServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfInfoServiceImpl.java new file mode 100644 index 0000000..7b0e1b8 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfInfoServiceImpl.java @@ -0,0 +1,150 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VnfInfoDao; +import org.onap.vfc.nfvo.res.service.entity.VmEntity; +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VmService; +import org.onap.vfc.nfvo.res.service.group.inf.VnfInfoService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfInfoServiceImpl implements VnfInfoService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoServiceImpl.class); + + private VnfInfoDao vnfInfoDao; + + private VmService vmService; + + /** + *
+ * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnfInfo(JSONObject object) throws ServiceException { + LOGGER.info("function=addVnfInfo; object: {}", object); + saveVm(object); + JSONObject vnf = new JSONObject(); + vnf.put("vnfInstanceId", object.get("vnfInstanceId")); + vnf.put("nsId", object.get("nsId")); + vnf.put("vnfmId", object.get("vnfmId")); + VnfInfoEntity vnfInfoEntity = VnfInfoEntity.toEntity(vnf); + int result; + if(!checkId(vnfInfoEntity.getVnfInstanceId())) { + result = vnfInfoDao.updateVnfInfo(vnfInfoEntity); + } else { + result = vnfInfoDao.addVnfInfo(vnfInfoEntity); + } + JSONObject resultObj = new JSONObject(); + if(result > 0) { + resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); + } else { + LOGGER.error("function=addVnfInfo; msg=add vnfInfo into DB error."); + resultObj.put("message", "Add vnfInfo into DB error."); + } + return resultObj; + } + + /** + *
+ * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vnfInstanceId) { + VnfInfoEntity vnf = vnfInfoDao.getVnfInfo(vnfInstanceId); + if(null == vnf) { + return true; + } + return false; + } + + /** + *
+ * + * @param object + * @throws ServiceException + * @since NFVO 0.5 + */ + private void saveVm(JSONObject object) throws ServiceException { + String vnfInstanceId = object.getString("vnfInstanceId"); + JSONArray vms = object.getJSONArray("vms"); + for(int i = 0; i < vms.size(); i++) { + JSONObject vmObj = vms.getJSONObject(i); + vmObj.put("vnfInstanceId", vnfInstanceId); + vmService.addVm(VmEntity.toEntity(vmObj)); + } + + } + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List getList(Map map) throws ServiceException { + return vnfInfoDao.getVnfInfos(map); + } + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + vmService.deleteByVnfId(id); + return vnfInfoDao.deleteVnfInfoById(id); + } + + public void setVnfInfoDao(VnfInfoDao vnfInfoDao) { + this.vnfInfoDao = vnfInfoDao; + } + + public void setVmService(VmService vmService) { + this.vmService = vmService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfServiceImpl.java new file mode 100644 index 0000000..552d252 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfServiceImpl.java @@ -0,0 +1,141 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.service.dao.inf.VnfDao; +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VnfInfoService; +import org.onap.vfc.nfvo.res.service.group.inf.VnfService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfServiceImpl implements VnfService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfServiceImpl.class); + + private VnfDao vnfDao; + + private VnfInfoService vnfInfoService; + + /** + *
+ * + * @param vnfEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException { + if(!checkId(vnfEntity.getId())) { + LOGGER.error("function=addVnf; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil + .getMessage("org.onap.vfc.nfvo.res.service.group.impl.VnfServiceImpl.add.id.check")); + } + if(StringUtils.isEmpty(vnfEntity.getId())) { + vnfEntity.setId(UUID.randomUUID().toString()); + } + int result = vnfDao.addVnf(vnfEntity); + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", vnfEntity.getId()); + restJson.put("name", vnfEntity.getName()); + } else { + LOGGER.error("function=addVnf; msg=add vnf into DB error."); + restJson.put("message", "Add vnf into DB error."); + } + return restJson; + } + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String id) { + VnfEntity vnf = vnfDao.getVnf(id); + if(null == vnf) { + return true; + } + return false; + } + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List getList(Map map) throws ServiceException { + return vnfDao.getVnfs(map); + } + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + deleteVnfInfo(id); + return vnfDao.deleteVnfById(id); + } + + /** + *
+ * + * @param id + * @throws ServiceException + * @since NFVO 0.5 + */ + private void deleteVnfInfo(String vnfInstanceId) throws ServiceException { + vnfInfoService.delete(vnfInstanceId); + } + + public void setVnfDao(VnfDao vnfDao) { + this.vnfDao = vnfDao; + } + + public void setVnfInfoService(VnfInfoService vnfInfoService) { + this.vnfInfoService = vnfInfoService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfStatusServiceImpl.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfStatusServiceImpl.java new file mode 100644 index 0000000..a846d59 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/impl/VnfStatusServiceImpl.java @@ -0,0 +1,117 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.impl; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.dao.inf.VnfStatusDao; +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VnfStatusService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VnfStatusServiceImpl implements VnfStatusService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusServiceImpl.class); + + private VnfStatusDao vnfStatusDao; + + /** + *
+ * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnfStatus(JSONObject object) throws ServiceException { + LOGGER.info("function=addVnfStatus; object: {}", object); + VnfStatusEntity vnfStatusEntity = VnfStatusEntity.toEntity(object); + int result; + if(!checkId(vnfStatusEntity.getVnfInstanceId())) { + result = vnfStatusDao.updateVnfStatus(vnfStatusEntity); + } else { + result = vnfStatusDao.addVnfStatus(vnfStatusEntity); + } + JSONObject resultObj = new JSONObject(); + if(result > 0) { + resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); + } else { + LOGGER.error("function=addVnfStatus; msg=add vnfStatus into DB error."); + resultObj.put("message", "Add vnfStatus into DB error."); + } + return resultObj; + } + + /** + *
+ * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vnfInstanceId) { + VnfStatusEntity vnfStatus = vnfStatusDao.getVnfStatus(vnfInstanceId); + if(null == vnfStatus) { + return true; + } + return false; + } + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List getList(Map map) throws ServiceException { + return vnfStatusDao.getVnfStatuss(map); + } + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return vnfStatusDao.deleteVnfStatusById(id); + } + + public void setVnfStatusDao(VnfStatusDao vnfStatusDao) { + this.vnfStatusDao = vnfStatusDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/GrantResService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/GrantResService.java new file mode 100644 index 0000000..502cba9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/GrantResService.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface GrantResService { + + /** + *
+ * + * @param object + * @return + * @since NFVO 0.5 + */ + JSONObject grantResource(JSONObject object) throws ServiceException; + + JSONObject grantResourceReal(JSONObject object) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/ResOperateService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/ResOperateService.java new file mode 100644 index 0000000..ebd1b7b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/ResOperateService.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * resource operational service class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface ResOperateService { + + /** + * Update iresource.
+ * + * @param tenantId + * @param vimId + * @param header + * @throws ServiceException + * @since NFVO 0.5 + */ + void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; + + /** + * Update all iResource.
+ * + * @throws ServiceException + * @since NFVO 0.5 + */ + void updateAllIRes() throws ServiceException; + + /** + * Add iResource.
+ * + * @param tenantId + * @param vimId + * @param header + * @throws ServiceException + * @since NFVO 0.5 + */ + void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; + + /** + * Delete iResource.
+ * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteIRes(String vimId) throws ServiceException; + + /** + *
+ * + * @param operateType + * @param vimId + * @throws ServiceException + * @since NFVO 0.5 + */ + void sendMsgMonitor(String operateType, String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VirtualLinkService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VirtualLinkService.java new file mode 100644 index 0000000..aaca1b9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VirtualLinkService.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +public interface VirtualLinkService { + + /** + *
+ * + * @param virtualLinkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException; + + /** + *
+ * + * @param map + * @return + * @since NFVO 0.5 + */ + List getList(Map map) throws ServiceException; + + /** + *
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VmService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VmService.java new file mode 100644 index 0000000..98d9565 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VmService.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VmEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VmService { + + JSONObject addVm(VmEntity vmEntity) throws ServiceException; + + List getList(Map map) throws ServiceException; + + int delete(String id) throws ServiceException; + + int deleteByVnfId(String vnfInstanceId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfInfoService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfInfoService.java new file mode 100644 index 0000000..891a8ac --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfInfoService.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfInfoService { + + JSONObject addVnfInfo(JSONObject object) throws ServiceException; + + List getList(Map map) throws ServiceException; + + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfService.java new file mode 100644 index 0000000..ab4c46d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfService.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfService { + + /** + *
+ * + * @param vnfEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException; + + /** + *
+ * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List getList(Map map) throws ServiceException; + + /** + *
+ * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfStatusService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfStatusService.java new file mode 100644 index 0000000..029dd1a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/group/inf/VnfStatusService.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VnfStatusService { + + JSONObject addVnfStatus(JSONObject object) throws ServiceException; + + List getList(Map map) throws ServiceException; + + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/HostMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/HostMapper.java new file mode 100644 index 0000000..ab3fdc9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/HostMapper.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.HostEntity; + +/** + * Host info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface HostMapper { + + /** + * It is used to get Host info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * It is used to get Hosts info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getHosts(Map condition); + + /** + * It is used to delete Hosts info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHost(String id); + + /** + * It is used to delete Hosts info.
+ * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId); + + /** + * It is used to add Hosts info.
+ * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity); + + /** + * It is used to add Hosts info.
+ * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity); + + /** + * It is used to update Hosts info.
+ * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/LocationMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/LocationMapper.java new file mode 100644 index 0000000..b06fd55 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/LocationMapper.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; + +/** + * + * Location Mapper Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationMapper { + + /** + * + * Get location.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + LocationEntity getLocation(String id); + + /** + * + * Get Country.
+ * + * @return + * @since NFVO 0.5 + */ + List getCountry(); + + /** + * + * Get location by country.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getLocationByCountry(Map condition); + + /** + * + * get locations.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getLocations(Map condition); + + /** + * + * Delete location.
+ * + * @param location + * @return + * @since NFVO 0.5 + */ + int deleteLocation(String location); + + /** + * + * Add location.
+ * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int addLocation(LocationEntity locationEntity); + + /** + * + * Add selective location.
+ * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity locationEntity); + + /** + * + * Update selective location.
+ * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity locationEntity); + + /** + * + * Update location.
+ * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity locationEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/NetworkMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/NetworkMapper.java new file mode 100644 index 0000000..6b71ca0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/NetworkMapper.java @@ -0,0 +1,125 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; + +/** + * + * Network Mapper Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkMapper { + + /** + * + * Get network details.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of networks.
+ * + * @param condition + * @return + * @since NFVO 0.5 + */ + List getNetworks(Map condition); + + /** + * + * Delete network.
+ * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteNetwork(String id); + + /** + * + * Delete network by VIM ID.
+ * + * @param vimId + * @return + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId); + + /** + * + * Add network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity); + + /** + * + * Add selective network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update selective network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update network.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity); + + /** + * + * Update network by VIM Id.
+ * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/PortMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/PortMapper.java new file mode 100644 index 0000000..d14b476 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/PortMapper.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.PortEntity; + +/** + * Port info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface PortMapper { + + /** + * It is used to get Port info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * It is used to get Ports info.
+ * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List getPorts(Map condition); + + /** + * It is used to delete Ports info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deletePort(String id); + + /** + * It is used to delete Ports info.
+ * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId); + + /** + * It is used to add Ports info.
+ * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity); + + /** + * It is used to add Ports info.
+ * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity); + + /** + * It is used to update Ports info.
+ * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/SitesMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/SitesMapper.java new file mode 100644 index 0000000..28407c3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/SitesMapper.java @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; + +/** + * ResPool info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesMapper { + + /** + * It is used to get Sites info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + SitesEntity getSite(String id); + + /** + * + * It is used to get Sites info.
+ * + * @param map + * @return + * @since NFVO 0.5 + */ + List getSites(Map map); + + /** + * It is used to get Sites info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + int deleteSite(String id); + + /** + * + * It is used to delete Site info.
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int addSite(SitesEntity entity); + + /** + * + * It is used to add Sites info.
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity entity); + + /** + * + * It is used to add Site info.
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity entity); + + /** + * + * It is used to update Sites info.
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSite(SitesEntity entity); + + /** + * + * It is used to update Site info.
+ * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity entity); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VimMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VimMapper.java new file mode 100644 index 0000000..6963637 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VimMapper.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; + +import org.onap.vfc.nfvo.res.service.entity.VimEntity; + +/** + * Vim info interface.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimMapper { + + /** + * It is used to get Vim info.
+ * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vims info.
+ * + * @return The get result + * @since NFVO 0.5 + */ + List getVims(); + + /** + * It is used to delete Vim info.
+ * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteVim(String id); + + /** + * It is used to add Vim info.
+ * + * @param vimEntity + * @return The add result + * @since NFVO 0.5 + */ + int addVim(VimEntity vimEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VirtualLinkMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VirtualLinkMapper.java new file mode 100644 index 0000000..5a1294b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VirtualLinkMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; + +public interface VirtualLinkMapper { + + int deleteByPrimaryKey(String id); + + int insert(VirtualLinkEntity record); + + int insertSelective(VirtualLinkEntity record); + + VirtualLinkEntity selectByPrimaryKey(String id); + + List getVls(Map condition); + + int updateByPrimaryKeySelective(VirtualLinkEntity record); + + int updateByPrimaryKey(VirtualLinkEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VmMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VmMapper.java new file mode 100644 index 0000000..51fea63 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VmMapper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VmEntity; + +public interface VmMapper { + + int deleteByPrimaryKey(String vmId); + + int deleteByVnfId(String vnfInstanceId); + + int insert(VmEntity record); + + int insertSelective(VmEntity record); + + VmEntity selectByPrimaryKey(String vmId); + + List getVms(Map condition); + + int updateByPrimaryKeySelective(VmEntity record); + + int updateByPrimaryKey(VmEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfInfoMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfInfoMapper.java new file mode 100644 index 0000000..c7a51ae --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfInfoMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; + +public interface VnfInfoMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfInfoEntity record); + + int insertSelective(VnfInfoEntity record); + + VnfInfoEntity selectByPrimaryKey(String vnfInstanceId); + + List getVnfInfos(Map condition); + + int updateByPrimaryKeySelective(VnfInfoEntity record); + + int updateByPrimaryKey(VnfInfoEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfMapper.java new file mode 100644 index 0000000..39bbeff --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; + +public interface VnfMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfEntity record); + + int insertSelective(VnfEntity record); + + VnfEntity selectByPrimaryKey(String id); + + List getVnfs(Map condition); + + int updateByPrimaryKeySelective(VnfEntity record); + + int updateByPrimaryKey(VnfEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfStatusMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfStatusMapper.java new file mode 100644 index 0000000..75dd652 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/mapper/VnfStatusMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; + +public interface VnfStatusMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfStatusEntity record); + + int insertSelective(VnfStatusEntity record); + + VnfStatusEntity selectByPrimaryKey(String vnfInstanceId); + + List getVnfStatuss(Map condition); + + int updateByPrimaryKeySelective(VnfStatusEntity record); + + int updateByPrimaryKey(VnfStatusEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/GrantResourseRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/GrantResourseRoa.java new file mode 100644 index 0000000..7affca5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/GrantResourseRoa.java @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.service.group.inf.GrantResService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.GRANTRES_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class GrantResourseRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(GrantResourseRoa.class); + + private GrantResService grantResService; + + @PUT + @Path("/stub") + public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); + } + + LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); + try { + return grantResService.grantResource(object); + } catch(ServiceException se) { + LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @PUT + public JSONObject grantResourceReal(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); + } + + LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); + try { + return grantResService.grantResourceReal(object); + } catch(ServiceException se) { + LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setGrantResService(GrantResService grantResService) { + this.grantResService = grantResService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/HostRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/HostRoa.java new file mode 100644 index 0000000..b8ab7b7 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/HostRoa.java @@ -0,0 +1,183 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Host; +import org.onap.vfc.nfvo.res.service.entity.HostEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Host ROA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.HOST_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class HostRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(HostRoa.class); + + private Host host; + + /** + * + * Get hosts.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getHosts(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List hosts = host.getList(map); + + JSONObject result = new JSONObject(); + result.put("hosts", hosts); + return result; + } + + /** + * + * Get host.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{hostId}") + public JSONObject getHost(@Context HttpServletRequest context, @PathParam("hostId") String id) + throws ServiceException { + LOGGER.info("HostRoa::getHost id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List hosts = host.getList(map); + + JSONObject result = new JSONObject(); + result.put("hosts", hosts); + return result; + } + + /** + * + * Add host.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + public JSONObject addHost(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("HostRoa::addHost:{}", object.toString()); + try { + int result = host.add(object); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::addHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete host.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + public JSONObject deleteHost(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("HostRoa::deleteHost id:{}", id); + try { + int result = host.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::deleteHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update host.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + public JSONObject updateHost(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("HostRoa::updateHost:{}", object.toString()); + try { + int result = host.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::updateHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setHost(Host host) { + this.host = host; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LimitsRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LimitsRoa.java new file mode 100644 index 0000000..849e64d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LimitsRoa.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.service.business.inf.LimitsBusiness; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.LIMITS_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class LimitsRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(LimitsRoa.class); + + private LimitsBusiness limitsBusiness; + + /** + *
+ * + * @param context + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getLimits(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + LOGGER.warn("function=getLimits, vimId={}", vimId); + return limitsBusiness.getLimits(vimId); + } + + public void setLimitsBusiness(LimitsBusiness limitsBusiness) { + this.limitsBusiness = limitsBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LocationRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LocationRoa.java new file mode 100644 index 0000000..b982b4c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/LocationRoa.java @@ -0,0 +1,316 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.JsonUtil; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Location; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.entity.LocationEntity; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Location ROA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.LOCATION_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class LocationRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationRoa.class); + + private Location location; + + private Sites sites; + + /** + * Get Locations Base.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getLocationsbase(@Context HttpServletRequest context) throws ServiceException { + Map condition = new HashMap<>(); + List locations = location.get(condition); + + JSONObject result = new JSONObject(); + result.put("locations", locations); + return result; + } + + /** + * Get Locations Base.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{locationId}") + public JSONObject getLocationbase(@Context HttpServletRequest context, @PathParam("locationId") String id) + throws ServiceException { + LOGGER.info("LocationRoa::getLocationbase id:{}", id); + Map map = new HashMap<>(); + map.put(ParamConstant.PARAM_ID, id); + List locations = location.get(map); + + JSONObject result = new JSONObject(); + result.put("locations", locations); + return result; + } + + /** + * Get Country.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/country") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getCountry(@Context HttpServletRequest context) throws ServiceException { + return RoaResponseUtil.get(location.getCountry()); + } + + /** + * Get Location by Country.
+ * + * @param context + * @param country + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/locationbycountry") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getLocationByCountry(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_COUNTRY) String country) throws ServiceException { + LOGGER.info("LocationRoa::getLocationByCountry country:{}", country); + Map condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_COUNTRY, country); + return RoaResponseUtil.get(location.getLocationByCountry(condition)); + } + + /** + * Get Cloud Service.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/cloudservice") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getCloudservice(@Context HttpServletRequest context) throws ServiceException { + return RoaResponseUtil.get(location.getCloudservice()); + } + + /** + * Get location details.
+ * + * @param context + * @param locations + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/site") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getLocation(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { + LOGGER.info("LocationRoa::getLocation locations:{}", locations); + Map condition = new HashMap<>(); + List loca = new ArrayList(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + loca = location.get(condition); + LOGGER.info("LocationRoa::getLocation loca:{}", loca); + return RoaResponseUtil.get(location.getLocationInfo(loca)); + } + + /** + * Add Location.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject addLocation(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("LocationRoa::addLocation : " + object.toString()); + try { + int result = location.add(object); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::addLocation error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete Location Base.
+ * + * @param context + * @param locations + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Path("/{location}") + public JSONObject deleteLocationbase(@Context HttpServletRequest context, + @PathParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { + LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); + Map condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + try { + int result = location.delete(locations); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::deleteLocationbase error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete Location.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject deleteLocation(@Context HttpServletRequest context) throws ServiceException { + + JSONObject object = RequestUtil.getJsonRequestBody(context); + String locations = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); + String id = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_ID); + LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); + + Map condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + SitesEntity sitesEntity = sites.get(condition); + try { + if(sitesEntity != null) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.used.check")); + } + int result = location.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::deleteLocation error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Update Location.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject updateLocation(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + String local = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); + Map localInfo = new HashMap<>(); + localInfo.put(ParamConstant.PARAM_LOCATION, local); + SitesEntity sitesEntity = sites.get(localInfo); + if(sitesEntity != null) { + LOGGER.error("function=updateLocation; msg=update error, because location is used."); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.used.check")); + } + LOGGER.info("LocationRoa::updateLocation : " + object.toString()); + + try { + int result = location.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::update Location error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setLocation(Location location) { + this.location = location; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/NetworkRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/NetworkRoa.java new file mode 100644 index 0000000..7f9d0f5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/NetworkRoa.java @@ -0,0 +1,189 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Network; +import org.onap.vfc.nfvo.res.service.entity.NetworkEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Network ROA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.NETWORKS_URL) +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public class NetworkRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkRoa.class); + + private Network network; + + /** + * + * Get details of networks.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getNetworks(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List networks = network.getList(map); + + JSONObject result = new JSONObject(); + result.put("networks", networks.toString()); + return result; + } + + /** + * + * Get network details.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{networkId}") + public JSONObject getNetwork(@Context HttpServletRequest context, @PathParam("networkId") String id) + throws ServiceException { + LOGGER.info("NetworkRoa::getNetwork id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List networks = network.getList(map); + + JSONObject result = new JSONObject(); + result.put("networks", networks.toString()); + return result; + } + + /** + * + * Add network.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject addNetwork(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("NetworkRoa::addNetwork:{}", object.toString()); + try { + int result = network.add(NetworkEntity.toEntity(object)); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::addNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete network.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject deleteNetwork(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("NetworkRoa::deleteNetwork id:{}", id); + try { + int result = network.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::deleteNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update network.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject updateNetwork(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("NetworkRoa::updateNetwork:{}", object.toString()); + try { + int result = network.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::updateNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setNetwork(Network network) { + this.network = network; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/PortRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/PortRoa.java new file mode 100644 index 0000000..952e326 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/PortRoa.java @@ -0,0 +1,183 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Port; +import org.onap.vfc.nfvo.res.service.entity.PortEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Port ROA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.PORT_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class PortRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortRoa.class); + + private Port port; + + /** + * + * Get details of Ports.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getPorts(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List ports = port.getList(map); + + JSONObject result = new JSONObject(); + result.put("ports", ports); + return result; + } + + /** + * + * Get port details.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{portId}") + public JSONObject getPort(@Context HttpServletRequest context, @PathParam("portId") String id) + throws ServiceException { + LOGGER.info("PortRoa::getPort id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List ports = port.getList(map); + + JSONObject result = new JSONObject(); + result.put("ports", ports); + return result; + } + + /** + * + * Add port.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + public JSONObject addPort(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("PortRoa::addPort:{}", object.toString()); + try { + int result = port.add(PortEntity.toEntity(object)); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::addPort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete port.
+ * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + public JSONObject deletePort(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("PortRoa::deletePort id:{}", id); + try { + int result = port.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::deletePort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update port.
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + public JSONObject updatePort(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("PortRoa::updatePort:{}", object.toString()); + try { + int result = port.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::updatePort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setPort(Port port) { + this.port = port; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/ResOperateRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/ResOperateRoa.java new file mode 100644 index 0000000..111160e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/ResOperateRoa.java @@ -0,0 +1,151 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.group.inf.ResOperateService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Resource Operate ROA Class.
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.RESOPERATE_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class ResOperateRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateRoa.class); + + private ResOperateService resOperateService; + + /** + * Update iResource pool.
+ * + * @param context + * @param tenantId + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Path(UrlConstant.MODRES_URL) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject updateIResPool(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + LOGGER.warn("ResPoolRoa::modVimId :{}", vimId); + JSONObject vimInfo = VimUtil.getVimById(vimId); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + try { + resOperateService.updateIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("update", vimId); + return RoaResponseUtil.update(HttpConstant.OK_CODE); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::updateIResPool error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Add all resource pool.
+ * + * @param context + * @param tenantId + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Path(UrlConstant.ADDRES_URL) + @Consumes(UrlConstant.APPLICATION_TYPE) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject addAllResPool(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_TENANTID) String tenantId, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + LOGGER.warn("ResOperateRoa::vimId :{}", vimId); + + try { + resOperateService.addIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("create", vimId); + return RoaResponseUtil.add(HttpConstant.OK_CODE); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::addAllResPool error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete iResource.
+ * + * @param context + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject deleteIRes(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + LOGGER.warn("ResOperateRoa::deleteIResource vimId:{}", vimId); + + try { + resOperateService.sendMsgMonitor("delete", vimId); + int result = resOperateService.deleteIRes(vimId); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::deleteIRes error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setResOperateService(ResOperateService resOperateService) { + this.resOperateService = resOperateService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SitesRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SitesRoa.java new file mode 100644 index 0000000..6d31aa8 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SitesRoa.java @@ -0,0 +1,224 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.VimUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.base.openstack.inf.Sites; +import org.onap.vfc.nfvo.res.service.entity.SitesEntity; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Sites ROA method
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +@Path(UrlConstant.SITES_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SitesRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesRoa.class); + + private Sites sites; + + /** + * getSites ROA method
+ * + * @param context + * @return the get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + @GET + public JSONObject getSites(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap(10); + List datacenters = sites.getList(map); + + JSONObject result = new JSONObject(); + result.put("datacenters", datacenters); + return result; + } + + /** + * getSite ROA method
+ * + * @param context + * @param id + * @return the get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + @GET + @Path("/{datacenterId}") + public JSONObject getSite(@Context HttpServletRequest context, @PathParam("datacenterId") String id) + throws ServiceException { + LOGGER.warn("SitesRoa::getSitesById id:{}", id); + Map map = new HashMap(10); + map.put(ParamConstant.PARAM_ID, id); + List datacenters = sites.getList(map); + + JSONObject result = new JSONObject(); + result.put("datacenters", datacenters); + return result; + } + + /** + * addSites ROA method
+ * + * @param context + * @param id + * @return the add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + @POST + public JSONObject addSites(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa:: start add Sites"); + try { + int result = sites.add(json); + sites.sendToMonitor(json); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::addSites error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * deleteSites ROA method
+ * + * @param context + * @param id + * @return the delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + @DELETE + @Path("/{datacenterId}") + public JSONObject deleteSites(@Context HttpServletRequest context, @PathParam("datacenterId") String id) + throws ServiceException { + LOGGER.warn("SitesRoa::deleteSites siteId:{}", id); + try { + int result = sites.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::deleteSites error: " + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * updateSites ROA method
+ * + * @param context + * @param id + * @return the update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + @PUT + public JSONObject updateSites(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa::start update Sites"); + try { + int result = sites.update(SitesEntity.toEntity(json)); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::updateSites error:" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * grant resource method + *
+ * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Path("/grant") + public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa::grant resource"); + try { + int result = sites.update(json); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::grant resource:" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @GET + @Path("/vims") + public String getVims(@Context HttpServletRequest context) throws ServiceException { + LOGGER.info("SitesRoa::get vims"); + JSONArray vims = VimUtil.getVims(); + JSONObject result = new JSONObject(); + result.put("data", vims); + return result.toString(); + } + + @GET + @Path("/vims/{vimId}") + public String getVim(@Context HttpServletRequest context, @PathParam("vimId") String vimId) + throws ServiceException { + LOGGER.info("SitesRoa::get vim by id: {}", vimId); + return VimUtil.getVimById(vimId).toString(); + } + + public void setSites(Sites sites) { + this.sites = sites; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SwaggerRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SwaggerRoa.java new file mode 100644 index 0000000..45ea2c1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/SwaggerRoa.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.io.IOException; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.IOUtils; + +/** + * Swagger API Doc.
+ * + * @author + * @version NFVO 0.5 Oct 24, 2016 + */ +@Path("/v1") +@Produces({MediaType.APPLICATION_JSON}) +public class SwaggerRoa { + /** + * API doc. + * @param filename + * @return + * @throws IOException + */ + @GET + @Path("/swagger.json") + public String apidoc() throws IOException{ + ClassLoader classLoader = getClass().getClassLoader(); + return IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VirtualLinkRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VirtualLinkRoa.java new file mode 100644 index 0000000..a30d673 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VirtualLinkRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.entity.VirtualLinkEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VirtualLinkService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +@Path(UrlConstant.VL_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VirtualLinkRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); + + private VirtualLinkService virtualLink; + + @GET + public JSONObject getVls(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List vls = virtualLink.getList(map); + LOGGER.info("VirtualLinkRoa::getVls:{}", vls.toString()); + JSONObject result = new JSONObject(); + result.put("vls", vls); + return result; + } + + @GET + @Path("/{vlId}") + public JSONObject getVl(@Context HttpServletRequest context, @PathParam("vlId") String id) throws ServiceException { + LOGGER.info("VirtualLinkRoa::getVl id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List vls = virtualLink.getList(map); + LOGGER.info("VirtualLinkRoa::getVl:{}", vls.toString()); + JSONObject result = new JSONObject(); + result.put("vls", vls); + return result; + } + + @POST + public JSONObject addVl(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVl; msg=add error, because vl is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.add.null")); + } + + LOGGER.info("VirtualLinkRoa::addVl:{}", object.toString()); + try { + return virtualLink.addVl(VirtualLinkEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VirtualLinkRoa::addVl error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVl(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVl; msg=delete error, because vlId is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.delete.vlId.null")); + } + LOGGER.info("VirtualLinkRoa::deleteVl id:{}", id); + try { + int result = virtualLink.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VirtualLinkRoa::deleteVl error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVirtualLink(VirtualLinkService virtualLink) { + this.virtualLink = virtualLink; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VmRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VmRoa.java new file mode 100644 index 0000000..5b17caa --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VmRoa.java @@ -0,0 +1,127 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.entity.VmEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VmService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.VM_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VmRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VmRoa.class); + + private VmService vmService; + + @GET + public JSONObject getVms(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List vms = vmService.getList(map); + LOGGER.info("VmRoa::getVms:{}", vms.toString()); + JSONObject result = new JSONObject(); + result.put("vms", vms); + return result; + } + + @GET + @Path("/{vmId}") + public JSONObject getVm(@Context HttpServletRequest context, @PathParam("vmId") String id) throws ServiceException { + LOGGER.info("VmRoa::getVm id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List vms = vmService.getList(map); + LOGGER.info("VmRoa::getVm:{}", vms.toString()); + JSONObject result = new JSONObject(); + result.put("vms", vms); + return result; + } + + @POST + public JSONObject addVm(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVm; msg=add error, because vm is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.add.null")); + } + + LOGGER.info("VmRoa::addVm:{}", object.toString()); + try { + return vmService.addVm(VmEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VmRoa::addVm error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVm(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVm; msg=delete error, because id is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.delete.id.null")); + } + LOGGER.info("VmRoa::deleteVm id:{}", id); + try { + int result = vmService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VmRoa::deleteVm error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVmService(VmService vmService) { + this.vmService = vmService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfInfoRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfInfoRoa.java new file mode 100644 index 0000000..c4f631c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfInfoRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.entity.VnfInfoEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VnfInfoService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +@Path(UrlConstant.VNFINFO_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfInfoRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoRoa.class); + + private VnfInfoService vnfInfoService; + + @GET + public JSONObject getVnfInfos(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List vnfInfos = vnfInfoService.getList(map); + LOGGER.info("VnfInfoRoa::getVnfInfos:{}", vnfInfos.toString()); + JSONObject result = new JSONObject(); + result.put("vnfInfos", vnfInfos); + return result; + } + + @GET + @Path("/{id}") + public JSONObject getVnfInfo(@Context HttpServletRequest context, @PathParam("id") String id) + throws ServiceException { + LOGGER.info("VnfInfoRoa::getVnfInfo id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List vnfInfos = vnfInfoService.getList(map); + LOGGER.info("VnfInfoRoa::getVnfInfo:{}", vnfInfos.toString()); + JSONObject result = new JSONObject(); + result.put("vnfInfos", vnfInfos); + return result; + } + + @POST + public JSONObject addVnfInfo(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnfInfo; msg=add error, because vnfInfo is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.add.null")); + } + + LOGGER.info("VnfInfoRoa::addVnfInfo:{}", object.toString()); + try { + return vnfInfoService.addVnfInfo(object); + } catch(ServiceException se) { + LOGGER.error("VnfInfoRoa::addVnfInfo error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnfInfo(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnfInfo; msg=delete error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.delete.id.null")); + } + LOGGER.info("VnfInfoRoa::deleteVnfInfo id:{}", id); + try { + int result = vnfInfoService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfInfoRoa::deleteVnfInfo error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfInfoService(VnfInfoService vnfInfoService) { + this.vnfInfoService = vnfInfoService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfRoa.java new file mode 100644 index 0000000..a60842b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfRoa.java @@ -0,0 +1,128 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.entity.VnfEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VnfService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +@Path(UrlConstant.VNF_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); + + private VnfService vnfService; + + @GET + public JSONObject getVnfs(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List vnfs = vnfService.getList(map); + LOGGER.info("VnfRoa::getVnfs:{}", vnfs.toString()); + JSONObject result = new JSONObject(); + result.put("vnfs", vnfs); + return result; + } + + @GET + @Path("/{vnfId}") + public JSONObject getVnf(@Context HttpServletRequest context, @PathParam("vnfId") String id) + throws ServiceException { + LOGGER.info("VnfRoa::getVnf id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List vnfs = vnfService.getList(map); + LOGGER.info("VnfRoa::getVnf:{}", vnfs.toString()); + JSONObject result = new JSONObject(); + result.put("vnfs", vnfs); + return result; + } + + @POST + public JSONObject addVnf(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnf; msg=add error, because vnf is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.add.null")); + } + + LOGGER.info("VnfRoa::addVnf:{}", object.toString()); + try { + return vnfService.addVnf(VnfEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VnfRoa::addVnf error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnf(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnf; msg=delete error, because id is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.delete.id.null")); + } + LOGGER.info("VnfRoa::deleteVnf id:{}", id); + try { + int result = vnfService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfRoa::deleteVnf error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfService(VnfService vnfService) { + this.vnfService = vnfService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfStatusRoa.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfStatusRoa.java new file mode 100644 index 0000000..d67c11b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/VnfStatusRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.onap.vfc.nfvo.res.common.ResourceUtil; +import org.onap.vfc.nfvo.res.common.constant.HttpConstant; +import org.onap.vfc.nfvo.res.common.constant.ParamConstant; +import org.onap.vfc.nfvo.res.common.constant.UrlConstant; +import org.onap.vfc.nfvo.res.common.util.request.RequestUtil; +import org.onap.vfc.nfvo.res.common.util.response.ResponseUtil; +import org.onap.vfc.nfvo.res.common.util.response.RoaResponseUtil; +import org.onap.vfc.nfvo.res.service.entity.VnfStatusEntity; +import org.onap.vfc.nfvo.res.service.group.inf.VnfStatusService; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.VNFSTATUS_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfStatusRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusRoa.class); + + private VnfStatusService vnfStatusService; + + @GET + public JSONObject getVnfStatuss(@Context HttpServletRequest context) throws ServiceException { + Map map = new HashMap<>(10); + List vnfStatus = vnfStatusService.getList(map); + LOGGER.info("VnfStatusRoa::getVnfStatuss:{}", vnfStatus.toString()); + JSONObject result = new JSONObject(); + result.put("vnfStatus", vnfStatus); + return result; + } + + @GET + @Path("/{id}") + public JSONObject getVnfStatus(@Context HttpServletRequest context, @PathParam("id") String id) + throws ServiceException { + LOGGER.info("VnfStatusRoa::getVnfStatus id:{}", id); + Map map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List vnfStatus = vnfStatusService.getList(map); + LOGGER.info("VnfStatusRoa::getVnfStatus:{}", vnfStatus.toString()); + JSONObject result = new JSONObject(); + result.put("vnfStatus", vnfStatus); + return result; + } + + @POST + public JSONObject addVnfStatus(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnfInfo; msg=add error, because vnfStatus is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.add.null")); + } + + LOGGER.info("VnfStatusRoa::addVnfStatus:{}", object.toString()); + try { + return vnfStatusService.addVnfStatus(object); + } catch(ServiceException se) { + LOGGER.error("VnfStatusRoa::addVnfStatus error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnfStatus(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnfStatus; msg=delete error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.delete.id.null")); + } + LOGGER.info("VnfStatusRoa::deleteVnfStatus id:{}", id); + try { + int result = vnfStatusService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfStatusRoa::deleteVnfStatys error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfStatusService(VnfStatusService vnfStatusService) { + this.vnfStatusService = vnfStatusService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ExceptionMessage.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ExceptionMessage.java new file mode 100644 index 0000000..2529c1f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ExceptionMessage.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest.exceptionmapper; + +import org.apache.http.HttpStatus; + +/** + * Exception response model.
+ * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ExceptionMessage { + + private String errorCode = "unknown.error"; + + private int httpCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; + + private String message; + + @Override + public String toString() { + return "Error {errorCode=" + this.errorCode + ", httpCode=" + this.httpCode + ", message=" + + this.message + "}"; + } + + public String getErrorCode() { + return this.errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getHttpCode() { + return this.httpCode; + } + + public void setHttpCode(int httpCode) { + this.httpCode = httpCode; + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/GenericExceptionMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/GenericExceptionMapper.java new file mode 100644 index 0000000..104c29a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/GenericExceptionMapper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +/** + * Generic exception response provider.
+ * + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +@Provider +public class GenericExceptionMapper implements ExceptionMapper{ + + @Override + public Response toResponse(Exception exception) { + ExceptionMessage message = new ExceptionMessage(); + message.setMessage(exception.getMessage()); + return Response.status(message.getHttpCode()).type( + MediaType.APPLICATION_JSON).entity(message).build(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ServiceExceptionMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ServiceExceptionMapper.java new file mode 100644 index 0000000..27d0c9f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/res/service/rest/exceptionmapper/ServiceExceptionMapper.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.vfc.nfvo.res.service.rest.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * ServiceException response provider.
+ * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +@Provider +public class ServiceExceptionMapper implements ExceptionMapper{ + + @Override + public Response toResponse(ServiceException exception) { + ExceptionMessage message = new ExceptionMessage(); + message.setErrorCode(exception.getId()); + message.setHttpCode(exception.getHttpCode()); + message.setMessage(exception.getMessage()); + return Response.status(message.getHttpCode()). + type(MediaType.APPLICATION_JSON).entity(message).build(); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java deleted file mode 100644 index 572de2b..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public class ResourceUtil { - - private ResourceUtil() { - - } - - /** - * It is used to get Message
- * - * @param key - * @return - * @since NFVO 0.5 - */ - public static String getMessage(String key) { - return key; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java deleted file mode 100644 index 5f2d417..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common; - -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 30, 2016 - */ -public class VimUtil { - - private static final Logger LOG = LoggerFactory.getLogger(VimUtil.class); - - private VimUtil() { - - } - - /** - * Get VIMs. - * - * @return - */ - public static JSONArray getVims() { - String esrResponse = - RestfulUtil.getResponseContent(UrlConstant.ESR_GET_VIMS_URL, new RestfulParametes(), "get"); - LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); - if(null == esrResponse) { - LOG.error("ESR return fail."); - return null; - } else { - return JSONArray.fromObject(esrResponse); - } - - } - - /** - * Get vimId by vimName. - * - * @return - */ - public static String getVimIdByName(String name) { - JSONArray vims = getVims(); - for(int i = 0; i < vims.size(); i++) { - JSONObject vim = vims.getJSONObject(i); - LOG.info("vimInfo: " + vim); - String vimName = vim.getString("name"); - String vimId = vim.getString("vimId"); - LOG.info("name:" + name + ", vimName:" + vimName + ", vimId:" + vimId); - if(name.trim().equalsIgnoreCase(vimName)) { - return vimId; - } - } - LOG.error("No vim with this vimName"); - return ""; - - } - - /** - * Get VIM. - * - * @param vimId - * @return - */ - public static JSONObject getVimById(String vimId) { - if(vimId == null || "".equals(vimId.trim())) { - LOG.error("Get vim ERROR, VimId is null. "); - return null; - } - JSONObject esrResponse = RestfulUtil.getResponseObj(String.format(UrlConstant.ESR_GET_VIM_URL, vimId), "get"); - LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); - if(null == esrResponse) { - LOG.error("ESR return fail."); - return null; - } else { - return esrResponse; - } - } - - /** - * Get tenants. - * - * @param vimId - * @return - */ - public static JSONArray getTenants(String vimId) { - String url = String.format(UrlConstant.GET_TENANT_URL, vimId); - JSONObject resultObj = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); - JSONArray tenants = resultObj.getJSONArray("tenants"); - LOG.info("Get tenants from multivim! tenants:{}", tenants); - return tenants; - } - - /** - *
- * - * @param tenant - * @param vimId - * @return - * @since NFVO 0.5 - */ - public static String getTenantIdByName(String tenant, String vimId) { - JSONArray tenants = VimUtil.getTenants(vimId); - String tenantId = ""; - for(int i = 0; i < tenants.size(); i++) { - JSONObject obj = tenants.getJSONObject(i); - String name = obj.getString("name"); - if(name.equalsIgnoreCase(tenant)) { - tenantId = obj.getString("id"); - } - } - LOG.info("GetTenantIdByName tenantId:{}", tenantId); - return tenantId; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java deleted file mode 100644 index 1e5941d..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.constant; - -/** - * HTTP constants
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public class Constant { - - public static final String RES_MANAGEMENT_DB = "resmanagementdb"; - - /** - * Database Delete/Modify/Add fail. - */ - public static final int ERROR_CODE = -1; - - /** - * Database Delete/Modify/Add success. - */ - public static final int OK_CODE = 1; - - /** - * Lack of resource. - */ - public static final int RES_NOT_ENOUGH_CODE = -2; - - /** - * Module name. - */ - public static final String MODULE_NAME = "Resmanagement"; - - public static final String RESPONSE_CONTENT = "responseContent"; - - public static final String STATUS_CODE = "statusCode"; - - /** - * Format Time - */ - public static final String DATE_FORMATE = "yyyy-MM-dd HH:mm:ss"; - - public static final String DATE_UTC_FORMATE = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - - public static final String UTC_FORMATE = "UTC"; - - public static final String DATE_DAY_FORMATE = "yyyy-MM-dd 00:00:00"; - - /** - * IAM - */ - - public static final String HTTP_CONTENT_TYPE = "Content-Type"; - - public static final String HTTP_CONTENT_TYPE_VALUE = "application/json;charset=UTF-8"; - - public static final String X_TENANT_ID = "X-Tenant-Id"; - - public static final String IAM_TOKEN = "x-auth-token"; - - public static final String IAM_AUTH_TOKEN = "X-Auth-Token"; - - public static final String IAM_USER_ID = "X-User-Id"; - - public static final String IAM_USER_NAME = "X-User-Name"; - - public static final String IAM_DOMAIN_NAME = "X-Domain-Name"; - - public static final String HEADER_SUBJECT_TOKEN = "X-Subject-Token"; - - public static final int REPEAT_REG_TIME = 60 * 1000; - - private Constant() { - // private constants - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java deleted file mode 100644 index f480b70..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.constant; - -/** - * - * Http constant class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class HttpConstant { - - public static final int ERROR_CODE = -1; - - public static final int OK_CODE = 1; - - public static final int HTTP_OK = 200; - - public static final int HTTP_CREATED = 201; - - public static final int HTTP_ACCEPTED = 202; - - public static final int HTTP_NOCONTENT = 204; - - public static final int HTTP_UNAUTHORIZED = 401; - - public static final int HTTP_BAD_REQUEST = 400; - - public static final int HTTP_NOTFOUND_CODE = 404; - - public static final int HTTP_CONFLICT_CODE = 409; - - public static final int HTTP_INVALID_PARAMETERS = 415; - - public static final int HTTP_INNERERROR_CODE = 500; - - public static final int INTERNAL_EXCEPTION_CODE = 600; - - public static final int TOKEN_HEAD_NULL_CODE = 601; - - public static final int TOKEN_USER_NULL_CODE = 602; - - public static final int SERVICE_URL_ERROR_CODE = 603; - - public static final int ACCESS_OBJ_NULL_CODE = 604; - - public static final int CONNECT_NOT_FOUND_CODE = 605; - - public static final int VCENTER_PARA_ERROR_CODE = 606; - - public static final int TYPE_PARA_ERROR_CODE = 607; - - public static final int CONNECT_FAIL_CODE = 608; - - public static final int DIS_CONNECT_FAIL_CODE = 609; - - public static final int HANDSHAKE_FAIL_CODE = 610; - - private HttpConstant() { - //private constructor - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java deleted file mode 100644 index 9ba0c4c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.constant; - -/** - *
- *

- * Contstant for System interactive. - *

- * - * @author - * @version NFVO 0.5 2016-3-17 - */ -public class ParamConstant { - - /** - * param key: vimId. - */ - public static final String PARAM_VIMID = "vimId"; - - /** - * param key: vimName - */ - public static final String PARAM_VIMNAME = "vimName"; - - /** - * param key: tenantId. - */ - public static final String PARAM_TENANTID = "tenantId"; - - public static final String TOTAL_CPU = "totalCPU"; - - public static final String USED_CPU = "usedCPU"; - - public static final String TOTAL_MEMORY = "totalMemory"; - - public static final String USED_MEMORY = "usedMemory"; - - public static final String TOTAL_DISK = "totalDisk"; - - public static final String USED_DISK = "usedDisk"; - - /** - * param key: data. - */ - public static final String PARAM_DATA = "data"; - - /** - * param key: id. - */ - public static final String PARAM_ID = "id"; - - /** - * param key: vimId - */ - public static final String PARAM_IP = "ip"; - - /** - * param key: role. - */ - public static final String PARAM_ROLE = "role"; - - /** - * param key: roleId. - */ - public static final String PARAM_ROLEID = "roleId"; - - /** - * param key: total. - */ - public static final String PARAM_TOTAL = "total"; - - /** - * param key: used. - */ - public static final String PARAM_USED = "used"; - - /** - * param key: vcpus. - */ - public static final String PARAM_VCPUS = "vcpus"; - - /** - * param key: disk. - */ - public static final String PARAM_DISK = "disk"; - - /** - * param key: cpumhz. - */ - public static final String PARAM_CPUMHZ = "cpumhz"; - - /** - * param key: countyr - */ - public static final String PARAM_COUNTRY = "country"; - - /** - * param key: vendorId - */ - public static final String PARAM_VENDORID = "vendorId"; - - /** - * param key: vendorName - */ - public static final String PARAM_VENDORNAME = "vendorName"; - - /** - * param key: memory. - */ - public static final String PARAM_MEMORY = "memory"; - - /** - * param key: name. - */ - public static final String PARAM_NAME = "name"; - - /** - * param key: status. - */ - public static final String PARAM_STATUS = "status"; - - /** - * param key: parent. - */ - public static final String PARAM_PARENT = "parent"; - - /** - * param key: location. - */ - public static final String PARAM_LOCATION = "location"; - - /** - * param key: siteName. - */ - public static final String PARAM_SITENAME = "siteName"; - - /** - * param key: vendor. - */ - public static final String PARAM_VENDOR = "vendor"; - - /** - * param key: vendors. - */ - public static final String PARAM_VENDORS = "vendors"; - - /** - * param key: tenantSites. - */ - public static final String PARAM_TENANTSITES = "tenantSites"; - - /** - * param key: siteId. - */ - public static final String PARAM_SITEID = "siteId"; - - /** - * param key: resArbitration. - */ - public static final String PARAM_RESARBITRATION = "resArbitration"; - - /** - * param key: userRole. - */ - public static final String PARAM_USERROLE = "userRole"; - - /** - * param key: admin. - */ - public static final String PARAM_ADMIN = "admin"; - - /** - * param key: tenant. - */ - public static final String PARAM_TENANT = "tenant"; - - /** - * param key: type. - */ - public static final String PARAM_TYPE = "type"; - - /** - * param key: action. - */ - public static final String PARAM_ACTION = "action"; - - /** - * param key: offline. - */ - public static final String PARAM_OFFLINE = "offline"; - - /** - * param key: online. - */ - public static final String PARAM_ONLINE = "online"; - - /** - * param key: drexecute. - */ - public static final String PARAM_DREXECUTE = "drexecute"; - - /** - * param key: drRollBack. - */ - public static final String PARAM_DRROLLBACK = "drrollback"; - - /** - * param key: scaleOut. - */ - public static final String PARAM_SCALEOUT = "scaleout"; - - /** - * param key: scaleIn. - */ - public static final String PARAM_SCALEIN = "scalein"; - - /** - * param key: network. - */ - public static final String PARAM_NETWORK = "networks"; - - /** - * param key: host. - */ - public static final String PARAM_HOST = "hosts"; - - /** - * param key: network. - */ - public static final String PARAM_PORT = "ports"; - - /** - * param key: providernetworks. - */ - public static final String PARAM_PROVIDERNETWORKS = "providernetworks"; - - /** - * param key: vims. - */ - public static final String PARAM_VIMS = "vims"; - - /** - * param key: vms. - */ - public static final String PARAM_VMS = "vms"; - - /** - * param key: vapps. - */ - public static final String PARAM_VAPPS = "vapps"; - - /** - * param key: vapp. - */ - public static final String PARAM_VAPP = "vapp"; - - /** - * param key: sites. - */ - public static final String PARAM_SITES = "sites"; - - /** - * param key: vduId. - */ - public static final String PARAM_VDUID = "vduId"; - - /** - * param key: vappId. - */ - public static final String PARAM_VAPPID = "vappId"; - - /** - * param key: hostId. - */ - public static final String PARAM_HOSTID = "hostId"; - - /** - * param key: projectId. - */ - public static final String PARAM_PROJECTID = "projectId"; - - /** - * param key: vnfmId. - */ - public static final String PARAM_VNFMID = "vnfmId"; - - /** - * param key: params. - */ - public static final String PARAM_PARAMS = "params"; - - /** - * param key: url. - */ - public static final String PARAM_URL = "url"; - - /** - * param key: post. - */ - public static final String PARAM_POST = "post"; - - /** - * param key: put. - */ - public static final String PARAM_PUT = "put"; - - /** - * param key: del. - */ - public static final String PARAM_DEL = "del"; - - /** - * param key: get. - */ - public static final String PARAM_GET = "get"; - - /** - * param key: retCode. - */ - public static final String PARAM_RETCODE = "retCode"; - - /** - * param key: ADD. - */ - public static final String PARAM_ADD = "add"; - - /** - * param key: active. - */ - public static final String PARAM_ACTIVE = "active"; - - /** - * param key: deleted. - */ - public static final String PARAM_DELETED = "deleted"; - - /** - * param key: deleting. - */ - public static final String PARAM_DELETING = "deleting"; - - /** - * param key: response - */ - public static final String PARAM_RESPONSE = "response"; - - /** - * param key: info - */ - public static final String PARAM_INFO = "info"; - - private ParamConstant() { - // private constructor - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java deleted file mode 100644 index a4fe9e0..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.constant; - -import org.openo.nfvo.resmanagement.common.ResourceUtil; - -/** - * Response constants.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public class ResponseConstant { - - public static final String ADD_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.success"); - - public static final String ADD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.error"); - - public static final String DEL_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.success"); - - public static final String DEL_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.error"); - - public static final String MOD_SUCESS_MSG = - ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.success"); - - public static final String MOD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.error"); - - public static final String QUERY_SUCESS_MSG = - ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.success"); - - public static final String QUERY_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.error"); - - public static final String DELSODORES_FAIL_MSG = "delete sodores error"; - - public static final String DELVNFMINFO_FAIL_MSG = "delete vnfm error"; - - public static final String RES_VERIFY_SUCESS_MSG = "nsdata verify sucessfully"; - - public static final String RES_VERIFY_FAIL_MSG = "res verify failed"; - - private ResponseConstant() { - // private constructor - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java deleted file mode 100644 index b9a93a1..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.constant; - -/** - *
- *

- * Constant for REST URL. - *

- * - * @author - * @version NFVO 0.5 2016-3-17 - */ -public class UrlConstant { - - /** - * networks target. - */ - public static final String LOCATION_TARGET = "location"; - - /** - * MSB register url. - */ - public static final String REST_MSB_REGISTER = "/openoapi/microservices/v1/services"; - - public static final String ESR_GET_VIM_URL = "/openoapi/extsys/v1/vims/%s"; - - public static final String ESR_GET_VIMS_URL = "/openoapi/extsys/v1/vims"; - - /** - * send resource info to monitor url - */ - public static final String SEND_MSG_MONITOR = "/openoapi/umc/v1/resinfo"; - - /** - * networks url. - */ - public static final String LOCATION_URL = "/v1/locations"; - - /** - * port url. - */ - public static final String PORT_URL = "/v1/ports"; - - /** - * host url. - */ - public static final String HOST_URL = "/v1/hosts"; - - /** - * vl url. - */ - public static final String VL_URL = "/v1/vl"; - - /** - * vnf url. - */ - public static final String VNF_URL = "/v1/vnf"; - - /** - * vnfinfo url. - */ - public static final String VNFINFO_URL = "/v1/vnfinfo"; - - /** - * vnfstatus url. - */ - public static final String VNFSTATUS_URL = "/v1/vnfstatus"; - - /** - * grant resource url. - */ - public static final String GRANTRES_URL = "/v1/resource/grant"; - - /** - * vm url. - */ - public static final String VM_URL = "/v1/vm"; - - /** - * sites target. - */ - public static final String SITES_TARGET = "sites"; - - /** - * sites url. - */ - public static final String SITES_URL = "/v1/datacenters"; - - /** - * networks target. - */ - public static final String NETWORKS_TARGET = "networks"; - - /** - * networks url. - */ - public static final String NETWORKS_URL = "/v1/networks"; - - /** - * updateres. - */ - public static final String MODRES_URL = "/updateres"; - - /** - * resoperate target. - */ - public static final String RESOPERATE_TARGET = "resoperate"; - - /** - * APPLICATION_TYPE. - */ - public static final String APPLICATION_TYPE = "application/json"; - - /** - * ADDRES. - */ - public static final String ADDRES_URL = "/resmgr/vims"; - - /** - * updatebytenant. - */ - public static final String UPDATE_BY_TENANT = "updatebytenant"; - - /** - * updatebyvapp. - */ - public static final String UPDATE_BY_VAPP = "updatebyvapp"; - - /** - * getNetworkURL. - */ - public static final String GET_NETWORK_URL = "/openoapi/multivim/v1/%s/%s/networks"; - - /** - * getTenantURL. - */ - public static final String GET_TENANT_URL = "/openoapi/multivim/v1/%s/tenants"; - - /** - * getHostURL. - */ - public static final String GET_HOST_URL = "/openoapi/multivim/v1/%s/%s/hosts"; - - /** - * getHostDetailURL. - */ - public static final String GET_HOSTDETAIL_URL = "/openoapi/multivim/v1/%s/%s/hosts/%s"; - - /** - * getNetworkURL. - */ - public static final String GET_PORT_URL = "/openoapi/multivim/v1/%s/%s/ports"; - - /** - * getLimitsURL. - */ - public static final String GET_LIMITS_URL = "/openoapi/multivim/v1/%s/%s/limits"; - - /** - * template notify M url. - */ - public static final String TEMPLATE_NOTIFY_M_URL = ""; - - /** - * tenantsite allot url. - */ - public static final String TENANTSITE_ALLOT_URL = "/v1/resmanage/tenantsite/allot"; - - /** - * tenantsite allot target. - */ - public static final String TENANTSITE_ALLOT_TARGET = "tenantsite/allot"; - - /** - * tenant url. - */ - public static final String TENANT_URL = "/v1/resmanage/tenant"; - - /** - * tenant target. - */ - public static final String TENANT_TARGET = "tenant"; - - /** - * rollback url. - */ - public static final String ROLLBACK_URL = "/v1/resmanage/rollback"; - - /** - * rollback target. - */ - public static final String ROLLBACK_TARGET = "rollback"; - - /** - * vms target. - */ - public static final String VIM_TARGET = "vim"; - - /** - * vms url. - */ - public static final String VIM_URL = "/v1/resmanage/vim"; - - /** - * https - */ - public static final String GET_HTTPS = "https://"; - - /** - * get token - */ - public static final String GET_IAM_TOKEN = "/v3/auth/tokens"; - - /** - * rest. - */ - public static final String REST = "/rest"; - - /** - * donsdata url. - */ - public static final String INSTALL_URL = "install"; - - /** - * donsdata url. - */ - public static final String UNINSTALL_URL = "uninstall"; - - /** - * respool url. - */ - public static final String RESOPERATE_URL = "/v1/resoperate"; - - /** - * limits url. - */ - public static final String LIMITS_URL = "/v1/limits"; - - private UrlConstant() { - // private constructor - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java deleted file mode 100644 index 5440a7a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util; - -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -/** - * - * Json Utility Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public final class JsonUtil { - - private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class); - - private static final int TYPE_STRING = 0; - - private static final int TYPE_INT = 1; - - private static final int TYPE_JSONA = 2; - - private static final int TYPE_JSONO = 3; - - private static final int TYPE_LONG = 4; - - private JsonUtil() { - } - - /** - * - * Get Json Field String.
- * - * @param jsonObj - * @param fieldName - * @return - * @since NFVO 0.5 - */ - public static String getJsonFieldStr(JSONObject jsonObj, String fieldName) { - return (String)getJsonFieldObject(jsonObj, fieldName, TYPE_STRING); - } - - /** - * - * Get Json Field Integer.
- * - * @param jsonObj - * @param fieldName - * @return - * @since NFVO 0.5 - */ - public static Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) { - return (Integer)getJsonFieldObject(jsonObj, fieldName, TYPE_INT); - } - - /** - * - * Get Json Field array.
- * - * @param jsonObj - * @param fieldName - * @return - * @since NFVO 0.5 - */ - public static JSONArray getJsonFieldArr(JSONObject jsonObj, String fieldName) { - return (JSONArray)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONA); - } - - /** - * - * Get Json Field Json.
- * - * @param jsonObj - * @param fieldName - * @return - * @since NFVO 0.5 - */ - public static JSONObject getJsonFieldJson(JSONObject jsonObj, String fieldName) { - return (JSONObject)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONO); - } - - /** - * - * Get Json Field Long.
- * - * @param jsonObj - * @param fieldName - * @return - * @since NFVO 0.5 - */ - public static Long getJsonFieldLong(JSONObject jsonObj, String fieldName) { - return (Long)getJsonFieldObject(jsonObj, fieldName, TYPE_LONG); - } - - /** - * - * Get Json Field Object.
- * - * @param jsonObj - * @param fieldName - * @param classType - * @return - * @since NFVO 0.5 - */ - private static Object getJsonFieldObject(JSONObject jsonObj, String fieldName, int classType) { - try { - if(null != jsonObj && jsonObj.has(fieldName)) { - Object result = new Object(); - switch(classType) { - case TYPE_STRING: - result = "null".equals(jsonObj.getString(fieldName)) ? "" : jsonObj.getString(fieldName); - break; - case TYPE_INT: - result = jsonObj.getInt(fieldName); - break; - case TYPE_JSONA: - result = jsonObj.getJSONArray(fieldName); - break; - case TYPE_JSONO: - result = jsonObj.getJSONObject(fieldName); - break; - case TYPE_LONG: - result = jsonObj.getLong(fieldName); - break; - default: - result = null; - break; - } - return result; - } - } catch(JSONException e) { - LOG.error("function=getJsonFieldLong, exception: {} ", e); - return null; - } - return null; - } - - /** - * - * Check whether the Json Object is empty.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static boolean isNullJson(JSONObject jsonObject) { - if(null == jsonObject || jsonObject.isEmpty()) { - return true; - } - return false; - } - - /** - * - * Get String value by Json.
- * - * @param json - * @param key - * @return - * @since NFVO 0.5 - */ - public static String getStrValueByjson(JSONObject json, String key) { - JSONArray names = json.names(); - String result = null; - for(int i = 0; i < names.size(); i++) { - String nodeName = names.getString(i); - if(json.optJSONObject(nodeName) != null) { - result = getStrValueByjson(json.getJSONObject(nodeName), key); - } - if(json.optJSONArray(nodeName) != null) { - result = getStrValueByJArray(json.getJSONArray(nodeName), key); - } - if(nodeName.equals(key)) { - result = json.getString(nodeName); - break; - } - } - return result; - } - - private static String getStrValueByJArray(JSONArray json, String key) { - String result = null; - for(int i = 0; i < json.size(); i++) { - if(json.optJSONObject(i) != null) { - result = getStrValueByjson(json.getJSONObject(i), key); - } - if(json.optJSONArray(i) != null) { - result = getStrValueByJArray(json.getJSONArray(i), key); - } - } - return result; - } - - /** - * - * Get Json Value by Json object.
- * - * @param json - * @param key - * @return - * @since NFVO 0.5 - */ - public static JSONObject getJsonValueByjson(JSONObject json, String key) { - JSONObject resultJson = new JSONObject(); - String result = getStrValueByjson(json, key); - if(null == result) { - return null; - } - resultJson.element(key, result); - return resultJson; - - } - - /** - * - * Get String Value by Json object.
- * - * @param json - * @param parentKey - * @param key - * @return - * @since NFVO 0.5 - */ - public static String getStrValueByJson(JSONObject json, String parentKey, String key) { - if(parentKey.isEmpty()) { - return getStrValueByjson(json, key); - } - JSONObject parentJson = getJsonValueByjson(json, parentKey); - if(isNullJson(parentJson)) { - return null; - } - return getStrValueByjson(parentJson, key); - - } - - /** - * - * Get response Data.
- * - * @param obj - * @return - * @since NFVO 0.5 - */ - public static JSONObject getResponseData(JSONObject obj) { - JSONObject result = new JSONObject(); - - Integer retCode = getJsonFieldInt(obj, ParamConstant.PARAM_RETCODE); - if(null == retCode || retCode == -1) { - return null; - } - - if(obj.optJSONObject(ParamConstant.PARAM_DATA) != null) { - result = obj.getJSONObject(ParamConstant.PARAM_DATA); - } else if(obj.optJSONArray(ParamConstant.PARAM_DATA) != null) { - result = obj.getJSONArray(ParamConstant.PARAM_DATA).getJSONObject(0); - } - if(result.isEmpty()) { - return null; - } - - if(result.containsKey(ParamConstant.PARAM_RETCODE)) { - result = getResponseData(result); - } - return result; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java deleted file mode 100644 index e644e27..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util; - -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulFactory; -import org.openo.baseservice.roa.util.restclient.RestfulOptions; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.Constant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -/** - * Restful Utility Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class RestfulUtil { - - public static final String TYPE_GET = "get"; - - public static final String TYPE_PUT = "put"; - - public static final String TYPE_POST = "post"; - - public static final String TYPE_DEL = "delete"; - - public static final String CONTENT_TYPE = "Content-type"; - - public static final String APPLICATION = "application/json"; - - private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class); - - private static final Restful REST_CLIENT = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); - - private RestfulUtil() { - } - - /** - * Get response object.
- * - * @param url - * @param type - * @return - * @since NFVO 0.5 - */ - public static JSONObject getResponseObj(String url, String type) { - return getResponseObj(url, new RestfulParametes(), type); - } - - /** - * Get response object.
- * - * @param url - * @param parametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static JSONObject getResponseObj(String url, RestfulParametes parametes, String type) { - try { - String content = RestfulUtil.getResponseContent(url, parametes, null, type); - LOGGER.error("function=getResponseObj, content : {}", content); - if(StringUtils.isEmpty(content)) { - return null; - } - return JSONObject.fromObject(content); - } catch(JSONException e) { - LOGGER.error("function=getResponseObj, exception : {}", e); - return null; - } - } - - /** - * Get response content.
- * - * @param url - * @param restParametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static String getResponseContent(String url, RestfulParametes restParametes, String type) { - return getResponseContent(url, restParametes, null, type); - } - - /** - * Get response map.
- * - * @param url - * @param restParametes - * @param opt - * @param type - * @return - * @since NFVO 0.5 - */ - public static Map getResponseMap(String url, RestfulParametes restParametes, RestfulOptions opt, - String type) { - RestfulResponse response = restfulResponse(url, restParametes, opt, type); - return getResponseMap(response); - } - - /** - * Get response content map.
- * - * @param url - * @param type - * @return - * @since NFVO 0.5 - */ - public static Map getResponseContentMap(String url, String type) { - RestfulResponse response = restfulResponse(url, new RestfulParametes(), null, type); - return getResponseMap(response); - } - - private static Map getResponseMap(RestfulResponse response) { - Map resMap = new HashMap<>(10); - if(null != response) { - resMap.put(Constant.RESPONSE_CONTENT, response.getResponseContent()); - resMap.put(Constant.STATUS_CODE, response.getStatus()); - } - return resMap; - } - - /** - * Get response content.
- * - * @param url - * @param restParametes - * @param opt - * @param type - * @return - * @since NFVO 0.5 - */ - public static String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, - String type) { - String responseContent = null; - RestfulResponse rsp = restfulResponse(url, restParametes, opt, type); - if(rsp != null) { - int httpStatus = rsp.getStatus(); - LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus); - if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) { - responseContent = rsp.getResponseContent(); - LOGGER.warn("function=getResponseContent, get response data success!responseContent={}", - responseContent); - } - } - return responseContent; - } - - /** - * Get restful response.
- * - * @param url - * @param restParametes - * @param type - * @return - * @since NFVO 0.5 - */ - public static RestfulResponse getRestfulResponse(String url, RestfulParametes restParametes, String type) { - return restfulResponse(url, restParametes, null, type); - } - - private static RestfulResponse restfulResponse(String url, RestfulParametes restParametes, RestfulOptions opt, - String type) { - RestfulResponse rsp = new RestfulResponse(); - try { - - if(REST_CLIENT != null) { - if(TYPE_GET.equals(type)) { - rsp = REST_CLIENT.get(url, restParametes, opt); - } else if(TYPE_POST.equals(type)) { - rsp = REST_CLIENT.post(url, restParametes, opt); - } else if(TYPE_PUT.equals(type)) { - rsp = REST_CLIENT.put(url, restParametes, opt); - } else if(TYPE_DEL.equals(type)) { - rsp = REST_CLIENT.delete(url, restParametes, opt); - } - } - } catch(ServiceException e) { - LOGGER.error("function=restfulResponse, get restful response catch exception {} ", e); - } - LOGGER.warn("function=restfulResponse, response status is {} ", rsp.getStatus()); - return rsp; - } - - /** - * encapsulate the java reflect exception.
- * - * @param methodName, Restful's method. - * @param objects, method param array. - * @return - * @since NFVO 0.5 - */ - public static RestfulResponse getRestRes(String methodName, Object... objects) { - try { - if(objects == null || REST_CLIENT == null) { - return null; - } - - Class[] classes = new Class[objects.length]; - for(int i = 0; i < objects.length; i++) { - classes[i] = objects[i].getClass(); - } - if(methodName.startsWith("async")) { - classes[classes.length - 1] = RestfulAsyncCallback.class; - } - - Class rtType = methodName.startsWith("async") ? void.class : RestfulResponse.class; - MethodType mt = MethodType.methodType(rtType, classes); - Object result = MethodHandles.lookup().findVirtual(REST_CLIENT.getClass(), methodName, mt) - .bindTo(REST_CLIENT).invokeWithArguments(objects); - if(result != null) { - return (RestfulResponse)result; - } - LOGGER.warn("function=getRestRes, msg: invoke Restful async {} method which return type is Void.", - methodName); - return null; - } catch(ReflectiveOperationException e) { - LOGGER.error("function=getRestRes, msg=error occurs, e={}.", e); - } catch(Throwable e) {// NOSONAR - LOGGER.error("function=getRestRes, msg=Throwable, e={}.", e); - try { - throw (ServiceException)new ServiceException().initCause(e.getCause()); - } catch(ServiceException se) { - LOGGER.error("function=getRestRes, msg=ServiceException occurs, e={}.", se); - } - } - return null; - } - - /** - * Get response.
- * - * @param restParametes - * @param url - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - public static JSONArray getResponseRes(RestfulParametes restParametes, String url) throws ServiceException { - String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); - if(null == result || result.isEmpty()) { - LOGGER.error("result from url:" + url + " result:" + result); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); - } - - JSONArray rsArray = null; - try { - JSONObject rsJson = JSONObject.fromObject(result); - rsArray = rsJson.getJSONArray(ParamConstant.PARAM_DATA); - } catch(JSONException e) { - LOGGER.error("getResources error:" + e); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); - } - return rsArray; - } - - /** - * Get response.
- * - * @param restParametes - * @param url - * @param iResName - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - public static JSONArray getResponseRes(RestfulParametes restParametes, String url, String iResName) - throws ServiceException { - String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); - if(null == result || result.isEmpty()) { - LOGGER.error("result from url:" + url + " result:" + result); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); - } - - JSONArray rsArray = null; - try { - JSONObject rsJson = JSONObject.fromObject(result); - rsArray = rsJson.getJSONArray(iResName); - String vimId = rsJson.getString(ParamConstant.PARAM_VIMID); - String vimName = rsJson.getString(ParamConstant.PARAM_VIMNAME); - for(int i = 0; i < rsArray.size(); i++) { - JSONObject jsonObj = rsArray.getJSONObject(i); - jsonObj.put(ParamConstant.PARAM_VIMID, vimId); - jsonObj.put(ParamConstant.PARAM_VIMNAME, vimName); - } - } catch(JSONException e) { - LOGGER.error("getResources error:" + e); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); - } - return rsArray; - } - - /** - *
- * - * @param paramsMap - * @param params - * @return - * @since NFVO 0.5 - */ - public static RestfulResponse getRemoteResponse(Map paramsMap, String params) { - String url = paramsMap.get("url"); - String methodType = paramsMap.get("methodType"); - - RestfulResponse rsp = null; - Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); - try { - - RestfulParametes restfulParametes = new RestfulParametes(); - Map headerMap = new HashMap<>(3); - headerMap.put(CONTENT_TYPE, APPLICATION); - restfulParametes.setHeaderMap(headerMap); - restfulParametes.setRawData(params); - - if(rest != null) { - if(TYPE_GET.equalsIgnoreCase(methodType)) { - rsp = rest.get(url, restfulParametes); - } else if(TYPE_POST.equalsIgnoreCase(methodType)) { - rsp = rest.post(url, restfulParametes); - } else if(TYPE_PUT.equalsIgnoreCase(methodType)) { - rsp = rest.put(url, restfulParametes); - } else if(TYPE_DEL.equalsIgnoreCase(methodType)) { - rsp = rest.delete(url, restfulParametes); - } - } - } catch(ServiceException e) { - LOGGER.error("function=getRemoteResponse, get restful response catch exception {}", e); - } - return rsp; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java deleted file mode 100644 index fd8f09f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util; - -import java.math.BigDecimal; -import java.text.DecimalFormat; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * String Utility Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public final class StringUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class); - - private StringUtil() { - } - - /** - * - * Check whether thestring is valid.
- * - * @param str - * @return - * @since NFVO 0.5 - */ - public static boolean isValidString(String str) { - if(null == str || str.isEmpty()) { - return false; - } - return true; - } - - /** - * - * Check whether the value is larger than zero.
- * - * @param strs - * @return - * @since NFVO 0.5 - */ - public static boolean isAnyLargeThanZero(String... strs) { - for(String str : strs) { - if(!StringUtils.isEmpty(str) && Float.parseFloat(str) > 0) { - LOGGER.info("isAnyLargeThanZero : {} is > 0", str); - return true; - } - } - return false; - } - - /** - * - * Check whether the value is Integer.
- * - * @param strs - * @return - * @since NFVO 0.5 - */ - public static boolean isInteger(String... strs) { - try { - for(String str : strs) { - if(!StringUtils.isEmpty(str)) { - int value = Integer.parseInt(str); - if(value < 0) { - return false; - } - } - } - } catch(NumberFormatException e) { - return false; - } - return true; - } - - /** - * - * Check whether the input is Numeric.
- * - * @param strs - * @return - * @since NFVO 0.5 - */ - public static boolean isNumeric(String... strs) { - try { - for(String str : strs) { - if(!StringUtils.isEmpty(str)) { - float value = Float.parseFloat(str); - if(value < 0) { - return false; - } - } - } - } catch(NumberFormatException e) { - return false; - } - return true; - } - - /** - * - * Compare zero by float.
- * - * @param tatol - * @param used - * @param drTotal - * @return - * @since NFVO 0.5 - */ - public static boolean compareZeroByFloat(String tatol, String used, String drTotal) { - Float ftotal = (float)0; - Float fused = (float)0; - Float fdrTotal = (float)0; - if(!StringUtils.isEmpty(tatol)) { - ftotal = new Float(tatol); - } - if(!StringUtils.isEmpty(used)) { - fused = new Float(used); - } - if(!StringUtils.isEmpty(drTotal)) { - fdrTotal = new Float(drTotal); - } - if(ftotal < fused + fdrTotal) { - return false; - } - - return true; - } - - /** - * - * Compare zero by integer.
- * - * @param tatol - * @param used - * @param drTotal - * @return - * @since NFVO 0.5 - */ - public static boolean compareZeroByInteger(String tatol, String used, String drTotal) { - Integer ftotal = (int)0; - Integer fused = (int)0; - Integer fdrTotal = (int)0; - if(!StringUtils.isEmpty(tatol)) { - ftotal = Integer.valueOf(tatol); - } - if(!StringUtils.isEmpty(used)) { - fused = Integer.valueOf(used); - } - if(!StringUtils.isEmpty(drTotal)) { - fdrTotal = Integer.valueOf(drTotal); - } - if(ftotal < fused + fdrTotal) { - return false; - } - return true; - } - - /** - * - * Number format.
- * - * @param data - * @return - * @since NFVO 0.5 - */ - public static String numFormat(String data) { - if(null != data && !("".equals(data))) { - BigDecimal var = new BigDecimal(data); - DecimalFormat formatWithoutFraction = new DecimalFormat("############"); - DecimalFormat formatWithFraction = new DecimalFormat("############.############"); - if(new BigDecimal(var.intValue()).compareTo(var) == 0) { - return formatWithoutFraction.format(var); - } - return formatWithFraction.format(var); - } - return null; - } - - /** - * - *
- * - * @param inputStr - * @return - * @since NFVO 0.5 - */ - public static boolean checkXss(String inputStr) { - return inputStr.matches("[A-Za-z0-9_.']+"); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java deleted file mode 100644 index 5eae4e3..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util.request; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -/** - *
- *

- * Utility used for request - *

- * - * @author - * @version NFVO 0.5 2016-3-17 - */ -public final class RequestUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(RequestUtil.class); - - /** - * Constructor
- *

- *

- * - * @since NFVO 0.5 - */ - private RequestUtil() { - } - - /** - * Get context string from http context - * - * @param context - * http context - * @return the needed string in http context - */ - public static String getStringRequestBody(HttpServletRequest context) { - try { - InputStream input = context.getInputStream(); - return IOUtils.toString(input); - } catch(IOException e) { - LOGGER.error("function=getStringRequestBody, get httpservletrequest body exception: {}", e); - return null; - } - } - - /** - * Get json parameter from http context - * - * @param context - * http context - * @return JSONObject - */ - public static JSONObject getJsonRequestBody(HttpServletRequest context) { - try { - String bodyStr = getStringRequestBody(context); - return JSONObject.fromObject(bodyStr); - } catch(JSONException e) { - LOGGER.error("function=getJsonRequestBody, maybe request param is not a jsonobject exception: {}", e); - return null; - } - } - - /** - * Get the body of all request in json format
- * - * @param context - * The http context - * @return JSONObject The body of all request in json format - * @since NFVO 0.5 - */ - public static JSONObject getAllJsonRequestBody(HttpServletRequest context) { - JSONObject requestBody = getJsonRequestBody(context); - if(null == requestBody) { - LOGGER.error("get httpservletrequest body exception"); - requestBody = new JSONObject(); - } - LOGGER.warn("function=getAllJsonRequestBody; msg=get request data is:[{}]", requestBody.toString()); - requestBody.put("header", getContextHeader(context)); - return requestBody; - } - - /** - * Get the context header
- * - * @param context - * The http context - * @return Map context header - * @since NFVO 0.5 - */ - @SuppressWarnings("unchecked") - private static Map getContextHeader(HttpServletRequest context) { - Map header = new HashMap(); - Enumeration headerNames = context.getHeaderNames(); - while(headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - String value = context.getHeader(headerName); - header.put(headerName, value); - } - return header; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java deleted file mode 100644 index d6b1415..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util.response; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import javax.servlet.http.HttpServletRequest; - -import net.sf.json.JSONObject; - -/** - * - * Response utility class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public final class ResponseUtil { - - private ResponseUtil() { - } - - /** - * Roa request common return function, default return code 200
- * - * @param retCode - * The request return code - * @param msg - * The request message - * @return JSONObject The response for http request - * @since NFVO 0.5 - */ - public static JSONObject genHttpResponse(int retCode, String msg) { - return genHttpResponse(null, createCodeMap(-1, retCode), msg, null); - } - - /** - * Roa request common return function, default return code 200
- * - * @param retCode - * The request return code - * @param msg - * The request message - * @param map - * Other request info of this request - * @return JSONObject The response for http request - * @since NFVO 0.5 - */ - public static JSONObject genHttpResponse(int retCode, String msg, Map map) { - return genHttpResponse(null, createCodeMap(-1, retCode), msg, map); - } - - /** - * Roa request common return method
- * - * @param context - * The http request context - * @param httpStatusCode - * The http response code - * @param retCode - * The http request return code - * @param msg - * The message of request - * @return JSONObject The response for http request - * @since NFVO 0.5 - */ - public static JSONObject genHttpResponse(HttpServletRequest context, int httpStatusCode, int retCode, String msg) { - return genHttpResponse(context, createCodeMap(httpStatusCode, retCode), msg, null); - } - - /** - * - * Roa request common return method.
- * - * @param context, The http request context - * @param codeMap - * @param msg, The message of request - * @param map, Other message of request - * @return - * @since NFVO 0.5 - */ - public static JSONObject genHttpResponse(HttpServletRequest context, Map codeMap, String msg, - Map map) { - JSONObject object = new JSONObject(); - - object.put("msg", msg); - if(null != map) { - Iterator> ite = map.entrySet().iterator(); - if(ite.hasNext()) { - Map.Entry entry = ite.next(); - object.put(entry.getKey(), entry.getValue().toString()); - } - } - return object; - } - - /** - * Create code map to maintenance the relationship between return code and - * http status code
- * - * @param httpStatusCode - * The http response code - * @param retCode - * The http request return code - * @return Map - * @since NFVO 0.5 - */ - private static Map createCodeMap(int httpStatusCode, int retCode) { - Map codeMap = new HashMap<>(5); - codeMap.put("httpStatusCode", httpStatusCode); - codeMap.put("retCode", retCode); - return codeMap; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java deleted file mode 100644 index dbb034d..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.common.util.response; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.ResponseConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- * Utility for generate Roa get/add/update/delete method status - *

- * - * @author - * @version NFVO 0.5 2016-3-17 - */ -public final class RoaResponseUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(RoaResponseUtil.class); - - private RoaResponseUtil() { - - } - - /** - * Generate get method response
- * - * @param list - * The basic response for get method - * @return JSONObject The response for http request - * @since NFVO 0.5 - */ - public static JSONObject get(List list) { - Map map = new HashMap(10); - map.put(ParamConstant.PARAM_DATA, list); - LOGGER.info("function=get; msg=get map:{}", map.toString()); - return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.QUERY_SUCESS_MSG, map); - } - - /** - * Generate different response by different parameter for add method
- * - * @param result - * The result - * @return JSONObject - * @since NFVO 0.5 - */ - public static JSONObject add(int result) { - LOGGER.info("function=add; msg=add result{}", result); - if(result <= 0) { - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.ADD_FAIL_MSG); - } else { - return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.ADD_SUCESS_MSG); - } - } - - /** - * Generate different response by different parameter for update method
- * - * @param result - * The result - * @return JSONObject The response for http request - * @since NFVO 0.5 - */ - public static JSONObject update(int result) { - LOGGER.info("function=update; msg=update result{}", result); - if(result <= 0) { - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.MOD_FAIL_MSG); - } else { - return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.MOD_SUCESS_MSG); - } - } - - /** - * Generate different response by different parameter for delete method
- * - * @param result - * The result - * @return delete JSONObject of the response for http request - * @since NFVO 0.5 - */ - public static JSONObject delete(int result) { - LOGGER.info("function=delete; msg=delete result{}", result); - if(result <= 0) { - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.DEL_FAIL_MSG); - } else { - return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.DEL_SUCESS_MSG); - } - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java deleted file mode 100644 index ad66303..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.activator; - -import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 22, 2016 - */ -public class ROAResmgrServicePostProcessor implements DestructionAwareBeanPostProcessor { - - private static final Logger LOG = LoggerFactory.getLogger(ROAResmgrServicePostProcessor.class); - - @Override - public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { - if(bean instanceof IResmgrAdapterMgrService) { - LOG.warn("Register to Microservice BUS!"); - IResmgrAdapterMgrService resmgrAdapterSvc = (IResmgrAdapterMgrService)bean; - resmgrAdapterSvc.register(); - } - - return bean; - } - - @Override - public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { - // TODO Auto-generated method stub - return bean; - } - - @Override - public void postProcessBeforeDestruction(Object bean, String name) throws BeansException { - // TODO Auto-generated method stub - - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java deleted file mode 100644 index 9e523e3..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.adapter.impl; - -import java.util.Map; - -import org.openo.baseservice.roa.util.restclient.RestfulResponse; -import org.openo.nfvo.resmanagement.common.constant.Constant; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 22, 2016 - */ -public class ResmgrAdapter2MSBManager implements IResmgrAdapter2MSBManager { - - private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapter2MSBManager.class); - - @Override - public JSONObject registerResmgr(Map paramsMap, JSONObject driverInfo) { - JSONObject resultObj = new JSONObject(); - - RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); - if(null == rsp) { - LOG.error("function=registerResmgr, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.ERROR_CODE); - return resultObj; - } - LOG.warn("function=registerResmgr, status={}, content={}.", rsp.getStatus(), rsp.getResponseContent()); - String resultCreate = rsp.getResponseContent(); - - if(rsp.getStatus() == HttpConstant.HTTP_CREATED) { - LOG.warn("function=registerResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", HttpConstant.HTTP_CREATED); - return resultObj; - } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { - LOG.error("function=registerResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", - rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,invalid parameters."); - } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { - LOG.error("function=registerResmgr, msg=MSB return fail,internal system error,status={}, result={}.", - rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,internal system error."); - } - resultObj.put("retCode", Constant.ERROR_CODE); - return resultObj; - } - - @Override - public JSONObject unregisterResmgr(Map paramsMap) { - JSONObject resultObj = new JSONObject(); - - RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, ""); - if(null == rsp) { - LOG.error("function=unregisterResmgr, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.ERROR_CODE); - return resultObj; - } - String resultCreate = rsp.getResponseContent(); - - if(rsp.getStatus() == HttpConstant.HTTP_NOCONTENT) { - LOG.warn("function=unregisterResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", HttpConstant.HTTP_NOCONTENT); - return resultObj; - } else if(rsp.getStatus() == HttpConstant.HTTP_NOTFOUND_CODE) { - LOG.error( - "function=unregisterResmgr, msg=MSB return fail,can't find the service instance.status={}, result={}.", - rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,can't find the service instance."); - } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { - LOG.error("function=unregisterResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", - rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,invalid parameters."); - } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { - LOG.error("function=unregisterResmgr, msg=MSB return fail,internal system error,status={}, result={}.", - rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,internal system error."); - } - resultObj.put("retCode", Constant.ERROR_CODE); - return resultObj; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java deleted file mode 100644 index ea9a53d..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.adapter.impl; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Executors; - -import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; -import org.openo.nfvo.resmanagement.common.constant.Constant; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager; -import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 22, 2016 - */ -@Service -public class ResmgrAdapterMgrService implements IResmgrAdapterMgrService { - - private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapterMgrService.class); - - public static final String RESMGRADAPTERINFO = "resmgradapterinfo.json"; - - @Override - public void register() { - // set BUS URL and mothedtype - Map paramsMap = new HashMap<>(); - paramsMap.put("url", UrlConstant.REST_MSB_REGISTER); - paramsMap.put("methodType", ParamConstant.PARAM_POST); - - // get resmgr info and raise registration - try { - String resmgrInfo = readVimAdapterInfoFromJson(); - if(!"".equals(resmgrInfo)) { - JSONObject adapterObject = JSONObject.fromObject(resmgrInfo); - RegisterResmgrThread resmgrThread = new RegisterResmgrThread(paramsMap, adapterObject); - Executors.newSingleThreadExecutor().submit(resmgrThread); - } else { - LOG.error("Resmgr info is null,please check!"); - } - - } catch(IOException e) { - LOG.error("Failed to read Resmgr info! " + e.getMessage(), e); - } - - } - - /** - * Retrieve VIM driver information. - * - * @return - * @throws IOException - */ - public static String readVimAdapterInfoFromJson() throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; - String fileContent = ""; - - String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator") - + "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator") - + RESMGRADAPTERINFO; - - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); - - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); - - if(num > 0) { - fileContent = new String(contentByte); - } - } catch(FileNotFoundException e) { - LOG.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } - } - - return fileContent; - } - - private static class RegisterResmgrThread implements Runnable { - - // Thread lock Object - private final Object lockObject = new Object(); - - private IResmgrAdapter2MSBManager adapter2MSBMgr = new ResmgrAdapter2MSBManager(); - - // url and mothedtype - private Map paramsMap; - - // driver body - private JSONObject adapterInfo; - - public RegisterResmgrThread(Map paramsMap, JSONObject adapterInfo) { - this.paramsMap = paramsMap; - this.adapterInfo = adapterInfo; - } - - @Override - public void run() { - LOG.info("start register resmgr", RegisterResmgrThread.class); - - if(paramsMap == null || adapterInfo == null) { - LOG.error("parameter is null,please check!", RegisterResmgrThread.class); - return; - } - - // catch Runtime Exception - try { - sendRequest(paramsMap, adapterInfo); - } catch(RuntimeException e) { - LOG.error(e.getMessage(), e); - } - - } - - private void sendRequest(Map paramsMap, JSONObject driverInfo) { - JSONObject resultObj = adapter2MSBMgr.registerResmgr(paramsMap, driverInfo); - - if(Integer.valueOf(resultObj.get("retCode").toString()) == HttpConstant.HTTP_CREATED) { - LOG.info("Resmgr has now Successfully Registered to the Microservice BUS!"); - } else { - LOG.error("Resmgr failed to Register to the Microservice BUS! Reason:" - + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); - - // if registration fails,wait one minute and try again - try { - synchronized(lockObject) { - lockObject.wait(Constant.REPEAT_REG_TIME); - } - } catch(InterruptedException e) { - LOG.error(e.getMessage(), e); - } - - sendRequest(this.paramsMap, this.adapterInfo); - } - - } - - } - - @Override - public void unregister() { - // unregister - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java deleted file mode 100644 index df00261..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.adapter.inf; - -import java.util.Map; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 22, 2016 - */ -public interface IResmgrAdapter2MSBManager { - - /** - *
- * - * @param paramsMap - * @param driverInfo - * @return - * @since NFVO 0.5 - */ - JSONObject registerResmgr(Map paramsMap, JSONObject driverInfo); - - /** - *
- * - * @param paramsMap - * @return - * @since NFVO 0.5 - */ - JSONObject unregisterResmgr(Map paramsMap); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java deleted file mode 100644 index 05d4739..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.adapter.inf; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 22, 2016 - */ -public interface IResmgrAdapterMgrService { - - /** - * Resmgr register interface. - */ - void register(); - - /** - * Resmgr unregister interface. - */ - void unregister(); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java deleted file mode 100644 index 131d7c7..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; -import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; - -import net.sf.json.JSONObject; - -/** - * - * Host implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class HostImpl implements Host { - - private HostBusiness hostBusiness; - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - return hostBusiness.addHost(HostEntity.toEntity(jsonObject)); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - return hostBusiness.updateHostSelective(HostEntity.toEntity(jsonObject)); - } - - @Override - public int update(HostEntity portEntity) throws ServiceException { - return hostBusiness.updateHostSelective(portEntity); - } - - @Override - public int delete(String id) throws ServiceException { - return hostBusiness.deleteHost(id); - } - - @Override - public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { - return hostBusiness.updateHostByVimId(HostEntity.toEntity(jsonObject)); - } - - @Override - public int deleteResByVimId(String vimId) throws ServiceException { - return hostBusiness.deleteHostByVimId(vimId); - } - - @Override - public List getList(Map condition) throws ServiceException { - return hostBusiness.getHosts(condition); - } - - public void setHostBusiness(HostBusiness hostBusiness) { - this.hostBusiness = hostBusiness; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java deleted file mode 100644 index 346ac84..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - * Location Implementation Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class LocationImpl implements Location { - - private LocationBusiness locationBusiness; - - private Sites sites; - - private static final Logger LOGGER = LoggerFactory.getLogger(LocationImpl.class); - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - return locationBusiness.addLocation(LocationEntity.toEntity(jsonObject)); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - return locationBusiness.updateLocationSelective(LocationEntity.toEntity(jsonObject)); - } - - @Override - public int delete(String location) throws ServiceException { - return locationBusiness.deleteLocation(location); - } - - @Override - public Map get(String id) throws ServiceException { - Map map = new HashMap<>(); - map.put(ParamConstant.PARAM_ID, id); - List sodores = locationBusiness.getLocations(map); - map.clear(); - map.put(ParamConstant.PARAM_DATA, sodores); - return map; - } - - @Override - public List get(Map condition) throws ServiceException { - return locationBusiness.getLocations(condition); - } - - @Override - public List getCountry() throws ServiceException { - return locationBusiness.getCountry(); - } - - @Override - public List getCloudservice() throws ServiceException { - LOGGER.info("get cloud service from external system"); - JSONArray vims = VimUtil.getVims(); - LOGGER.info("vims: " + vims.toString()); - List cloudService = new ArrayList<>(); - for(int i = 0; i < vims.size(); i++) { - String vimName = vims.getJSONObject(i).getString("name"); - cloudService.add(vimName); - } - return cloudService; - } - - @Override - public List getLocationByCountry(Map condition) throws ServiceException { - return locationBusiness.getLocationByCountry(condition); - } - - @Override - public LocationEntity getLocation(Map condition) throws ServiceException { - List locationlist = locationBusiness.getLocations(condition); - if(null == locationlist || locationlist.isEmpty()) { - return null; - } - return locationlist.get(0); - } - - @Override - public List getLocationInfo(List locationInfo) throws ServiceException { - ArrayList newSites = new ArrayList<>(); - Map condition = new HashMap<>(); - for(int i = 0; i < locationInfo.size(); i++) { - LocationEntity locationEntity = locationInfo.get(i); - String latitude = locationEntity.getLatitude(); - String longitude = locationEntity.getLongitude(); - String locatSite = locationEntity.getLocation(); - condition.put(ParamConstant.PARAM_LOCATION, locatSite); - LOGGER.info("LocationRoa::getLocation condition:{}", condition); - List sitesEntity = sites.getList(condition); - LOGGER.info("LocationRoa::getLocation sitesEntity:{}", sitesEntity); - if(null != sitesEntity && !sitesEntity.isEmpty()) { - for(SitesEntity entity : sitesEntity) { - JSONObject site = JSONObject.fromObject(entity.toString()); - JSONObject resTotalJo = site.getJSONObject("total"); - JSONObject resUsedlJo = site.getJSONObject("used"); - JSONObject ressiteJo = computingSite(resTotalJo, resUsedlJo); - site.element("latitude", latitude); - site.element("longitude", longitude); - site.element("siteDetail", ressiteJo); - LOGGER.info("LocationRoa::getLocation latitude:{}, longitude:{}", latitude, longitude); - LOGGER.info("LocationRoa::getLocation site:{}", site); - newSites.add(site); - } - } - } - return newSites; - } - - /** - * Computing site.
- * - * @param total - * @param used - * @return - * @since NFVO 0.5 - */ - public JSONObject computingSite(JSONObject total, JSONObject used) { - String vcpus = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_VCPUS); - String memorys = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_MEMORY); - String disks = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_DISK); - String vcpusused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_VCPUS); - String memoryused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_MEMORY); - String diskused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_DISK); - float cpu = Float.parseFloat(vcpusused) / Float.parseFloat(vcpus); - float memory = Float.parseFloat(memoryused) / Integer.parseInt(memorys); - float disk = Float.parseFloat(diskused) / Float.parseFloat(disks); - JSONObject resTotalJo = new JSONObject(); - resTotalJo.put(ParamConstant.PARAM_VCPUS, String.valueOf(Math.round(cpu * 100)) + "%"); - resTotalJo.put(ParamConstant.PARAM_MEMORY, String.valueOf(Math.round(memory * 100)) + "%"); - resTotalJo.put(ParamConstant.PARAM_DISK, String.valueOf(Math.round(disk * 100)) + "%"); - - return resTotalJo; - } - - public LocationBusiness getLocationBusiness() { - return locationBusiness; - } - - public void setLocationBusiness(LocationBusiness locationBusiness) { - this.locationBusiness = locationBusiness; - } - - public void setSites(Sites sites) { - this.sites = sites; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java deleted file mode 100644 index b9ec757..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; -import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * Network implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class NetworkImpl implements Network { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkImpl.class); - - private NetworkBusiness networkBusiness; - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - LOGGER.warn("function=addPort; jsonObject={}", jsonObject); - JSONObject networkObj = dataParse(jsonObject); - return networkBusiness.addNetwork(NetworkEntity.toEntity(networkObj)); - } - - private JSONObject dataParse(JSONObject jsonObject) { - JSONObject portObj = new JSONObject(); - portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); - portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); - portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); - portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); - portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - portObj.put("physicalNetwork", JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); - portObj.put("networkType", JsonUtil.getJsonFieldStr(jsonObject, "networkType")); - portObj.put("segmentationId", JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); - return portObj; - } - - @Override - public int add(NetworkEntity entity) throws ServiceException { - return networkBusiness.addNetwork(entity); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - return networkBusiness.updateNetworkSelective(NetworkEntity.toEntity(jsonObject)); - } - - @Override - public int delete(String id) throws ServiceException { - return networkBusiness.deleteNetwork(id); - } - - @Override - public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { - return networkBusiness.updateNetworkByVimId(NetworkEntity.toEntity(jsonObject)); - } - - @Override - public List getList(Map condition) throws ServiceException { - return networkBusiness.getNetworks(condition); - } - - @Override - public int deleteResByVimId(String vimId) throws ServiceException { - return networkBusiness.deleteNetworkByVimId(vimId); - } - - public void setNetworkBusiness(NetworkBusiness networkBusiness) { - this.networkBusiness = networkBusiness; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java deleted file mode 100644 index 3dee172..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; -import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * Port implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class PortImpl implements Port { - - private static final Logger LOGGER = LoggerFactory.getLogger(PortImpl.class); - - private PortBusiness portBusiness; - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - LOGGER.warn("function=addPort; jsonObject={}", jsonObject); - JSONObject portObj = dataParse(jsonObject); - return portBusiness.addPort(PortEntity.toEntity(portObj)); - } - - private JSONObject dataParse(JSONObject jsonObject) { - JSONObject portObj = new JSONObject(); - portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); - portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); - portObj.put("networkId", JsonUtil.getJsonFieldStr(jsonObject, "networkId")); - portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); - portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); - portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - return portObj; - } - - @Override - public int add(PortEntity portEntity) throws ServiceException { - return portBusiness.addPort(portEntity); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - return portBusiness.updatePortSelective(PortEntity.toEntity(jsonObject)); - } - - @Override - public int update(PortEntity portEntity) throws ServiceException { - return portBusiness.updatePortSelective(portEntity); - } - - @Override - public int delete(String id) throws ServiceException { - return portBusiness.deletePort(id); - } - - @Override - public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { - return portBusiness.updatePortByVimId(PortEntity.toEntity(jsonObject)); - } - - @Override - public int deleteResByVimId(String vimId) throws ServiceException { - return portBusiness.deletePortByVimId(vimId); - } - - @Override - public List getList(Map condition) throws ServiceException { - return portBusiness.getPorts(condition); - } - - public void setPortBusiness(PortBusiness portBusiness) { - this.portBusiness = portBusiness; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java deleted file mode 100644 index 6b9345e..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; -import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * DC info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public class SitesImpl implements Sites { - - private static final Logger LOGGER = LoggerFactory.getLogger(SitesImpl.class); - - private SitesBusiness sitesBusiness; - - private LimitsBusiness limitsBusiness; - - private ResOperateService resOperateService; - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - LOGGER.info("Add datacenter jsonObject: {}", jsonObject); - SitesEntity sitesEntity = SitesEntity.toEntity(jsonObject); - sitesEntity.setStatus(ParamConstant.PARAM_ACTIVE); - String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); - String vimId = VimUtil.getVimIdByName(vimName); - sitesEntity.setVimId(vimId); - JSONObject resource = limitsBusiness.getLimits(vimId); - sitesEntity.setVimName(resource.getString(ParamConstant.PARAM_VIMNAME)); - sitesEntity.setTotalCPU(resource.getString(ParamConstant.TOTAL_CPU)); - sitesEntity.setUsedCPU(resource.getString(ParamConstant.USED_CPU)); - sitesEntity.setTotalMemory(resource.getString(ParamConstant.TOTAL_MEMORY)); - sitesEntity.setUsedMemory(resource.getString(ParamConstant.USED_MEMORY)); - sitesEntity.setTotalDisk(resource.getString(ParamConstant.TOTAL_DISK)); - sitesEntity.setUsedDisk(resource.getString(ParamConstant.USED_DISK)); - if(StringUtils.isEmpty(sitesEntity.getId())) { - sitesEntity.setId(UUID.randomUUID().toString()); - jsonObject.put(ParamConstant.PARAM_ID, sitesEntity.getId()); - } - LOGGER.info("Add datacenter sitesEntity: {}", sitesEntity.toString()); - return sitesBusiness.addSite(sitesEntity); - } - - /** - *
- * - * @param json - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public void sendToMonitor(JSONObject jsonObject) throws ServiceException { - LOGGER.info("SitesImpl sendToMonitor jsonObject: {}", jsonObject); - String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); - String vimId = VimUtil.getVimIdByName(vimName); - JSONObject vimInfo = VimUtil.getVimById(vimId); - LOGGER.info("SitesImpl sendToMonitor vimInfo: {}", vimInfo); - String tenant = vimInfo.getString("tenant"); - String tenantId = VimUtil.getTenantIdByName(tenant, vimId); - JSONObject json = new JSONObject(); - json.put("header", null); - LOGGER.info("tenantId:{}, vimId:{}", tenantId, vimId); - resOperateService.addIRes(tenantId, vimId, json); - resOperateService.sendMsgMonitor("create", vimId); - } - - @Override - public int update(SitesEntity sitesEntity) throws ServiceException { - return sitesBusiness.updateSiteSelective(sitesEntity); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - LOGGER.info("grantResource jsonObject: {}", jsonObject); - JSONObject sitesObj = dataParse(jsonObject); - return sitesBusiness.updateSiteSelective(SitesEntity.toEntity(sitesObj)); - } - - private JSONObject dataParse(JSONObject jsonObject) throws ServiceException { - String vimId = jsonObject.getString(ParamConstant.PARAM_VIMID); - Map condition = new HashMap<>(); - condition.put("vimId", vimId); - SitesEntity sitesEntity = get(condition); - if(null == sitesEntity) { - LOGGER.error("Get sites null, vimId={}", vimId); - return null; - } - return computeSiteUsed(jsonObject, sitesEntity); - } - - private JSONObject computeSiteUsed(JSONObject jsonObject, SitesEntity sitesEntity) throws ServiceException { - String action = JsonUtil.getJsonFieldStr(jsonObject, "action"); - String usedCpu = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_CPU); - String usedMemory = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_MEMORY); - String usedDisk = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_DISK); - String oldCpu = sitesEntity.getUsedCPU(); - String oldMemory = sitesEntity.getUsedMemory(); - String oldDisk = sitesEntity.getUsedDisk(); - String newCpu = accumOrFreeRes(usedCpu, oldCpu, action, sitesEntity.getTotalCPU(), "cpu"); - String newMemory = accumOrFreeRes(usedMemory, oldMemory, action, sitesEntity.getTotalMemory(), "memory"); - String newDisk = accumOrFreeRes(usedDisk, oldDisk, action, sitesEntity.getTotalDisk(), "disk"); - - JSONObject resUsed = new JSONObject(); - resUsed.put(ParamConstant.USED_CPU, newCpu); - resUsed.put(ParamConstant.USED_MEMORY, newMemory); - resUsed.put(ParamConstant.USED_DISK, newDisk); - resUsed.put("id", sitesEntity.getId()); - resUsed.put("name", sitesEntity.getName()); - resUsed.put("status", sitesEntity.getStatus()); - resUsed.put("location", sitesEntity.getLocation()); - resUsed.put("country", sitesEntity.getCountry()); - resUsed.put(ParamConstant.PARAM_VIMID, sitesEntity.getVimId()); - resUsed.put(ParamConstant.PARAM_VIMNAME, sitesEntity.getVimName()); - resUsed.put(ParamConstant.TOTAL_CPU, sitesEntity.getTotalCPU()); - resUsed.put(ParamConstant.TOTAL_MEMORY, sitesEntity.getTotalMemory()); - resUsed.put(ParamConstant.TOTAL_DISK, sitesEntity.getTotalDisk()); - return resUsed; - } - - private String accumOrFreeRes(String resUsed, String resOld, String action, String total, String type) - throws ServiceException { - BigDecimal iResUsed = new BigDecimal(resUsed); - BigDecimal iResOld = new BigDecimal(resOld); - BigDecimal itotal = new BigDecimal(total); - if("online".equals(action)) { - if(iResOld.add(iResUsed).compareTo(itotal) > 0) { - throw new ServiceException("Grant resource fail! The " + type + " resource not enough."); - } - return String.valueOf(iResOld.add(iResUsed)); - } else { - if(iResOld.subtract(iResUsed).compareTo(BigDecimal.ZERO) < 0) { - throw new ServiceException("Grant resource fail! The " + type + " resource used below zero."); - } - return String.valueOf(iResOld.subtract(iResUsed)); - } - } - - @Override - public int updateResource(JSONObject jsonObject) throws ServiceException { - return sitesBusiness.updateSiteResource(SitesEntity.toEntity(jsonObject)); - } - - @Override - public int delete(String id) throws ServiceException { - Map map = new HashMap(10); - map.put(ParamConstant.PARAM_ID, id); - List datacenters = getList(map); - SitesEntity site = datacenters.get(0); - LOGGER.info("site: {}", site); - String vimId = site.getVimId(); - LOGGER.info("vimId: {}", vimId); - resOperateService.sendMsgMonitor("delete", vimId); - resOperateService.deleteIRes(vimId); - return sitesBusiness.deleteSite(id); - } - - @Override - public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { - return sitesBusiness.updateSiteByVimId(SitesEntity.toEntity(jsonObject)); - } - - @Override - public List getList(Map condition) throws ServiceException { - return sitesBusiness.getSites(condition); - } - - @Override - public SitesEntity get(Map condition) throws ServiceException { - List siteList = sitesBusiness.getSites(condition); - if(null == siteList || siteList.isEmpty()) { - return null; - } - return siteList.get(0); - } - - @Override - public int deleteResByVimId(String vimId) throws ServiceException { - return 0; - } - - public void setSitesBusiness(SitesBusiness sitesBusiness) { - this.sitesBusiness = sitesBusiness; - } - - public void setLimitsBusiness(LimitsBusiness limitsBusiness) { - this.limitsBusiness = limitsBusiness; - } - - public void setResOperateService(ResOperateService resOperateService) { - this.resOperateService = resOperateService; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java deleted file mode 100644 index d1405a2..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; -import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; - -import net.sf.json.JSONObject; - -/** - * Vim info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public class VimImpl implements Vim { - - private VimBusiness vimBusiness; - - @Override - public int add(String id) throws ServiceException { - return vimBusiness.addVim(id); - } - - @Override - public int add(JSONObject jsonObject) throws ServiceException { - return add(jsonObject.getString("id")); - } - - @Override - public int update(JSONObject jsonObject) throws ServiceException { - return 0; - } - - @Override - public int delete(String id) throws ServiceException { - return vimBusiness.deleteVim(id); - } - - @Override - public VimEntity getVim(String id) throws ServiceException { - return vimBusiness.getVim(id); - } - - @Override - public List getList() throws ServiceException { - return vimBusiness.getVims(); - } - - @Override - public List getVimInfo(Map condition) throws ServiceException { - // get vim from vimadapter - return new ArrayList(); - } - - public void setVimBusiness(VimBusiness vimBusiness) { - this.vimBusiness = vimBusiness; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java deleted file mode 100644 index 44adb19..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface Host extends InterfaceResManagement { - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; - - /** - *
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList(Map condition) throws ServiceException; - - /** - *
- * - * @param resPoolEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int update(HostEntity resPoolEntity) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java deleted file mode 100644 index a89e48e..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface InterfaceResManagement extends ResManagement { - - /** - *
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteResByVimId(String vimId) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java deleted file mode 100644 index 7ee574c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; - -import net.sf.json.JSONObject; - -/** - * Location details class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface Location extends ResManagement { - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - Map get(String id) throws ServiceException; - - /** - * Get list of locations.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List get(Map condition) throws ServiceException; - - /** - * Get location details.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - LocationEntity getLocation(Map condition) throws ServiceException; - - /** - * Get location info.
- * - * @param locationInfo - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getLocationInfo(List locationInfo) throws ServiceException; - - /** - * Get Country.
- * - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getCountry() throws ServiceException; - - /** - * Get location by country.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getLocationByCountry(Map condition) throws ServiceException; - - /** - * Get cloud services.
- * - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getCloudservice() throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java deleted file mode 100644 index bd00e1a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; - -import net.sf.json.JSONObject; - -/** - * - * Network class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface Network extends InterfaceResManagement { - - /** - * - * Update status by VIM Id.
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; - - /** - * - * Get list of networks.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList(Map condition) throws ServiceException; - - /** - *
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int add(NetworkEntity entity) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java deleted file mode 100644 index 3ef79b3..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface Port extends InterfaceResManagement { - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; - - /** - *
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList(Map condition) throws ServiceException; - - /** - *
- * - * @param resPoolEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int update(PortEntity resPoolEntity) throws ServiceException; - - /** - *
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int add(PortEntity portEntity) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java deleted file mode 100644 index 8acbf77..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface ResManagement { - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int add(JSONObject jsonObject) throws ServiceException; - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int update(JSONObject jsonObject) throws ServiceException; - - /* - * key : parameter key value : parameter value - */ - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int delete(String id) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java deleted file mode 100644 index ab2e104..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface Sites extends InterfaceResManagement { - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; - - /** - *
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList(Map condition) throws ServiceException; - - /** - *
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - SitesEntity get(Map condition) throws ServiceException; - - /** - *
- * - * @param jsonObject - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateResource(JSONObject jsonObject) throws ServiceException; - - /** - *
- * - * @param sitesEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int update(SitesEntity sitesEntity) throws ServiceException; - - /** - *
- * - * @param json - * @throws ServiceException - * @since NFVO 0.5 - */ - void sendToMonitor(JSONObject json) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java deleted file mode 100644 index f923e0f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.base.openstack.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; - -import net.sf.json.JSONObject; - -/** - * Virtualised Infrastructure Manager.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public interface Vim extends ResManagement { - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - VimEntity getVim(String id) throws ServiceException; - - /** - *
- * - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList() throws ServiceException; - - /** - * - * Get VIM information.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getVimInfo(Map condition) throws ServiceException; - - /** - *
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int add(String vimId) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java deleted file mode 100644 index 6da2657..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.HostDao; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * Host business implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class HostBusinessImpl implements HostBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(HostBusinessImpl.class); - - private HostDao hostDao; - - @Override - public HostEntity getHost(String id) { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getHost; msg=get error, because id is empty."); - return null; - } - return hostDao.getHost(id); - } - - @Override - public List getHosts(Map condition) { - return hostDao.getHosts(condition); - } - - @Override - public int deleteHost(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=deleteHost; msg=delete error, because id is empty."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.id.null")); - } - HostEntity rp = hostDao.getHost(id); - if(null == rp) { - return hostDao.deleteHost(id); - } - - return hostDao.deleteHost(id); - } - - @Override - public int addHost(HostEntity hostEntity) throws ServiceException { - if(null == hostEntity) { - LOGGER.error("function=addHost; msg=add error, because hostEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); - } - - if(!checkId(hostEntity.getId())) { - LOGGER.error("function=addHost; msg=add error, because id is already exist."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); - } - if(StringUtils.isEmpty(hostEntity.getId())) { - hostEntity.setId(UUID.randomUUID().toString()); - } - return hostDao.addHost(hostEntity); - } - - @Override - public int addHostSelective(HostEntity hostEntity) throws ServiceException { - if(null == hostEntity) { - LOGGER.error("function=addHostSelective; msg=add error, because hostEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); - } - if(!checkId(hostEntity.getId())) { - LOGGER.error("function=addHostSelective; msg=add error, because id is allready exist."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); - } - - if(StringUtils.isEmpty(hostEntity.getId())) { - hostEntity.setId(UUID.randomUUID().toString()); - } - return hostDao.addHostSelective(hostEntity); - } - - private boolean checkId(String id) { - HostEntity respool = hostDao.getHost(id); - if(null == respool) { - return true; - } - return false; - } - - @Override - public int updateHostSelective(HostEntity hostEntity) throws ServiceException { - if(!checkId(hostEntity.getId())) { - return hostDao.updateHostSelective(hostEntity); - } else { - return addHostSelective(hostEntity); - } - } - - @Override - public int updateHost(HostEntity hostEntity) throws ServiceException { - if(null == hostEntity) { - LOGGER.error("function=updateHost; msg=update error, because hostEntity is null."); - throw new ServiceException("update error, because hostEntity is null."); - } - - return hostDao.updateHost(hostEntity); - } - - @Override - public int updateHostByVimId(HostEntity hostEntity) throws ServiceException { - if(null == hostEntity) { - LOGGER.error("function=updateHostByVimId; msg=update error, because hostEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.update.entity.null")); - } - return hostDao.updateHostByVimId(hostEntity); - } - - @Override - public int deleteHostByVimId(String vimId) throws ServiceException { - if(StringUtils.isEmpty(vimId)) { - LOGGER.error("function=deleteHostByVimId; msg=delete error, because VimId is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.vimid.check")); - } - return hostDao.deleteHostByVimId(vimId); - } - - public void setHostDao(HostDao hostDao) { - this.hostDao = hostDao; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java deleted file mode 100644 index eeb2de0..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class LimitsBusinessImpl implements LimitsBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(LimitsBusinessImpl.class); - - /** - *
- * - * @param vimId - * @param tenantId - * @return - * @since NFVO 0.5 - */ - private JSONObject getResponse(String vimId, String tenantId) { - LOGGER.info("function=getResponse; vimId={}, tenantId={}", vimId, tenantId); - String url = String.format(UrlConstant.GET_LIMITS_URL, vimId, tenantId); - JSONObject result = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); - LOGGER.warn("function=getResponse; result={}", result); - if(null == result) { - JSONObject obj = new JSONObject(); - obj.put("msg", "getLimits fail!"); - return obj; - } - return result; - } - - @Override - public JSONObject getLimits(String vimId) throws ServiceException { - JSONObject vimInfo = VimUtil.getVimById(vimId); - LOGGER.info("GetLimits vimInfo: {}", vimInfo); - String vimName = vimInfo.getString("name"); - String tenant = vimInfo.getString("tenant"); - String tenantId = VimUtil.getTenantIdByName(tenant, vimId); - - JSONObject limits = getResponse(vimId, tenantId); - - String totalCPU = String.valueOf(limits.get("maxTotalCores")); - String totalMemory = String.valueOf(limits.get("maxTotalRAMSize")); - String totalDisk = String.valueOf(limits.get("maxTotalVolumeGigabytes")); - String usedCPU = String.valueOf(limits.get("totalCoresUsed")); - String usedMemory = String.valueOf(limits.get("totalRAMUsed")); - String usedDisk = String.valueOf(limits.get("totalGigabytesUsed")); - - JSONObject result = new JSONObject(); - result.put("vimId", vimId); - result.put("vimName", vimName); - result.put("totalCPU", totalCPU); - result.put("totalMemory", totalMemory); - result.put("totalDisk", totalDisk); - result.put("usedCPU", usedCPU); - result.put("usedMemory", usedMemory); - result.put("usedDisk", usedDisk); - LOGGER.info("getLimits result:{}", result); - return result; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java deleted file mode 100644 index 76ee2a0..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.util.StringUtil; -import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * Location Business implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class LocationBusinessImpl implements LocationBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(LocationBusinessImpl.class); - - private LocationDao locationDao; - - /** - * - * Check location.
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - public boolean checkLocation(LocationEntity locationEntity) throws ServiceException { - String location = locationEntity.getLocation(); - Map map = new HashMap<>(); - map.put(ParamConstant.PARAM_LOCATION, location); - List locationList = getLocations(map); - if(locationList == null || locationList.isEmpty()) { - return false; - } - return true; - } - - /** - * - * Check Latitude.;
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - public boolean checkLatitude(LocationEntity locationEntity) throws ServiceException { - String latitu = locationEntity.getLatitude(); - String longitu = locationEntity.getLongitude(); - if("-0".equals(locationEntity.getLatitude())) { - locationEntity.setLatitude("0"); - } - if("-0".equals(locationEntity.getLongitude())) { - locationEntity.setLongitude("0"); - } - float latitude = Float.parseFloat(latitu); - float longitude = Float.parseFloat(longitu); - if((latitude >= -90 && latitude <= 90) && (longitude >= -180 && longitude <= 180)) { - return true; - } - return false; - } - - private boolean checkModified(LocationEntity locationEntity) { - String newCountry = locationEntity.getCountry(); - String newLocation = locationEntity.getLocation(); - String id = locationEntity.getId(); - LocationEntity selectLocation = locationDao.getLocation(id); - if(null == selectLocation) { - return false; - } - String oldCountry = selectLocation.getCountry(); - String oldLocation = selectLocation.getLocation(); - if(newCountry.equals(oldCountry) && newLocation.equals(oldLocation)) { - return true; - } - return false; - } - - @Override - public LocationEntity getLocation(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getLocation; msg=get error, because id is empty."); - return null; - } - return locationDao.getLocation(id); - } - - @Override - public List getCountry() throws ServiceException { - return locationDao.getCountry(); - } - - @Override - public List getLocationByCountry(Map condition) throws ServiceException { - return locationDao.getLocationByCountry(condition); - } - - @Override - public List getLocations(Map condition) throws ServiceException { - return locationDao.getLocations(condition); - } - - @Override - public int deleteLocation(String location) throws ServiceException { - if(StringUtils.isEmpty(location)) { - LOGGER.error("function=deleteLocation; msg=delete error, because location is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.base.entity.check")); - } - return locationDao.deleteLocation(location); - } - - @Override - public int addLocation(LocationEntity locationEntity) throws ServiceException { - if(null == locationEntity) { - LOGGER.error("function=addLocation; msg=add error, because locationEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); - } - if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) - || !StringUtil.checkXss(locationEntity.getLatitude()) - || !StringUtil.checkXss(locationEntity.getLongitude())) { - LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); - } - if(checkLocation(locationEntity)) { - LOGGER.error("function=addLocation; msg=add Location error, because location exist."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.check")); - } - if(!checkLatitude(locationEntity)) { - LOGGER.error("function=addLocation; msg=add Location error, because latitude or longitude illegal."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.latitude.check")); - } - if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { - locationEntity.setId(UUID.randomUUID().toString()); - } - LOGGER.error("function=addLocation; msg=add DO success, : " + locationEntity); - return locationDao.addLocation(locationEntity); - - } - - @Override - public int addLocationSelective(LocationEntity locationEntity) throws ServiceException { - if(null == locationEntity) { - LOGGER.error("function=addLocationSelective; msg=add error, because locationEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); - } - if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) - || !StringUtil.checkXss(locationEntity.getLatitude()) - || !StringUtil.checkXss(locationEntity.getLongitude())) { - LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); - } - if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { - locationEntity.setId(UUID.randomUUID().toString()); - } - return locationDao.addLocationSelective(locationEntity); - } - - @Override - public int updateLocationSelective(LocationEntity locationEntity) throws ServiceException { - if(null == locationEntity) { - LOGGER.error("function=updateLocationSelective; msg=update error, because locationEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.check")); - } - if(!checkLatitude(locationEntity)) { - LOGGER.error("function=updateLocationSelective; msg=update Location error, " - + "because latitude or longitude illegal."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); - } - if(!checkModified(locationEntity)) { - LOGGER.error("function=updateLocationSelective; msg=update Location error, " - + "because country or location be modified."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.modified.check")); - } - return locationDao.updateLocationSelective(locationEntity); - } - - @Override - public int updateLocation(LocationEntity locationEntity) throws ServiceException { - if(null == locationEntity) { - LOGGER.error("function=updateLocation; msg=update error, because locationEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.null")); - } - if(!checkLatitude(locationEntity)) { - LOGGER.error("function=updateLocation; msg=update Location error, because latitude or longitude illegal."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); - } - return locationDao.updateLocation(locationEntity); - } - - public LocationDao getLocationDao() { - return locationDao; - } - - public void setLocationDao(LocationDao locationDao) { - this.locationDao = locationDao; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java deleted file mode 100644 index 811c3e4..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Network business implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class NetworkBusinessImpl implements NetworkBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkBusinessImpl.class); - - private NetworkDao networkDao; - - @Override - public NetworkEntity getNetwork(String id) { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getNetwork; msg=get error, because id is empty."); - return null; - } - return networkDao.getNetwork(id); - } - - @Override - public List getNetworks(Map condition) { - return networkDao.getNetworks(condition); - } - - @Override - public int deleteNetwork(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=deleteNetwork; msg=delete error, because id is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.delete.id.null")); - } - return networkDao.deleteNetwork(id); - } - - @Override - public int addNetwork(NetworkEntity networkEntity) throws ServiceException { - if(null == networkEntity) { - LOGGER.error("function=addNetwork; msg=add error, because networkEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); - } - if(!checkId(networkEntity.getId())) { - return networkDao.updateNetworkSelective(networkEntity); - } - if(StringUtils.isEmpty(networkEntity.getId())) { - networkEntity.setId(UUID.randomUUID().toString()); - } - return networkDao.addNetwork(networkEntity); - } - - @Override - public int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException { - if(null == networkEntity) { - LOGGER.error("function=addNetworkSelective; msg=add error, because networkEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); - } - if(!checkId(networkEntity.getId())) { - return networkDao.updateNetworkSelective(networkEntity); - } - if(StringUtils.isEmpty(networkEntity.getId())) { - networkEntity.setId(UUID.randomUUID().toString()); - } - return networkDao.addNetworkSelective(networkEntity); - } - - private boolean checkId(String id) { - NetworkEntity network = networkDao.getNetwork(id); - if(null == network) { - return true; - } - return false; - } - - @Override - public int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException { - if(null == networkEntity) { - LOGGER.error("function=updateNetworkSelective; msg=update error, because networkEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); - } - return networkDao.updateNetworkSelective(networkEntity); - } - - @Override - public int updateNetwork(NetworkEntity networkEntity) throws ServiceException { - if(null == networkEntity) { - LOGGER.error("function=updateNetwork; msg=update error, because networkEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); - } - return networkDao.updateNetwork(networkEntity); - } - - @Override - public int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException { - if(null == networkEntity) { - LOGGER.error("function=updateNetworkByVimId; msg=update error, because networkEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); - } - return networkDao.updateNetworkByVimId(networkEntity); - } - - @Override - public int deleteNetworkByVimId(String vimId) throws ServiceException { - if(StringUtils.isEmpty(vimId)) { - LOGGER.error("function=deleteNetworkByVimId; msg=delete error, because VimId is empty."); - throw new ServiceException(ResourceUtil.getMessage("")); - } - return networkDao.deleteNetworkByVimId(vimId); - } - - public void setNetworkDao(NetworkDao networkDao) { - this.networkDao = networkDao; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java deleted file mode 100644 index ce715d9..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.PortDao; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Port business implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class PortBusinessImpl implements PortBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(PortBusinessImpl.class); - - private PortDao portDao; - - @Override - public PortEntity getPort(String id) { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getPort; msg=get error, because id is empty."); - return null; - } - return portDao.getPort(id); - } - - @Override - public List getPorts(Map condition) { - return portDao.getPorts(condition); - } - - @Override - public int deletePort(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=deletePort; msg=delete error, because id is empty."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.id.null")); - } - PortEntity rp = portDao.getPort(id); - if(null == rp) { - return portDao.deletePort(id); - } - - return portDao.deletePort(id); - } - - @Override - public int addPort(PortEntity portEntity) throws ServiceException { - if(null == portEntity) { - LOGGER.error("function=addPort; msg=add error, because portEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); - } - - if(!checkId(portEntity.getId())) { - return portDao.updatePortSelective(portEntity); - } - if(StringUtils.isEmpty(portEntity.getId())) { - portEntity.setId(UUID.randomUUID().toString()); - } - return portDao.addPort(portEntity); - } - - @Override - public int addPortSelective(PortEntity portEntity) throws ServiceException { - if(null == portEntity) { - LOGGER.error("function=addPortSelective; msg=add error, because portEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); - } - if(!checkId(portEntity.getId())) { - return portDao.updatePortSelective(portEntity); - } - - if(StringUtils.isEmpty(portEntity.getId())) { - portEntity.setId(UUID.randomUUID().toString()); - } - return portDao.addPortSelective(portEntity); - } - - private boolean checkId(String id) { - PortEntity respool = portDao.getPort(id); - if(null == respool) { - return true; - } - return false; - } - - @Override - public int updatePortSelective(PortEntity portEntity) throws ServiceException { - if(null == portEntity) { - LOGGER.error("function=updatePortSelective; msg=update error, because portEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); - } - - return portDao.updatePortSelective(portEntity); - } - - @Override - public int updatePort(PortEntity portEntity) throws ServiceException { - if(null == portEntity) { - LOGGER.error("function=updatePort; msg=update error, because portEntity is null."); - throw new ServiceException("update error, because portEntity is null."); - } - - return portDao.updatePort(portEntity); - } - - @Override - public int updatePortByVimId(PortEntity portEntity) throws ServiceException { - if(null == portEntity) { - LOGGER.error("function=updatePortByVimId; msg=update error, because portEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); - } - return portDao.updatePortByVimId(portEntity); - } - - @Override - public int deletePortByVimId(String vimId) throws ServiceException { - if(StringUtils.isEmpty(vimId)) { - LOGGER.error("function=deletePortByVimId; msg=delete error, because VimId is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.vimid.check")); - } - return portDao.deletePortByVimId(vimId); - } - - public void setPortDao(PortDao portDao) { - this.portDao = portDao; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java deleted file mode 100644 index 6ffb3fc..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Sites info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public class SitesBusinessImpl implements SitesBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(SitesBusinessImpl.class); - - private SitesDao sitesDao; - - private static final String TYPE_ADD = "add"; - - private static final String TYPE_UPDATE = "update"; - - private static final String TYPE_DELETE = "delete"; - - @Override - public SitesEntity getSite(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getSite; msg=get error, because id is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.null")); - } - return sitesDao.getSite(id); - } - - @Override - public List getSites(Map condition) { - return sitesDao.getSites(condition); - } - - @Override - public int deleteSite(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=deleteSite; msg=delete error, because id is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.delete.id.null")); - } - - return sitesDao.deleteSite(id); - } - - @Override - public int addSite(SitesEntity sitesEntity) throws ServiceException { - LOGGER.info("addSite sitesEntity"); - if(null == sitesEntity) { - LOGGER.error("function=addSite; msg=add error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); - } - // if(!StringUtil.checkXss(sitesEntity.getName()) || - // !StringUtil.checkXss(sitesEntity.getCountry()) - // || !StringUtil.checkXss(sitesEntity.getLocation())) { - // LOGGER.error("function=addLocation; msg=add site error, because XSS injection."); - // throw new ServiceException( - // ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); - // } - LOGGER.info("sitesEntity: " + sitesEntity.toString()); - this.checkSite(sitesEntity, TYPE_ADD); - SitesEntity.dataFramat(sitesEntity); - LOGGER.info("Add datacenter data into DB."); - return sitesDao.addSite(sitesEntity); - } - - private void checkSite(SitesEntity sitesEntity, String type) throws ServiceException { - if(TYPE_ADD.equals(type)) { - checkId(sitesEntity.getId()); - checkSiteName(sitesEntity.getName()); - if(!SitesEntity.checkResource(sitesEntity)) { - LOGGER.error("function=checkRespool; msg=site{} resource error", sitesEntity.toString()); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.resource.check")); - } - } - } - - private void checkSiteName(String siteName) throws ServiceException { - Map siteMap = new HashMap<>(10); - siteMap.put(ParamConstant.PARAM_NAME, siteName); - List siteList = sitesDao.getSites(siteMap); - if(null != siteList && !siteList.isEmpty()) { - LOGGER.error("function=checkSiteName; msg=site: {} has already exist.", siteName); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.name.check")); - } - } - - private void checkId(String id) throws ServiceException { - SitesEntity site = sitesDao.getSite(id); - if(null != site) { - LOGGER.error("function=checkId; msg=add error, because id is already exist."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.check")); - } - } - - @Override - public int addSiteSelective(SitesEntity sitesEntity) throws ServiceException { - if(null == sitesEntity) { - LOGGER.error("function=addSiteSelective; msg=add error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); - } - this.checkSite(sitesEntity, TYPE_ADD); - - if(StringUtils.isEmpty(sitesEntity.getId())) { - sitesEntity.setId(UUID.randomUUID().toString()); - } - SitesEntity.dataFramat(sitesEntity); - return sitesDao.addSiteSelective(sitesEntity); - } - - @Override - public int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException { - if(null == sitesEntity) { - LOGGER.error("function=updateSiteSelective; msg=update error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); - } - - this.checkSite(sitesEntity, TYPE_UPDATE); - SitesEntity.dataFramat(sitesEntity); - return sitesDao.updateSiteSelective(sitesEntity); - } - - @Override - public int updateSite(SitesEntity sitesEntity) throws ServiceException { - if(null == sitesEntity) { - LOGGER.error("function=updateSite; msg=update error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); - } - this.checkSite(sitesEntity, TYPE_UPDATE); - SitesEntity.dataFramat(sitesEntity); - return sitesDao.updateSite(sitesEntity); - } - - @Override - public int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException { - if(null == sitesEntity) { - LOGGER.error("function=updateSiteByVimId; msg=update error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); - } - SitesEntity.dataFramat(sitesEntity); - return sitesDao.updateSiteByVimId(sitesEntity); - } - - @Override - public int updateSiteResource(SitesEntity sitesEntity) throws ServiceException { - if(null == sitesEntity) { - LOGGER.error("function=updateSiteResource; msg=update error, because sitesEntity is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); - } - SitesEntity.dataFramat(sitesEntity); - return sitesDao.updateSiteSelective(sitesEntity); - } - - public void setSitesDao(SitesDao sitesDao) { - this.sitesDao = sitesDao; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java deleted file mode 100644 index 6cbcfc4..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.impl; - -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.util.StringUtil; -import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness; -import org.openo.nfvo.resmanagement.service.dao.inf.VimDao; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Vim info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public class VimBusinessImpl implements VimBusiness { - - private static final Logger LOGGER = LoggerFactory.getLogger(VimBusinessImpl.class); - - private VimDao vimDao; - - @Override - public VimEntity getVim(String id) { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=getVim; msg=get error, because id is empty."); - return null; - } - return vimDao.getVim(id); - } - - @Override - public List getVims() { - return vimDao.getVims(); - } - - @Override - public int deleteVim(String id) throws ServiceException { - if(StringUtils.isEmpty(id)) { - LOGGER.error("function=deleteVim; msg=deleteVim error, because id is empty."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.del.id.check")); - } - return vimDao.deleteVim(id); - } - - @Override - public int addVim(String id) throws ServiceException { - if(!StringUtil.isValidString(id)) { - LOGGER.error("function=addVim; msg=add error, because id is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.null")); - } - if(!checkId(id)) { - LOGGER.error("function=addVim; msg=add error, because id is already exist."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.check")); - } - - VimEntity vimEntity = new VimEntity(); - vimEntity.setId(id); - return vimDao.addVim(vimEntity); - } - - private boolean checkId(String id) { - VimEntity vim = vimDao.getVim(id); - if(null == vim) { - return true; - } - return false; - } - - public void setVimDao(VimDao vimDao) { - this.vimDao = vimDao; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java deleted file mode 100644 index 803c96e..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; - -/** - * Host Buisiness Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 31, 2016 - */ -public interface HostBusiness { - - /** - * - * Get host.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - HostEntity getHost(String id); - - /** - * - * Get details of hosts.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getHosts(Map condition); - - /** - * - * Delete host.
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteHost(String id) throws ServiceException; - - /** - * - * Delete host by VIM Id.
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteHostByVimId(String vimId) throws ServiceException; - - /** - * - * Add host.
- * - * @param hostEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addHost(HostEntity hostEntity) throws ServiceException; - - /** - * - * Add selective host.
- * - * @param hostEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addHostSelective(HostEntity hostEntity) throws ServiceException; - - /** - * - * Update selective host.
- * - * @param hostEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateHostSelective(HostEntity hostEntity) throws ServiceException; - - /** - * - * Update host.
- * - * @param hostEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateHost(HostEntity hostEntity) throws ServiceException; - - /** - * - * Update host by VIM Id.
- * - * @param hostEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateHostByVimId(HostEntity hostEntity) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java deleted file mode 100644 index b78b6a8..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface LimitsBusiness { - - /** - *
- * - * @param paramJson - * @return - * @since NFVO 0.5 - */ - JSONObject getLimits(String vimId) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java deleted file mode 100644 index fd5cef2..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; - -/** - * - * Location Business Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface LocationBusiness { - - /** - * - * Get Location.
- * - * @param location - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - LocationEntity getLocation(String location) throws ServiceException; - - /** - * - * Get Locations.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getLocations(Map condition) throws ServiceException; - - /** - * - * Delete Location.
- * - * @param location - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteLocation(String location) throws ServiceException; - - /** - * - * Add Location.
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addLocation(LocationEntity locationEntity) throws ServiceException; - - /** - * - * Add Selective Location.
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addLocationSelective(LocationEntity locationEntity) throws ServiceException; - - /** - * - * Update Selective Location.
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateLocationSelective(LocationEntity locationEntity) throws ServiceException; - - /** - * - * Update Location.
- * - * @param locationEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateLocation(LocationEntity locationEntity) throws ServiceException; - - /** - * - * Get Country.
- * - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getCountry() throws ServiceException; - - /** - * - * Get Location By Country.
- * - * @param condition - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getLocationByCountry(Map condition) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java deleted file mode 100644 index be0c9dc..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; - -/** - * - * Network Business class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface NetworkBusiness { - - /** - * - * Get network details.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - NetworkEntity getNetwork(String id); - - /** - * - * Get details of available networks.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getNetworks(Map condition); - - /** - * - * Delete Network.
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteNetwork(String id) throws ServiceException; - - /** - * - * Delete network by Virtual Infrastructure Manager ID.
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteNetworkByVimId(String vimId) throws ServiceException; - - /** - * - * Add Network.
- * - * @param networkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addNetwork(NetworkEntity networkEntity) throws ServiceException; - - /** - * - * Add Selective Network.
- * - * @param networkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException; - - /** - * - * Update Selective Network.
- * - * @param networkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException; - - /** - * - * Update Network.
- * - * @param networkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateNetwork(NetworkEntity networkEntity) throws ServiceException; - - /** - * - * Update network by Virtual Infrastructure Manager ID.
- * - * @param networkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java deleted file mode 100644 index b81a3e1..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; - -/** - * Port Buisiness Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 31, 2016 - */ -public interface PortBusiness { - - /** - * - * Get Port.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - PortEntity getPort(String id); - - /** - * - * Get details of ports.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getPorts(Map condition); - - /** - * - * Delete Port.
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deletePort(String id) throws ServiceException; - - /** - * - * Delete port by VIM ID.
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deletePortByVimId(String vimId) throws ServiceException; - - /** - * - * Add port.
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addPort(PortEntity portEntity) throws ServiceException; - - /** - * - * Add selective port.
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int addPortSelective(PortEntity portEntity) throws ServiceException; - - /** - * - * Update selective port.
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updatePortSelective(PortEntity portEntity) throws ServiceException; - - /** - * - * Update port.
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updatePort(PortEntity portEntity) throws ServiceException; - - /** - * - * Update port by VIM Id.
- * - * @param portEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int updatePortByVimId(PortEntity portEntity) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java deleted file mode 100644 index 8d11a39..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; - -/** - * DC info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface SitesBusiness { - - /** - * It is used to get Site info.
- * - * @param id - * @return The get result - * @throws ServiceException When get failed. - * @since NFVO 0.5 - */ - SitesEntity getSite(String id) throws ServiceException; - - /** - * It is used to get Sites info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getSites(Map condition); - - /** - * It is used to delete Site info.
- * - * @param id - * @return The delete result - * @throws ServiceException When delete failed. - * @since NFVO 0.5 - */ - int deleteSite(String id) throws ServiceException; - - /** - * It is used to add Site info.
- * - * @param sitesEntity - * @return The add result - * @throws ServiceException When add failed. - * @since NFVO 0.5 - */ - int addSite(SitesEntity sitesEntity) throws ServiceException; - - /** - * It is used to add Site info.
- * - * @param sitesEntity - * @return The add result - * @throws ServiceException When add failed. - * @since NFVO 0.5 - */ - int addSiteSelective(SitesEntity sitesEntity) throws ServiceException; - - /** - * It is used to update Site info.
- * - * @param sitesEntity - * @return The update result - * @throws ServiceException When update failed. - * @since NFVO 0.5 - */ - int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException; - - /** - * It is used to create update Site info.
- * - * @param sitesEntity - * @return The update result - * @throws ServiceException When update failed. - * @since NFVO 0.5 - */ - int updateSite(SitesEntity sitesEntity) throws ServiceException; - - /** - * It is used to update Site info.
- * - * @param sitesEntity - * @return The update result - * @throws ServiceException When update failed. - * @since NFVO 0.5 - */ - int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException; - - /** - * It is used to update Site info.
- * - * @param sitesEntity - * @return The update result - * @throws ServiceException When update failed. - * @since NFVO 0.5 - */ - int updateSiteResource(SitesEntity sitesEntity) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java deleted file mode 100644 index 8806e7a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.business.inf; - -import java.util.List; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; - -/** - * Vim info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface VimBusiness { - - /** - * It is used to get Vim info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - VimEntity getVim(String id); - - /** - * It is used to get Vim info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - List getVims(); - - /** - * It is used to delete Vim info.
- * - * @param id - * @return the delete result - * @throws ServiceException When delete failed. - * @since NFVO 0.5 - */ - int deleteVim(String id) throws ServiceException; - - /** - * It is used to add Vim info.
- * - * @param id - * @return the add result - * @throws ServiceException When add failed. - * @since NFVO 0.5 - */ - int addVim(String id) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java deleted file mode 100644 index e3a76ca..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import org.apache.ibatis.session.SqlSession; - -/** - *
- *

- * Database abstract class to get the MapperManager - *

- * - * @author - * @version NFVO 0.5 2016-3-17 - */ -public class AbstractDao { - - private SqlSession session; - - protected AbstractDao() { - //added this private costructor to fix static errors. - } - - public SqlSession getSession() { - return session; - } - - public void setSession(SqlSession session) { - this.session = session; - } - - /** - * get Mybatis Mapper
- * - * @param type - * The type of Class - * @return Mapper - * @since NFVO 0.5 - */ - public T getMapperManager(Class type) { - return (T)getSession().getMapper(type); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java deleted file mode 100644 index 1c5c03c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.HostDao; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; -import org.openo.nfvo.resmanagement.service.mapper.HostMapper; - -/** - * - * Host DAO implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class HostDaoImpl extends AbstractDao implements HostDao { - - @Override - public HostEntity getHost(String id) { - return getMapperManager(HostMapper.class).getHost(id); - } - - @Override - public List getHosts(Map condition) { - return getMapperManager(HostMapper.class).getHosts(condition); - } - - @Override - public int deleteHost(String id) { - return getMapperManager(HostMapper.class).deleteHost(id); - } - - @Override - public int deleteHostByVimId(String vimId) { - return getMapperManager(HostMapper.class).deleteHostByVimId(vimId); - } - - @Override - public int addHost(HostEntity hostEntity) { - return getMapperManager(HostMapper.class).addHost(hostEntity); - } - - @Override - public int addHostSelective(HostEntity hostEntity) { - return getMapperManager(HostMapper.class).addHostSelective(hostEntity); - } - - @Override - public int updateHostSelective(HostEntity hostEntity) { - return getMapperManager(HostMapper.class).updateHostSelective(hostEntity); - } - - @Override - public int updateHost(HostEntity hostEntity) { - return getMapperManager(HostMapper.class).updateHost(hostEntity); - } - - @Override - public int updateHostByVimId(HostEntity hostEntity) { - return getMapperManager(HostMapper.class).updateHostByVimId(hostEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java deleted file mode 100644 index 949f19f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; -import org.openo.nfvo.resmanagement.service.mapper.LocationMapper; - -/** - * - * Location DAO implemetation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class LocationDaoImpl extends AbstractDao implements LocationDao { - - @Override - public LocationEntity getLocation(String id) { - return getMapperManager(LocationMapper.class).getLocation(id); - } - - @Override - public List getCountry() { - return getMapperManager(LocationMapper.class).getCountry(); - } - - @Override - public List getLocationByCountry(Map condition) { - return getMapperManager(LocationMapper.class).getLocationByCountry(condition); - } - - @Override - public List getLocations(Map condition) { - return getMapperManager(LocationMapper.class).getLocations(condition); - } - - @Override - public int deleteLocation(String id) { - return getMapperManager(LocationMapper.class).deleteLocation(id); - } - - @Override - public int addLocation(LocationEntity locationEntity) { - return getMapperManager(LocationMapper.class).addLocation(locationEntity); - } - - @Override - public int addLocationSelective(LocationEntity locationEntity) { - return getMapperManager(LocationMapper.class).addLocationSelective(locationEntity); - } - - @Override - public int updateLocationSelective(LocationEntity locationEntity) { - return getMapperManager(LocationMapper.class).updateLocationSelective(locationEntity); - } - - @Override - public int updateLocation(LocationEntity locationEntity) { - return getMapperManager(LocationMapper.class).updateLocation(locationEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java deleted file mode 100644 index 12769a2..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; -import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; - -/** - * - * Network DAO implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class NetworkDaoImpl extends AbstractDao implements NetworkDao { - - @Override - public NetworkEntity getNetwork(String id) { - return getMapperManager(NetworkMapper.class).getNetwork(id); - } - - @Override - public List getNetworks(Map condition) { - return getMapperManager(NetworkMapper.class).getNetworks(condition); - } - - @Override - public int deleteNetwork(String id) { - return getMapperManager(NetworkMapper.class).deleteNetwork(id); - } - - @Override - public int deleteNetworkByVimId(String vimId) { - return getMapperManager(NetworkMapper.class).deleteNetworkByVimId(vimId); - } - - @Override - public int addNetwork(NetworkEntity networkEntity) { - return getMapperManager(NetworkMapper.class).addNetwork(networkEntity); - } - - @Override - public int addNetworkSelective(NetworkEntity networkEntity) { - return getMapperManager(NetworkMapper.class).addNetworkSelective(networkEntity); - } - - @Override - public int updateNetworkSelective(NetworkEntity networkEntity) { - return getMapperManager(NetworkMapper.class).updateNetworkSelective(networkEntity); - } - - @Override - public int updateNetwork(NetworkEntity networkEntity) { - return getMapperManager(NetworkMapper.class).updateNetwork(networkEntity); - } - - @Override - public int updateNetworkByVimId(NetworkEntity networkEntity) { - return getMapperManager(NetworkMapper.class).updateNetworkByVimId(networkEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java deleted file mode 100644 index e113c7a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.PortDao; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; -import org.openo.nfvo.resmanagement.service.mapper.PortMapper; - -/** - * - * Port DAO implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class PortDaoImpl extends AbstractDao implements PortDao { - - @Override - public PortEntity getPort(String id) { - return getMapperManager(PortMapper.class).getPort(id); - } - - @Override - public List getPorts(Map condition) { - return getMapperManager(PortMapper.class).getPorts(condition); - } - - @Override - public int deletePort(String id) { - return getMapperManager(PortMapper.class).deletePort(id); - } - - @Override - public int deletePortByVimId(String vimId) { - return getMapperManager(PortMapper.class).deletePortByVimId(vimId); - } - - @Override - public int addPort(PortEntity portEntity) { - return getMapperManager(PortMapper.class).addPort(portEntity); - } - - @Override - public int addPortSelective(PortEntity portEntity) { - return getMapperManager(PortMapper.class).addPortSelective(portEntity); - } - - @Override - public int updatePortSelective(PortEntity portEntity) { - return getMapperManager(PortMapper.class).updatePortSelective(portEntity); - } - - @Override - public int updatePort(PortEntity portEntity) { - return getMapperManager(PortMapper.class).updatePort(portEntity); - } - - @Override - public int updatePortByVimId(PortEntity portEntity) { - return getMapperManager(PortMapper.class).updatePortByVimId(portEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java deleted file mode 100644 index 2d29d7b..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.openo.nfvo.resmanagement.service.mapper.SitesMapper; - -/** - * DC interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public class SitesDaoImpl extends AbstractDao implements SitesDao { - - @Override - public SitesEntity getSite(String id) { - return getMapperManager(SitesMapper.class).getSite(id); - } - - @Override - public List getSites(Map condition) { - return getMapperManager(SitesMapper.class).getSites(condition); - } - - @Override - public int deleteSite(String id) { - return getMapperManager(SitesMapper.class).deleteSite(id); - } - - @Override - public int addSite(SitesEntity sitesEntity) { - return getMapperManager(SitesMapper.class).addSite(sitesEntity); - } - - @Override - public int addSiteSelective(SitesEntity sitesEntity) { - return getMapperManager(SitesMapper.class).addSiteSelective(sitesEntity); - } - - @Override - public int updateSiteSelective(SitesEntity sitesEntity) { - return getMapperManager(SitesMapper.class).updateSiteSelective(sitesEntity); - } - - @Override - public int updateSite(SitesEntity sitesEntity) { - return getMapperManager(SitesMapper.class).updateSite(sitesEntity); - } - - @Override - public int updateSiteByVimId(SitesEntity sitesEntity) { - return getMapperManager(SitesMapper.class).updateSiteByVimId(sitesEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java deleted file mode 100644 index e73b251..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; - -import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; -import org.openo.nfvo.resmanagement.service.dao.inf.VimDao; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; -import org.openo.nfvo.resmanagement.service.mapper.VimMapper; - -/** - * Vim interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 25, 2016 - */ -public class VimDaoImpl extends AbstractDao implements VimDao { - - @Override - public VimEntity getVim(String id) { - return getMapperManager(VimMapper.class).getVim(id); - } - - @Override - public List getVims() { - return getMapperManager(VimMapper.class).getVims(); - } - - @Override - public int deleteVim(String id) { - return getMapperManager(VimMapper.class).deleteVim(id); - } - - @Override - public int addVim(VimEntity vimEntity) { - return getMapperManager(VimMapper.class).addVim(vimEntity); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java deleted file mode 100644 index 96ed906..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao; -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; -import org.openo.nfvo.resmanagement.service.mapper.VirtualLinkMapper; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VirtualLinkDaoImpl extends AbstractDao implements VirtualLinkDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public VirtualLinkEntity getVl(String id) { - return getMapperManager(VirtualLinkMapper.class).selectByPrimaryKey(id); - } - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - @Override - public List getVls(Map condition) { - return getMapperManager(VirtualLinkMapper.class).getVls(condition); - } - - /** - *
- * - * @param virtualLinkEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int addVl(VirtualLinkEntity virtualLinkEntity) { - return getMapperManager(VirtualLinkMapper.class).insert(virtualLinkEntity); - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVlById(String id) { - return getMapperManager(VirtualLinkMapper.class).deleteByPrimaryKey(id); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java deleted file mode 100644 index ee3806c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.inf.VmDao; -import org.openo.nfvo.resmanagement.service.entity.VmEntity; -import org.openo.nfvo.resmanagement.service.mapper.VmMapper; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VmDaoImpl extends AbstractDao implements VmDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public VmEntity getVm(String id) { - return getMapperManager(VmMapper.class).selectByPrimaryKey(id); - } - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - @Override - public List getVms(Map condition) { - return getMapperManager(VmMapper.class).getVms(condition); - } - - /** - *
- * - * @param vmEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int addVm(VmEntity vmEntity) { - return getMapperManager(VmMapper.class).insert(vmEntity); - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVmById(String id) { - return getMapperManager(VmMapper.class).deleteByPrimaryKey(id); - } - - /** - *
- * - * @param vmEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int updateVm(VmEntity vmEntity) { - return getMapperManager(VmMapper.class).updateByPrimaryKeySelective(vmEntity); - } - - /** - *
- * - * @param vnfInstanceId - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVmByVnfId(String vnfInstanceId) { - return getMapperManager(VmMapper.class).deleteByVnfId(vnfInstanceId); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java deleted file mode 100644 index 42bb5b5..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao; -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; -import org.openo.nfvo.resmanagement.service.mapper.VnfMapper; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VnfDaoImpl extends AbstractDao implements VnfDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public VnfEntity getVnf(String id) { - return getMapperManager(VnfMapper.class).selectByPrimaryKey(id); - } - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - @Override - public List getVnfs(Map condition) { - return getMapperManager(VnfMapper.class).getVnfs(condition); - } - - /** - *
- * - * @param vnfEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int addVnf(VnfEntity vnfEntity) { - return getMapperManager(VnfMapper.class).insert(vnfEntity); - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVnfById(String id) { - return getMapperManager(VnfMapper.class).deleteByPrimaryKey(id); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java deleted file mode 100644 index 6e8d32b..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao; -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; -import org.openo.nfvo.resmanagement.service.mapper.VnfInfoMapper; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VnfInfoDaoImpl extends AbstractDao implements VnfInfoDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public VnfInfoEntity getVnfInfo(String id) { - return getMapperManager(VnfInfoMapper.class).selectByPrimaryKey(id); - } - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - @Override - public List getVnfInfos(Map condition) { - return getMapperManager(VnfInfoMapper.class).getVnfInfos(condition); - } - - /** - *
- * - * @param vmEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int addVnfInfo(VnfInfoEntity vnfInfoEntity) { - return getMapperManager(VnfInfoMapper.class).insert(vnfInfoEntity); - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVnfInfoById(String id) { - return getMapperManager(VnfInfoMapper.class).deleteByPrimaryKey(id); - } - - /** - *
- * - * @param vnfInfoEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int updateVnfInfo(VnfInfoEntity vnfInfoEntity) { - return getMapperManager(VnfInfoMapper.class).updateByPrimaryKeySelective(vnfInfoEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java deleted file mode 100644 index ed7db95..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao; -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; -import org.openo.nfvo.resmanagement.service.mapper.VnfStatusMapper; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public class VnfStatusDaoImpl extends AbstractDao implements VnfStatusDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public VnfStatusEntity getVnfStatus(String id) { - return getMapperManager(VnfStatusMapper.class).selectByPrimaryKey(id); - } - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - @Override - public List getVnfStatuss(Map condition) { - return getMapperManager(VnfStatusMapper.class).getVnfStatuss(condition); - } - - /** - *
- * - * @param vnfStatusEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int addVnfStatus(VnfStatusEntity vnfStatusEntity) { - return getMapperManager(VnfStatusMapper.class).insert(vnfStatusEntity); - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - @Override - public int deleteVnfStatusById(String id) { - return getMapperManager(VnfStatusMapper.class).deleteByPrimaryKey(id); - } - - /** - *
- * - * @param vnfStatusEntity - * @return - * @since NFVO 0.5 - */ - @Override - public int updateVnfStatus(VnfStatusEntity vnfStatusEntity) { - return getMapperManager(VnfStatusMapper.class).updateByPrimaryKeySelective(vnfStatusEntity); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java deleted file mode 100644 index a48c6aa..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.HostEntity; - -/** - * Host info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface HostDao { - - /** - * It is used to get Host info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - HostEntity getHost(String id); - - /** - * It is used to get Hosts info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getHosts(Map condition); - - /** - * It is used to delete Hosts info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deleteHost(String id); - - /** - * It is used to delete Hosts info.
- * - * @param vimId - * @return The delete result - * @since NFVO 0.5 - */ - int deleteHostByVimId(String vimId); - - /** - * It is used to add Hosts info.
- * - * @param hostEntity - * @return The add result - * @since NFVO 0.5 - */ - int addHost(HostEntity hostEntity); - - /** - * It is used to add Hosts info.
- * - * @param hostEntity - * @return The add result - * @since NFVO 0.5 - */ - int addHostSelective(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHostSelective(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHost(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHostByVimId(HostEntity hostEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java deleted file mode 100644 index dcf2c9f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; - -/** - * - * Location DAO Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface LocationDao { - - /** - * - * Get Location.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - LocationEntity getLocation(String id); - - /** - * - * Get Locations.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getLocations(Map condition); - - /** - * - * Delete Location.
- * - * @param location - * @return - * @since NFVO 0.5 - */ - int deleteLocation(String location); - - /** - * - * Add Location.
- * - * @param sodoResEntity - * @return - * @since NFVO 0.5 - */ - int addLocation(LocationEntity sodoResEntity); - - /** - * - * Add Selective Location.
- * - * @param sodoResEntity - * @return - * @since NFVO 0.5 - */ - int addLocationSelective(LocationEntity sodoResEntity); - - /** - * - * Update selective location.
- * - * @param sodoResEntity - * @return - * @since NFVO 0.5 - */ - int updateLocationSelective(LocationEntity sodoResEntity); - - /** - * - * Update Location.
- * - * @param sodoResEntity - * @return - * @since NFVO 0.5 - */ - int updateLocation(LocationEntity sodoResEntity); - - /** - * - * Get Country.
- * - * @return - * @since NFVO 0.5 - */ - List getCountry(); - - /** - * - * Get Location by Country.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getLocationByCountry(Map condition); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java deleted file mode 100644 index 0725bd9..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; - -/** - * - * Network DOA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface NetworkDao { - - /** - * - * Get Network Details.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - NetworkEntity getNetwork(String id); - - /** - * - * Get details of available networks.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getNetworks(Map condition); - - /** - * - * Delete Network.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - int deleteNetwork(String id); - - /** - * - * Delete network by VIM ID.
- * - * @param vimId - * @return - * @since NFVO 0.5 - */ - int deleteNetworkByVimId(String vimId); - - /** - * - * Add Network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int addNetwork(NetworkEntity networkEntity); - - /** - * - * Add selective network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int addNetworkSelective(NetworkEntity networkEntity); - - /** - * - * Update selective network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetworkSelective(NetworkEntity networkEntity); - - /** - * - * Update network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetwork(NetworkEntity networkEntity); - - /** - * - * Update network by VIM ID.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetworkByVimId(NetworkEntity networkEntity); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java deleted file mode 100644 index f558b5d..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.PortEntity; - -/** - * Port info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface PortDao { - - /** - * It is used to get Port info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - PortEntity getPort(String id); - - /** - * It is used to get Ports info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getPorts(Map condition); - - /** - * It is used to delete Ports info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deletePort(String id); - - /** - * It is used to delete Ports info.
- * - * @param vimId - * @return The delete result - * @since NFVO 0.5 - */ - int deletePortByVimId(String vimId); - - /** - * It is used to add Ports info.
- * - * @param portEntity - * @return The add result - * @since NFVO 0.5 - */ - int addPort(PortEntity portEntity); - - /** - * It is used to add Ports info.
- * - * @param portEntity - * @return The add result - * @since NFVO 0.5 - */ - int addPortSelective(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePortSelective(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePort(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePortByVimId(PortEntity portEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java deleted file mode 100644 index f978c8b..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; - -/** - * Sites info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface SitesDao { - - /** - * It is used to get Sites info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - SitesEntity getSite(String id); - - /** - * It is used to get Sites info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getSites(Map condition); - - /** - * It is used to get Sites info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - int deleteSite(String id); - - /** - * It is used to delete Sites info.
- * - * @param sitesEntity - * @return The delete result - * @since NFVO 0.5 - */ - int addSite(SitesEntity sitesEntity); - - /** - * It is used to add Sites info.
- * - * @param sitesEntity - * @return The add result - * @since NFVO 0.5 - */ - int addSiteSelective(SitesEntity sitesEntity); - - /** - * It is used to add Sites info.
- * - * @param sitesEntity - * @return The add result - * @since NFVO 0.5 - */ - int updateSiteSelective(SitesEntity sitesEntity); - - /** - * It is used to update Sites info.
- * - * @param sitesEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateSite(SitesEntity sitesEntity); - - /** - * It is used to update Sites info.
- * - * @param sitesEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateSiteByVimId(SitesEntity sitesEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java deleted file mode 100644 index 1b17a46..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; - -import org.openo.nfvo.resmanagement.service.entity.VimEntity; - -/** - * Vim info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface VimDao { - - /** - * It is used to get Vim info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - VimEntity getVim(String id); - - /** - * It is used to get Vims info.
- * - * @return The get result - * @since NFVO 0.5 - */ - List getVims(); - - /** - * It is used to delete Vim info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deleteVim(String id); - - /** - * It is used to add Vim info.
- * - * @param vimEntity - * @return The add result - * @since NFVO 0.5 - */ - int addVim(VimEntity vimEntity); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java deleted file mode 100644 index ead3975..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VirtualLinkDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - VirtualLinkEntity getVl(String id); - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getVls(Map condition); - - /** - *
- * - * @param virtualLinkEntity - * @return - * @since NFVO 0.5 - */ - int addVl(VirtualLinkEntity virtualLinkEntity); - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - int deleteVlById(String id); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java deleted file mode 100644 index 6d2b6b6..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VmEntity; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VmDao { - - VmEntity getVm(String id); - - List getVms(Map condition); - - int addVm(VmEntity vmEntity); - - int deleteVmById(String id); - - int updateVm(VmEntity vmEntity); - - int deleteVmByVnfId(String vnfInstanceId); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java deleted file mode 100644 index 7f72ce3..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VnfDao { - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - VnfEntity getVnf(String id); - - /** - *
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getVnfs(Map condition); - - /** - *
- * - * @param vnfEntity - * @return - * @since NFVO 0.5 - */ - int addVnf(VnfEntity vnfEntity); - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - int deleteVnfById(String id); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java deleted file mode 100644 index 9e2aade..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VnfInfoDao { - - VnfInfoEntity getVnfInfo(String id); - - List getVnfInfos(Map condition); - - int addVnfInfo(VnfInfoEntity vnfInfoEntity); - - int deleteVnfInfoById(String id); - - int updateVnfInfo(VnfInfoEntity vnfInfoEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java deleted file mode 100644 index ef5ba9b..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.dao.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public interface VnfStatusDao { - - VnfStatusEntity getVnfStatus(String id); - - List getVnfStatuss(Map condition); - - int addVnfStatus(VnfStatusEntity vnfStatusEntity); - - int deleteVnfStatusById(String id); - - int updateVnfStatus(VnfStatusEntity vnfStatusEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java deleted file mode 100644 index f8166da..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * Host entity class.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 31, 2016 - */ -public class HostEntity { - - private String id; - - private String name; - - private String cpu; - - private String memory; - - private String disk; - - private String vimId; - - private String vimName; - - /** - * @return Returns the id. - */ - public String getId() { - return id; - } - - /** - * @param id The id to set. - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param name The name to set. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Returns the cpu. - */ - public String getCpu() { - return cpu; - } - - /** - * @param cpu The cpu to set. - */ - public void setCpu(String cpu) { - this.cpu = cpu; - } - - /** - * @return Returns the memory. - */ - public String getMemory() { - return memory; - } - - /** - * @param memory The memory to set. - */ - public void setMemory(String memory) { - this.memory = memory; - } - - /** - * @return Returns the disk. - */ - public String getDisk() { - return disk; - } - - /** - * @param disk The disk to set. - */ - public void setDisk(String disk) { - this.disk = disk; - } - - /** - * @return Returns the vimId. - */ - public String getVimId() { - return vimId; - } - - /** - * @param vimId The vimId to set. - */ - public void setVimId(String vimId) { - this.vimId = vimId; - } - - /** - * @return Returns the vimName. - */ - public String getVimName() { - return vimName; - } - - /** - * @param vimName The vimName to set. - */ - public void setVimName(String vimName) { - this.vimName = vimName; - } - - /** - * - * To entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static HostEntity toEntity(JSONObject jsonObject) { - HostEntity hostEntity = new HostEntity(); - hostEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - hostEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - hostEntity.setCpu(JsonUtil.getJsonFieldStr(jsonObject, "cpu")); - hostEntity.setMemory(JsonUtil.getJsonFieldStr(jsonObject, "memory")); - hostEntity.setDisk(JsonUtil.getJsonFieldStr(jsonObject, "disk")); - hostEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - hostEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - return hostEntity; - } - - @Override - public String toString() { - JSONObject hostResJson = new JSONObject(); - hostResJson.put("id", StringUtils.trimToEmpty(this.getId())); - hostResJson.put("name", StringUtils.trimToEmpty(this.getName())); - hostResJson.put("cpu", StringUtils.trimToEmpty(this.getCpu())); - hostResJson.put("memory", StringUtils.trimToEmpty(this.getMemory())); - hostResJson.put("disk", StringUtils.trimToEmpty(this.getDisk())); - hostResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); - hostResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); - return hostResJson.toString(); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java deleted file mode 100644 index eab8ca0..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * - * Location entity class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class LocationEntity { - - /** - * This field was generated by MyBatis Generator. This field corresponds to - * the database column location.ID - * - * @mbggenerated - */ - private String id; - - /** - * This field was generated by MyBatis Generator. This field corresponds to - * the database column location.COUNTRY - * - * @mbggenerated - */ - private String country; - - /** - * This field was generated by MyBatis Generator. This field corresponds to - * the database column location.LOCATION - * - * @mbggenerated - */ - private String location; - - /** - * This field was generated by MyBatis Generator. This field corresponds to - * the database column location.LATITUDE - * - * @mbggenerated - */ - private String latitude; - - /** - * This field was generated by MyBatis Generator. This field corresponds to - * the database column location.LONGITUDE - * - * @mbggenerated - */ - private String longitude; - - private String description; - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column location.ID - * - * @return the value of location.ID - * @mbggenerated - */ - public String getId() { - return id; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column location.ID - * - * @param id - * the value for location.ID - * @mbggenerated - */ - public void setId(String id) { - this.id = id == null ? null : id.trim(); - } - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column location.COUNTRY - * - * @return the value of location.COUNTRY - * @mbggenerated - */ - public String getCountry() { - return country; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column location.COUNTRY - * - * @param country - * the value for location.COUNTRY - * @mbggenerated - */ - public void setCountry(String country) { - this.country = country == null ? null : country.trim(); - } - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column location.LOCATION - * - * @return the value of location.LOCATION - * @mbggenerated - */ - public String getLocation() { - return location; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column location.LOCATION - * - * @param location - * the value for location.LOCATION - * @mbggenerated - */ - public void setLocation(String location) { - this.location = location == null ? null : location.trim(); - } - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column location.LATITUDE - * - * @return the value of location.LATITUDE - * @mbggenerated - */ - public String getLatitude() { - return latitude; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column location.LATITUDE - * - * @param latitude - * the value for location.LATITUDE - * @mbggenerated - */ - public void setLatitude(String latitude) { - this.latitude = latitude == null ? null : latitude.trim(); - } - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column location.LONGITUDE - * - * @return the value of location.LONGITUDE - * @mbggenerated - */ - public String getLongitude() { - return longitude; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column location.LONGITUDE - * - * @param longitude - * the value for location.LONGITUDE - * @mbggenerated - */ - public void setLongitude(String longitude) { - this.longitude = longitude == null ? null : longitude.trim(); - } - - /** - * @return Returns the description. - */ - public String getDescription() { - return description; - } - - /** - * @param description The description to set. - */ - public void setDescription(String description) { - this.description = description == null ? null : description.trim(); - } - - /** - * - * To Entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static LocationEntity toEntity(JSONObject jsonObject) { - LocationEntity sodoresesEntity = new LocationEntity(); - sodoresesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - sodoresesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); - sodoresesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); - sodoresesEntity.setLatitude(JsonUtil.getJsonFieldStr(jsonObject, "latitude")); - sodoresesEntity.setLongitude(JsonUtil.getJsonFieldStr(jsonObject, "longitude")); - sodoresesEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); - return sodoresesEntity; - } - - @Override - public String toString() { - JSONObject locationJson = new JSONObject(); - locationJson.put("id", StringUtils.trimToEmpty(this.getId())); - locationJson.put("country", StringUtils.trimToEmpty(this.getCountry())); - locationJson.put("location", StringUtils.trimToEmpty(this.getLocation())); - locationJson.put("latitude", StringUtils.trimToEmpty(this.getLatitude())); - locationJson.put("longitude", StringUtils.trimToEmpty(this.getLongitude())); - locationJson.put("description", StringUtils.trimToEmpty(this.getDescription())); - return locationJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java deleted file mode 100644 index f65ad37..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * - * Network entity class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class NetworkEntity { - - /** - * This field corresponds to the database column network.ID - */ - private String id; - - /** - * This field corresponds to the database column network.NAME - */ - private String name; - - /** - * This field corresponds to the database column network.TENANT_ID - */ - private String tenantId; - - /** - * This field corresponds to the database column network.VIM_ID - */ - private String vimId; - - /** - * This field corresponds to the database column ivm.VIM_NAME - */ - private String vimName; - - /** - * This field corresponds to the database column network.STATUS - */ - private String status; - - /** - * This field corresponds to the database column network.PHYSICAL_NETWORK - */ - - private String physicalNetwork; - - /** - * This field corresponds to the database column network.NETWORK_TYPE - */ - private String networkType; - - /** - * This field corresponds to the database column network.SEGMENTATION_ID - */ - private String segmentationId; - - /** - * return the value of network.ID - */ - public String getId() { - return id; - } - - /** - * This method sets the value of the database column network.ID - * - * @param id - * the value for network.ID - */ - public void setId(String id) { - this.id = id == null ? null : id.trim(); - } - - /** - * return the value of network.NAME - */ - public String getName() { - return name; - } - - /** - * This method sets the value of the database column network.NAME - * - * @param name - * the value for network.NAME - */ - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - /** - * return the value of network.TENANT_ID - */ - public String getTenantId() { - return tenantId; - } - - /** - * This method sets the value of the database column network.TENANT_ID - * - * @param tenantId - * the value for network.TENANT_ID - */ - public void setTenantId(String tenantId) { - this.tenantId = tenantId == null ? null : tenantId.trim(); - } - - /** - * return the value of network.VIM_ID - */ - public String getVimId() { - return vimId; - } - - /** - * This method sets the value of the database column network.VIM_ID - * - * @param networkVimId - * the value for network.VIM_ID - */ - public void setVimId(String networkVimId) { - this.vimId = networkVimId == null ? null : networkVimId.trim(); - } - - /** - * return the value of ivm.VIM_NAME - */ - public String getVimName() { - return vimName; - } - - /** - * This method sets the value of the database column ivm.VIM_NAME - * - * @param networkVimName - * the value for ivm.VIM_NAME - */ - public void setVimName(String networkVimName) { - this.vimName = networkVimName == null ? null : networkVimName.trim(); - } - - /** - * return the value of network.STATUS - */ - public String getStatus() { - return status; - } - - /** - * This method sets the value of the database column network.STATUS - * - * @param networkStatus - * the value for network.STATUS - */ - public void setStatus(String networkStatus) { - this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase(); - } - - /** - * return the value of network.PHYSICAL_NETWORK - */ - public String getPhysicalNetwork() { - return physicalNetwork; - } - - /** - * This method sets the value of the database column - * network.PHYSICAL_NETWORK - * - * @param physicalNetwork - * the value for network.PHYSICAL_NETWORK - */ - public void setPhysicalNetwork(String physicalNetwork) { - this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim(); - } - - /** - * return the value of network.NETWORK_TYPE - */ - public String getNetworkType() { - return networkType; - } - - /** - * This method sets the value of the database column network.NETWORK_TYPE - * - * @param networkType - * the value for network.NETWORK_TYPE - */ - public void setNetworkType(String networkType) { - this.networkType = networkType == null ? null : networkType.trim(); - } - - /** - * return the value of network.SEGMENTATION_ID - */ - public String getSegmentationId() { - return segmentationId; - } - - /** - * This method sets the value of the database column network.SEGMENTATION_ID - * - * @param segmentationId - * the value for network.SEGMENTATION_ID - */ - public void setSegmentationId(String segmentationId) { - this.segmentationId = segmentationId == null ? null : segmentationId.trim(); - } - - /** - * - * To Entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static NetworkEntity toEntity(JSONObject jsonObject) { - NetworkEntity sitesEntity = new NetworkEntity(); - sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - sitesEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); - sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); - sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - sitesEntity.setPhysicalNetwork(JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); - sitesEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); - sitesEntity.setSegmentationId(JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); - return sitesEntity; - } - - @Override - public String toString() { - JSONObject networkJson = new JSONObject(); - networkJson.put("id", StringUtils.trimToEmpty(this.getId())); - networkJson.put("name", StringUtils.trimToEmpty(this.getName())); - networkJson.put("tenant_id", StringUtils.trimToEmpty(this.getTenantId())); - networkJson.put("status", StringUtils.trimToEmpty(this.getStatus())); - networkJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); - networkJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); - networkJson.put("provider:physical_network", StringUtils.trimToEmpty(this.getPhysicalNetwork())); - networkJson.put("provider:network_type", StringUtils.trimToEmpty(this.getNetworkType())); - networkJson.put("provider:segmentation_id", StringUtils.trimToEmpty(this.getSegmentationId())); - return networkJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java deleted file mode 100644 index 4700554..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * Port Entity Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 31, 2016 - */ -public class PortEntity { - - private String id; - - private String name; - - private String networkId; - - private String status; - - private String tenantId; - - private String vimId; - - private String vimName; - - /** - * @return Returns the id. - */ - public String getId() { - return id; - } - - /** - * @param id The id to set. - */ - public void setId(String id) { - this.id = id == null ? null : id.trim(); - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param name The name to set. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Returns the networkId. - */ - public String getNetworkId() { - return networkId; - } - - /** - * @param networkId The networkId to set. - */ - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - /** - * @return Returns the status. - */ - public String getStatus() { - return status; - } - - /** - * @param status The status to set. - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * @return Returns the tenantId. - */ - public String getTenantId() { - return tenantId; - } - - /** - * @param tenantId The tenantId to set. - */ - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - /** - * @return Returns the vimId. - */ - public String getVimId() { - return vimId; - } - - /** - * @param vimId The vimId to set. - */ - public void setVimId(String vimId) { - this.vimId = vimId; - } - - /** - * @return Returns the vimName. - */ - public String getVimName() { - return vimName; - } - - /** - * @param vimName The vimName to set. - */ - public void setVimName(String vimName) { - this.vimName = vimName; - } - - /** - * - * To Entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static PortEntity toEntity(JSONObject jsonObject) { - PortEntity portEntity = new PortEntity(); - portEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - portEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - portEntity.setNetworkId(JsonUtil.getJsonFieldStr(jsonObject, "networkId")); - portEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); - portEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); - portEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - portEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - return portEntity; - } - - @Override - public String toString() { - JSONObject portResJson = new JSONObject(); - portResJson.put("id", StringUtils.trimToEmpty(this.getId())); - portResJson.put("name", StringUtils.trimToEmpty(this.getName())); - portResJson.put("networkId", StringUtils.trimToEmpty(this.getNetworkId())); - portResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); - portResJson.put("tenantId", StringUtils.trimToEmpty(this.getTenantId())); - portResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); - portResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); - return portResJson.toString(); - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java deleted file mode 100644 index 33c1942..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.common.util.StringUtil; - -import net.sf.json.JSONObject; - -/** - * - * Sites entity class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class SitesEntity { - - private String id; - - private String name; - - private String location; - - private String country; - - private String vimId; - - private String vimName; - - private String status; - - private String totalCPU = "0"; - - private String totalMemory = "0"; - - private String totalDisk = "0"; - - private String usedCPU = "0"; - - private String usedMemory = "0"; - - private String usedDisk = "0"; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id == null ? null : id.trim(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location == null ? null : location.trim(); - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country == null ? null : country.trim(); - } - - public String getVimId() { - return vimId; - } - - public void setVimId(String siteVimId) { - this.vimId = siteVimId == null ? null : siteVimId.trim(); - } - - public String getVimName() { - return vimName; - } - - public void setVimName(String siteVimName) { - this.vimName = siteVimName == null ? null : siteVimName.trim(); - } - - public String getStatus() { - return status; - } - - public void setStatus(String siteStatus) { - this.status = siteStatus == null ? null : siteStatus.trim().toLowerCase(); - } - - /** - * @return Returns the totalCPU. - */ - public String getTotalCPU() { - return totalCPU; - } - - /** - * @param totalCPU The totalCPU to set. - */ - public void setTotalCPU(String totalCPU) { - this.totalCPU = totalCPU == null ? null : totalCPU.trim(); - } - - /** - * @return Returns the totalMemory. - */ - public String getTotalMemory() { - return totalMemory; - } - - /** - * @param totalMemory The totalMemory to set. - */ - public void setTotalMemory(String totalMemory) { - this.totalMemory = totalMemory == null ? null : totalMemory.trim(); - } - - /** - * @return Returns the totalDisk. - */ - public String getTotalDisk() { - return totalDisk; - } - - /** - * @param totalDisk The totalDisk to set. - */ - public void setTotalDisk(String totalDisk) { - this.totalDisk = totalDisk == null ? null : totalDisk.trim(); - } - - /** - * @return Returns the usedCPU. - */ - public String getUsedCPU() { - return usedCPU; - } - - /** - * @param usedCPU The usedCPU to set. - */ - public void setUsedCPU(String usedCPU) { - this.usedCPU = usedCPU == null ? null : usedCPU.trim(); - } - - /** - * @return Returns the usedMemory. - */ - public String getUsedMemory() { - return usedMemory; - } - - /** - * @param usedMemory The usedMemory to set. - */ - public void setUsedMemory(String usedMemory) { - this.usedMemory = usedMemory == null ? null : usedMemory.trim(); - } - - /** - * @return Returns the usedDisk. - */ - public String getUsedDisk() { - return usedDisk; - } - - /** - * @param usedDisk The usedDisk to set. - */ - public void setUsedDisk(String usedDisk) { - this.usedDisk = usedDisk == null ? null : usedDisk.trim(); - } - - /** - * - * To Entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static SitesEntity toEntity(JSONObject jsonObject) { - SitesEntity sitesEntity = new SitesEntity(); - sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); - sitesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); - sitesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); - sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - sitesEntity.setTotalCPU(JsonUtil.getJsonFieldStr(jsonObject, "totalCPU")); - sitesEntity.setTotalMemory(JsonUtil.getJsonFieldStr(jsonObject, "totalMemory")); - sitesEntity.setTotalDisk(JsonUtil.getJsonFieldStr(jsonObject, "totalDisk")); - sitesEntity.setUsedCPU(JsonUtil.getJsonFieldStr(jsonObject, "usedCPU")); - sitesEntity.setUsedMemory(JsonUtil.getJsonFieldStr(jsonObject, "usedMemory")); - sitesEntity.setUsedDisk(JsonUtil.getJsonFieldStr(jsonObject, "usedDisk")); - return sitesEntity; - } - - @Override - public String toString() { - JSONObject siteResJson = new JSONObject(); - siteResJson.put("id", StringUtils.trimToEmpty(this.getId())); - siteResJson.put("name", StringUtils.trimToEmpty(this.getName())); - siteResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); - siteResJson.put("location", StringUtils.trimToEmpty(this.getLocation())); - siteResJson.put("country", StringUtils.trimToEmpty(this.getCountry())); - siteResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); - siteResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); - siteResJson.put("totalCPU", StringUtils.trimToEmpty(this.getTotalCPU())); - siteResJson.put("totalMemory", StringUtils.trimToEmpty(this.getTotalMemory())); - siteResJson.put("totalDisk", StringUtils.trimToEmpty(this.getTotalDisk())); - siteResJson.put("usedCPU", StringUtils.trimToEmpty(this.getUsedCPU())); - siteResJson.put("usedMemory", StringUtils.trimToEmpty(this.getUsedMemory())); - siteResJson.put("usedDisk", StringUtils.trimToEmpty(this.getUsedDisk())); - - return siteResJson.toString(); - } - - /** - * - * Check whther the resource is zero.
- * - * @param siteEntity - * @return - * @since NFVO 0.5 - */ - public static boolean checkResourceIsZero(SitesEntity siteEntity) { - - if(StringUtil.isAnyLargeThanZero(siteEntity.getUsedCPU(), siteEntity.getUsedMemory(), - siteEntity.getUsedDisk())) { - return false; - } - - return true; - } - - /** - * - * Check resource.
- * - * @param siteEntity - * @return - * @since NFVO 0.5 - */ - public static boolean checkResource(SitesEntity siteEntity) { - String cpu = siteEntity.getTotalCPU(); - String memory = siteEntity.getTotalMemory(); - String disk = siteEntity.getTotalDisk(); - String cpuUsed = siteEntity.getUsedCPU(); - String memoryUsed = siteEntity.getUsedMemory(); - String diskUsed = siteEntity.getUsedDisk(); - - if(!StringUtil.isInteger(cpu, cpuUsed)) { - return false; - } - - if(!StringUtil.isNumeric(memory, disk, memoryUsed, diskUsed)) { - return false; - } - return true; - } - - /** - * - * Format data.
- * - * @param siteEntity - * @since NFVO 0.5 - */ - public static void dataFramat(SitesEntity siteEntity) { - siteEntity.setTotalCPU(StringUtil.numFormat(siteEntity.getTotalCPU())); - siteEntity.setTotalMemory(StringUtil.numFormat(siteEntity.getTotalMemory())); - siteEntity.setTotalDisk(StringUtil.numFormat(siteEntity.getTotalDisk())); - siteEntity.setUsedCPU(StringUtil.numFormat(siteEntity.getUsedCPU())); - siteEntity.setUsedMemory(StringUtil.numFormat(siteEntity.getUsedMemory())); - siteEntity.setUsedDisk(StringUtil.numFormat(siteEntity.getUsedDisk())); - - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java deleted file mode 100644 index 9959101..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * - * Virtualised infrastructure manager entity class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class VimEntity { - - /** - * This field corresponds to the database column vim.ID - * - * @mbggenerated - */ - private String id; - - /** - * This field corresponds to the database column vim.ID - * - * @mbggenerated - */ - private String name; - - /** - * This method was generated by MyBatis Generator. This method returns the - * value of the database column vim.ID - * - * @return the value of vim.ID - */ - public String getId() { - return id; - } - - /** - * This method was generated by MyBatis Generator. This method sets the - * value of the database column vim.ID - * - * @param id - * the value for vim.ID - */ - public void setId(String id) { - this.id = id == null ? null : id.trim(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * - * To Entity.
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static VimEntity toEntity(JSONObject jsonObject) { - VimEntity vimEntity = new VimEntity(); - vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - return vimEntity; - } - - /** - * - * To String.
- * - * @return - * @since NFVO 0.5 - */ - public String toString() { - JSONObject resJson = new JSONObject(); - resJson.put("id", StringUtils.trimToEmpty(this.getId())); - resJson.put("name", StringUtils.trimToEmpty(this.getName())); - return resJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java deleted file mode 100644 index c9a38d9..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import java.io.Serializable; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * @author l00345485 - * @date 2016-10-27 - */ -public class VirtualLinkEntity implements Serializable { - - /** */ - private String id; - - /** */ - private String name; - - /** */ - private String backendId; - - /** */ - private String isPublic; - - /** */ - private String dcName; - - /** */ - private String vimId; - - /** */ - private String vimName; - - /** */ - private String physicialNet; - - /** */ - private String nsId; - - /** */ - private String nsName; - - /** */ - private String description; - - /** */ - private String networkType; - - /** */ - private String segmentation; - - /** */ - private String mtu; - - /** */ - private String vlanTransparent; - - /** */ - private String routerExternal; - - /** */ - private String resourceProviderType; - - /** */ - private String resourceProviderId; - - private static final long serialVersionUID = 1L; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getBackendId() { - return backendId; - } - - public void setBackendId(String backendId) { - this.backendId = backendId; - } - - public String getIsPublic() { - return isPublic; - } - - public void setIsPublic(String isPublic) { - this.isPublic = isPublic; - } - - public String getDcName() { - return dcName; - } - - public void setDcName(String dcName) { - this.dcName = dcName; - } - - public String getVimId() { - return vimId; - } - - public void setVimId(String vimId) { - this.vimId = vimId; - } - - public String getVimName() { - return vimName; - } - - public void setVimName(String vimName) { - this.vimName = vimName; - } - - public String getPhysicialNet() { - return physicialNet; - } - - public void setPhysicialNet(String physicialNet) { - this.physicialNet = physicialNet; - } - - public String getNsId() { - return nsId; - } - - public void setNsId(String nsId) { - this.nsId = nsId; - } - - public String getNsName() { - return nsName; - } - - public void setNsName(String nsName) { - this.nsName = nsName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getNetworkType() { - return networkType; - } - - public void setNetworkType(String networkType) { - this.networkType = networkType; - } - - public String getSegmentation() { - return segmentation; - } - - public void setSegmentation(String segmentation) { - this.segmentation = segmentation; - } - - public String getMtu() { - return mtu; - } - - public void setMtu(String mtu) { - this.mtu = mtu; - } - - public String getVlanTransparent() { - return vlanTransparent; - } - - public void setVlanTransparent(String vlanTransparent) { - this.vlanTransparent = vlanTransparent; - } - - public String getRouterExternal() { - return routerExternal; - } - - public void setRouterExternal(String routerExternal) { - this.routerExternal = routerExternal; - } - - public String getResourceProviderType() { - return resourceProviderType; - } - - public void setResourceProviderType(String resourceProviderType) { - this.resourceProviderType = resourceProviderType; - } - - public String getResourceProviderId() { - return resourceProviderId; - } - - public void setResourceProviderId(String resourceProviderId) { - this.resourceProviderId = resourceProviderId; - } - - /** - *
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static VirtualLinkEntity toEntity(JSONObject jsonObject) { - VirtualLinkEntity virtualLinkEntity = new VirtualLinkEntity(); - virtualLinkEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "vlInstanceId")); - virtualLinkEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - virtualLinkEntity.setBackendId(JsonUtil.getJsonFieldStr(jsonObject, "backendId")); - virtualLinkEntity.setIsPublic(JsonUtil.getJsonFieldStr(jsonObject, "isPublic")); - virtualLinkEntity.setDcName(JsonUtil.getJsonFieldStr(jsonObject, "dcName")); - virtualLinkEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - virtualLinkEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - virtualLinkEntity.setPhysicialNet(JsonUtil.getJsonFieldStr(jsonObject, "physicialNet")); - virtualLinkEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); - virtualLinkEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); - virtualLinkEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); - virtualLinkEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); - virtualLinkEntity.setSegmentation(JsonUtil.getJsonFieldStr(jsonObject, "segmentation")); - virtualLinkEntity.setMtu(JsonUtil.getJsonFieldStr(jsonObject, "mtu")); - virtualLinkEntity.setVlanTransparent(JsonUtil.getJsonFieldStr(jsonObject, "vlanTransparent")); - virtualLinkEntity.setRouterExternal(JsonUtil.getJsonFieldStr(jsonObject, "routerExternal")); - virtualLinkEntity.setResourceProviderId(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderId")); - virtualLinkEntity.setResourceProviderType(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderType")); - return virtualLinkEntity; - } - - @Override - public String toString() { - JSONObject virtualLinkResJson = new JSONObject(); - virtualLinkResJson.put("id", StringUtils.trimToEmpty(this.getId())); - virtualLinkResJson.put("name", StringUtils.trimToEmpty(this.getName())); - virtualLinkResJson.put("backendId", StringUtils.trimToEmpty(this.getBackendId())); - virtualLinkResJson.put("isPublic", StringUtils.trimToEmpty(this.getIsPublic())); - virtualLinkResJson.put("dcName", StringUtils.trimToEmpty(this.getDcName())); - virtualLinkResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); - virtualLinkResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); - virtualLinkResJson.put("physicialNet", StringUtils.trimToEmpty(this.getPhysicialNet())); - virtualLinkResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); - virtualLinkResJson.put("nsName", StringUtils.trimToEmpty(this.getNsName())); - virtualLinkResJson.put("description", StringUtils.trimToEmpty(this.getDescription())); - virtualLinkResJson.put("networkType", StringUtils.trimToEmpty(this.getNetworkType())); - virtualLinkResJson.put("segmentation", StringUtils.trimToEmpty(this.getSegmentation())); - virtualLinkResJson.put("mtu", StringUtils.trimToEmpty(this.getMtu())); - virtualLinkResJson.put("vlanTransparent", StringUtils.trimToEmpty(this.getVlanTransparent())); - virtualLinkResJson.put("routerExternal", StringUtils.trimToEmpty(this.getRouterExternal())); - virtualLinkResJson.put("resourceProviderId", StringUtils.trimToEmpty(this.getResourceProviderId())); - virtualLinkResJson.put("resourceProviderType", StringUtils.trimToEmpty(this.getResourceProviderType())); - return virtualLinkResJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java deleted file mode 100644 index e01cabd..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import java.io.Serializable; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * @author l00345485 - * @date 2016-10-28 - */ -public class VmEntity implements Serializable { - - /** */ - private String vmId; - - /** */ - private String vmName; - - /** */ - private String vmStatus; - - /** */ - private String vnfInstanceId; - - private static final long serialVersionUID = 1L; - - public String getVmId() { - return vmId; - } - - public void setVmId(String vmId) { - this.vmId = vmId; - } - - public String getVmName() { - return vmName; - } - - public void setVmName(String vmName) { - this.vmName = vmName; - } - - public String getVmStatus() { - return vmStatus; - } - - public void setVmStatus(String vmStatus) { - this.vmStatus = vmStatus; - } - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public static VmEntity toEntity(JSONObject jsonObject) { - VmEntity vmEntity = new VmEntity(); - vmEntity.setVmId(JsonUtil.getJsonFieldStr(jsonObject, "vmId")); - vmEntity.setVmName(JsonUtil.getJsonFieldStr(jsonObject, "vmName")); - vmEntity.setVmStatus(JsonUtil.getJsonFieldStr(jsonObject, "vmStatus")); - vmEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); - return vmEntity; - } - - @Override - public String toString() { - JSONObject vmResJson = new JSONObject(); - vmResJson.put("vmId", StringUtils.trimToEmpty(this.getVmId())); - vmResJson.put("vmName", StringUtils.trimToEmpty(this.getVmName())); - vmResJson.put("vmStatus", StringUtils.trimToEmpty(this.getVmStatus())); - vmResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); - return vmResJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java deleted file mode 100644 index 3a18524..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import java.io.Serializable; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * @author l00345485 - * @date 2016-10-28 - */ -public class VnfEntity implements Serializable { - - /** */ - private String id; - - /** */ - private String vnfInstanceId; - - /** */ - private String vnfInstanceName; - - /** */ - private String nsId; - - /** */ - private String nsName; - - /** */ - private String vnfmId; - - /** */ - private String vnfmName; - - /** */ - private String vnfPackageName; - - /** */ - private String vnfDescriptorName; - - /** */ - private String vimId; - - /** */ - private String vimName; - - /** */ - private String vimTenant; - - /** */ - private String jobId; - - /** */ - private String vnfStatus; - - /** */ - private String vnfType; - - /** */ - private Integer maxVm; - - /** */ - private Integer maxCpu; - - /** */ - private Integer maxDisk; - - /** */ - private Integer maxRam; - - /** */ - private Integer maxShd; - - /** */ - private Integer maxNet; - - /** */ - private String name; - - private static final long serialVersionUID = 1L; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getVnfInstanceName() { - return vnfInstanceName; - } - - public void setVnfInstanceName(String vnfInstanceName) { - this.vnfInstanceName = vnfInstanceName; - } - - public String getNsId() { - return nsId; - } - - public void setNsId(String nsId) { - this.nsId = nsId; - } - - public String getNsName() { - return nsName; - } - - public void setNsName(String nsName) { - this.nsName = nsName; - } - - public String getVnfmId() { - return vnfmId; - } - - public void setVnfmId(String vnfmId) { - this.vnfmId = vnfmId; - } - - public String getVnfmName() { - return vnfmName; - } - - public void setVnfmName(String vnfmName) { - this.vnfmName = vnfmName; - } - - public String getVnfPackageName() { - return vnfPackageName; - } - - public void setVnfPackageName(String vnfPackageName) { - this.vnfPackageName = vnfPackageName; - } - - public String getVnfDescriptorName() { - return vnfDescriptorName; - } - - public void setVnfDescriptorName(String vnfDescriptorName) { - this.vnfDescriptorName = vnfDescriptorName; - } - - public String getVimId() { - return vimId; - } - - public void setVimId(String vimId) { - this.vimId = vimId; - } - - public String getVimName() { - return vimName; - } - - public void setVimName(String vimName) { - this.vimName = vimName; - } - - public String getVimTenant() { - return vimTenant; - } - - public void setVimTenant(String vimTenant) { - this.vimTenant = vimTenant; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public String getVnfStatus() { - return vnfStatus; - } - - public void setVnfStatus(String vnfStatus) { - this.vnfStatus = vnfStatus; - } - - public String getVnfType() { - return vnfType; - } - - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public Integer getMaxVm() { - return maxVm; - } - - public void setMaxVm(Integer maxVm) { - this.maxVm = maxVm; - } - - public Integer getMaxCpu() { - return maxCpu; - } - - public void setMaxCpu(Integer maxCpu) { - this.maxCpu = maxCpu; - } - - public Integer getMaxDisk() { - return maxDisk; - } - - public void setMaxDisk(Integer maxDisk) { - this.maxDisk = maxDisk; - } - - public Integer getMaxRam() { - return maxRam; - } - - public void setMaxRam(Integer maxRam) { - this.maxRam = maxRam; - } - - public Integer getMaxShd() { - return maxShd; - } - - public void setMaxShd(Integer maxShd) { - this.maxShd = maxShd; - } - - public Integer getMaxNet() { - return maxNet; - } - - public void setMaxNet(Integer maxNet) { - this.maxNet = maxNet; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - *
- * - * @param jsonObject - * @return - * @since NFVO 0.5 - */ - public static VnfEntity toEntity(JSONObject jsonObject) { - VnfEntity vnfEntity = new VnfEntity(); - vnfEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); - vnfEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); - vnfEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); - vnfEntity.setVnfInstanceName(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceName")); - vnfEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); - vnfEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); - vnfEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); - vnfEntity.setVnfmName(JsonUtil.getJsonFieldStr(jsonObject, "vnfmName")); - vnfEntity.setVnfPackageName(JsonUtil.getJsonFieldStr(jsonObject, "vnfPackageName")); - vnfEntity.setVnfDescriptorName(JsonUtil.getJsonFieldStr(jsonObject, "vnfDescriptorName")); - vnfEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); - vnfEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); - vnfEntity.setVimTenant(JsonUtil.getJsonFieldStr(jsonObject, "vimTenant")); - vnfEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); - vnfEntity.setVnfStatus(JsonUtil.getJsonFieldStr(jsonObject, "vnfStatus")); - vnfEntity.setVnfType(JsonUtil.getJsonFieldStr(jsonObject, "vnfType")); - vnfEntity.setMaxVm(JsonUtil.getJsonFieldInt(jsonObject, "maxVm")); - vnfEntity.setMaxCpu(JsonUtil.getJsonFieldInt(jsonObject, "maxCpu")); - vnfEntity.setMaxDisk(JsonUtil.getJsonFieldInt(jsonObject, "maxDisk")); - vnfEntity.setMaxRam(JsonUtil.getJsonFieldInt(jsonObject, "maxRam")); - vnfEntity.setMaxShd(JsonUtil.getJsonFieldInt(jsonObject, "maxShd")); - vnfEntity.setMaxNet(JsonUtil.getJsonFieldInt(jsonObject, "maxNet")); - return vnfEntity; - } - - @Override - public String toString() { - JSONObject vnfResJson = new JSONObject(); - vnfResJson.put("id", StringUtils.trimToEmpty(this.getId())); - vnfResJson.put("name", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfInstanceName", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("nsId", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("nsName", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfmId", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfmName", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfPackageName", StringUtils.trimToEmpty(this.getId())); - vnfResJson.put("vnfDescriptorName", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vimId", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vimName", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vimTenant", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("jobId", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfStatus", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("vnfType", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxVm", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxCpu", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxDisk", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxRam", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxShd", StringUtils.trimToEmpty(this.getName())); - vnfResJson.put("maxNet", StringUtils.trimToEmpty(this.getName())); - return vnfResJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java deleted file mode 100644 index 023f491..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import java.io.Serializable; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * @author l00345485 - * @date 2016-10-28 - */ -public class VnfInfoEntity implements Serializable { - - /** */ - private String vnfInstanceId; - - /** */ - private String nsId; - - /** */ - private String vnfmId; - - private static final long serialVersionUID = 1L; - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getNsId() { - return nsId; - } - - public void setNsId(String nsId) { - this.nsId = nsId; - } - - public String getVnfmId() { - return vnfmId; - } - - public void setVnfmId(String vnfmId) { - this.vnfmId = vnfmId; - } - - public static VnfInfoEntity toEntity(JSONObject jsonObject) { - VnfInfoEntity vnfInfoEntity = new VnfInfoEntity(); - vnfInfoEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); - vnfInfoEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); - vnfInfoEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); - return vnfInfoEntity; - } - - @Override - public String toString() { - JSONObject vnfInfoResJson = new JSONObject(); - vnfInfoResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); - vnfInfoResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); - vnfInfoResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); - return vnfInfoResJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java deleted file mode 100644 index 290f264..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.entity; - -import java.io.Serializable; - -import org.apache.commons.lang3.StringUtils; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; - -import net.sf.json.JSONObject; - -/** - * @author l00345485 - * @date 2016-10-29 - */ -public class VnfStatusEntity implements Serializable { - - /** */ - private String vnfInstanceId; - - /** */ - private String jobId; - - /** */ - private String nsId; - - /** */ - private String vnfmId; - - /** */ - private String responseDescriptor; - - /** */ - private String status; - - /** */ - private String progress; - - /** */ - private String statusDescription; - - /** */ - private String errorCode; - - /** */ - private String responseId; - - /** */ - private String responseHistoryList; - - /** */ - private String addVm; - - /** */ - private String delVm; - - private static final long serialVersionUID = 1L; - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public String getNsId() { - return nsId; - } - - public void setNsId(String nsId) { - this.nsId = nsId; - } - - public String getVnfmId() { - return vnfmId; - } - - public void setVnfmId(String vnfmId) { - this.vnfmId = vnfmId; - } - - public String getResponseDescriptor() { - return responseDescriptor; - } - - public void setResponseDescriptor(String responseDescriptor) { - this.responseDescriptor = responseDescriptor; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getProgress() { - return progress; - } - - public void setProgress(String progress) { - this.progress = progress; - } - - public String getStatusDescription() { - return statusDescription; - } - - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getResponseId() { - return responseId; - } - - public void setResponseId(String responseId) { - this.responseId = responseId; - } - - public String getResponseHistoryList() { - return responseHistoryList; - } - - public void setResponseHistoryList(String responseHistoryList) { - this.responseHistoryList = responseHistoryList; - } - - public String getAddVm() { - return addVm; - } - - public void setAddVm(String addVm) { - this.addVm = addVm; - } - - public String getDelVm() { - return delVm; - } - - public void setDelVm(String delVm) { - this.delVm = delVm; - } - - public static VnfStatusEntity toEntity(JSONObject jsonObject) { - VnfStatusEntity vnfStatusEntity = new VnfStatusEntity(); - vnfStatusEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); - vnfStatusEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); - vnfStatusEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); - vnfStatusEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); - vnfStatusEntity.setResponseDescriptor(JsonUtil.getJsonFieldStr(jsonObject, "responseDescriptor")); - vnfStatusEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); - vnfStatusEntity.setProgress(JsonUtil.getJsonFieldStr(jsonObject, "progress")); - vnfStatusEntity.setStatusDescription(JsonUtil.getJsonFieldStr(jsonObject, "statusDescription")); - vnfStatusEntity.setErrorCode(JsonUtil.getJsonFieldStr(jsonObject, "errorCode")); - vnfStatusEntity.setResponseId(JsonUtil.getJsonFieldStr(jsonObject, "responseId")); - vnfStatusEntity.setResponseHistoryList(JsonUtil.getJsonFieldStr(jsonObject, "responseHistoryList")); - vnfStatusEntity.setAddVm(JsonUtil.getJsonFieldStr(jsonObject, "addVm")); - vnfStatusEntity.setDelVm(JsonUtil.getJsonFieldStr(jsonObject, "delVm")); - return vnfStatusEntity; - } - - @Override - public String toString() { - JSONObject vnfStatusResJson = new JSONObject(); - vnfStatusResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); - vnfStatusResJson.put("jobId", StringUtils.trimToEmpty(this.getJobId())); - vnfStatusResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); - vnfStatusResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); - vnfStatusResJson.put("responseDescriptor", StringUtils.trimToEmpty(this.getResponseDescriptor())); - vnfStatusResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); - vnfStatusResJson.put("progress", StringUtils.trimToEmpty(this.getProgress())); - vnfStatusResJson.put("statusDescription", StringUtils.trimToEmpty(this.getStatusDescription())); - vnfStatusResJson.put("errorCode", StringUtils.trimToEmpty(this.getErrorCode())); - vnfStatusResJson.put("responseId", StringUtils.trimToEmpty(this.getResponseId())); - vnfStatusResJson.put("responseHistoryList", StringUtils.trimToEmpty(this.getResponseHistoryList())); - vnfStatusResJson.put("addVm", StringUtils.trimToEmpty(this.getAddVm())); - vnfStatusResJson.put("delVm", StringUtils.trimToEmpty(this.getDelVm())); - return vnfStatusResJson.toString(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java deleted file mode 100644 index 4a8a633..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.group.inf.GrantResService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public class GrantResServiceImpl implements GrantResService { - - private static final Logger LOGGER = LoggerFactory.getLogger(GrantResServiceImpl.class); - - private Sites sites; - - /** - *
- * - * @param object - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject grantResource(JSONObject object) throws ServiceException { - LOGGER.info("function=grantResource; object: {}", object.toString()); - JSONObject additionalparam = object.getJSONObject("additionalParam"); - String vimId = additionalparam.getString("vimid"); - JSONObject vimJson = VimUtil.getVimById(vimId); - String tenant = vimJson.getString("tenant"); - JSONObject accessinfo = new JSONObject(); - accessinfo.put("tenant", tenant); - JSONObject vim = new JSONObject(); - vim.put("vimid", vimId); - vim.put("accessinfo", accessinfo); - LOGGER.info("function=grantResource; vim: {}", vim.toString()); - JSONObject result = new JSONObject(); - result.put("vim", vim); - return result; - } - - @Override - public JSONObject grantResourceReal(JSONObject object) throws ServiceException { - LOGGER.info("function=grantResource; object: {}", object.toString()); - String vimId = object.getString("vimId"); - JSONObject vimJson = VimUtil.getVimById(vimId); - JSONObject vim = parseVim(vimJson); - String resType = ""; - JSONArray resArr = new JSONArray(); - if(object.containsKey("addResource")) { - resType = "addResource"; - resArr = parseResource(object, resType); - } else if(object.containsKey("removeResource")) { - resType = "removeResource"; - resArr = parseResource(object, resType); - } - JSONObject resInfo = getResInfo(object, resType); - resInfo.put("vimId", vimId); - sites.update(resInfo); - - JSONObject result = new JSONObject(); - result.put("vim", vim); - result.put("zone", ""); - result.put("zoneGroup", ""); - result.put(resType, resArr); - result.put("tempResource", ""); - result.put("updateResource", ""); - result.put("vimAssets", new JSONObject()); - result.put("additionalParam", ""); - LOGGER.info("function=grantResource; result: {}", result.toString()); - return result; - } - - private JSONObject getResInfo(JSONObject object, String type) { - JSONArray arr = object.getJSONArray(type); - LOGGER.info("function=getResInfo; arr: {}, type: {}", arr, type); - JSONObject resourceObj = new JSONObject(); - if("addResource".equals(type)) { - resourceObj = getGrantResource(arr); - resourceObj.put("action", "online"); - } else if("removeResource".equals(type)) { - resourceObj = getGrantResource(arr); - resourceObj.put("action", "offline"); - } - LOGGER.info("function=getResInfo; resutl: {}", resourceObj.toString()); - return resourceObj; - } - - /** - *
- * - * @param addResource - * @return - * @since NFVO 0.5 - */ - private JSONObject getGrantResource(JSONArray resource) { - int cpuNum = 0; - int memNum = 0; - int diskNum = 0; - for(int i = 0; i < resource.size(); i++) { - JSONObject res = resource.getJSONObject(i); - JSONObject vCpu = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") - .getJSONObject("virtualCpu"); - int vCpuNum = vCpu.getInt("numVirtualCpu"); - JSONObject vMem = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") - .getJSONObject("virtualMemory"); - int vMemNum = vMem.getInt("virtualMemSize"); - JSONObject vDisk = res.getJSONObject("resourceTemplate").getJSONObject("virtualStorageDescriptor"); - int vDiskNum = vDisk.getInt("sizeOfStorage"); - cpuNum = cpuNum + vCpuNum; - memNum = memNum + vMemNum; - diskNum = diskNum + vDiskNum; - } - JSONObject obj = new JSONObject(); - obj.put("usedCPU", String.valueOf(cpuNum)); - obj.put("usedMemory", String.valueOf(memNum)); - obj.put("usedDisk", String.valueOf(diskNum)); - return obj; - } - - /** - *
- * - * @param object - * @return - * @since NFVO 0.5 - */ - private JSONArray parseResource(JSONObject object, String key) { - JSONArray newResources = new JSONArray(); - JSONArray oldResource = object.getJSONArray(key); - LOGGER.info("function=parseResource; Resource: {}", oldResource.toString()); - for(int i = 0; i < oldResource.size(); i++) { - JSONObject res = oldResource.getJSONObject(i); - JSONObject obj = new JSONObject(); - obj.put("reservationId", ""); - obj.put("resourceProviderId", ""); - obj.put("zoneId", ""); - obj.put("vimId", object.getString("vimId")); - obj.put("resourceDefinitionId", res.getString("resourceDefinitionId")); - newResources.add(obj); - } - LOGGER.info("function=parseResource; Parse Resource result: {}", newResources.toString()); - return newResources; - } - - /** - *
- * - * @param vimJson - * @return - * @since NFVO 0.5 - */ - private JSONObject parseVim(JSONObject vimJson) { - LOGGER.info("function=grantResource; vimJson: {}", vimJson.toString()); - JSONObject interfaceInfo = new JSONObject(); - interfaceInfo.put("vimType", vimJson.getString("type")); - interfaceInfo.put("apiVersion", "v2"); - interfaceInfo.put("protocolType", "http"); - JSONObject accessInfo = new JSONObject(); - accessInfo.put("tenant", vimJson.getString("tenant")); - accessInfo.put("username", vimJson.getString("userName")); - accessInfo.put("password", vimJson.getString("password")); - JSONObject vim = new JSONObject(); - vim.put("vimInfoId", vimJson.getString("vimId")); - vim.put("vimId", vimJson.getString("vimId")); - vim.put("interfaceInfo", interfaceInfo); - vim.put("accessInfo", accessInfo); - vim.put("interfaceEndpoint", vimJson.getString("url")); - return vim; - } - - /** - * @param sites The sites to set. - */ - public void setSites(Sites sites) { - this.sites = sites; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java deleted file mode 100644 index 0699b98..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - * iResource add service implementation.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class IResourceAddServiceImpl { - - private static final Logger LOGGER = LoggerFactory.getLogger(IResourceAddServiceImpl.class); - - /** - * Add iResource.
- * - * @param restParametes - * @param iResMap - * @throws ServiceException - * @since NFVO 0.5 - */ - @Transactional(rollbackFor = ServiceException.class) - public void addIRes(RestfulParametes restParametes, Map iResMap) - throws ServiceException { - addIResources(iResMap, createResUrlMap(), restParametes); - } - - private void addIResources(Map iResMap, HashMap urlMap, - RestfulParametes restParametes) throws ServiceException { - for(String iResName : iResMap.keySet()) { - if(ParamConstant.PARAM_HOST.equals(iResName)) { - addHostResource(iResMap, restParametes, String.format(urlMap.get(iResName), - restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), - iResName); - } else { - String url = String.format(urlMap.get(iResName), restParametes.get(ParamConstant.PARAM_VIMID), - restParametes.get(ParamConstant.PARAM_TENANTID)); - JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); - LOGGER.warn("function=addIResources; iResArray={}", iResArray); - for(Object object : iResArray) { - JSONObject iRes = JSONObject.fromObject(object); - int result = iResMap.get(iResName).add(iRes); - LOGGER.warn("function=addIResources; msg=iRes name is [{}],result is [{}]", iResName, result); - } - } - } - } - - /** - * Add Host Resource.
- * - * @param iResMap - * @param restParametes - * @param url - * @param iResName - * @throws ServiceException - * @since NFVO 0.5 - */ - public static void addHostResource(Map iResMap, RestfulParametes restParametes, - String url, String iResName) throws ServiceException { - JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); - LOGGER.warn("function=addHostResource; hostResArray={}", hostResArray); - for(Object object : hostResArray) { - JSONObject hostRes = JSONObject.fromObject(object); - String hostZone = hostRes.getString("zone"); - if("internal".equals(hostZone)) { - continue; - } - String hostName = hostRes.getString("name"); - String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), - restParametes.get(ParamConstant.PARAM_TENANTID), hostName); - - String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); - if(result == null) { - continue; - } - JSONObject hostObj = JSONObject.fromObject(result); - JSONObject host = hostDataParse(hostObj, hostName); - int res = iResMap.get(iResName).add(host); - LOGGER.warn("function=addHostResource; result={}, res={}", result, res); - if(res < 0) { - LOGGER.error("function=addHostResource; add into DB fail!"); - } - - } - } - - /** - *
- * - * @param hostObj - * @param hostName - * @return - * @since NFVO 0.5 - */ - public static JSONObject hostDataParse(JSONObject hostObj, String hostName) { - LOGGER.warn("function=hostDataParse; hostObj={}, hostName={}", hostObj, hostName); - JSONArray hostArray = hostObj.getJSONArray("host"); - for(Object object : hostArray) { - JSONObject hostObject = JSONObject.fromObject(object); - if(hostObject.getString("project").contains("total")) { - String vimId = JsonUtil.getJsonFieldStr(hostObj, "vimId"); - String hostId = vimId + hostName; - JSONObject host = new JSONObject(); - host.put("id", hostId); - host.put("name", hostName); - host.put("cpu", JsonUtil.getJsonFieldStr(hostObject, "cpu")); - host.put("memory", JsonUtil.getJsonFieldStr(hostObject, "memory_mb")); - host.put("disk", JsonUtil.getJsonFieldStr(hostObject, "disk_gb")); - host.put("vimId", JsonUtil.getJsonFieldStr(hostObj, "vimId")); - host.put("vimName", JsonUtil.getJsonFieldStr(hostObj, "vimName")); - return host; - } - } - return new JSONObject(); - } - - private HashMap createResUrlMap() { - HashMap urlMap = new HashMap(10); - urlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); - urlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); - urlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); - return urlMap; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java deleted file mode 100644 index 59cff09..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * iResource delete service implementation.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class IResourceDelServiceImpl { - - private static final Logger LOGGER = LoggerFactory.getLogger(IResourceDelServiceImpl.class); - - /** - * - * Delete iResource.
- * - * @param vimId - * @param iResMap - * @param vim - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - public int deleteIRes(String vimId, Map iResMap, Vim vim) throws ServiceException { - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_VIMID, vimId); - - checkIResDelResult(vimId, iResMap); - return vim.delete(vimId); - } - - private void checkIResDelResult(String vimId, Map iResMap) throws ServiceException { - for(String keyName : iResMap.keySet()) { - if(iResMap.get(keyName).deleteResByVimId(vimId) < 0) { - LOGGER.error("function=checkIResDelResult; msg=delete {} failed,", keyName); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.delete.fail") - + keyName); - } - LOGGER.warn("function=checkIResDelResult; msg=delete {} success", keyName); - } - - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java deleted file mode 100644 index b789bf9..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - * iResource update service implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class IResourceUpdateServiceImpl { - - private static final Logger LOGGER = LoggerFactory.getLogger(IResourceUpdateServiceImpl.class); - - /** - * Update iResource.
- * - * @param vimId - * @param restParametes - * @param iResMap - * @param sites - * @throws ServiceException - * @since NFVO 0.5 - */ - @Transactional(rollbackFor = ServiceException.class) - public void updateIRes(String vimId, RestfulParametes restParametes, Map iResMap) - throws ServiceException { - - updateIResByName(iResMap, createResUrlMap(), restParametes, vimId); - } - - private void updateIResByName(Map iResMap, HashMap updateUrlMap, - RestfulParametes restParametes, String vimId) throws ServiceException { - for(String resName : updateUrlMap.keySet()) { - if(ParamConstant.PARAM_HOST.equals(resName)) { - updateHostResource(iResMap, restParametes, String.format(updateUrlMap.get(resName), - restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), - resName); - } else if(iResMap.get(resName).deleteResByVimId(vimId) >= 0) { - String url = String.format(updateUrlMap.get(resName), restParametes.get(ParamConstant.PARAM_VIMID), - restParametes.get(ParamConstant.PARAM_TENANTID)); - JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, resName); - LOGGER.warn("function=addIResources; iResArray={}", iResArray); - for(Object object : iResArray) { - JSONObject iRes = JSONObject.fromObject(object); - int result = iResMap.get(resName).add(iRes); - LOGGER.warn("function=updateIResByName; msg=iRes name is [{}],result is [{}]", resName, result); - - } - } - } - } - - private void updateHostResource(Map iResMap, RestfulParametes restParametes, - String url, String iResName) throws ServiceException { - - JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); - LOGGER.warn("function=updateHostResource; hostResArray={}", hostResArray); - for(Object object : hostResArray) { - JSONObject hostRes = JSONObject.fromObject(object); - String hostZone = hostRes.getString("zone"); - if("internal".equals(hostZone)) { - continue; - } - String hostName = hostRes.getString("name"); - String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), - restParametes.get(ParamConstant.PARAM_TENANTID), hostName); - - String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); - JSONObject hostObj = JSONObject.fromObject(result); - JSONObject host = IResourceAddServiceImpl.hostDataParse(hostObj, hostName); - int res = iResMap.get(ParamConstant.PARAM_HOST).update(host); - LOGGER.warn("function=updateHostResource; result={}, res={}", result, res); - if(res < 0) { - LOGGER.error("function=updateHostResource; add into DB fail!"); - } - - } - } - - private HashMap createResUrlMap() { - HashMap updateUrlMap = new HashMap(10); - updateUrlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); - updateUrlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); - updateUrlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); - return updateUrlMap; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java deleted file mode 100644 index 788e487..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.Constant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.common.util.StringUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; -import org.openo.nfvo.resmanagement.service.entity.VimEntity; -import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - * Resource operation service implementation class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public class ResOperateServiceImpl implements ResOperateService { - - private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateServiceImpl.class); - - private Sites sites; - - private Network network; - - private Host host; - - private Port port; - - private Vim vim; - - private IResourceAddServiceImpl iResourceAddServiceImpl; - - private IResourceUpdateServiceImpl iResourceUpdateServiceImpl; - - private IResourceDelServiceImpl iResourceDelServiceImpl; - - @Override - @Transactional(rollbackFor = ServiceException.class) - public void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { - LOGGER.warn("function=addIRes; msg=add IResource by vimId:[{}], tenantId:[{}]", vimId, tenantId); - if(!StringUtil.isValidString(vimId) || !StringUtil.isValidString(tenantId)) { - LOGGER.warn("function=addIRes; msg=vimId[{}] is valid", vimId); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.vimId")); - } - - RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); - HashMap iResMap = createMap(); - - if(vim.add(vimId) <= 0) { - LOGGER.error("VimId exists"); - throw new ServiceException("VimId exists"); - } - - iResourceAddServiceImpl.addIRes(restParametes, iResMap); - } - - @Override - @Transactional(rollbackFor = ServiceException.class) - public void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { - if(!StringUtil.isValidString(vimId)) { - LOGGER.error("function=updateIRes; msg=vimId is not exist"); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); - } - - RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); - HashMap iResMap = createMap(); - iResourceUpdateServiceImpl.updateIRes(vimId, restParametes, iResMap); - } - - @Override - public void updateAllIRes() throws ServiceException { - LOGGER.warn("function=updateAllIRes; msg=update all IResource"); - List vims = vim.getList(); - if(vims.isEmpty()) { - LOGGER.error("function=updateAllIRes; msg=vimId is not exist"); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); - } - for(VimEntity vimEntity : vims) { - String vimId = vimEntity.getId(); - LOGGER.warn("function=updateAllIRes; msg=start update vimId:{}", vimId); - updateIRes(null, vimId, new JSONObject()); - } - } - - @Override - @Transactional(rollbackFor = ServiceException.class) - public int deleteIRes(String vimId) throws ServiceException { - LOGGER.warn("function=deleteAllRes; msg=deleteResPool vimId: {}", vimId); - if(StringUtils.isEmpty(vimId)) { - LOGGER.error("function=deleteAllRes; msg=vimId is null"); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.res.no.vimId")); - } - - return iResourceDelServiceImpl.deleteIRes(vimId, createMap(), vim); - } - - private RestfulParametes createRestfulParametes(String tenantId, String vimId, JSONObject header) { - RestfulParametes restParametes = new RestfulParametes(); - restParametes.put("vimId", vimId); - restParametes.put("tenantId", tenantId); - restParametes.putHttpContextHeader("Content-Type", "application/json"); - JSONObject headers = JsonUtil.getJsonFieldJson(header, "header"); - if(null == headers || !headers.has("x-auth-token")) { - String token = "TestToken"; - LOGGER.warn("function=createRestfulParametes; msg=create token."); - restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, token); - return restParametes; - } - restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, - JsonUtil.getJsonFieldStr(headers, Constant.IAM_AUTH_TOKEN)); - return restParametes; - } - - private HashMap createMap() { - HashMap iResMap = new HashMap(10); - iResMap.put(ParamConstant.PARAM_NETWORK, network); - iResMap.put(ParamConstant.PARAM_HOST, host); - iResMap.put(ParamConstant.PARAM_PORT, port); - return iResMap; - } - - public void setSites(Sites sites) { - this.sites = sites; - } - - public void setNetwork(Network network) { - this.network = network; - } - - public void setHost(Host host) { - this.host = host; - } - - public void setPort(Port port) { - this.port = port; - } - - public void setVim(Vim vim) { - this.vim = vim; - } - - /** - * Set iResource Add service implemtation.
- * - * @param iResourceAddServiceImpl - * @since NFVO 0.5 - */ - public void setiResourceAddServiceImpl(IResourceAddServiceImpl iResourceAddServiceImpl) { - this.iResourceAddServiceImpl = iResourceAddServiceImpl; - } - - /** - * Set iResource update service implementation.
- * - * @param iResourceUpdateServiceImpl - * @since NFVO 0.5 - */ - public void setiResourceUpdateServiceImpl(IResourceUpdateServiceImpl iResourceUpdateServiceImpl) { - this.iResourceUpdateServiceImpl = iResourceUpdateServiceImpl; - } - - /** - * Set iresource delete service implementation.
- * - * @param iResourceDelServiceImpl - * @since NFVO 0.5 - */ - public void setiResourceDelServiceImpl(IResourceDelServiceImpl iResourceDelServiceImpl) { - this.iResourceDelServiceImpl = iResourceDelServiceImpl; - } - - /** - *
- * - * @param string - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public void sendMsgMonitor(String operateType, String vimId) throws ServiceException { - LOGGER.info("Enter sendMsgMonitor!"); - Map map = new HashMap<>(10); - map.put("vimId", vimId); - List hosts = host.getList(map); - for(HostEntity entity : hosts) { - JSONObject msgObj = new JSONObject(); - msgObj.put("operationType", operateType); - msgObj.put("resourceType", "HOST"); - msgObj.put("label", entity.getName()); - if("delete".equals(operateType)) { - JSONArray deleteIds = new JSONArray(); - deleteIds.add(entity.getId()); - msgObj.put("deleteIds", deleteIds); - } else { - JSONArray data = new JSONArray(); - JSONObject obj = JSONObject.fromObject(entity); - obj.put("oid", entity.getId()); - obj.put("moc", "nfv.host.linux"); - data.add(obj); - msgObj.put("data", data); - } - RestfulParametes restfulParametes = new RestfulParametes(); - Map headerMap = new HashMap<>(3); - headerMap.put("Content-Type", "application/json"); - restfulParametes.setHeaderMap(headerMap); - restfulParametes.setRawData(msgObj.toString()); - LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); - String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, - ParamConstant.PARAM_POST); - LOGGER.warn(result); - } - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java deleted file mode 100644 index 5dd726c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao; -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 27, 2016 - */ -public class VirtualLinkServiceImpl implements VirtualLinkService { - - private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkServiceImpl.class); - - private VirtualLinkDao virtualLinkDao; - - /** - *
- * - * @param virtualLinkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException { - if(!checkId(virtualLinkEntity.getId())) { - LOGGER.error("function=addVl; msg=add error, because id is already exist."); - throw new ServiceException(ResourceUtil - .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VirtualLinkServiceImpl.add.id.check")); - } - if(StringUtils.isEmpty(virtualLinkEntity.getId())) { - virtualLinkEntity.setId(UUID.randomUUID().toString()); - } - int result = virtualLinkDao.addVl(virtualLinkEntity); - JSONObject restJson = new JSONObject(); - if(result > 0) { - restJson.put("id", virtualLinkEntity.getId()); - restJson.put("name", virtualLinkEntity.getName()); - } else { - LOGGER.error("function=addVl; msg=add vl into DB error."); - restJson.put("message", "Add Vl into DB error."); - } - return restJson; - - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - private boolean checkId(String id) { - VirtualLinkEntity vl = virtualLinkDao.getVl(id); - if(null == vl) { - return true; - } - return false; - } - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public List getList(Map map) throws ServiceException { - return virtualLinkDao.getVls(map); - } - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int delete(String id) throws ServiceException { - return virtualLinkDao.deleteVlById(id); - } - - public void setVirtualLinkDao(VirtualLinkDao virtualLinkDao) { - this.virtualLinkDao = virtualLinkDao; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java deleted file mode 100644 index 51ec0dd..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.RestfulUtil; -import org.openo.nfvo.resmanagement.service.dao.inf.VmDao; -import org.openo.nfvo.resmanagement.service.entity.VmEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VmService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public class VmServiceImpl implements VmService { - - private static final Logger LOGGER = LoggerFactory.getLogger(VmServiceImpl.class); - - private VmDao vmDao; - - /** - *
- * - * @param vmEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject addVm(VmEntity vmEntity) throws ServiceException { - int result; - if(!checkId(vmEntity.getVmId())) { - result = vmDao.updateVm(vmEntity); - sendMsgMonitor("create", vmEntity); - } else { - if(StringUtils.isEmpty(vmEntity.getVmId())) { - vmEntity.setVmId(UUID.randomUUID().toString()); - } - result = vmDao.addVm(vmEntity); - sendMsgMonitor("update", vmEntity); - } - JSONObject restJson = new JSONObject(); - if(result > 0) { - restJson.put("id", vmEntity.getVmId()); - restJson.put("name", vmEntity.getVmName()); - } else { - LOGGER.error("function=addVm; msg=add vm into DB error."); - restJson.put("message", "Add vm into DB error."); - } - return restJson; - } - - /** - *
- * - * @param vmId - * @return - * @since NFVO 0.5 - */ - private boolean checkId(String vmId) { - VmEntity vm = vmDao.getVm(vmId); - if(null == vm) { - return true; - } - return false; - } - - public void sendMsgMonitor(String operateType, VmEntity vmEntity) throws ServiceException { - JSONObject msgObj = new JSONObject(); - msgObj.put("operationType", operateType); - msgObj.put("resourceType", "VDU"); - msgObj.put("label", vmEntity.getVmName()); - if("delete".equals(operateType)) { - JSONArray deleteIds = new JSONArray(); - deleteIds.add(vmEntity.getVmId()); - msgObj.put("deleteIds", deleteIds); - } else { - JSONArray data = new JSONArray(); - JSONObject obj = JSONObject.fromObject(vmEntity); - obj.put("oid", vmEntity.getVmId()); - obj.put("moc", "nfv.vdu.linux"); - data.add(obj); - msgObj.put("data", data); - } - LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); - RestfulParametes restfulParametes = new RestfulParametes(); - Map headerMap = new HashMap<>(3); - headerMap.put("Content-Type", "application/json"); - restfulParametes.setHeaderMap(headerMap); - restfulParametes.setRawData(msgObj.toString()); - String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, - ParamConstant.PARAM_POST); - LOGGER.warn(result); - - } - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public List getList(Map map) throws ServiceException { - return vmDao.getVms(map); - } - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int delete(String id) throws ServiceException { - return vmDao.deleteVmById(id); - } - - public void setVmDao(VmDao vmDao) { - this.vmDao = vmDao; - } - - /** - *
- * - * @param vnfInstanceId - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int deleteByVnfId(String vnfInstanceId) throws ServiceException { - Map map = new HashMap<>(10); - map.put("vnfInstanceId", vnfInstanceId); - List vms = vmDao.getVms(map); - for(int i = 0; i < vms.size(); i++) { - VmEntity vm = vms.get(i); - sendMsgMonitor("delete", vm); - } - return vmDao.deleteVmByVnfId(vnfInstanceId); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java deleted file mode 100644 index fb34127..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao; -import org.openo.nfvo.resmanagement.service.entity.VmEntity; -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VmService; -import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VnfInfoServiceImpl implements VnfInfoService { - - private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoServiceImpl.class); - - private VnfInfoDao vnfInfoDao; - - private VmService vmService; - - /** - *
- * - * @param object - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject addVnfInfo(JSONObject object) throws ServiceException { - LOGGER.info("function=addVnfInfo; object: {}", object); - saveVm(object); - JSONObject vnf = new JSONObject(); - vnf.put("vnfInstanceId", object.get("vnfInstanceId")); - vnf.put("nsId", object.get("nsId")); - vnf.put("vnfmId", object.get("vnfmId")); - VnfInfoEntity vnfInfoEntity = VnfInfoEntity.toEntity(vnf); - int result; - if(!checkId(vnfInfoEntity.getVnfInstanceId())) { - result = vnfInfoDao.updateVnfInfo(vnfInfoEntity); - } else { - result = vnfInfoDao.addVnfInfo(vnfInfoEntity); - } - JSONObject resultObj = new JSONObject(); - if(result > 0) { - resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); - } else { - LOGGER.error("function=addVnfInfo; msg=add vnfInfo into DB error."); - resultObj.put("message", "Add vnfInfo into DB error."); - } - return resultObj; - } - - /** - *
- * - * @param vnfInstanceId - * @return - * @since NFVO 0.5 - */ - private boolean checkId(String vnfInstanceId) { - VnfInfoEntity vnf = vnfInfoDao.getVnfInfo(vnfInstanceId); - if(null == vnf) { - return true; - } - return false; - } - - /** - *
- * - * @param object - * @throws ServiceException - * @since NFVO 0.5 - */ - private void saveVm(JSONObject object) throws ServiceException { - String vnfInstanceId = object.getString("vnfInstanceId"); - JSONArray vms = object.getJSONArray("vms"); - for(int i = 0; i < vms.size(); i++) { - JSONObject vmObj = vms.getJSONObject(i); - vmObj.put("vnfInstanceId", vnfInstanceId); - vmService.addVm(VmEntity.toEntity(vmObj)); - } - - } - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public List getList(Map map) throws ServiceException { - return vnfInfoDao.getVnfInfos(map); - } - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int delete(String id) throws ServiceException { - vmService.deleteByVnfId(id); - return vnfInfoDao.deleteVnfInfoById(id); - } - - public void setVnfInfoDao(VnfInfoDao vnfInfoDao) { - this.vnfInfoDao = vnfInfoDao; - } - - public void setVmService(VmService vmService) { - this.vmService = vmService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java deleted file mode 100644 index 3a1a02e..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao; -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; -import org.openo.nfvo.resmanagement.service.group.inf.VnfService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public class VnfServiceImpl implements VnfService { - - private static final Logger LOGGER = LoggerFactory.getLogger(VnfServiceImpl.class); - - private VnfDao vnfDao; - - private VnfInfoService vnfInfoService; - - /** - *
- * - * @param vnfEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException { - if(!checkId(vnfEntity.getId())) { - LOGGER.error("function=addVnf; msg=add error, because id is already exist."); - throw new ServiceException(ResourceUtil - .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VnfServiceImpl.add.id.check")); - } - if(StringUtils.isEmpty(vnfEntity.getId())) { - vnfEntity.setId(UUID.randomUUID().toString()); - } - int result = vnfDao.addVnf(vnfEntity); - JSONObject restJson = new JSONObject(); - if(result > 0) { - restJson.put("id", vnfEntity.getId()); - restJson.put("name", vnfEntity.getName()); - } else { - LOGGER.error("function=addVnf; msg=add vnf into DB error."); - restJson.put("message", "Add vnf into DB error."); - } - return restJson; - } - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - private boolean checkId(String id) { - VnfEntity vnf = vnfDao.getVnf(id); - if(null == vnf) { - return true; - } - return false; - } - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public List getList(Map map) throws ServiceException { - return vnfDao.getVnfs(map); - } - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int delete(String id) throws ServiceException { - deleteVnfInfo(id); - return vnfDao.deleteVnfById(id); - } - - /** - *
- * - * @param id - * @throws ServiceException - * @since NFVO 0.5 - */ - private void deleteVnfInfo(String vnfInstanceId) throws ServiceException { - vnfInfoService.delete(vnfInstanceId); - } - - public void setVnfDao(VnfDao vnfDao) { - this.vnfDao = vnfDao; - } - - public void setVnfInfoService(VnfInfoService vnfInfoService) { - this.vnfInfoService = vnfInfoService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java deleted file mode 100644 index 7e37561..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.impl; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao; -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public class VnfStatusServiceImpl implements VnfStatusService { - - private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusServiceImpl.class); - - private VnfStatusDao vnfStatusDao; - - /** - *
- * - * @param object - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public JSONObject addVnfStatus(JSONObject object) throws ServiceException { - LOGGER.info("function=addVnfStatus; object: {}", object); - VnfStatusEntity vnfStatusEntity = VnfStatusEntity.toEntity(object); - int result; - if(!checkId(vnfStatusEntity.getVnfInstanceId())) { - result = vnfStatusDao.updateVnfStatus(vnfStatusEntity); - } else { - result = vnfStatusDao.addVnfStatus(vnfStatusEntity); - } - JSONObject resultObj = new JSONObject(); - if(result > 0) { - resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); - } else { - LOGGER.error("function=addVnfStatus; msg=add vnfStatus into DB error."); - resultObj.put("message", "Add vnfStatus into DB error."); - } - return resultObj; - } - - /** - *
- * - * @param vnfInstanceId - * @return - * @since NFVO 0.5 - */ - private boolean checkId(String vnfInstanceId) { - VnfStatusEntity vnfStatus = vnfStatusDao.getVnfStatus(vnfInstanceId); - if(null == vnfStatus) { - return true; - } - return false; - } - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public List getList(Map map) throws ServiceException { - return vnfStatusDao.getVnfStatuss(map); - } - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @Override - public int delete(String id) throws ServiceException { - return vnfStatusDao.deleteVnfStatusById(id); - } - - public void setVnfStatusDao(VnfStatusDao vnfStatusDao) { - this.vnfStatusDao = vnfStatusDao; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java deleted file mode 100644 index 4c52b9c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public interface GrantResService { - - /** - *
- * - * @param object - * @return - * @since NFVO 0.5 - */ - JSONObject grantResource(JSONObject object) throws ServiceException; - - JSONObject grantResourceReal(JSONObject object) throws ServiceException; - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java deleted file mode 100644 index 7e2069f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -import net.sf.json.JSONObject; - -/** - * resource operational service class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface ResOperateService { - - /** - * Update iresource.
- * - * @param tenantId - * @param vimId - * @param header - * @throws ServiceException - * @since NFVO 0.5 - */ - void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; - - /** - * Update all iResource.
- * - * @throws ServiceException - * @since NFVO 0.5 - */ - void updateAllIRes() throws ServiceException; - - /** - * Add iResource.
- * - * @param tenantId - * @param vimId - * @param header - * @throws ServiceException - * @since NFVO 0.5 - */ - void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; - - /** - * Delete iResource.
- * - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int deleteIRes(String vimId) throws ServiceException; - - /** - *
- * - * @param operateType - * @param vimId - * @throws ServiceException - * @since NFVO 0.5 - */ - void sendMsgMonitor(String operateType, String vimId) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java deleted file mode 100644 index cd1ea93..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 27, 2016 - */ -public interface VirtualLinkService { - - /** - *
- * - * @param virtualLinkEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException; - - /** - *
- * - * @param map - * @return - * @since NFVO 0.5 - */ - List getList(Map map) throws ServiceException; - - /** - *
- * - * @param id - * @return - * @since NFVO 0.5 - */ - int delete(String id) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java deleted file mode 100644 index 668f9d3..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VmEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public interface VmService { - - JSONObject addVm(VmEntity vmEntity) throws ServiceException; - - List getList(Map map) throws ServiceException; - - int delete(String id) throws ServiceException; - - int deleteByVnfId(String vnfInstanceId) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java deleted file mode 100644 index 6e736d6..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VnfInfoService { - - JSONObject addVnfInfo(JSONObject object) throws ServiceException; - - List getList(Map map) throws ServiceException; - - int delete(String id) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java deleted file mode 100644 index 4fbe45e..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -public interface VnfService { - - /** - *
- * - * @param vnfEntity - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException; - - /** - *
- * - * @param map - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - List getList(Map map) throws ServiceException; - - /** - *
- * - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - int delete(String id) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java deleted file mode 100644 index cdc826c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.group.inf; - -import java.util.List; -import java.util.Map; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -public interface VnfStatusService { - - JSONObject addVnfStatus(JSONObject object) throws ServiceException; - - List getList(Map map) throws ServiceException; - - int delete(String id) throws ServiceException; -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java deleted file mode 100644 index 643c581..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.HostEntity; - -/** - * Host info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface HostMapper { - - /** - * It is used to get Host info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - HostEntity getHost(String id); - - /** - * It is used to get Hosts info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getHosts(Map condition); - - /** - * It is used to delete Hosts info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deleteHost(String id); - - /** - * It is used to delete Hosts info.
- * - * @param vimId - * @return The delete result - * @since NFVO 0.5 - */ - int deleteHostByVimId(String vimId); - - /** - * It is used to add Hosts info.
- * - * @param hostEntity - * @return The add result - * @since NFVO 0.5 - */ - int addHost(HostEntity hostEntity); - - /** - * It is used to add Hosts info.
- * - * @param hostEntity - * @return The add result - * @since NFVO 0.5 - */ - int addHostSelective(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHostSelective(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHost(HostEntity hostEntity); - - /** - * It is used to update Hosts info.
- * - * @param hostEntity - * @return The update result - * @since NFVO 0.5 - */ - int updateHostByVimId(HostEntity hostEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java deleted file mode 100644 index 2a2ec5c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; - -/** - * - * Location Mapper Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface LocationMapper { - - /** - * - * Get location.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - LocationEntity getLocation(String id); - - /** - * - * Get Country.
- * - * @return - * @since NFVO 0.5 - */ - List getCountry(); - - /** - * - * Get location by country.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getLocationByCountry(Map condition); - - /** - * - * get locations.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getLocations(Map condition); - - /** - * - * Delete location.
- * - * @param location - * @return - * @since NFVO 0.5 - */ - int deleteLocation(String location); - - /** - * - * Add location.
- * - * @param locationEntity - * @return - * @since NFVO 0.5 - */ - int addLocation(LocationEntity locationEntity); - - /** - * - * Add selective location.
- * - * @param locationEntity - * @return - * @since NFVO 0.5 - */ - int addLocationSelective(LocationEntity locationEntity); - - /** - * - * Update selective location.
- * - * @param locationEntity - * @return - * @since NFVO 0.5 - */ - int updateLocationSelective(LocationEntity locationEntity); - - /** - * - * Update location.
- * - * @param locationEntity - * @return - * @since NFVO 0.5 - */ - int updateLocation(LocationEntity locationEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java deleted file mode 100644 index b727f4f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; - -/** - * - * Network Mapper Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -public interface NetworkMapper { - - /** - * - * Get network details.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - NetworkEntity getNetwork(String id); - - /** - * - * Get details of networks.
- * - * @param condition - * @return - * @since NFVO 0.5 - */ - List getNetworks(Map condition); - - /** - * - * Delete network.
- * - * @param id - * @return - * @since NFVO 0.5 - */ - int deleteNetwork(String id); - - /** - * - * Delete network by VIM ID.
- * - * @param vimId - * @return - * @since NFVO 0.5 - */ - int deleteNetworkByVimId(String vimId); - - /** - * - * Add network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int addNetwork(NetworkEntity networkEntity); - - /** - * - * Add selective network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int addNetworkSelective(NetworkEntity networkEntity); - - /** - * - * Update selective network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetworkSelective(NetworkEntity networkEntity); - - /** - * - * Update network.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetwork(NetworkEntity networkEntity); - - /** - * - * Update network by VIM Id.
- * - * @param networkEntity - * @return - * @since NFVO 0.5 - */ - int updateNetworkByVimId(NetworkEntity networkEntity); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java deleted file mode 100644 index 9cae421..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.PortEntity; - -/** - * Port info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface PortMapper { - - /** - * It is used to get Port info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - PortEntity getPort(String id); - - /** - * It is used to get Ports info.
- * - * @param condition - * @return The get result - * @since NFVO 0.5 - */ - List getPorts(Map condition); - - /** - * It is used to delete Ports info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deletePort(String id); - - /** - * It is used to delete Ports info.
- * - * @param vimId - * @return The delete result - * @since NFVO 0.5 - */ - int deletePortByVimId(String vimId); - - /** - * It is used to add Ports info.
- * - * @param portEntity - * @return The add result - * @since NFVO 0.5 - */ - int addPort(PortEntity portEntity); - - /** - * It is used to add Ports info.
- * - * @param portEntity - * @return The add result - * @since NFVO 0.5 - */ - int addPortSelective(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePortSelective(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePort(PortEntity portEntity); - - /** - * It is used to update Ports info.
- * - * @param portEntity - * @return The update result - * @since NFVO 0.5 - */ - int updatePortByVimId(PortEntity portEntity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java deleted file mode 100644 index e86d5e1..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; - -/** - * ResPool info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface SitesMapper { - - /** - * It is used to get Sites info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - SitesEntity getSite(String id); - - /** - * - * It is used to get Sites info.
- * - * @param map - * @return - * @since NFVO 0.5 - */ - List getSites(Map map); - - /** - * It is used to get Sites info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - int deleteSite(String id); - - /** - * - * It is used to delete Site info.
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int addSite(SitesEntity entity); - - /** - * - * It is used to add Sites info.
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int addSiteSelective(SitesEntity entity); - - /** - * - * It is used to add Site info.
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int updateSiteSelective(SitesEntity entity); - - /** - * - * It is used to update Sites info.
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int updateSite(SitesEntity entity); - - /** - * - * It is used to update Site info.
- * - * @param entity - * @return - * @since NFVO 0.5 - */ - int updateSiteByVimId(SitesEntity entity); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java deleted file mode 100644 index 1c4573a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; - -import org.openo.nfvo.resmanagement.service.entity.VimEntity; - -/** - * Vim info interface.
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -public interface VimMapper { - - /** - * It is used to get Vim info.
- * - * @param id - * @return The get result - * @since NFVO 0.5 - */ - VimEntity getVim(String id); - - /** - * It is used to get Vims info.
- * - * @return The get result - * @since NFVO 0.5 - */ - List getVims(); - - /** - * It is used to delete Vim info.
- * - * @param id - * @return The delete result - * @since NFVO 0.5 - */ - int deleteVim(String id); - - /** - * It is used to add Vim info.
- * - * @param vimEntity - * @return The add result - * @since NFVO 0.5 - */ - int addVim(VimEntity vimEntity); - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java deleted file mode 100644 index c4cba74..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; - -public interface VirtualLinkMapper { - - int deleteByPrimaryKey(String id); - - int insert(VirtualLinkEntity record); - - int insertSelective(VirtualLinkEntity record); - - VirtualLinkEntity selectByPrimaryKey(String id); - - List getVls(Map condition); - - int updateByPrimaryKeySelective(VirtualLinkEntity record); - - int updateByPrimaryKey(VirtualLinkEntity record); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java deleted file mode 100644 index 4cb4878..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VmEntity; - -public interface VmMapper { - - int deleteByPrimaryKey(String vmId); - - int deleteByVnfId(String vnfInstanceId); - - int insert(VmEntity record); - - int insertSelective(VmEntity record); - - VmEntity selectByPrimaryKey(String vmId); - - List getVms(Map condition); - - int updateByPrimaryKeySelective(VmEntity record); - - int updateByPrimaryKey(VmEntity record); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java deleted file mode 100644 index 45d4f45..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; - -public interface VnfInfoMapper { - - int deleteByPrimaryKey(String vnfInstanceId); - - int insert(VnfInfoEntity record); - - int insertSelective(VnfInfoEntity record); - - VnfInfoEntity selectByPrimaryKey(String vnfInstanceId); - - List getVnfInfos(Map condition); - - int updateByPrimaryKeySelective(VnfInfoEntity record); - - int updateByPrimaryKey(VnfInfoEntity record); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java deleted file mode 100644 index 5d0078f..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; - -public interface VnfMapper { - - int deleteByPrimaryKey(String vnfInstanceId); - - int insert(VnfEntity record); - - int insertSelective(VnfEntity record); - - VnfEntity selectByPrimaryKey(String id); - - List getVnfs(Map condition); - - int updateByPrimaryKeySelective(VnfEntity record); - - int updateByPrimaryKey(VnfEntity record); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java deleted file mode 100644 index c7e5c7a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.mapper; - -import java.util.List; -import java.util.Map; - -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; - -public interface VnfStatusMapper { - - int deleteByPrimaryKey(String vnfInstanceId); - - int insert(VnfStatusEntity record); - - int insertSelective(VnfStatusEntity record); - - VnfStatusEntity selectByPrimaryKey(String vnfInstanceId); - - List getVnfStatuss(Map condition); - - int updateByPrimaryKeySelective(VnfStatusEntity record); - - int updateByPrimaryKey(VnfStatusEntity record); -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java deleted file mode 100644 index 47a9a02..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.service.group.inf.GrantResService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -@Path(UrlConstant.GRANTRES_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class GrantResourseRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(GrantResourseRoa.class); - - private GrantResService grantResService; - - @PUT - @Path("/stub") - public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); - } - - LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); - try { - return grantResService.grantResource(object); - } catch(ServiceException se) { - LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @PUT - public JSONObject grantResourceReal(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); - } - - LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); - try { - return grantResService.grantResourceReal(object); - } catch(ServiceException se) { - LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setGrantResService(GrantResService grantResService) { - this.grantResService = grantResService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java deleted file mode 100644 index 98e7da0..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; -import org.openo.nfvo.resmanagement.service.entity.HostEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * - * Host ROA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.HOST_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class HostRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(HostRoa.class); - - private Host host; - - /** - * - * Get hosts.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - public JSONObject getHosts(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List hosts = host.getList(map); - - JSONObject result = new JSONObject(); - result.put("hosts", hosts); - return result; - } - - /** - * - * Get host.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/{hostId}") - public JSONObject getHost(@Context HttpServletRequest context, @PathParam("hostId") String id) - throws ServiceException { - LOGGER.info("HostRoa::getHost id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List hosts = host.getList(map); - - JSONObject result = new JSONObject(); - result.put("hosts", hosts); - return result; - } - - /** - * - * Add host.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @POST - public JSONObject addHost(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("HostRoa::addHost:{}", object.toString()); - try { - int result = host.add(object); - return RoaResponseUtil.add(result); - } catch(ServiceException se) { - LOGGER.error("HostRoa::addHost error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Delete host.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - public JSONObject deleteHost(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - LOGGER.info("HostRoa::deleteHost id:{}", id); - try { - int result = host.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("HostRoa::deleteHost error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Update host.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - public JSONObject updateHost(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("HostRoa::updateHost:{}", object.toString()); - try { - int result = host.update(object); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("HostRoa::updateHost error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setHost(Host host) { - this.host = host; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java deleted file mode 100644 index 5275dfe..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.LIMITS_URL) -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class LimitsRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(LimitsRoa.class); - - private LimitsBusiness limitsBusiness; - - /** - *
- * - * @param context - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - public JSONObject getLimits(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { - LOGGER.warn("function=getLimits, vimId={}", vimId); - return limitsBusiness.getLimits(vimId); - } - - public void setLimitsBusiness(LimitsBusiness limitsBusiness) { - this.limitsBusiness = limitsBusiness; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java deleted file mode 100644 index f3bb351..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.JsonUtil; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.entity.LocationEntity; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * Location ROA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.LOCATION_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class LocationRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(LocationRoa.class); - - private Location location; - - private Sites sites; - - /** - * Get Locations Base.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - public JSONObject getLocationsbase(@Context HttpServletRequest context) throws ServiceException { - Map condition = new HashMap<>(); - List locations = location.get(condition); - - JSONObject result = new JSONObject(); - result.put("locations", locations); - return result; - } - - /** - * Get Locations Base.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/{locationId}") - public JSONObject getLocationbase(@Context HttpServletRequest context, @PathParam("locationId") String id) - throws ServiceException { - LOGGER.info("LocationRoa::getLocationbase id:{}", id); - Map map = new HashMap<>(); - map.put(ParamConstant.PARAM_ID, id); - List locations = location.get(map); - - JSONObject result = new JSONObject(); - result.put("locations", locations); - return result; - } - - /** - * Get Country.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/country") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject getCountry(@Context HttpServletRequest context) throws ServiceException { - return RoaResponseUtil.get(location.getCountry()); - } - - /** - * Get Location by Country.
- * - * @param context - * @param country - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/locationbycountry") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject getLocationByCountry(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_COUNTRY) String country) throws ServiceException { - LOGGER.info("LocationRoa::getLocationByCountry country:{}", country); - Map condition = new HashMap<>(); - condition.put(ParamConstant.PARAM_COUNTRY, country); - return RoaResponseUtil.get(location.getLocationByCountry(condition)); - } - - /** - * Get Cloud Service.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/cloudservice") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject getCloudservice(@Context HttpServletRequest context) throws ServiceException { - return RoaResponseUtil.get(location.getCloudservice()); - } - - /** - * Get location details.
- * - * @param context - * @param locations - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/site") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject getLocation(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { - LOGGER.info("LocationRoa::getLocation locations:{}", locations); - Map condition = new HashMap<>(); - List loca = new ArrayList(); - condition.put(ParamConstant.PARAM_LOCATION, locations); - loca = location.get(condition); - LOGGER.info("LocationRoa::getLocation loca:{}", loca); - return RoaResponseUtil.get(location.getLocationInfo(loca)); - } - - /** - * Add Location.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject addLocation(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("LocationRoa::addLocation : " + object.toString()); - try { - int result = location.add(object); - return RoaResponseUtil.add(result); - } catch(ServiceException se) { - LOGGER.error("LocationRoa::addLocation error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * Delete Location Base.
- * - * @param context - * @param locations - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - @Path("/{location}") - public JSONObject deleteLocationbase(@Context HttpServletRequest context, - @PathParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { - LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); - Map condition = new HashMap<>(); - condition.put(ParamConstant.PARAM_LOCATION, locations); - try { - int result = location.delete(locations); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("LocationRoa::deleteLocationbase error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * Delete Location.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject deleteLocation(@Context HttpServletRequest context) throws ServiceException { - - JSONObject object = RequestUtil.getJsonRequestBody(context); - String locations = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); - String id = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_ID); - LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); - - Map condition = new HashMap<>(); - condition.put(ParamConstant.PARAM_LOCATION, locations); - SitesEntity sitesEntity = sites.get(condition); - try { - if(sitesEntity != null) { - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.used.check")); - } - int result = location.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("LocationRoa::deleteLocation error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * Update Location.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject updateLocation(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - String local = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); - Map localInfo = new HashMap<>(); - localInfo.put(ParamConstant.PARAM_LOCATION, local); - SitesEntity sitesEntity = sites.get(localInfo); - if(sitesEntity != null) { - LOGGER.error("function=updateLocation; msg=update error, because location is used."); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.used.check")); - } - LOGGER.info("LocationRoa::updateLocation : " + object.toString()); - - try { - int result = location.update(object); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("LocationRoa::update Location error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setLocation(Location location) { - this.location = location; - } - - public void setSites(Sites sites) { - this.sites = sites; - } - -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java deleted file mode 100644 index 8a3e0bd..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; -import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * - * Network ROA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.NETWORKS_URL) -@Consumes({MediaType.APPLICATION_JSON}) -@Produces({MediaType.APPLICATION_JSON}) -public class NetworkRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkRoa.class); - - private Network network; - - /** - * - * Get details of networks.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - public JSONObject getNetworks(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List networks = network.getList(map); - - JSONObject result = new JSONObject(); - result.put("networks", networks.toString()); - return result; - } - - /** - * - * Get network details.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/{networkId}") - public JSONObject getNetwork(@Context HttpServletRequest context, @PathParam("networkId") String id) - throws ServiceException { - LOGGER.info("NetworkRoa::getNetwork id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List networks = network.getList(map); - - JSONObject result = new JSONObject(); - result.put("networks", networks.toString()); - return result; - } - - /** - * - * Add network.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @POST - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - public JSONObject addNetwork(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("NetworkRoa::addNetwork:{}", object.toString()); - try { - int result = network.add(NetworkEntity.toEntity(object)); - return RoaResponseUtil.add(result); - } catch(ServiceException se) { - LOGGER.error("NetworkRoa::addNetwork error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Delete network.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - public JSONObject deleteNetwork(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - LOGGER.info("NetworkRoa::deleteNetwork id:{}", id); - try { - int result = network.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("NetworkRoa::deleteNetwork error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Update network.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - public JSONObject updateNetwork(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("NetworkRoa::updateNetwork:{}", object.toString()); - try { - int result = network.update(object); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("NetworkRoa::updateNetwork error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setNetwork(Network network) { - this.network = network; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java deleted file mode 100644 index 1d79f93..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; -import org.openo.nfvo.resmanagement.service.entity.PortEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * - * Port ROA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.PORT_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class PortRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(PortRoa.class); - - private Port port; - - /** - * - * Get details of Ports.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - public JSONObject getPorts(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List ports = port.getList(map); - - JSONObject result = new JSONObject(); - result.put("ports", ports); - return result; - } - - /** - * - * Get port details.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @GET - @Path("/{portId}") - public JSONObject getPort(@Context HttpServletRequest context, @PathParam("portId") String id) - throws ServiceException { - LOGGER.info("PortRoa::getPort id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List ports = port.getList(map); - - JSONObject result = new JSONObject(); - result.put("ports", ports); - return result; - } - - /** - * - * Add port.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @POST - public JSONObject addPort(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("PortRoa::addPort:{}", object.toString()); - try { - int result = port.add(PortEntity.toEntity(object)); - return RoaResponseUtil.add(result); - } catch(ServiceException se) { - LOGGER.error("PortRoa::addPort error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Delete port.
- * - * @param context - * @param id - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - public JSONObject deletePort(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - LOGGER.info("PortRoa::deletePort id:{}", id); - try { - int result = port.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("PortRoa::deletePort error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * - * Update port.
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - public JSONObject updatePort(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - - LOGGER.info("PortRoa::updatePort:{}", object.toString()); - try { - int result = port.update(object); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("PortRoa::updatePort error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setPort(Port port) { - this.port = port; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java deleted file mode 100644 index 1e68e83..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2016-2017 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - * Resource Operate ROA Class.
- *

- *

- * - * @author - * @version NFVO 0.5 Sep 10, 2016 - */ -@Path(UrlConstant.RESOPERATE_URL) -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class ResOperateRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateRoa.class); - - private ResOperateService resOperateService; - - /** - * Update iResource pool.
- * - * @param context - * @param tenantId - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - @Path(UrlConstant.MODRES_URL) - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject updateIResPool(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { - JSONObject json = RequestUtil.getAllJsonRequestBody(context); - LOGGER.warn("ResPoolRoa::modVimId :{}", vimId); - JSONObject vimInfo = VimUtil.getVimById(vimId); - String tenant = vimInfo.getString("tenant"); - String tenantId = VimUtil.getTenantIdByName(tenant, vimId); - try { - resOperateService.updateIRes(tenantId, vimId, json); - resOperateService.sendMsgMonitor("update", vimId); - return RoaResponseUtil.update(HttpConstant.OK_CODE); - } catch(ServiceException se) { - LOGGER.error("ResOperateRoa::updateIResPool error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * Add all resource pool.
- * - * @param context - * @param tenantId - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @POST - @Path(UrlConstant.ADDRES_URL) - @Consumes(UrlConstant.APPLICATION_TYPE) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject addAllResPool(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_TENANTID) String tenantId, - @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { - JSONObject json = RequestUtil.getAllJsonRequestBody(context); - LOGGER.warn("ResOperateRoa::vimId :{}", vimId); - - try { - resOperateService.addIRes(tenantId, vimId, json); - resOperateService.sendMsgMonitor("create", vimId); - return RoaResponseUtil.add(HttpConstant.OK_CODE); - } catch(ServiceException se) { - LOGGER.error("ResOperateRoa::addAllResPool error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * Delete iResource.
- * - * @param context - * @param vimId - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public JSONObject deleteIRes(@Context HttpServletRequest context, - @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { - LOGGER.warn("ResOperateRoa::deleteIResource vimId:{}", vimId); - - try { - resOperateService.sendMsgMonitor("delete", vimId); - int result = resOperateService.deleteIRes(vimId); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("ResOperateRoa::deleteIRes error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setResOperateService(ResOperateService resOperateService) { - this.resOperateService = resOperateService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java deleted file mode 100644 index 192d33d..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.VimUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; -import org.openo.nfvo.resmanagement.service.entity.SitesEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -/** - * Sites ROA method
- *

- *

- * - * @author - * @version NFVO 0.5 Aug 24, 2016 - */ -@Path(UrlConstant.SITES_URL) -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class SitesRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(SitesRoa.class); - - private Sites sites; - - /** - * getSites ROA method
- * - * @param context - * @return the get result - * @throws ServiceException When get failed. - * @since NFVO 0.5 - */ - @GET - public JSONObject getSites(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap(10); - List datacenters = sites.getList(map); - - JSONObject result = new JSONObject(); - result.put("datacenters", datacenters); - return result; - } - - /** - * getSite ROA method
- * - * @param context - * @param id - * @return the get result - * @throws ServiceException When get failed. - * @since NFVO 0.5 - */ - @GET - @Path("/{datacenterId}") - public JSONObject getSite(@Context HttpServletRequest context, @PathParam("datacenterId") String id) - throws ServiceException { - LOGGER.warn("SitesRoa::getSitesById id:{}", id); - Map map = new HashMap(10); - map.put(ParamConstant.PARAM_ID, id); - List datacenters = sites.getList(map); - - JSONObject result = new JSONObject(); - result.put("datacenters", datacenters); - return result; - } - - /** - * addSites ROA method
- * - * @param context - * @param id - * @return the add result - * @throws ServiceException When add failed. - * @since NFVO 0.5 - */ - @POST - public JSONObject addSites(@Context HttpServletRequest context) throws ServiceException { - JSONObject json = RequestUtil.getAllJsonRequestBody(context); - - LOGGER.warn("SitesRoa:: start add Sites"); - try { - int result = sites.add(json); - sites.sendToMonitor(json); - return RoaResponseUtil.add(result); - } catch(ServiceException se) { - LOGGER.error("SitesRoa::addSites error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * deleteSites ROA method
- * - * @param context - * @param id - * @return the delete result - * @throws ServiceException When delete failed. - * @since NFVO 0.5 - */ - @DELETE - @Path("/{datacenterId}") - public JSONObject deleteSites(@Context HttpServletRequest context, @PathParam("datacenterId") String id) - throws ServiceException { - LOGGER.warn("SitesRoa::deleteSites siteId:{}", id); - try { - int result = sites.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("SitesRoa::deleteSites error: " + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * updateSites ROA method
- * - * @param context - * @param id - * @return the update result - * @throws ServiceException When update failed. - * @since NFVO 0.5 - */ - @PUT - public JSONObject updateSites(@Context HttpServletRequest context) throws ServiceException { - JSONObject json = RequestUtil.getAllJsonRequestBody(context); - - LOGGER.warn("SitesRoa::start update Sites"); - try { - int result = sites.update(SitesEntity.toEntity(json)); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("SitesRoa::updateSites error:" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - /** - * grant resource method - *
- * - * @param context - * @return - * @throws ServiceException - * @since NFVO 0.5 - */ - @PUT - @Path("/grant") - public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { - JSONObject json = RequestUtil.getAllJsonRequestBody(context); - - LOGGER.warn("SitesRoa::grant resource"); - try { - int result = sites.update(json); - return RoaResponseUtil.update(result); - } catch(ServiceException se) { - LOGGER.error("SitesRoa::grant resource:" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @GET - @Path("/vims") - public String getVims(@Context HttpServletRequest context) throws ServiceException { - LOGGER.info("SitesRoa::get vims"); - JSONArray vims = VimUtil.getVims(); - JSONObject result = new JSONObject(); - result.put("data", vims); - return result.toString(); - } - - @GET - @Path("/vims/{vimId}") - public String getVim(@Context HttpServletRequest context, @PathParam("vimId") String vimId) - throws ServiceException { - LOGGER.info("SitesRoa::get vim by id: {}", vimId); - return VimUtil.getVimById(vimId).toString(); - } - - public void setSites(Sites sites) { - this.sites = sites; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java deleted file mode 100644 index 0e9bf48..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.io.IOException; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.apache.commons.io.IOUtils; - -/** - * Swagger API Doc.
- * - * @author - * @version NFVO 0.5 Oct 24, 2016 - */ -@Path("/v1") -@Produces({MediaType.APPLICATION_JSON}) -public class SwaggerRoa { - /** - * API doc. - * @param filename - * @return - * @throws IOException - */ - @GET - @Path("/swagger.json") - public String apidoc() throws IOException{ - ClassLoader classLoader = getClass().getClassLoader(); - return IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java deleted file mode 100644 index 524a474..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 27, 2016 - */ -@Path(UrlConstant.VL_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class VirtualLinkRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); - - private VirtualLinkService virtualLink; - - @GET - public JSONObject getVls(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List vls = virtualLink.getList(map); - LOGGER.info("VirtualLinkRoa::getVls:{}", vls.toString()); - JSONObject result = new JSONObject(); - result.put("vls", vls); - return result; - } - - @GET - @Path("/{vlId}") - public JSONObject getVl(@Context HttpServletRequest context, @PathParam("vlId") String id) throws ServiceException { - LOGGER.info("VirtualLinkRoa::getVl id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List vls = virtualLink.getList(map); - LOGGER.info("VirtualLinkRoa::getVl:{}", vls.toString()); - JSONObject result = new JSONObject(); - result.put("vls", vls); - return result; - } - - @POST - public JSONObject addVl(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=addVl; msg=add error, because vl is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.add.null")); - } - - LOGGER.info("VirtualLinkRoa::addVl:{}", object.toString()); - try { - return virtualLink.addVl(VirtualLinkEntity.toEntity(object)); - } catch(ServiceException se) { - LOGGER.error("VirtualLinkRoa::addVl error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @DELETE - @Path("/{id}") - public JSONObject deleteVl(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - if(id == null) { - LOGGER.error("function=deleteVl; msg=delete error, because vlId is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.delete.vlId.null")); - } - LOGGER.info("VirtualLinkRoa::deleteVl id:{}", id); - try { - int result = virtualLink.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("VirtualLinkRoa::deleteVl error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setVirtualLink(VirtualLinkService virtualLink) { - this.virtualLink = virtualLink; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java deleted file mode 100644 index cb9d2b6..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.entity.VmEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VmService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -@Path(UrlConstant.VM_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class VmRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(VmRoa.class); - - private VmService vmService; - - @GET - public JSONObject getVms(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List vms = vmService.getList(map); - LOGGER.info("VmRoa::getVms:{}", vms.toString()); - JSONObject result = new JSONObject(); - result.put("vms", vms); - return result; - } - - @GET - @Path("/{vmId}") - public JSONObject getVm(@Context HttpServletRequest context, @PathParam("vmId") String id) throws ServiceException { - LOGGER.info("VmRoa::getVm id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List vms = vmService.getList(map); - LOGGER.info("VmRoa::getVm:{}", vms.toString()); - JSONObject result = new JSONObject(); - result.put("vms", vms); - return result; - } - - @POST - public JSONObject addVm(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=addVm; msg=add error, because vm is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.add.null")); - } - - LOGGER.info("VmRoa::addVm:{}", object.toString()); - try { - return vmService.addVm(VmEntity.toEntity(object)); - } catch(ServiceException se) { - LOGGER.error("VmRoa::addVm error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @DELETE - @Path("/{id}") - public JSONObject deleteVm(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - if(id == null) { - LOGGER.error("function=deleteVm; msg=delete error, because id is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.delete.id.null")); - } - LOGGER.info("VmRoa::deleteVm id:{}", id); - try { - int result = vmService.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("VmRoa::deleteVm error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setVmService(VmService vmService) { - this.vmService = vmService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java deleted file mode 100644 index b6fd5a5..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -@Path(UrlConstant.VNFINFO_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class VnfInfoRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoRoa.class); - - private VnfInfoService vnfInfoService; - - @GET - public JSONObject getVnfInfos(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List vnfInfos = vnfInfoService.getList(map); - LOGGER.info("VnfInfoRoa::getVnfInfos:{}", vnfInfos.toString()); - JSONObject result = new JSONObject(); - result.put("vnfInfos", vnfInfos); - return result; - } - - @GET - @Path("/{id}") - public JSONObject getVnfInfo(@Context HttpServletRequest context, @PathParam("id") String id) - throws ServiceException { - LOGGER.info("VnfInfoRoa::getVnfInfo id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List vnfInfos = vnfInfoService.getList(map); - LOGGER.info("VnfInfoRoa::getVnfInfo:{}", vnfInfos.toString()); - JSONObject result = new JSONObject(); - result.put("vnfInfos", vnfInfos); - return result; - } - - @POST - public JSONObject addVnfInfo(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=addVnfInfo; msg=add error, because vnfInfo is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.add.null")); - } - - LOGGER.info("VnfInfoRoa::addVnfInfo:{}", object.toString()); - try { - return vnfInfoService.addVnfInfo(object); - } catch(ServiceException se) { - LOGGER.error("VnfInfoRoa::addVnfInfo error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @DELETE - @Path("/{id}") - public JSONObject deleteVnfInfo(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - if(id == null) { - LOGGER.error("function=deleteVnfInfo; msg=delete error, because id is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.delete.id.null")); - } - LOGGER.info("VnfInfoRoa::deleteVnfInfo id:{}", id); - try { - int result = vnfInfoService.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("VnfInfoRoa::deleteVnfInfo error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setVnfInfoService(VnfInfoService vnfInfoService) { - this.vnfInfoService = vnfInfoService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java deleted file mode 100644 index 4d5fc47..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.entity.VnfEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VnfService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 28, 2016 - */ -@Path(UrlConstant.VNF_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class VnfRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); - - private VnfService vnfService; - - @GET - public JSONObject getVnfs(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List vnfs = vnfService.getList(map); - LOGGER.info("VnfRoa::getVnfs:{}", vnfs.toString()); - JSONObject result = new JSONObject(); - result.put("vnfs", vnfs); - return result; - } - - @GET - @Path("/{vnfId}") - public JSONObject getVnf(@Context HttpServletRequest context, @PathParam("vnfId") String id) - throws ServiceException { - LOGGER.info("VnfRoa::getVnf id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List vnfs = vnfService.getList(map); - LOGGER.info("VnfRoa::getVnf:{}", vnfs.toString()); - JSONObject result = new JSONObject(); - result.put("vnfs", vnfs); - return result; - } - - @POST - public JSONObject addVnf(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=addVnf; msg=add error, because vnf is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.add.null")); - } - - LOGGER.info("VnfRoa::addVnf:{}", object.toString()); - try { - return vnfService.addVnf(VnfEntity.toEntity(object)); - } catch(ServiceException se) { - LOGGER.error("VnfRoa::addVnf error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @DELETE - @Path("/{id}") - public JSONObject deleteVnf(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - if(id == null) { - LOGGER.error("function=deleteVnf; msg=delete error, because id is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.delete.id.null")); - } - LOGGER.info("VnfRoa::deleteVnf id:{}", id); - try { - int result = vnfService.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("VnfRoa::deleteVnf error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setVnfService(VnfService vnfService) { - this.vnfService = vnfService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java deleted file mode 100644 index 1e7d9f4..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.nfvo.resmanagement.common.ResourceUtil; -import org.openo.nfvo.resmanagement.common.constant.HttpConstant; -import org.openo.nfvo.resmanagement.common.constant.ParamConstant; -import org.openo.nfvo.resmanagement.common.constant.UrlConstant; -import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; -import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; -import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; -import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; -import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.json.JSONObject; - -/** - *
- *

- *

- * - * @author - * @version NFVO 0.5 Oct 29, 2016 - */ -@Path(UrlConstant.VNFSTATUS_URL) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class VnfStatusRoa { - - private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusRoa.class); - - private VnfStatusService vnfStatusService; - - @GET - public JSONObject getVnfStatuss(@Context HttpServletRequest context) throws ServiceException { - Map map = new HashMap<>(10); - List vnfStatus = vnfStatusService.getList(map); - LOGGER.info("VnfStatusRoa::getVnfStatuss:{}", vnfStatus.toString()); - JSONObject result = new JSONObject(); - result.put("vnfStatus", vnfStatus); - return result; - } - - @GET - @Path("/{id}") - public JSONObject getVnfStatus(@Context HttpServletRequest context, @PathParam("id") String id) - throws ServiceException { - LOGGER.info("VnfStatusRoa::getVnfStatus id:{}", id); - Map map = new HashMap<>(10); - map.put(ParamConstant.PARAM_ID, id); - List vnfStatus = vnfStatusService.getList(map); - LOGGER.info("VnfStatusRoa::getVnfStatus:{}", vnfStatus.toString()); - JSONObject result = new JSONObject(); - result.put("vnfStatus", vnfStatus); - return result; - } - - @POST - public JSONObject addVnfStatus(@Context HttpServletRequest context) throws ServiceException { - JSONObject object = RequestUtil.getJsonRequestBody(context); - if(null == object) { - LOGGER.error("function=addVnfInfo; msg=add error, because vnfStatus is null."); - throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.add.null")); - } - - LOGGER.info("VnfStatusRoa::addVnfStatus:{}", object.toString()); - try { - return vnfStatusService.addVnfStatus(object); - } catch(ServiceException se) { - LOGGER.error("VnfStatusRoa::addVnfStatus error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - @DELETE - @Path("/{id}") - public JSONObject deleteVnfStatus(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) - throws ServiceException { - if(id == null) { - LOGGER.error("function=deleteVnfStatus; msg=delete error, because id is null."); - throw new ServiceException( - ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.delete.id.null")); - } - LOGGER.info("VnfStatusRoa::deleteVnfStatus id:{}", id); - try { - int result = vnfStatusService.delete(id); - return RoaResponseUtil.delete(result); - } catch(ServiceException se) { - LOGGER.error("VnfStatusRoa::deleteVnfStatys error:{}" + se); - return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); - } - } - - public void setVnfStatusService(VnfStatusService vnfStatusService) { - this.vnfStatusService = vnfStatusService; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java deleted file mode 100644 index 8f57345..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; - -import org.apache.http.HttpStatus; - -/** - * Exception response model.
- * - * @author - * @version NFVO 0.5 Sep 27, 2016 - */ -public class ExceptionMessage { - - private String errorCode = "unknown.error"; - - private int httpCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; - - private String message; - - @Override - public String toString() { - return "Error {errorCode=" + this.errorCode + ", httpCode=" + this.httpCode + ", message=" - + this.message + "}"; - } - - public String getErrorCode() { - return this.errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - public int getHttpCode() { - return this.httpCode; - } - - public void setHttpCode(int httpCode) { - this.httpCode = httpCode; - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java deleted file mode 100644 index d557e0c..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -/** - * Generic exception response provider.
- * - * - * @author - * @version NFVO 0.5 Sep 27, 2016 - */ -@Provider -public class GenericExceptionMapper implements ExceptionMapper{ - - @Override - public Response toResponse(Exception exception) { - ExceptionMessage message = new ExceptionMessage(); - message.setMessage(exception.getMessage()); - return Response.status(message.getHttpCode()).type( - MediaType.APPLICATION_JSON).entity(message).build(); - } -} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java deleted file mode 100644 index a45852a..0000000 --- a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016 Huawei Technologies Co., Ltd. - * - * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.openo.baseservice.remoteservice.exception.ServiceException; - -/** - * ServiceException response provider.
- * - * @author - * @version NFVO 0.5 Sep 27, 2016 - */ -@Provider -public class ServiceExceptionMapper implements ExceptionMapper{ - - @Override - public Response toResponse(ServiceException exception) { - ExceptionMessage message = new ExceptionMessage(); - message.setErrorCode(exception.getId()); - message.setHttpCode(exception.getHttpCode()); - message.setMessage(exception.getMessage()); - return Response.status(message.getHttpCode()). - type(MediaType.APPLICATION_JSON).entity(message).build(); - } - -} diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml index 850eef4..7c4c1da 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.HostEntity"> @@ -58,7 +58,7 @@ limitations under the License. where VIM_ID = #{vimId,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.HostEntity"> insert into host (ID, NAME, CPU, MEMORY, DISK, VIM_ID, VIM_NAME) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{cpu,jdbcType=VARCHAR}, @@ -66,7 +66,7 @@ limitations under the License. , #{vimName,jdbcType=VARCHAR}) + parameterType="org.onap.vfc.nfvo.res.service.entity.HostEntity"> insert into host @@ -116,7 +116,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.HostEntity"> update host @@ -148,7 +148,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.HostEntity"> update host set NAME = #{name,jdbcType=VARCHAR}, CPU = #{cpu,jdbcType=VARCHAR}, @@ -159,7 +159,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.HostEntity"> update host diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml index b0ecba2..22e8885 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.LocationEntity"> @@ -68,7 +68,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.LocationEntity"> insert into location (ID, COUNTRY, LOCATION, LATITUDE, LONGITUDE, DESCRIPTION) @@ -77,7 +77,7 @@ limitations under the License. #{latitude,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}) + parameterType="org.onap.vfc.nfvo.res.service.entity.LocationEntity"> insert into location @@ -122,7 +122,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.LocationEntity"> update location @@ -145,7 +145,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.LocationEntity"> update location set COUNTRY = #{country,jdbcType=VARCHAR}, diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml index 65e4d67..dbae050 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> @@ -64,7 +64,7 @@ limitations under the License. where VIM_ID = #{vimId,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> insert into network (ID, NAME, TENANT_ID, VIM_ID, VIM_NAME, STATUS, PHYSICAL_NETWORK, NETWORK_TYPE, SEGMENTATION_ID @@ -77,7 +77,7 @@ limitations under the License. ) + parameterType="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> insert into network @@ -139,7 +139,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> update network @@ -170,7 +170,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> update network set NAME = #{name,jdbcType=VARCHAR}, TENANT_ID = #{tenantId,jdbcType=VARCHAR}, @@ -183,7 +183,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.NetworkEntity"> update network diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml index 765dcfe..5cdb358 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.PortEntity"> @@ -55,7 +55,7 @@ limitations under the License. where VIM_ID = #{vimId,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.PortEntity"> insert into port (ID, NAME, NWTWORK_ID, STATUS, TENANT_ID, VIM_ID, VIM_NAME) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, @@ -64,7 +64,7 @@ limitations under the License. , #{vimName,jdbcType=VARCHAR}) + parameterType="org.onap.vfc.nfvo.res.service.entity.PortEntity"> insert into port @@ -114,7 +114,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.PortEntity"> update port @@ -139,7 +139,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.PortEntity"> update port set NAME = #{name,jdbcType=VARCHAR}, NWTWORK_ID = #{networkId,jdbcType=VARCHAR}, @@ -150,7 +150,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.PortEntity"> update port diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml index 14f7b52..17fad53 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> @@ -70,7 +70,7 @@ limitations under the License. #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> insert into site (ID, NAME, LOCATION, COUNTRY, VIM_ID, VIM_NAME, STATUS,TOTAL_CPU, TOTAL_MEMORY, TOTAL_DISK, @@ -89,7 +89,7 @@ limitations under the License. #{usedDisk,jdbcType=VARCHAR}) + parameterType="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> insert into site @@ -175,7 +175,7 @@ limitations under the License. + parameterType="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> update site @@ -218,7 +218,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> update site set NAME = #{name,jdbcType=VARCHAR}, LOCATION @@ -240,7 +240,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.SitesEntity"> update site diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml index e6f38ef..90d09ed 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml @@ -16,9 +16,9 @@ limitations under the License. --> - + + type="org.onap.vfc.nfvo.res.service.entity.VimEntity"> @@ -45,7 +45,7 @@ limitations under the License. where ID = #{id,jdbcType=VARCHAR} + parameterType="org.onap.vfc.nfvo.res.service.entity.VimEntity"> insert into vim (ID) values (#{id,jdbcType=VARCHAR}) diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml index b4d2394..c73dbed 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -61,7 +61,7 @@ delete from vl where id = #{id,jdbcType=VARCHAR} - + insert into vl (id, name, backend_id, is_public, dc_name, vim_id, vim_name, physicial_net, ns_id, @@ -77,7 +77,7 @@ #{routerExternal,jdbcType=VARCHAR}, #{resourceProviderType,jdbcType=VARCHAR}, #{resourceProviderId,jdbcType=VARCHAR} ) - + insert into vl @@ -192,7 +192,7 @@ - + update vl @@ -249,7 +249,7 @@ where id = #{id,jdbcType=VARCHAR} - + update vl set name = #{name,jdbcType=VARCHAR}, backend_id = #{backendId,jdbcType=VARCHAR}, diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml index dc2376c..6c5fd68 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -52,13 +52,13 @@ delete from vm where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + insert into vm (vm_id, vm_name, vm_status, vnf_instance_id) values (#{vmId,jdbcType=VARCHAR}, #{vmName,jdbcType=VARCHAR}, #{vmStatus,jdbcType=VARCHAR}, #{vnfInstanceId,jdbcType=VARCHAR}) - + insert into vm @@ -89,7 +89,7 @@ - + update vm @@ -104,7 +104,7 @@ where vm_id = #{vmId,jdbcType=VARCHAR} - + update vm set vm_name = #{vmName,jdbcType=VARCHAR}, vm_status = #{vmStatus,jdbcType=VARCHAR}, diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml index 135ccc1..e4220fb 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -44,13 +44,13 @@ delete from vnfinfo where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + insert into vnfinfo (vnf_instance_id, ns_id, vnfm_id ) values (#{vnfInstanceId,jdbcType=VARCHAR}, #{nsId,jdbcType=VARCHAR}, #{vnfmId,jdbcType=VARCHAR} ) - + insert into vnfinfo @@ -75,7 +75,7 @@ - + update vnfinfo @@ -87,7 +87,7 @@ where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + update vnfinfo set ns_id = #{nsId,jdbcType=VARCHAR}, vnfm_id = #{vnfmId,jdbcType=VARCHAR} diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml index cd187c3..bf36b81 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -65,7 +65,7 @@ delete from vnf where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + insert into vnf (id, vnf_instance_id, vnf_instance_name, ns_id, ns_name, vnfm_id, vnfm_name, vnf_package_name, vnf_descriptor_name, @@ -83,7 +83,7 @@ #{maxRam,jdbcType=INTEGER}, #{maxShd,jdbcType=INTEGER}, #{maxNet,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}) - + insert into vnf @@ -222,7 +222,7 @@ - + update vnf @@ -291,7 +291,7 @@ where id = #{id,jdbcType=VARCHAR} - + update vnf set vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR}, vnf_instance_name = #{vnfInstanceName,jdbcType=VARCHAR}, diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml index 08a5101..a23a39e 100644 --- a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -55,7 +55,7 @@ delete from vnfstatus where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + insert into vnfstatus (vnf_instance_id, job_id, ns_id, vnfm_id, response_descriptor, status, progress, status_description, error_code, @@ -67,7 +67,7 @@ #{responseId,jdbcType=VARCHAR}, #{responseHistoryList,jdbcType=VARCHAR}, #{addVm,jdbcType=VARCHAR}, #{delVm,jdbcType=VARCHAR}) - + insert into vnfstatus @@ -152,7 +152,7 @@ - + update vnfstatus @@ -194,7 +194,7 @@ where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} - + update vnfstatus set job_id = #{jobId,jdbcType=VARCHAR}, ns_id = #{nsId,jdbcType=VARCHAR}, diff --git a/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml b/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml index a24efd5..f08019e 100644 --- a/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml +++ b/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml @@ -66,217 +66,217 @@ + class="org.onap.vfc.nfvo.res.service.dao.impl.LocationDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.LocationBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.LocationImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.PortDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.PortBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.PortImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.HostDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.HostBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.HostImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.NetworkDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.NetworkBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.NetworkImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.SitesDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.SitesBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.SitesImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.VimDaoImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.VimBusinessImpl"> + class="org.onap.vfc.nfvo.res.service.base.openstack.impl.VimImpl"> + class="org.onap.vfc.nfvo.res.service.business.impl.LimitsBusinessImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.VirtualLinkDaoImpl"> + class="org.onap.vfc.nfvo.res.service.group.impl.VirtualLinkServiceImpl"> - + + class="org.onap.vfc.nfvo.res.service.dao.impl.VnfDaoImpl"> + class="org.onap.vfc.nfvo.res.service.group.impl.VnfServiceImpl"> - + - + - + - + + class="org.onap.vfc.nfvo.res.service.dao.impl.VnfInfoDaoImpl"> + class="org.onap.vfc.nfvo.res.service.group.impl.VnfInfoServiceImpl"> - + - + - + - + - + - + + class="org.onap.vfc.nfvo.res.service.group.impl.ResOperateServiceImpl"> @@ -288,22 +288,22 @@ + class="org.onap.vfc.nfvo.res.service.group.impl.IResourceUpdateServiceImpl"> + class="org.onap.vfc.nfvo.res.service.group.impl.IResourceAddServiceImpl"> + class="org.onap.vfc.nfvo.res.service.group.impl.IResourceDelServiceImpl"> - + - + @@ -324,8 +324,8 @@ - - + + diff --git a/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml b/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml index 38394ae..9133d04 100644 --- a/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml +++ b/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml @@ -37,6 +37,6 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> - - + + \ No newline at end of file -- cgit 1.2.3-korg