Skip to content

Commit

Permalink
Completed the code documentation and added the Dokka's docu!
Browse files Browse the repository at this point in the history
  • Loading branch information
N7ghtm4r3 committed Nov 17, 2024
1 parent 828d83a commit 90ea794
Show file tree
Hide file tree
Showing 459 changed files with 118,552 additions and 1 deletion.
16 changes: 16 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
plugins {
id("java")
id("maven-publish")
id("org.springframework.boot") version "3.2.3"
kotlin("jvm")
}

apply(plugin = "io.spring.dependency-management")

group = "com.tecknobit"
version = "1.0.0"

Expand All @@ -28,6 +31,19 @@ dependencies {
implementation("com.tecknobit.ametistacore:ametistacore:1.0.0")
}

afterEvaluate {
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.tecknobit.ametista"
artifactId = "Ametista"
version = "1.0.0"
from(components["java"])
}
}
}
}

configurations.all {
exclude("commons-logging", "commons-logging")
}
21 changes: 21 additions & 0 deletions backend/src/main/java/Launcher.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.tecknobit.apimanager.apis.ServerProtector;
import com.tecknobit.apimanager.exceptions.SaveData;
import com.tecknobit.equinox.environment.controllers.EquinoxController;
import com.tecknobit.equinox.resourcesutils.ResourcesProvider;
Expand Down Expand Up @@ -77,13 +78,26 @@ public static void main(String[] args) {
SpringApplication.run(Launcher.class, args);
}

/**
* Method to check whether the program arguments list contains invalid commands such {@link ServerProtector#DELETE_SERVER_SECRET_AND_INTERRUPT_COMMAND}
*
* @param args The program arguments list
* @return whether the program arguments list contains invalid commands as {@code boolean}
*/
private static boolean hasInvalidCommand(String[] args) {
for (String arg : args)
if (arg.equals(DELETE_SERVER_SECRET_AND_INTERRUPT_COMMAND))
return true;
return false;
}

