public abstract class FtpCommand extends Object
Constructor and Description |
---|
FtpCommand()
Default Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkLoggedIn(FtpServerChannel channel)
Check with current session is valid.
|
protected void |
denyGuestAccessForWriteableCommands(String cmdKey)
Guest user has read-only privileges.
|
String |
encodeArgument(String arg,
String charset)
Encodes the string that came in through the InputStreamReader
with the given character set.
|
protected abstract void |
execute(FtpServerChannel channel,
String cmdKey,
Argument[] flags,
Argument[] positionals)
Execute the command.
|
protected String |
formatCmdline(String cmdKey,
String cmdline)
For some commands, add quotes around cmdline input.
|
String |
getHomeFolderPath(FdkSession fdksession)
Get the home folder path.
|
protected int[] |
getPotentialArgs()
Gets the argument type a particular flag is expecting.
|
protected String[] |
getPotentialFlags()
Gets the potentials flags that the CommandlineArguments
object might be expecting.
|
protected void |
handleException(FtpServerChannel channel,
Exception exception,
String cmdKey)
Send a generic error message.
|
String |
normalizePath(FtpSession psession,
String path)
Convert to absolute path if not already.
|
void |
run(FtpServerChannel channel,
String cmdKey,
String cmdline)
Run the command.
|
public final void run(FtpServerChannel channel, String cmdKey, String cmdline)
protected String formatCmdline(String cmdKey, String cmdline) throws Exception
Exception
protected void denyGuestAccessForWriteableCommands(String cmdKey) throws Exception
Exception
protected String[] getPotentialFlags()
protected int[] getPotentialArgs()
protected abstract void execute(FtpServerChannel channel, String cmdKey, Argument[] flags, Argument[] positionals) throws Exception
Exception
protected void handleException(FtpServerChannel channel, Exception exception, String cmdKey) throws Exception
channel
- the server channelexception
- exception objectcmdKey
- the command attemptedException
protected void checkLoggedIn(FtpServerChannel channel) throws FtpException
FtpException
public String getHomeFolderPath(FdkSession fdksession) throws FdkException, Exception
FdkException
Exception
public String encodeArgument(String arg, String charset) throws Exception
arg
- the string to be encodedcharset
- the character set to encode the stringException
public String normalizePath(FtpSession psession, String path) throws FtpException
FtpException
Copyright © 2023. All rights reserved.