Package eirb.pub.app.server
Class ServerVault
java.lang.Object
eirb.pub.app.server.ServerVault
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteVault(ServerVaultFile serverVaultFile) Delete the vault from the servervoiddeleteVault(UUID id) Delete the vault with the given idgetVault(ServerVaultFile serverVaultFile) Retrieve a Vault from the server (get updated vault)Retrieve a Vault from the serverGet the list of the vault owned by the authenticated user *Send a new VaultFile to the server.voidupdateVault(ServerVaultFile vault) Update a Vault by submitting a new version to the server
-
Constructor Details
-
ServerVault
-
-
Method Details
-
getVaultList
public List<Pair<UUID,String>> getVaultList() throws IOException, AuthenticationException, TimeoutExceptionGet the list of the vault owned by the authenticated user *- Returns:
- the HashMap with (key=id, value=vaultName) of the user
- Throws:
IOException- If an error occurred with the server connectionAuthenticationException- if the user is no longer authenticatedTimeoutException
-
getVault
public ServerVaultFile getVault(UUID id) throws ForbiddenAccessException, AuthenticationException, IOException, VaultFileIOException, VaultFileFormatException, TimeoutException Retrieve a Vault from the server- Parameters:
id- , id of the vault- Returns:
- the vault with the given id, not a GetRequest because not possible to have a body with a getRequest
- Throws:
AuthenticationException- if the user is not authenticatedForbiddenAccessException- if the user do not have access to the desired vault (or don't exist on the server anymore)VaultFileIOException- if the building operation of the vaultFile failedVaultFileFormatException- If the format of the vault file is not respectedIOException- if an error occurred with the connectionTimeoutException
-
getVault
public ServerVaultFile getVault(ServerVaultFile serverVaultFile) throws ForbiddenAccessException, AuthenticationException, IOException, VaultFileIOException, VaultFileFormatException, TimeoutException Retrieve a Vault from the server (get updated vault)- Parameters:
serverVaultFile- vault that we want to get the update from the server- Returns:
- the vault with the given id, not a GetRequest because not possible to have a body with a getRequest
- Throws:
AuthenticationException- if the user is not authenticatedForbiddenAccessException- if the user do not have access to the desired vault (or don't exist on the server anymore)VaultFileIOException- if the building operation of the vaultFile failedVaultFileFormatException- If the format of the vault file is not respectedTimeoutException- if the request took too much time to completeIOException- if an error occurred with the connection
-
updateVault
public void updateVault(ServerVaultFile vault) throws ForbiddenAccessException, AuthenticationException, VaultUpdateException, IOException, TimeoutException Update a Vault by submitting a new version to the serverIf an update was made on the server, an error will be raised with the VaultFile present on the server to merge it with the current one. This one can be found in the Exception, rerun this method to correctly push the desired version of the Vault
- Parameters:
vault- Version of the ServerVaultFile to be push to the server- Throws:
ForbiddenAccessException- The authenticated user can't update the give Vault (check VaultFile Server id provided)AuthenticationException- The user is not authenticatedTimeoutException- if the request took too much time to completeVaultUpdateException- A more recent version of the vault is present of the server, merge the VaultFile present in the Exception with the current one and remake the requestIOException
-
postVault
public ServerVaultFile postVault(VaultFile vault) throws AuthenticationException, IOException, TimeoutException Send a new VaultFile to the server. It will be saved with the other vaultFile from the authenticated user. Return a ServerVaultFile which contains the vault, id and hash of the vaultUpdate the vaultFile with the server-id of the uploaded vault
/!\ Warning this method is used to create a new Vault in the user account not to update an existing one
- Parameters:
vault- , type: VaultFile- Throws:
AuthenticationException- If the user is not authenticatedTimeoutException- if the request took too much time to completeIOException- If the connection with the server breaks
-
deleteVault
public void deleteVault(UUID id) throws ForbiddenAccessException, AuthenticationException, IOException, TimeoutException Delete the vault with the given id- Parameters:
id- id of the vault we want to delete- Throws:
IOException- If a problem occurres with the server connectionAuthenticationException- If the user is not authenticated (or the token is outdated)TimeoutException- if the request took too much time to completeForbiddenAccessException- Can't delete the vault because the user has no access to the ressource
-
deleteVault
public void deleteVault(ServerVaultFile serverVaultFile) throws IOException, ForbiddenAccessException, AuthenticationException, TimeoutException Delete the vault from the server- Parameters:
serverVaultFile- vault to remove from the server- Throws:
IOException- If a problem occurres with the server connectionAuthenticationException- If the user is not authenticated (or the token is outdated)TimeoutException- if the request took too much time to completeForbiddenAccessException- Can't delete the vault because the user has no access to the ressource
-