This is an automated email from the ASF dual-hosted git repository. elecharny pushed a commit to branch 1.2.X in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/1.2.X by this push: new 06626f79 Some more javadoc warning fixes 06626f79 is described below commit 06626f79a00e5158038de88ee792f4292d6c0e42 Author: emmanuel lecharny <elecha...@apache.org> AuthorDate: Mon Jan 13 04:47:18 2025 +0100 Some more javadoc warning fixes --- .../org/apache/ftpserver/impl/FtpIoSession.java | 177 +++++++++++++++++---- .../apache/ftpserver/impl/FtpReplyTranslator.java | 47 ++++-- .../org/apache/ftpserver/util/BaseProperties.java | 86 +++++++++- .../java/org/apache/ftpserver/ftplet/DataType.java | 2 + 4 files changed, 265 insertions(+), 47 deletions(-) diff --git a/core/src/main/java/org/apache/ftpserver/impl/FtpIoSession.java b/core/src/main/java/org/apache/ftpserver/impl/FtpIoSession.java index b7b33777..aaba9b07 100644 --- a/core/src/main/java/org/apache/ftpserver/impl/FtpIoSession.java +++ b/core/src/main/java/org/apache/ftpserver/impl/FtpIoSession.java @@ -570,6 +570,10 @@ public class FtpIoSession implements IoSession { } /* End wrapped IoSession methods */ + /** + * Reset the session state. It will remove the 'rename-from' and 'file-offset' + * attributes from the session + */ public void resetState() { removeAttribute(ATTRIBUTE_RENAME_FROM); removeAttribute(ATTRIBUTE_FILE_OFFSET); @@ -588,10 +592,20 @@ public class FtpIoSession implements IoSession { } } + /** + * Get the 'file-system' attribute + * + * @return The 'file-system' attribute value + */ public FileSystemView getFileSystemView() { return (FileSystemView) getAttribute(ATTRIBUTE_FILE_SYSTEM); } + /** + * Get the 'user' attribute + * + * @return The 'user' attribute value + */ public User getUser() { return (User) getAttribute(ATTRIBUTE_USER); } @@ -605,45 +619,95 @@ public class FtpIoSession implements IoSession { return containsAttribute(ATTRIBUTE_USER); } + /** + * Get the session listener + * + * @return The session listener + */ public Listener getListener() { return (Listener) getAttribute(ATTRIBUTE_LISTENER); } + /** + * Set the listener attribute + * + * @param listener The listener to set + */ public void setListener(Listener listener) { setAttribute(ATTRIBUTE_LISTENER, listener); } + /** + * Get a Ftp session + * + * @return a new Ftp session instance + */ public FtpSession getFtpletSession() { return new DefaultFtpSession(this); } + /** + * Get the session's language + *- + * @return The session language + */ public String getLanguage() { return (String) getAttribute(ATTRIBUTE_LANGUAGE); } + /** + * Set the session language + * + * @param language The language to set + */ public void setLanguage(String language) { setAttribute(ATTRIBUTE_LANGUAGE, language); } - public String getUserArgument() { - return (String) getAttribute(ATTRIBUTE_USER_ARGUMENT); - } - + /** + * Set the 'user' attribute + * + * @param user The user for this session + */ public void setUser(User user) { setAttribute(ATTRIBUTE_USER, user); } + /** + * Get the user argument + * + * @return The user argument to set + */ + public String getUserArgument() { + return (String) getAttribute(ATTRIBUTE_USER_ARGUMENT); + } + + /** + * Set the user argument + * + * @param userArgument The user argument to set + */ public void setUserArgument(String userArgument) { setAttribute(ATTRIBUTE_USER_ARGUMENT, userArgument); } + /** + * Get the max idle time + * + * @return The configured max idle time + */ public int getMaxIdleTime() { return (Integer) getAttribute(ATTRIBUTE_MAX_IDLE_TIME, 0); } + /** + * Set the max idle time for a session + * + * @param maxIdleTime Maximum time a session can idle + */ public void setMaxIdleTime(int maxIdleTime) { setAttribute(ATTRIBUTE_MAX_IDLE_TIME, maxIdleTime); @@ -659,21 +723,40 @@ public class FtpIoSession implements IoSession { } } + /** + * Increment the number of failed logins + */ public synchronized void increaseFailedLogins() { int failedLogins = (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0); failedLogins++; setAttribute(ATTRIBUTE_FAILED_LOGINS, failedLogins); } + /** + * Get the 'failed-logins' attribute. It contains the number + * of failed logins during this session + * + * @return The number of failed logins + */ public int getFailedLogins() { return (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0); } + /** + * Set the login attributes: 'login-time' and 'file-system' + * + * @param fsview The file system view + */ public void setLogin(FileSystemView fsview) { setAttribute(ATTRIBUTE_LOGIN_TIME, new Date()); setAttribute(ATTRIBUTE_FILE_SYSTEM, fsview); } + /** + * Reinitialize the session. It will disconnect the user, + * and clear the 'user', 'user-argument', 'login-time', 'file-system', + * 'rename-from' and 'file-offset' session attributes + */ public void reinitialize() { logoutUser(); removeAttribute(ATTRIBUTE_USER); @@ -684,6 +767,9 @@ public class FtpIoSession implements IoSession { removeAttribute(ATTRIBUTE_FILE_OFFSET); } + /** + * Logout the connected user + */ public void logoutUser() { ServerFtpStatistics stats = ((ServerFtpStatistics) context.getFtpStatistics()); if (stats != null) { @@ -695,63 +781,96 @@ public class FtpIoSession implements IoSession { } } + /** + * Get the 'file-offset' attribute value. Default to 0 if none is set + * + * @return The 'file-offset' attribute value + */ + public long getFileOffset() { + return (Long) getAttribute(ATTRIBUTE_FILE_OFFSET, 0L); + } + + /** + * Set the 'file-offset' attribute value. + * + * @param fileOffset The 'file-offset' attribute value + */ public void setFileOffset(long fileOffset) { setAttribute(ATTRIBUTE_FILE_OFFSET, fileOffset); } + /** + * Get the 'rename-from' attribute + * + * @return The 'rename-from' attribute value + */ + public FtpFile getRenameFrom() { + return (FtpFile) getAttribute(ATTRIBUTE_RENAME_FROM); + } + + /** + * Set the 'rename-from' attribute + * + * @param renFr The 'rename-from' attribute value + */ public void setRenameFrom(FtpFile renFr) { setAttribute(ATTRIBUTE_RENAME_FROM, renFr); } - public FtpFile getRenameFrom() { - return (FtpFile) getAttribute(ATTRIBUTE_RENAME_FROM); - } - - public long getFileOffset() { - return (Long) getAttribute(ATTRIBUTE_FILE_OFFSET, 0L); + /** + * Get the structure attribute. We support only <code>FILE</code> + * + * @return The structure attribute + */ + public Structure getStructure() { + return (Structure) getAttribute(ATTRIBUTE_STRUCTURE, Structure.FILE); } + /** + * Set the transfert structure + * + * @param structure The structure (only FILE is currently supported) + */ public void setStructure(Structure structure) { setAttribute(ATTRIBUTE_STRUCTURE, structure); } + /** + * Get the data type (ascii or binary) + * + * @return The data type + */ + public DataType getDataType() { + return (DataType) getAttribute(ATTRIBUTE_DATA_TYPE, DataType.ASCII); + } + + /** + * Set the data type + * + * @param dataType The data type to use (ASCII or BINARY) + */ public void setDataType(DataType dataType) { setAttribute(ATTRIBUTE_DATA_TYPE, dataType); } /** - * {@inheritDoc} + * Get the 'session-id' attribute. If none is set, and RandomUUID is created. + * + * @return The 'session-id' attribute value */ public UUID getSessionId() { synchronized (wrappedSession) { if (!wrappedSession.containsAttribute(ATTRIBUTE_SESSION_ID)) { wrappedSession.setAttribute(ATTRIBUTE_SESSION_ID, UUID.randomUUID()); } + return (UUID) wrappedSession.getAttribute(ATTRIBUTE_SESSION_ID); } } - /** - * Get the structure attribute. We support only <code>FILE</code> - * - * @return The structure attribute - */ - public Structure getStructure() { - return (Structure) getAttribute(ATTRIBUTE_STRUCTURE, Structure.FILE); - } - - /** - * Get the data type (ascii or binary) - * - * @return The data type - */ - public DataType getDataType() { - return (DataType) getAttribute(ATTRIBUTE_DATA_TYPE, DataType.ASCII); - } - /** * Get the login time * diff --git a/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java b/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java index 6f920479..391356d1 100644 --- a/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java +++ b/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java @@ -38,79 +38,100 @@ import org.apache.ftpserver.util.DateUtils; */ public class FtpReplyTranslator { - + /** Client last access time */ public static final String CLIENT_ACCESS_TIME = "client.access.time"; + /** Client connection time */ public static final String CLIENT_CON_TIME = "client.con.time"; + /** Client directory */ public static final String CLIENT_DIR = "client.dir"; + /** Client home directory */ public static final String CLIENT_HOME = "client.home"; + /** Client IP */ public static final String CLIENT_IP = "client.ip"; + /** Client login name */ public static final String CLIENT_LOGIN_NAME = "client.login.name"; + /** Client login time */ public static final String CLIENT_LOGIN_TIME = "client.login.time"; + /** Output code */ public static final String OUTPUT_CODE = "output.code"; + /** Output message */ public static final String OUTPUT_MSG = "output.msg"; + /** Request argyments */ public static final String REQUEST_ARG = "request.arg"; + /** Request command */ public static final String REQUEST_CMD = "request.cmd"; + /** Request line */ public static final String REQUEST_LINE = "request.line"; // /////////////////////// All Server Vatiables ///////////////////////// + /** Server IP address */ public static final String SERVER_IP = "server.ip"; + /** Server port */ public static final String SERVER_PORT = "server.port"; + /** Current connection number */ public static final String STAT_CON_CURR = "stat.con.curr"; + /** Total connections number */ public static final String STAT_CON_TOTAL = "stat.con.total"; + /** Total directories created */ public static final String STAT_DIR_CREATE_COUNT = "stat.dir.create.count"; + /** Total directories removed */ public static final String STAT_DIR_DELETE_COUNT = "stat.dir.delete.count"; + /** Total files deleted */ public static final String STAT_FILE_DELETE_COUNT = "stat.file.delete.count"; + /** Total bytes donwloaded */ public static final String STAT_FILE_DOWNLOAD_BYTES = "stat.file.download.bytes"; + /** Total files downloaded */ public static final String STAT_FILE_DOWNLOAD_COUNT = "stat.file.download.count"; + /** Total bytes uploaded */ public static final String STAT_FILE_UPLOAD_BYTES = "stat.file.upload.bytes"; + /** Total files uploaded */ public static final String STAT_FILE_UPLOAD_COUNT = "stat.file.upload.count"; + /** Current anonymous login number */ public static final String STAT_LOGIN_ANON_CURR = "stat.login.anon.curr"; + /** Total number of aonymous logins */ public static final String STAT_LOGIN_ANON_TOTAL = "stat.login.anon.total"; + /** Current login number */ public static final String STAT_LOGIN_CURR = "stat.login.curr"; + /** Total number of logins */ public static final String STAT_LOGIN_TOTAL = "stat.login.total"; + /** Server starting time */ public static final String STAT_START_TIME = "stat.start.time"; /** * Returns the translated message. * - * @param session - * the FTP session for which a reply is to be sent - * @param request - * the FTP request object - * @param context - * the FTP server context - * @param code - * the reply code - * @param subId - * the ID of the sub message - * @param basicMsg - * the basic message + * @param session the FTP session for which a reply is to be sent + * @param request the FTP request object + * @param context the FTP server context + * @param code the reply code + * @param subId the ID of the sub message + * @param basicMsg the basic message * @return the translated message */ public static String translateMessage(FtpIoSession session, FtpRequest request, FtpServerContext context, diff --git a/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java b/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java index fbdae09d..de4e51bc 100644 --- a/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java +++ b/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java @@ -40,7 +40,7 @@ import org.apache.ftpserver.ftplet.FtpException; * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public class BaseProperties extends Properties { - + /** The serial version UID */ private static final long serialVersionUID = 5572645129592131953L; /** @@ -77,6 +77,13 @@ public class BaseProperties extends Properties { return prop.toLowerCase().equals("true"); } + /** + * Get boolean value. + * + * @param str The property to read + * @param bol The default boolean value + * @return The boolean value + */ public boolean getBoolean(final String str, final boolean bol) { try { return getBoolean(str); @@ -105,6 +112,13 @@ public class BaseProperties extends Properties { } } + /** + * Get integer value. + * + * @param str The property to read + * @param intVal The default integer value + * @return The integer value + */ public int getInteger(final String str, final int intVal) { try { return getInteger(str); @@ -133,6 +147,13 @@ public class BaseProperties extends Properties { } } + /** + * Get long value. + * + * @param str The property to read + * @param val The default long value + * @return The long value + */ public long getLong(final String str, final long val) { try { return getLong(str); @@ -161,6 +182,13 @@ public class BaseProperties extends Properties { } } + /** + * Get double value. + * + * @param str The property to read + * @param doubleVal The default double value + * @return The double value + */ public double getDouble(final String str, final double doubleVal) { try { return getDouble(str); @@ -189,6 +217,13 @@ public class BaseProperties extends Properties { } } + /** + * Get <code>InetAddress</code>. + * + * @param str The property to read + * @param addr The default <code>InetAddress</code> + * @return The <code>InetAddress</code> value + */ public InetAddress getInetAddress(final String str, final InetAddress addr) { try { return getInetAddress(str); @@ -213,6 +248,13 @@ public class BaseProperties extends Properties { return value; } + /** + * Get <code>String</code>. + * + * @param str The property to read + * @param s The default <code>String</code> + * @return The <code>String</code> value + */ public String getString(final String str, final String s) { try { return getString(str); @@ -236,6 +278,13 @@ public class BaseProperties extends Properties { return new File(value); } + /** + * Get <code>File</code> object. + * + * @param str The property to read + * @param fl The default <code>File</code> + * @return The <code>StriFileng</code> value + */ public File getFile(final String str, final File fl) { try { return getFile(str); @@ -264,6 +313,13 @@ public class BaseProperties extends Properties { } } + /** + * Get <code>Class</code> object + * + * @param str The property to read + * @param cls The default <code>Class</code> + * @return The <code>Class</code> value + */ public Class<?> getClass(final String str, final Class<?> cls) { try { return getClass(str); @@ -287,6 +343,13 @@ public class BaseProperties extends Properties { return TimeZone.getTimeZone(value); } + /** + * Get the time zone from a date + * + * @param str The date as a String + * @param tz The default time zone if the String does not contain one + * @return The parsed time zone of the default time zone if the parsed one does not contain a time zone + */ public TimeZone getTimeZone(final String str, final TimeZone tz) { try { return getTimeZone(str); @@ -314,8 +377,14 @@ public class BaseProperties extends Properties { } } - public SimpleDateFormat getDateFormat(final String str, - final SimpleDateFormat fmt) { + /** + * Get <code>DateFormat</code> object. + * + * @param str The property to read + * @param fmt The default <code>DateFormat</code> + * @return The <code>DateFormat</code> value + */ + public SimpleDateFormat getDateFormat(final String str, final SimpleDateFormat fmt) { try { return getDateFormat(str); } catch (FtpException ex) { @@ -331,8 +400,7 @@ public class BaseProperties extends Properties { * @throws FtpException If the property is null * @return The <code>Date</code> value */ - public Date getDate(final String str, final DateFormat fmt) - throws FtpException { + public Date getDate(final String str, final DateFormat fmt) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); @@ -345,6 +413,14 @@ public class BaseProperties extends Properties { } } + /** + * Get <code>Date</code> object. + * + * @param str The property to read + * @param fmt The date format to use + * @param dt The <code>Date</code> to return as a default value if the string does not contain a date + * @return The <code>Date</code> value + */ public Date getDate(final String str, final DateFormat fmt, final Date dt) { try { return getDate(str, fmt); diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java index 7b7e9950..b1492173 100644 --- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java +++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java @@ -47,9 +47,11 @@ public enum DataType { case 'A': case 'a': return ASCII; + case 'I': case 'i': return BINARY; + default: throw new IllegalArgumentException("Unknown data type: " + argument); }