2 * Copyright 2017 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.
16 package org.onap.vnfsdk.marketplace.onboarding.onboardmanager;
18 import org.onap.vnfsdk.marketplace.common.FileUtil;
19 import org.onap.vnfsdk.marketplace.db.resource.PackageManager;
20 import org.onap.vnfsdk.marketplace.entity.EnumResult;
21 import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest;
22 import org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest.FunctionTestHook;
23 import org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle.LifecycleTestHook;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public final class OnBoardingHandler
29 private static final Logger logger = LoggerFactory.getLogger(OnBoardingHandler.class);
31 public void handleOnBoardingReq(OnBoradingRequest onBoradingReq)
33 //Handle Package Life cycle/Validation
34 //------------------------------------
35 LifecycleTestHook oLifecycleTestHook = new LifecycleTestHook();
36 int iLifeCycleResponse = oLifecycleTestHook.exec(onBoradingReq);
37 if(EnumResult.SUCCESS.getIndex() != iLifeCycleResponse)
39 logger.error("Onboarding falied for Package Id during Lifecycle Test:" + onBoradingReq.getCsarId());
42 //Handle Package FunctionTest
43 //-------------------------
44 FunctionTestHook oFunctionTestHook = new FunctionTestHook();
45 int iFuncTestResponse = oFunctionTestHook.exec(onBoradingReq);
46 if(EnumResult.SUCCESS.getIndex() != iFuncTestResponse)
48 logger.error("Onboarding falied for Package Id during Function Test:" + onBoradingReq.getCsarId());
52 FileUtil.deleteDirectory(onBoradingReq.getPackagePath());
55 PackageManager.getInstance().updateDwonloadCount(onBoradingReq.getCsarId());
59 logger.error("Download count udate failed for Package:" + onBoradingReq.getPackagePath() ,e);