1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.waarp.ftp.core.data;
19
20 import java.util.List;
21
22 import org.waarp.common.command.exception.CommandAbstractException;
23 import org.waarp.common.logging.WaarpLogger;
24 import org.waarp.common.logging.WaarpLoggerFactory;
25 import org.waarp.ftp.core.command.FtpCommandCode;
26 import org.waarp.ftp.core.exception.FtpNoFileException;
27 import org.waarp.ftp.core.file.FtpFile;
28
29
30
31
32
33
34
35 public class FtpTransfer {
36 private static final WaarpLogger logger = WaarpLoggerFactory.getLogger(FtpTransfer.class);
37
38
39
40
41 private final FtpCommandCode command;
42
43
44
45
46 private final List<String> info;
47
48
49
50
51 private String path = null;
52
53
54
55
56 private final FtpFile currentFile;
57
58
59
60
61 private boolean status = false;
62
63
64
65
66
67
68 public FtpTransfer(FtpCommandCode command, List<String> fileOrInfo,
69 String path) {
70 this.command = command;
71 info = fileOrInfo;
72 this.path = path;
73 currentFile = null;
74 }
75
76
77
78
79
80 public FtpTransfer(FtpCommandCode command, FtpFile file) {
81 this.command = command;
82 currentFile = file;
83 try {
84 path = file.getFile();
85 } catch (CommandAbstractException e) {
86 }
87 info = null;
88 }
89
90
91
92
93 public FtpCommandCode getCommand() {
94 return command;
95 }
96
97
98
99
100
101 public FtpFile getFtpFile() throws FtpNoFileException {
102 if (currentFile == null) {
103 throw new FtpNoFileException("No file associated with the transfer");
104 }
105 return currentFile;
106 }
107
108
109
110
111 public List<String> getInfo() {
112 return info;
113 }
114
115
116
117
118 public String getPath() {
119 return path;
120 }
121
122
123
124
125 public boolean getStatus() {
126 return status;
127 }
128
129
130
131
132 public void setStatus(boolean status) {
133 if (!status) {
134 logger.debug("Status false", new Exception("Trace only exception"));
135 }
136 this.status = status;
137 }
138
139
140
141
142 @Override
143 public String toString() {
144 return command.name() + " " + path;
145 }
146 }