Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
magaupp committed Dec 29, 2024
1 parent 6e53045 commit 85af640
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage;
import de.tum.cit.aet.artemis.programming.domain.ProjectType;

/**
* Provides licensing information for proprietary software to build jobs via environment variables.
*/
@Profile(PROFILE_CORE)
@Service
public class LicenseService {
Expand All @@ -24,6 +27,14 @@ public LicenseService(LicenseConfiguration licenseConfiguration) {
this.licenseConfiguration = licenseConfiguration;
}

/**
* Checks whether a required license is configured for the specified exercise type.
* If no license is required this returns true.
*
* @param programmingLanguage the programming language of the exercise type
* @param projectType the project type of the exercise type
* @return whether a required license is configured
*/
public boolean isLicensed(ProgrammingLanguage programmingLanguage, @Nullable ProjectType projectType) {
if (programmingLanguage == ProgrammingLanguage.MATLAB && projectType == null) {
return licenseConfiguration.getMatlabLicenseServer() != null;
Expand All @@ -32,6 +43,13 @@ public boolean isLicensed(ProgrammingLanguage programmingLanguage, @Nullable Pro
return true;
}

/**
* Returns environment variables required to run programming exercise tests.
*
* @param programmingLanguage the programming language of the exercise
* @param projectType the project type of the exercise
* @return environment variables for the specified exercise type
*/
public Map<String, String> getEnvironment(ProgrammingLanguage programmingLanguage, @Nullable ProjectType projectType) {
if (programmingLanguage == ProgrammingLanguage.MATLAB && projectType == null) {
return Map.of("MLM_LICENSE_FILE", Objects.requireNonNull(licenseConfiguration.getMatlabLicenseServer()));
Expand Down

0 comments on commit 85af640

Please sign in to comment.