2 * Copyright 2017 BOCO Corporation. CMCC 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.nfvo.emsdriver.commons.ftp;
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.util.Date;
22 import org.apache.commons.net.ftp.FTPClient;
23 import org.apache.commons.net.ftp.FTPFile;
25 public class AFtpRemoteFile implements RemoteFile{
26 protected FTPClient ftpClient = null;
27 protected FTPFile ftpFile = null;
28 protected String currDir = null;
30 public AFtpRemoteFile(FTPFile rfile, FTPClient ftpClient, String currDir)
32 this.ftpClient = ftpClient;
34 this.currDir = currDir;
37 public long getSize() {
38 return ftpFile.getSize();
41 public String getFileName() {
42 return ftpFile.getName();
45 public String getAbsFileName() {
46 return currDir.concat(getFileName());
49 public boolean isDirectory() {
50 return ftpFile.isDirectory();
52 public boolean isFile() {
53 return ftpFile.isFile();
56 public String getOwner() {
57 return ftpFile.getUser();
60 public Date getModifyDate() {
61 return ftpFile.getTimestamp().getTime();
63 public boolean renameTo(String newName) throws IOException {
64 return ftpClient.rename(
65 currDir.concat(getFileName()), newName);
67 public boolean remove() throws IOException {
68 return ftpClient.deleteFile(
69 currDir.concat(getFileName()));
72 public InputStream getInputStream() throws IOException {
73 return ftpClient.retrieveFileStream(this.getAbsFileName());
76 public void release() {