AppData : simplification du système. Suppression de la nécéssité de passer un objet User pour réaliser les opérations
This commit is contained in:
parent
1a3b796f61
commit
18df312592
@ -68,8 +68,6 @@ public class AppData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method when a user signs up.
|
* Use this method when a user signs up.
|
||||||
*
|
*
|
||||||
@ -99,14 +97,14 @@ public class AppData {
|
|||||||
* False indicates the failure of the operation.
|
* False indicates the failure of the operation.
|
||||||
*
|
*
|
||||||
* @param file The file to add
|
* @param file The file to add
|
||||||
* @param user The user who wants to add the file
|
* @param userName The name of the user who wants to add the file
|
||||||
* @return True if the user is found and a file with the same name doesn't already exist for this user. False otherwise.
|
* @return True if the user is found and a file with the same name doesn't already exist for this user. False otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean addFileFor(File file, User user) {
|
public boolean addFileFor(File file, String userName) {
|
||||||
if (!this.users.containsKey(user.getName())) {
|
if (!this.users.containsKey(userName)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.users.get(user.getName()).addFile(file);
|
this.users.get(userName).addFile(file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,28 +117,28 @@ public class AppData {
|
|||||||
* False indicates the failure of the operation.
|
* False indicates the failure of the operation.
|
||||||
*
|
*
|
||||||
* @param fileName The name of the file to delete
|
* @param fileName The name of the file to delete
|
||||||
* @param user The user who wants to delete the file
|
* @param userName The name of the user who wants to delete the file
|
||||||
* @return True if the user is found and the file was deleted. False otherwise.
|
* @return True if the user is found and the file was deleted. False otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean deleteFileOf(String fileName, User user) {
|
public boolean deleteFileOf(String fileName, String userName) {
|
||||||
if (!this.users.containsKey(user.getName())) {
|
if (!this.users.containsKey(userName)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return this.users.get(user.getName()).deleteFile(fileName);
|
return this.users.get(userName).deleteFile(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param user The user who wants to add a storage for their file
|
* @param userName The name of the user who wants to add a storage for their file
|
||||||
* @param file The file that needs a new storage
|
* @param file The file that needs a new storage
|
||||||
* @param storage The storage to add
|
* @param storage The storage to add
|
||||||
* @return True if the storage was added. False otherwise.
|
* @return True if the storage was added. False otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean addStorage(User user, File file, String storage) {
|
public boolean addStorage(String userName, File file, String storage) {
|
||||||
if (!this.users.containsKey(user.getName())) {
|
if (!this.users.containsKey(userName)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return this.users.get(user.getName()).addStorage(file, storage);
|
return this.users.get(userName).addStorage(file, storage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,8 @@ public class RepositoryTests {
|
|||||||
storage.add("StorBackEnd1");
|
storage.add("StorBackEnd1");
|
||||||
File file1 = new File("File1", 15, "8d8d8d8d", storage);
|
File file1 = new File("File1", 15, "8d8d8d8d", storage);
|
||||||
files.put(file1.getName(), file1);
|
files.put(file1.getName(), file1);
|
||||||
User user1 = new User("User1", "Password", "djdjjdj", files);
|
|
||||||
appData.setAppConfig(appConfig);
|
appData.setAppConfig(appConfig);
|
||||||
//appData.addUser(user1);
|
appData.addUser("User1", "Password", "djdjjdj");
|
||||||
JsonAdapter jsonAdapter = new JsonAdapter(appData);
|
JsonAdapter jsonAdapter = new JsonAdapter(appData);
|
||||||
//WHEN Repository calls save method
|
//WHEN Repository calls save method
|
||||||
String filePath = "src/test/resources/test.json";
|
String filePath = "src/test/resources/test.json";
|
||||||
|
Loading…
Reference in New Issue
Block a user