server.JFilesServer - rsanchez-wsu/jfiles GitHub Wiki
The main class of the JFiles server application.
Package: server
Configs:
-
maxThreads
- Default 10 -
Port
- Default 9786
Currently supported commands:
MV <filename> <directory>
- This command will move a file to a different directory
FIND <filename>
- This command will return a file from the filesystem
ERROR <message>
- This command will return an error with a custom error message
LS <source>
- This command will return a list of files in a given directory
INFO <message>
- This command will return a client connection information
RM <filename>
- This command will move a file from the filesystem
RMDIR <directory>
- This command will remove a directory from the filesystem
TOUCH <filename>
- This command will modify a file`s timestamp to be current
MKDIR <directory>
- This command will create a directory
QUIT
- This command will exit the user from their session
CD <directory>
- This command will navigate the user to a different directory
PWD <file>
- This command will print the file information
LOGIN <username> <password>
- This command will log a user in
RECV <filename>
- This command will display the contents of a file to the user
SEND <filename>
- This command will send a file to a user
Currently supported admin commands:
RESTART
- This command will restart the server
UPDATE
- This command will update the server`s files
STOP
- This command will halt the server
START
- This command will start the server
PING
- This command will send a response back from the server
GROUPADD
- This command will take multiple usernames and add them to the database
WRITE
- This command will output to a text file instead of the console
ADDUSER
- This command will create a user in the database
USERDEL
- This command will delete a user from the database
LOGOUT
- This command log a user out of the application
USERS
- This command will return a list of usernames that are users of the application
LWRITE
- This command will write a log to a file of the user's choice
WRITE
- This command will write to a file of the user's choice
Parameters:
-
port
- The port number for the server to run on.
Private:
-
static int PORT
- Default value of 9786. -
JFilesServerThread[] clients
- Default size of 50. ServerSocket server
Thread thread
-
int clientCount
- The total number of clients connected.
Creates a new JFilesServer on member variable PORT
.
Handles an incoming message from a client. The id
is the id of the client, which comes from JFilesServerThread.getid(). input
is the message from the client.
Removes and terminates a client. The id
is the id of the client, which comes from JFilesServerThread.getid().
While true, wait for a client to connect. When a new connection is established, addThread() is called.
Checks to make sure command
has at least one argument.
Returns the system.getProperties("user.dir").
Initiates a new client thread and starts it.
Accesses the XML configuration files and loads in the default configurations if there are any.
Creates an XML file for something.
Creates an XML node.
Parameters:
-
doc
- Document to create node for -
name
- Name of node that should be created.
Returns the newly created Node element.
Searches through the clients array for the JFilesServerThread.getid() value that equals id
. Returns the index value of the clients array.
Sends the list the files in the dir
directory, filtered with searchTerm
, to clients[id
]. The search term can contain Glob Patterns.
calls findCmd() inside of all directories inside the dir
directory.