Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Resident App

Laura Partac edited this page Jun 9, 2022 · 9 revisions

Tree

Actions

DeleteDeal

PushDeal

TreeActionsEnum

TreeDeal

FileSystemTree

TreeDirectory

WildcardTreeDirectory

ConnectivityResident

The class responsible for the communication between two devices which is established by sending actions: fetch, sync and delete.

Class Summary

Constructors

  • A constructor with arguments:
public ConnectivityResident(Peer peer, SynchronizedDirectory synchronizedDirectory)
  • A constructor with no arguments:
public ConnectivityResident()

Methods

Summary

public Peer getPeer()
public void setSynchronizedDirectory(SynchronizedDirectory synchronizedDirectory)
public List<Connection> getConnectedDevices()
public List<Connection> getLastSearch()
public void setPeer(Peer peer)
private void sendFileSystemTree(Connection connection, FileSystemTree fileSystemTree) throws FileNotFoundException, IOException
private void sendAction(Connection connection, TreeActionsEnum action) throws IOException
public void fetchFiles(Connection connection) throws  IOException
public void syncFiles(Connection connection) throws IOException
private void sendModifiedFiles(Connection connection, FileSystemTree fileSystemTree) throws IOException
public void incomingAction(Connection connection, FileSystemTree fileSystemTree)
public void run()

Details

1. public Peer getPeer()

The getter for the peer attribute, returning the current instance of the Peer object which is responsible for keeping track of the connected devices.

Returns:

  • peer -> The current instance of the Peer object.

2. public void setSynchronizedDirectory(SynchronizedDirectory synchronizedDirectory)

The setter for synchronizedDirectory.

Parameters:

  • synchronizedDirectory -> the desired instance of SynchronizedDirectory, the class responsible for managing the directory wished to be syncronized between devices.

3. public List getConnectedDevices()

The method that invokes the getConnectedDevices method from the peer object in order to obtain the currently connected devices.

Returns:

  • lastSearch -> a list of devices (List).

4. public List getLastSearch()

The getter for the lastSearch attribute.

Returns:

  • lastSearch -> the current state of the list representing the connected devices.

5. public void setPeer(Peer peer)

The setter for the peer attribute.

Parameters:

  • the instance of Peer wished to be used in the communication.

6. private void sendFileSystemTree(Connection connection, FileSystemTree fileSystemTree) throws FileNotFoundException, IOException

This method is used to send and create the json file.

Parameters:

  • connection -> The connection representing a device.

  • fileSystemTree -> The object which will provide the method necessary for converting to json.

Throws:

  • FileNotFoundException
  • IOException

7. private void sendAction(Connection connection, TreeActionsEnum action) throws IOException

This method is used to create the FileSystemTree from the TreeDirectory, then send an action request to the specified device.

Parameters:

  • connection -> The connection representing the device.

  • action -> The type of action to be executed (fetch, sync or delete).

Throws:

  • IOException

8. public void fetchFiles(Connection connection) throws IOException

This method is used to invoke the method that will send the fetch action.

Parameters:

  • connection -> The device the action is addressed to.

Throws:

  • IOException

9. public void syncFiles(Connection connection) throws IOException

This method is used to invoke the method that will send the sync action.

Parameters:

  • connection -> The device the action is addressed to.

Throws:

  • IOException

10. private void sendModifiedFiles(Connection connection, FileSystemTree fileSystemTree) throws IOException

This method is used to send the modified files to a specified device by instantiating a new push deal with the required parameters.

Parameters:

  • connection -> The device to be interacted with.

  • fileSystemTree -> The object used to extract the root.

Throws:

  • IOException

11. public void incomingAction(Connection connection, FileSystemTree fileSystemTree)

This method is used to analyze the fileSystemTree in order to invoke the methods responsible for executing the given commands.

Parameters:

  • connection -> The device to be interacted with.

  • fileSystemTree -> The object through which the type of action is accessed.

12. @Override public void run()

The method responsible with checking on the status of the connection and whether or not an action has been requested, invoking the method which will further analyze the command.

SynchronizedDirectory

Testing

Clone this wiki locally