in app/config/Switches.scala [26:49]
def allSwitches: Map[String, SwitchState] = atomicSwitchMap.get()
def setEmergencySwitch(state: SwitchState): Option[Unit] = {
val name = "emergency"
val newStates = allSwitches + (name -> state)
val json = Json.toJson(newStates)
val jsonString = Json.stringify(json)
val metaData = new ObjectMetadata()
metaData.setContentLength(jsonString.getBytes("UTF-8").length)
try {
val request = new PutObjectRequest(config.switchBucket, fileName, new StringInputStream(jsonString), metaData)
s3Client.putObject(request)
log.info(s"$name has been updated to ${state.name}")
atomicSwitchMap.set(newStates)
notifier.sendStateChangeNotification(name, state)
Some(())
} catch {
case e: Exception => {
log.error(s"Unable to update switch $name ${state.name}", e)
None
}
}
}