@@ -21,10 +21,11 @@ import software.aws.toolkits.core.utils.getLogger
2121import software.aws.toolkits.jetbrains.core.DefaultRemoteResourceResolverProvider
2222import software.aws.toolkits.jetbrains.core.RemoteResourceResolverProvider
2323import java.io.InputStream
24+ import java.nio.file.Path
25+ import java.nio.file.Paths
2426import java.time.Duration
2527
2628private const val NOTIFICATION_ENDPOINT = " https://idetoolkits-hostedfiles.amazonaws.com/Notifications/JetBrains/1.json" // TODO: Replace with actual endpoint
27- private const val NOTIFICATIONS_RESOURCE_PATH = " /software/aws/toolkits/resources/notifications.json"
2829private const val MAX_RETRIES = 3
2930private const val RETRY_DELAY_MS = 1000L
3031
@@ -52,18 +53,18 @@ class NotificationPollingServiceImpl :
5253 Disposable {
5354
5455 private var state = State ()
55- private var currentETag: String? = null
5656 private val alarm = AlarmFactory .getInstance().create(Alarm .ThreadToUse .POOLED_THREAD , this )
5757 private val pollingIntervalMs = Duration .ofMinutes(10 ).toMillis()
5858 private val resourceResolver: RemoteResourceResolverProvider = DefaultRemoteResourceResolverProvider ()
5959 private val notificationsResource = object : RemoteResource {
60- override val name: String = NOTIFICATIONS_RESOURCE_PATH
60+ override val name: String = " notifications.json "
6161 override val urls: List <String > = listOf (NOTIFICATION_ENDPOINT )
6262 override val remoteResolveParser: RemoteResolveParser = NotificationFileValidator
6363 }
6464
6565 data class State (
6666 var currentETag : String? = null ,
67+ var cachedFilePath : String? = null
6768 )
6869
6970 override fun getState (): State = state
@@ -96,15 +97,16 @@ class NotificationPollingServiceImpl :
9697 while (retryCount < MAX_RETRIES ) {
9798 try {
9899 val newETag = getNotificationETag()
99- if (newETag == currentETag) {
100+ if (newETag == state. currentETag) {
100101 LOG .debug { " No updates available for notifications" }
101102 return false
102103 }
103- resourceResolver.get()
104+ val resolvedPath = resourceResolver.get()
104105 .resolve(notificationsResource)
105106 .toCompletableFuture()
106107 .get()
107- currentETag = newETag
108+ state.currentETag = newETag
109+ state.cachedFilePath = resolvedPath.toString()
108110 return true
109111 } catch (e: Exception ) {
110112 lastException = e
@@ -127,6 +129,10 @@ class NotificationPollingServiceImpl :
127129 request.connection.headerFields[" ETag" ]?.firstOrNull() ? : " "
128130 }
129131
132+ // Helper method to get Path from stored String
133+ fun getCachedPath (): Path ? =
134+ state.cachedFilePath?.let { Paths .get(it) }
135+
130136 /* *
131137 * Emits telemetry metric for polling failures
132138 */
0 commit comments