2 * Copyright 2016 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.resmanagement.service.business.impl;
19 import java.util.List;
21 import org.apache.commons.lang3.StringUtils;
22 import org.onap.vfc.nfvo.resmanagement.common.ResourceUtil;
23 import org.onap.vfc.nfvo.resmanagement.common.util.StringUtil;
24 import org.onap.vfc.nfvo.resmanagement.service.business.inf.VimBusiness;
25 import org.onap.vfc.nfvo.resmanagement.service.dao.inf.VimDao;
26 import org.onap.vfc.nfvo.resmanagement.service.entity.VimEntity;
27 import org.openo.baseservice.remoteservice.exception.ServiceException;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * Vim info interface.<br/>
37 * @version NFVO 0.5 Aug 24, 2016
39 public class VimBusinessImpl implements VimBusiness {
41 private static final Logger LOGGER = LoggerFactory.getLogger(VimBusinessImpl.class);
43 private VimDao vimDao;
46 public VimEntity getVim(String id) {
47 if(StringUtils.isEmpty(id)) {
48 LOGGER.error("function=getVim; msg=get error, because id is empty.");
51 return vimDao.getVim(id);
55 public List<VimEntity> getVims() {
56 return vimDao.getVims();
60 public int deleteVim(String id) throws ServiceException {
61 if(StringUtils.isEmpty(id)) {
62 LOGGER.error("function=deleteVim; msg=deleteVim error, because id is empty.");
63 throw new ServiceException(
64 ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.del.id.check"));
66 return vimDao.deleteVim(id);
70 public int addVim(String id) throws ServiceException {
71 if(!StringUtil.isValidString(id)) {
72 LOGGER.error("function=addVim; msg=add error, because id is null.");
73 throw new ServiceException(
74 ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.null"));
77 LOGGER.error("function=addVim; msg=add error, because id is already exist.");
78 throw new ServiceException(
79 ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.check"));
82 VimEntity vimEntity = new VimEntity();
84 return vimDao.addVim(vimEntity);
87 private boolean checkId(String id) {
88 VimEntity vim = vimDao.getVim(id);
95 public void setVimDao(VimDao vimDao) {