@@ -16,7 +16,6 @@ import software.aws.toolkits.jetbrains.services.amazonq.project.manifest.Manifes
1616import  java.nio.file.Path 
1717import  java.nio.file.Paths 
1818
19- 
2019class  ManifestFetcher  {
2120
2221    private  val  lspManifestUrl =  " https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json" 
@@ -30,7 +29,7 @@ class ManifestFetcher {
3029    /* *
3130     * Method which will be used to fetch latest manifest. 
3231     * */  
33-     fun  fetch ()  : ManifestManager .Manifest ?  {
32+     fun  fetch (): ManifestManager .Manifest ?  {
3433        val  localManifest =  fetchManifestFromLocal()
3534        if  (localManifest !=  null ) {
3635            return  localManifest
@@ -39,13 +38,12 @@ class ManifestFetcher {
3938        return  remoteManifest
4039    }
4140
42-     private  fun  fetchManifestFromRemote ()  : ManifestManager .Manifest ?  {
43-         val  manifest  :  ManifestManager .Manifest ? 
41+     private  fun  fetchManifestFromRemote (): ManifestManager .Manifest ?  {
42+         val  manifest:  ManifestManager .Manifest ? 
4443        try  {
4544            val  manifestString =  getTextFromUrl(lspManifestUrl)
4645            manifest =  manifestManager.readManifestFile(manifestString) ? :  return  null 
47-         }
48-         catch  (e:  Exception ) {
46+         } catch  (e:  Exception ) {
4947            logger.error(" error fetching lsp manifest from remote URL ${e.message} " 
5048            return  null 
5149        }
@@ -61,23 +59,21 @@ class ManifestFetcher {
6159    private  fun  updateManifestCache () {
6260        try  {
6361            saveFileFromUrl(lspManifestUrl, lspManifestFilePath)
64-         }
65-         catch  (e:  Exception ) {
62+         } catch  (e:  Exception ) {
6663            logger.error(" error occurred while saving lsp manifest to local cache ${e.message} " 
6764        }
6865    }
6966
70-     private  fun  fetchManifestFromLocal ()  : ManifestManager .Manifest ?  {
71-         var  manifest  :  ManifestManager .Manifest ?  =  null 
67+     private  fun  fetchManifestFromLocal (): ManifestManager .Manifest ?  {
68+         var  manifest:  ManifestManager .Manifest ?  =  null 
7269        val  localETag =  getManifestETagFromLocal()
7370        val  remoteETag =  getManifestETagFromUrl()
7471        //  If local and remote have same ETag, we can re-use the manifest file from local to fetch artifacts.
7572        if  (localETag !=  null  &&  remoteETag !=  null  &&  localETag ==  remoteETag) {
7673            try  {
7774                val  manifestContent =  lspManifestFilePath.readText()
7875                manifest =  manifestManager.readManifestFile(manifestContent) ? :  return  null 
79-             }
80-             catch  (e:  Exception ) {
76+             } catch  (e:  Exception ) {
8177                logger.error(" error reading lsp manifest file from local ${e.message} " 
8278                return  null 
8379            }
@@ -86,21 +82,20 @@ class ManifestFetcher {
8682        return  manifest
8783    }
8884
89-     private  fun  getManifestETagFromLocal ()  : String?  {
90-         if (lspManifestFilePath.exists()) {
85+     private  fun  getManifestETagFromLocal (): String?  {
86+         if   (lspManifestFilePath.exists()) {
9187            val  messageDigest =  DigestUtil .md5()
9288            DigestUtil .updateContentHash(messageDigest, lspManifestFilePath)
9389            return  StringUtil .toHexString(messageDigest.digest())
9490        }
9591        return  null 
9692    }
9793
98-     private  fun  getManifestETagFromUrl ()  : String?  {
94+     private  fun  getManifestETagFromUrl (): String?  {
9995        try  {
10096            val  actualETag =  getETagFromUrl(lspManifestUrl)
10197            return  actualETag.trim(' "' 
102-         }
103-         catch  (e:  Exception ) {
98+         } catch  (e:  Exception ) {
10499            logger.error(" error fetching ETag of lsp manifest from url." 
105100        }
106101        return  null 
0 commit comments