From 0161077cdd0506a41008ac9ea1291f7772d17355 Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Sat, 5 Mar 2022 17:35:09 +0100 Subject: [PATCH] =?UTF-8?q?Syst=C3=A8me=20de=20synchronisation=20de=20l'in?= =?UTF-8?q?formation=20entre=20FileFrontEnd<>StorBackEnd=20->=20addStorage?= =?UTF-8?q?=20:=20ajouter=20des=20StorBackEnd=20=C3=A0=20un=20fichier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/lightcontainer/storage/AppData.java | 14 ++++++++++++++ app/src/main/java/lightcontainer/storage/User.java | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/src/main/java/lightcontainer/storage/AppData.java b/app/src/main/java/lightcontainer/storage/AppData.java index ba10605..88b245e 100644 --- a/app/src/main/java/lightcontainer/storage/AppData.java +++ b/app/src/main/java/lightcontainer/storage/AppData.java @@ -129,4 +129,18 @@ public class AppData { return this.users.get(user.getName()).deleteFile(fileName); } } + + /** + * @param user The user who wants to add a storage for their file + * @param file The file that needs a new storage + * @param storage The storage to add + * @return True if the storage was added. False otherwise. + */ + public boolean addStorage(User user, File file, String storage) { + if (!this.users.containsKey(user.getName())) { + return false; + } else { + return this.users.get(user.getName()).addStorage(file, storage); + } + } } diff --git a/app/src/main/java/lightcontainer/storage/User.java b/app/src/main/java/lightcontainer/storage/User.java index 1623703..683fb07 100644 --- a/app/src/main/java/lightcontainer/storage/User.java +++ b/app/src/main/java/lightcontainer/storage/User.java @@ -69,4 +69,17 @@ public class User { return false; } } + + /** + * @param file The file that needs a storage + * @param storage The storage name + * @return True if the storage was added to the file. False otherwise. + */ + public boolean addStorage(File file, String storage) { + if (this.files.containsKey(file.getName())) { + return file.addStorage(storage); + } else { + return false; + } + } }