Package com.inesm.KeyManager.services
Class KeyManager
java.lang.Object
com.inesm.KeyManager.services.KeyManager
Provides all key management functionalities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a key in the database.createMission(Mission mission) Creates a mission in the database.createStation(Station station) Creates a station in the databasevoidDeletes a key from the database.voiddeleteMission(String missionUUID) Deletes a mission from the database.voiddeleteStation(String path) Deletes a station from the database.Gets a key and related information from the database.getKeys()Gets all keys, and key related information from the database.getKeysForMission(String missionUUID) Gets all keys and key related information regarding a specific mission.getMission(String missionUUID) Gets a mission and all related information from the database.Gets all missions and related information from the database.getStationbyPath(String path) Gets a station from the database.Gets all station in the database.Patches a key object.Patches a mission.patchStation(Station update) Patches a station.updateKeyState(Key key) Updates the state of a key object in the database.
-
Constructor Details
-
KeyManager
Constructor for the key manager.- Parameters:
rep- the key repository
-
-
Method Details
-
getKeys
Gets all keys, and key related information from the database.- Returns:
- a list containing all the keys inside the database.
-
getKeysForMission
Gets all keys and key related information regarding a specific mission.- Parameters:
missionUUID- the missionUUID of the mission- Returns:
- a list containing all the keys associated with that mission
- Throws:
ObjectNotFoundException- if the specified mission could not be found
-
getKey
Gets a key and related information from the database.- Parameters:
keyUUID- the keyUUID of the key- Returns:
- the object containing all the key information
- Throws:
ObjectNotFoundException- if the key could not be found in the database
-
createKey
Creates a key in the database.- Parameters:
key- the object containing the key information to be stored, not null- Returns:
- the created key in the database
- Throws:
InvalidParametersException- if there were invalid parameters in the key creation
-
patchKey
Patches a key object. Will only update the initialized fields of the key object, the others will remain the one's in the original key object.- Parameters:
key- the object containing the patch information, not null, must have keyUUID set- Returns:
- the result of the patch operation
- Throws:
InvalidParametersException- if invalid parameters were provided in the patch objectObjectNotFoundException- if the object referenced by the patch could not be found
-
updateKeyState
Updates the state of a key object in the database.- Parameters:
key- the key object to be updated, not null, must have state and keyUUID set- Returns:
- the updated key object
- Throws:
InvalidParametersException- if the key contained invalid parametersObjectNotFoundException- if the key referenced could not be found
-
deleteKey
Deletes a key from the database.- Parameters:
keyUUID- the keyUUID of the key to be deleted- Throws:
ObjectNotFoundException- if the key could not be found
-
getMissions
Gets all missions and related information from the database.- Returns:
- a list containing the missions
-
getMission
Gets a mission and all related information from the database.- Parameters:
missionUUID- the missionUUID of the mission- Returns:
- the specified mission
- Throws:
ObjectNotFoundException- if the specified mission is can not be found
-
createMission
Creates a mission in the database.- Parameters:
mission- the mission object to be created- Returns:
- the created mission object
- Throws:
InvalidParametersException- if the received mission object contained invalid parameters
-
patchMission
public Mission patchMission(Mission update, List<Station> added, List<Station> removed) throws ObjectNotFoundException, InvalidParametersException Patches a mission. Will only update the initialized fields of the mission object, the others will remain the one's in the original mission object.- Parameters:
update- the object containing the fields to be updated, not null, must have missionUUID setadded- list array that will contain the added shared stations, preferably emptyremoved- the list array that will contain the removed shared stations, preferably empty- Returns:
- the patched mission
- Throws:
ObjectNotFoundException- if the mission object could not be foundInvalidParametersException- if the mission contained invalid parameters
-
deleteMission
Deletes a mission from the database. Will also delete all the mission sharing information and constituting keys.- Parameters:
missionUUID- the missionUUID of the mission to be deleted- Throws:
ObjectNotFoundException- if the mission could not be found
-
getStations
Gets all station in the database.- Returns:
- a list containing all the stations
-
createStation
Creates a station in the database- Parameters:
station- the station to be created, not null- Returns:
- the created station object
- Throws:
InvalidParametersException- if the station object contained invalid parameters
-
patchStation
public Station patchStation(Station update) throws ObjectNotFoundException, InvalidParametersException Patches a station. Will only update the initialized fields of the station object, the others will remain the one's in the original station object.- Parameters:
update- the station containing the fields to be updated, not null, must have path set- Returns:
- the updated station object
- Throws:
ObjectNotFoundException- if the station to be updated could not be foundInvalidParametersException- if the station update contained invalid parameters
-
deleteStation
public void deleteStation(String path) throws ObjectNotFoundException, StationCurrentlyAssignedException, ResourceLockedException Deletes a station from the database.- Parameters:
path- the path of the station to be deleted- Throws:
ObjectNotFoundException- if the station specified could not be foundStationCurrentlyAssignedException- if the station is owner, or a shared station of a missionResourceLockedException- if the station constitutes a current station
-
getStationbyPath
Gets a station from the database.- Parameters:
path- the path of the station to be retrieved.- Returns:
- a station object containing the station information
- Throws:
ObjectNotFoundException- if the specified station could not be found
-