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.filemanage.http;
19 import java.io.IOException;
21 import org.onap.vnfsdk.marketplace.filemanage.FileManager;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 public class HttpFileManagerImpl implements FileManager {
27 private static final Logger LOGGER = LoggerFactory.getLogger(HttpFileManagerImpl.class);
30 public boolean upload(String srcPath, String dstPath) {
32 LOGGER.info("start upload file.srcPath:{} dstPath{}" , srcPath , dstPath);
33 File srcFile = new File(srcPath);
34 if (!srcFile.exists()) {
35 LOGGER.error("src file not exist!");
39 String targetDir = ToolUtil.getHttpServerAbsolutePath() + dstPath;
41 ToolUtil.copyDirectory(srcPath, targetDir, true);
42 } catch (IOException e1) {
44 LOGGER.error("ErrorMsg: failed to copy file:", e1);
46 LOGGER.info("upload file success!");
51 public boolean download(String srcPath, String dstPath) {
52 // TODO Auto-generated method stub
57 public boolean delete(String srcPath) {
58 LOGGER.info("start delete file from http server.srcPath:{}" , srcPath);
59 boolean flag = ToolUtil.deleteDir(new File(ToolUtil.getHttpServerAbsolutePath() + srcPath));
60 LOGGER.info("delete file from http server end.flag:{}" , flag);