|
|
|
@ -271,12 +271,13 @@ public abstract class ClientManagement extends ServeErrors implements Runnable {
|
|
|
|
|
/** Implementation of Runnable
|
|
|
|
|
*/
|
|
|
|
|
public void run() {
|
|
|
|
|
boolean isrunning = true;
|
|
|
|
|
while (isrunning){
|
|
|
|
|
boolean isRunning = true;
|
|
|
|
|
while (isRunning) {
|
|
|
|
|
try {
|
|
|
|
|
int i = 1;
|
|
|
|
|
String[] list = listDirectory();
|
|
|
|
|
System.out.println("Files present on the server:");
|
|
|
|
|
System.out.println("R: Refresh file list");
|
|
|
|
|
System.out.println("0: Exit the program");
|
|
|
|
|
for(String listItem: list) {
|
|
|
|
|
System.out.println(i + ": " + listItem);
|
|
|
|
@ -285,19 +286,21 @@ public abstract class ClientManagement extends ServeErrors implements Runnable {
|
|
|
|
|
System.out.println("Type the number associated with the file to download:");
|
|
|
|
|
String f = scanner.nextLine();
|
|
|
|
|
if (f.equals("0")) {
|
|
|
|
|
isrunning = false;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
isRunning = false;
|
|
|
|
|
} else if (f.equals("R") || f.equals("r")) {
|
|
|
|
|
writeLog("File list refresh.", LogLevel.Info);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
int j = Integer.parseInt(f);
|
|
|
|
|
if (j <= list.length) {
|
|
|
|
|
j--;
|
|
|
|
|
download(list[j]);
|
|
|
|
|
System.out.println("File " + f + " sucessfully downloaded");
|
|
|
|
|
writeLog("File " + f + " sucessfully downloaded", LogLevel.Info);
|
|
|
|
|
} else {
|
|
|
|
|
writeLog("File " + f + " unsucessfully downloaded, wrong number", LogLevel.Error);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
System.out.println("File " + f + " unsucessfully downloaded, wrong number");
|
|
|
|
|
writeLog("File " + f + " unsucessfully downloaded, wrong number", LogLevel.Info);
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
writeLog("File " + f + " unsucessfully downloaded, wrong number", LogLevel.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (EmptyDirectory e) {
|
|
|
|
|