1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.waarp.ftp.core.data;
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 import java.util.List;
30
31
32
33
34 public class FtpTransfer {
35 private static final WaarpLogger logger =
36 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;
52
53
54
55
56 private final FtpFile currentFile;
57
58
59
60
61 private boolean status;
62
63
64
65
66
67
68 public FtpTransfer(final FtpCommandCode command,
69 final List<String> fileOrInfo, final 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(final FtpCommandCode command, final FtpFile file) {
81 this.command = command;
82 currentFile = file;
83 try {
84 path = file.getFile();
85 } catch (final CommandAbstractException ignored) {
86
87 }
88 info = null;
89 }
90
91
92
93
94 public final FtpCommandCode getCommand() {
95 return command;
96 }
97
98
99
100
101
102
103 public final FtpFile getFtpFile() throws FtpNoFileException {
104 if (currentFile == null) {
105 throw new FtpNoFileException("No file associated with the transfer");
106 }
107 return currentFile;
108 }
109
110
111
112
113 public final List<String> getInfo() {
114 return info;
115 }
116
117
118
119
120 public final String getPath() {
121 return path;
122 }
123
124
125
126
127 public final boolean getStatus() {
128 return status;
129 }
130
131
132
133
134 public final void setStatus(final boolean status) {
135 if (!status && logger.isDebugEnabled()) {
136 logger.debug("Status false", new Exception("Trace only"));
137 }
138 this.status = status;
139 }
140
141
142
143
144 @Override
145 public String toString() {
146 return command.name() + ' ' + path;
147 }
148 }