|
|
|
@ -67,19 +67,18 @@ public class ServerManagementUDP implements Runnable {
|
|
|
|
|
* @return data to be send as response
|
|
|
|
|
*/
|
|
|
|
|
String processRequest(String request) {
|
|
|
|
|
System.out.print(request);
|
|
|
|
|
String res = protocolID + "\n";
|
|
|
|
|
String formattedRequest[] = request.split("\n");
|
|
|
|
|
try {
|
|
|
|
|
try {
|
|
|
|
|
checkProtocolID(formattedRequest[0]);
|
|
|
|
|
System.out.print("juste avant le switch");
|
|
|
|
|
switch (formattedRequest[1]) {
|
|
|
|
|
case "LIST":
|
|
|
|
|
System.out.print("liste detectee");
|
|
|
|
|
System.out.println("List request");
|
|
|
|
|
res += sendFileList();
|
|
|
|
|
break;
|
|
|
|
|
case "DOWNLOAD":
|
|
|
|
|
System.out.println("Download request: " + formattedRequest[2]);
|
|
|
|
|
res += upload(formattedRequest[2]);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -102,7 +101,6 @@ public class ServerManagementUDP implements Runnable {
|
|
|
|
|
/** Initialize local list of all files allowed to be shared.
|
|
|
|
|
*/
|
|
|
|
|
private void initFileList() {
|
|
|
|
|
System.out.println(baseDirectory);
|
|
|
|
|
File folder = new File(baseDirectory);
|
|
|
|
|
File[] files = folder.listFiles();
|
|
|
|
|
/* Add non-recursively files's names to fileList */
|
|
|
|
@ -119,7 +117,6 @@ public class ServerManagementUDP implements Runnable {
|
|
|
|
|
* @throws ProtocolError
|
|
|
|
|
*/
|
|
|
|
|
private void checkProtocolID(String msgProtocolID) throws ProtocolError {
|
|
|
|
|
System.out.print(msgProtocolID + "\n" + protocolID);
|
|
|
|
|
if (!protocolID.equals(msgProtocolID)) {
|
|
|
|
|
throw new ProtocolError();
|
|
|
|
|
}
|
|
|
|
|