generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML4SE-168] Connection between server and client. Uploading log files.
- Loading branch information
mikrise2
committed
Dec 6, 2023
1 parent
fd12b94
commit 27128ff
Showing
19 changed files
with
137 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/requests/IdRequests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jetbrains.research.tasktracker.requests | ||
|
||
import com.intellij.openapi.diagnostic.Logger | ||
import io.ktor.client.* | ||
import io.ktor.client.call.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.request.forms.* | ||
import io.ktor.http.* | ||
import kotlinx.coroutines.runBlocking | ||
import org.jetbrains.research.tasktracker.TaskTrackerPlugin | ||
import org.jetbrains.research.tasktracker.config.MainTaskTrackerConfig.Companion.getRoute | ||
import org.jetbrains.research.tasktracker.ui.main.panel.storage.GlobalPluginStorage | ||
|
||
object IdRequests { | ||
private val client = HttpClient(CIO) | ||
private val logger = Logger.getInstance(IdRequests::class.java) | ||
|
||
@Suppress("TooGenericExceptionCaught") | ||
fun getUserId(name: String, email: String): Int? = | ||
runBlocking { | ||
val url = getRoute("create-user") | ||
try { | ||
return@runBlocking client.submitForm( | ||
url = url, | ||
formParameters = parameters { | ||
append("name", name) | ||
append("email", email) | ||
} | ||
).body<Int>() | ||
} catch (e: Exception) { | ||
logger.error("Server interaction error while getting user id! Url: $url", e) | ||
} | ||
return@runBlocking null | ||
} | ||
|
||
@Suppress("TooGenericExceptionCaught") | ||
fun getResearchId(): Int? = | ||
runBlocking { | ||
val url = getRoute("create-research") | ||
val pluginInfoConfig = TaskTrackerPlugin.mainConfig.pluginInfoConfig | ||
?: error("MainPageConfig must not be null") | ||
try { | ||
requireNotNull(GlobalPluginStorage.userId) { "User id is not defined" } | ||
return@runBlocking client.submitForm( | ||
url = url, | ||
formParameters = parameters { | ||
append("name", pluginInfoConfig.pluginName) | ||
append("description", pluginInfoConfig.pluginDescription) | ||
append("user_id", GlobalPluginStorage.userId.toString()) | ||
} | ||
).body<Int>() | ||
} catch (e: IllegalArgumentException) { | ||
logger.error(e.localizedMessage) | ||
} catch (e: Exception) { | ||
logger.error("Server interaction error while getting user id! Url: $url", e) | ||
} | ||
return@runBlocking null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/Loggable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package org.jetbrains.research.tasktracker.tracking | ||
|
||
import org.jetbrains.research.tasktracker.requests.FileRequests | ||
import java.io.File | ||
|
||
interface Loggable { | ||
abstract class Loggable { | ||
|
||
val subDir: String | ||
abstract val logFileType: String | ||
|
||
fun getLogFiles(): List<File> | ||
abstract fun getLogFiles(): List<File> | ||
|
||
fun send() = getLogFiles().all { | ||
FileRequests.sendFile(it, this.logFileType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.