/**
* Method to generate the admin code for the server instance
*
* @param args The program arguments list
*
* @return the generated admin code as {@link String}
*/
private static String generateAdminCode(String[] args) {
String adminCode = null;
try {
Expand All @@ -96,6 +110,13 @@ private static String generateAdminCode(String[] args) {
return adminCode;
}

/**
* Method to assemble the save message for the {@link SaveData} exception
*
* @param adminCode The generated admin code
*
* @return the save message assembled as {@link String}
*/
private static String getSaveMessage(String adminCode) {
return format(" to correctly register a new user in the Ametista system.\nThe admin code: %sto authenticate as " +
"an admin, keep it safe!", adminCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.tecknobit.ametistacore.models.AmetistaApplication;
import com.tecknobit.ametistacore.models.Platform;
import com.tecknobit.ametistacore.models.analytics.performance.PerformanceAnalytic.PerformanceAnalyticType;
import com.tecknobit.apimanager.annotations.RequestPath;
import com.tecknobit.equinox.environment.controllers.EquinoxController;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -22,6 +23,7 @@
import static com.tecknobit.ametistacore.models.analytics.performance.PerformanceAnalytic.PERFORMANCE_ANALYTIC_TYPE_KEY;
import static com.tecknobit.ametistacore.models.analytics.performance.PerformanceAnalytic.PerformanceAnalyticType.ISSUES_PER_SESSION;
import static com.tecknobit.ametistacore.models.analytics.performance.PerformanceAnalytic.PerformanceAnalyticType.TOTAL_ISSUES;
import static com.tecknobit.apimanager.apis.APIRequest.RequestMethod.PUT;
import static com.tecknobit.apimanager.apis.ServerProtector.SERVER_SECRET_KEY;
import static com.tecknobit.apimanager.apis.sockets.SocketManager.StandardResponseCode.SUCCESSFUL;
import static com.tecknobit.equinox.Requester.RESPONSE_DATA_KEY;
Expand All @@ -40,15 +42,35 @@
@RequestMapping(BASE_EQUINOX_ENDPOINT + APPLICATIONS_KEY + "/{" + APPLICATION_IDENTIFIER_KEY + "}")
public class AmetistaCollectorController extends DefaultAmetistaController {

/**
* {@code IS_DEBUG_MODE} whether the analytics sent by the Ametista-Engine must be counted
*/
private static final String IS_DEBUG_MODE = "is_debug_mode";

/**
* {@code PLATFORM_ALREADY_CONNECTED} error message used when the platform requested to connect is already connected
*/
private static final String PLATFORM_ALREADY_CONNECTED = "platform_already_connected_key";

/**
* {@code DEBUG_OPERATION_EXECUTED_SUCCESSFULLY} message sent when the collection request has been completed successfully
*/
private static final String DEBUG_OPERATION_EXECUTED_SUCCESSFULLY = "debug_operation_executed_successfully_key";

/**
* {@code collectorHelper} helper to manage the collection operations
*/
@Autowired
private CollectorHelper collectorHelper;

/**
* Method to connect a new platform for the application
*
* @param applicationId The identifier of the application
* @param serverSecret The token of the user
* @param platform The platform to connect
* @return the result of the request as {@link String}
*/
@PutMapping(
params = {
PLATFORM_KEY
Expand All @@ -57,6 +79,11 @@ public class AmetistaCollectorController extends DefaultAmetistaController {
SERVER_SECRET_KEY
}
)
@RequestPath(
path = "/api/v1/applications/{application_id}",
query_parameters = "?platform={platform}",
method = PUT
)
public String connectPlatform(
@PathVariable(APPLICATION_IDENTIFIER_KEY) String applicationId,
@RequestHeader(SERVER_SECRET_KEY) String serverSecret,
Expand All @@ -70,7 +97,32 @@ public String connectPlatform(
collectorHelper.connectPlatform(applicationId, platform);
return successResponse();
}


/**
* Method to collect a new issue for the application
*
* @param applicationId Identifier of the application
* @param serverSecret User token for authentication
* @param appVersion Version of the application where the issue occurred
* @param platform Platform to connect
* @param isDebugMode Specifies whether analytics sent by the Ametista-Engine should be counted
* @param payload Request payload containing the device, browser, and issue details:
* <pre>
* {
* "device": {
* "device_id": " the device identifier -> [String]",
* "brand": "the device brand -> [String]",
* "model": "the device model -> [String]",
* "os": "the operating system of the device -> [String]",
* "os_version": "the version of the operating system of the device -> [String]"
* },
* "browser": "(WEB) the browser where the issue occurred -> [String]",
* "browser_version": "(WEB) the version of the browser where the issue occurred -> [String]",
* "issue": "the issue cause message -> [String]"
* }
* </pre>
* @return result of the request as {@link String}.
*/
@PutMapping(
path = "/" + ISSUES_KEY,
params = {
Expand All @@ -81,6 +133,11 @@ public String connectPlatform(
SERVER_SECRET_KEY
}
)
@RequestPath(
path = "/api/v1/applications/{application_id}/issues",
query_parameters = "?app_version={app_version}&platform={platform}&is_debug_mode={is_debug_mode}",
method = PUT
)
public String collectIssue(
@PathVariable(APPLICATION_IDENTIFIER_KEY) String applicationId,
@RequestHeader(SERVER_SECRET_KEY) String serverSecret,
Expand All @@ -103,6 +160,17 @@ public String collectIssue(
}
}

/**
* Method to collect an analytics for the application
*
* @param applicationId Identifier of the application
* @param serverSecret User token for authentication
* @param appVersion Version of the application where the issue occurred
* @param platform Platform to connect
* @param isDebugMode Specifies whether analytics sent by the Ametista-Engine should be counted
* @param payload The request payload with the different analytic stats to store
* @return result of the request as {@link String}.
*/
@PutMapping(
path = "/" + PERFORMANCE_ANALYTICS_KEY,
params = {
Expand All @@ -114,6 +182,11 @@ public String collectIssue(
SERVER_SECRET_KEY
}
)
@RequestPath(
path = "/api/v1/applications/{application_id}/performance_analytics",
query_parameters = "?app_version={app_version}&platform={platform}&is_debug_mode={is_debug_mode}",
method = PUT
)
public String collectAnalytic(
@PathVariable(APPLICATION_IDENTIFIER_KEY) String applicationId,
@RequestHeader(SERVER_SECRET_KEY) String serverSecret,
Expand All @@ -139,12 +212,25 @@ public String collectAnalytic(
}
}

/**
* Method to send the debug request response
*
* @return the request response as {@link String}
*/
private String sendDebugRequestResponse() {
return new JSONObject()
.put(RESPONSE_STATUS_KEY, SUCCESSFUL)
.put(RESPONSE_DATA_KEY, mantis.getResource(DEBUG_OPERATION_EXECUTED_SUCCESSFULLY)).toString();
}

/**
* Method to validate the collector request checking the server secret and the identifier of the application sent
*
* @param applicationId Identifier of the application
* @param serverSecret User token for authentication
*
* @return result of the validation as {@link AmetistaApplication}
*/
private AmetistaApplication validateCollectorRequest(String applicationId, String serverSecret) {
if (!serverProtector.serverSecretMatches(serverSecret))
return null;
Expand Down
4 changes: 4 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ afterEvaluate {
configurations.all {
exclude("commons-logging", "commons-logging")
}

kotlin {
jvmToolchain(18)
}
97 changes: 97 additions & 0 deletions docs/backend/[root]/-launcher/-launcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!doctype html>
<html class="no-js">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
<title>Launcher</title>
<link href="../../../images/logo-icon.svg" rel="icon" type="image/svg">
<script>var pathToRoot = "../../../";</script>
<script>document.documentElement.classList.replace("no-js","js");</script>
<script>const storage = localStorage.getItem("dokka-dark-mode")
if (storage == null) {
const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
if (osDarkSchemePreferred === true) {
document.getElementsByTagName("html")[0].classList.add("theme-dark")
}
} else {
const savedDarkMode = JSON.parse(storage)
if(savedDarkMode === true) {
document.getElementsByTagName("html")[0].classList.add("theme-dark")
}
}
</script>
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async></script>
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async></script>
<link href="../../../styles/style.css" rel="Stylesheet">
<link href="../../../styles/main.css" rel="Stylesheet">
<link href="../../../styles/prism.css" rel="Stylesheet">
<link href="../../../styles/logo-styles.css" rel="Stylesheet">
<link href="../../../styles/font-jb-sans-auto.css" rel="Stylesheet">
<script type="text/javascript" src="../../../scripts/clipboard.js" async></script>
<script type="text/javascript" src="../../../scripts/navigation-loader.js" async></script>
<script type="text/javascript" src="../../../scripts/platform-content-handler.js" async></script>
<script type="text/javascript" src="../../../scripts/main.js" defer></script>
<script type="text/javascript" src="../../../scripts/prism.js" async></script>
<script type="text/javascript" src="../../../scripts/symbol-parameters-wrapper_deferred.js" defer></script>
</head>
<body>
<div class="root">
<nav class="navigation" id="navigation-wrapper">
<div class="navigation--inner">
<div class="navigation-title">
<button class="menu-toggle" id="menu-toggle" type="button">toggle menu</button>
<div class="library-name">
<a class="library-name--link" href="../../../index.html">
Ametista
</a></div>
<div class="library-version">
</div>
</div>
<div class="filter-section" id="filter-section">
<button class="platform-tag platform-selector jvm-like" data-active=""
data-filter=":backend:dokkaHtmlPartial/main">jvm
</button>
</div>
</div>
<div class="navigation-controls">
<button class="navigation-controls--btn navigation-controls--theme" id="theme-toggle-button" type="button">
switch theme
</button>
<div class="navigation-controls--btn navigation-controls--search" id="searchBar" role="button">search in
API
</div>
</div>
</nav>
<div id="container">
<div class="sidebar" id="leftColumn">
<div class="sidebar--inner" id="sideMenu"></div>
</div>
<div id="main">
<div class="main-content" data-page-type="member" id="content"
pageids="backend::/Launcher/Launcher/#/PointingToDeclaration//-612206970">
<div class="breadcrumbs"><a href="../../index.html">backend</a><span class="delimiter">/</span><a
href="../index.html">[root]</a><span class="delimiter">/</span><a href="index.html">Launcher</a><span
class="delimiter">/</span><span class="current">Launcher</span></div>
<div class="cover ">
<h1 class="cover"><span><span>Launcher</span></span></h1>
</div>
<div class="platform-hinted " data-platform-hinted="data-platform-hinted">
<div class="content sourceset-dependent-content" data-active=""
data-togglable=":backend:dokkaHtmlPartial/main">
<div class="symbol monospace"><span class="token keyword">constructor</span><span
class="token punctuation">(</span><span class="token punctuation">)</span></div>
</div>
</div>
</div>
<div class="footer">
<span class="go-to-top-icon"><a href="#content"
id="go-to-top-link"></a></span><span>© 2024 Copyright</span><span
class="pull-right"><span>Generated by </span><a
href="https://github.com/Kotlin/dokka"><span>dokka</span><span
class="padded-icon"></span></a></span>
</div>
</div>
</div>
</div>
</body>
</html>

Loading

0 comments on commit 90ea794

Please sign in to comment.