garydgregory commented on a change in pull request #82:
URL: https://github.com/apache/commons-vfs/pull/82#discussion_r429481129
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java
##########
@@ -529,10 +536,59 @@ protected OutputStream doGetOutputStream(final boolean
bAppend) throws Exception
String getRelPath() {
return relPath;
}
-
- private long getTimestamp() {
- final Calendar timestamp = this.fileInfo != null ?
this.fileInfo.getTimestamp() : null;
- return timestamp == null ? DEFAULT_TIMESTAMP :
timestamp.getTime().getTime();
+
+ private long getTimestamp() throws Exception {
+ final long mdtm = this.mdtmTimestamp.get() == DEFAULT_TIMESTAMP ?
getMdtmTimestamp() : this.mdtmTimestamp.get();
+ final Calendar listTimestamp = this.fileInfo != null ?
this.fileInfo.getTimestamp() : null;
+ return mdtm != DEFAULT_TIMESTAMP ? mdtm : (listTimestamp != null ?
listTimestamp.getTimeInMillis() : DEFAULT_TIMESTAMP);
+ }
+
+ /**
+ * Get the more accurate MDTM lastmodified file timestamp if supported by
the remote FTP server.
Review comment:
"Get" -> "Gets".
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
##########
@@ -292,4 +292,43 @@ public OutputStream storeFileStream(final String relPath)
throws IOException {
return getFtpClient().storeFileStream(relPath);
}
}
+
+ /**
+ * Determine what extended features the remote FTP server supports.
+ * <p>
+ * If this command is supported, the server will reply with a multi-line
response where each line of
+ * the response contains an extended feature command supported by the
server.
+ *
+ * @throws IOException If the underlying FTP client encountered an error
+ */
Review comment:
Add `@since 2.7.0` to new public and protected methods.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
##########
@@ -292,4 +292,43 @@ public OutputStream storeFileStream(final String relPath)
throws IOException {
return getFtpClient().storeFileStream(relPath);
}
}
+
+ /**
+ * Determine what extended features the remote FTP server supports.
+ * <p>
+ * If this command is supported, the server will reply with a multi-line
response where each line of
+ * the response contains an extended feature command supported by the
server.
+ *
+ * @throws IOException If the underlying FTP client encountered an error
+ */
+ @Override
+ public boolean features() throws IOException {
+ try {
+ return getFtpClient().features();
+ } catch (final IOException ex) {
+ disconnect();
+ return getFtpClient().features();
+ }
+ }
+
+ /**
+ * The MDTM command is used to preserve a file's original date and time
information after file transfer. It is typically
+ * more accurate than the {@code "LIST"} command response. Time values are
always represented in UTC (GMT), and in the Gregorian calendar
+ * regardless of what calendar may have been in use at the date and time
the file was last modified.
+ * <p>
+ * NOTE: not all remote FTP servers support {@code MDTM}.
+ *
Review comment:
Close HTML tag.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
##########
@@ -292,4 +292,43 @@ public OutputStream storeFileStream(final String relPath)
throws IOException {
return getFtpClient().storeFileStream(relPath);
}
}
+
+ /**
+ * Determine what extended features the remote FTP server supports.
+ * <p>
+ * If this command is supported, the server will reply with a multi-line
response where each line of
+ * the response contains an extended feature command supported by the
server.
+ *
+ * @throws IOException If the underlying FTP client encountered an error
+ */
+ @Override
+ public boolean features() throws IOException {
+ try {
+ return getFtpClient().features();
+ } catch (final IOException ex) {
+ disconnect();
+ return getFtpClient().features();
+ }
+ }
+
+ /**
+ * The MDTM command is used to preserve a file's original date and time
information after file transfer. It is typically
+ * more accurate than the {@code "LIST"} command response. Time values are
always represented in UTC (GMT), and in the Gregorian calendar
+ * regardless of what calendar may have been in use at the date and time
the file was last modified.
+ * <p>
+ * NOTE: not all remote FTP servers support {@code MDTM}.
+ *
+ * @param relPath The relative path of the file object to execute {@code
MDTM} command against
+ * @return new {@code FTPFile} object containing the {@code MDTM}
timestamp.
+ * @throws IOException If the underlying FTP client encountered an error
+ */
+ @Override
Review comment:
Add `@since 2.7.0` to new public and protected methods.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
##########
@@ -69,5 +69,14 @@ default void setBufferSize(final int bufferSize) throws
FileSystemException {
}
OutputStream storeFileStream(String relPath) throws IOException;
-
+
+ default boolean features() throws IOException {
Review comment:
Add Javadoc and `@since 2.7.0` to new public and protected methods.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
##########
@@ -292,4 +292,43 @@ public OutputStream storeFileStream(final String relPath)
throws IOException {
return getFtpClient().storeFileStream(relPath);
}
}
+
+ /**
+ * Determine what extended features the remote FTP server supports.
+ * <p>
+ * If this command is supported, the server will reply with a multi-line
response where each line of
+ * the response contains an extended feature command supported by the
server.
+ *
Review comment:
Please close all HTML tags, in this case with `</p>`
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
##########
@@ -69,5 +69,14 @@ default void setBufferSize(final int bufferSize) throws
FileSystemException {
}
OutputStream storeFileStream(String relPath) throws IOException;
-
+
+ default boolean features() throws IOException {
+ // Backward compatibility: return false ("FEAT" not supported)
+ return false;
+ }
+
+ default FTPFile mdtmFile(final String relPath) throws IOException {
Review comment:
Add Javadoc and `@since 2.7.0` to new public and protected methods.
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
##########
@@ -69,5 +69,14 @@ default void setBufferSize(final int bufferSize) throws
FileSystemException {
}
OutputStream storeFileStream(String relPath) throws IOException;
-
+
+ default boolean features() throws IOException {
Review comment:
I don't get this method name.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]