Esempio n. 1
0
 private Command saveDataOnServer(Command cmd)
 {
     XmlManager xmlManager = new XmlManager();
     List<string> allRootPaths = xmlManager.getAllChilds();
     string category = cmd.Parameter;
     string filename = cmd.Filename;
     FileManager MyFileManager = new FileManager();
     CommandFactory cmdFactory = new CommandFactory();
     //TODO: IS PATH FOR SAVING DATA ALLOWED? (NOT SOOO IMPORTANT)
     MyFileManager.saveFile(filename, cmd.Data);
     Logger.saveDataOnServer(cmd);
     return CommandFactory.createCommand(cmd.Id, SERVERNAME, STATUS, filename, "saved file", new byte[1]);
 }
Esempio n. 2
0
 private Command getAvaibleFiles(Command cmd)
 {
     XmlManager xmlManager = new XmlManager();
     FileManager fileManager = new FileManager();
     List<string> allFilePaths = fileManager.listAllFilesInCategoryFolders(xmlManager.getAllChilds());
     Logger.print(allFilePaths.Count+"");
     //allFilePaths = sortFilesByCreationTime(allFilePaths);
     return CommandFactory.createCommand(cmd.Id, SERVERNAME, SEND_AVAIBLE_FILES, "none", concatFiles(allFilePaths), new byte[1]);
 }
Esempio n. 3
0
 private Command getDataFromServer(Command cmd)
 {
     XmlManager xmlManager = new XmlManager();
     Security SmartSecurity = new Security();
     string category = cmd.Parameter;
     string filename = cmd.Filename;
     //TODO: IS FILE PATH ALLOWED?
     FileManager MyFileManager = new FileManager();
     byte[] data = MyFileManager.loadFile(category, filename);
     Logger.getDataFromServer();
     return CommandFactory.createCommand(cmd.Id, SERVERNAME, SEND_DATA_TO_CLIENT, filename, category, data);
 }
Esempio n. 4
0
 private Command deleteFileFromServer(Command cmd)
 {
     Security SmartSecurity = new Security();
     XmlManager xmlManager = new XmlManager();
     List<string> allRootPaths = xmlManager.getAllChilds();
     CommandFactory cmdFactory = new CommandFactory();
     //TODO: IS FILE PATH ALLOWED?
     //if (SmartSecurity.PathIsAllowed(allRootPaths,cmd.Filename))
     //{
     FileManager fileManager = new FileManager();
     fileManager.deleteFile(cmd.Filename);
     return CommandFactory.createCommand(SmartAuthenticator.Id,SERVERNAME,STATUS,cmd.Filename,"deleted file",new byte[1]);
     //}
     //return CommandFactory.createCommand(SmartAuthenticator.Id, SERVERNAME, STATUS, cmd.Filename, "not deleted file", new byte[1]);
 }