Skip to content

Commit

Permalink
Merge branch 'develop' into feature/development/AnalysisOfEndpointCon…
Browse files Browse the repository at this point in the history
…nectionsConfigFile
  • Loading branch information
Jan-Thurner authored Sep 30, 2024
2 parents 75b98dd + 4932dc9 commit 44c1207
Show file tree
Hide file tree
Showing 53 changed files with 268 additions and 299 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Refer to [Using JHipster in production](http://www.jhipster.tech/production) for
The following command can automate the deployment to a server. The example shows the deployment to the main Artemis test server (which runs a virtual machine):

```shell
./artemis-server-cli deploy username@artemistest.ase.in.tum.de -w build/libs/Artemis-7.5.5.war
./artemis-server-cli deploy username@artemistest.ase.in.tum.de -w build/libs/Artemis-7.5.6.war
```

## Architecture
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
}

group = "de.tum.cit.aet.artemis"
version = "7.5.5"
version = "7.5.6"
description = "Interactive Learning with Individual Feedback"

java {
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/telemetry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Example configuration in `application-prod.yml`:
telemetry:
enabled: true
sendAdminDetails: false
destination: telemetry.artemis.cit.tum.de
destination: https://telemetry.artemis.cit.tum.de
info:
contact: contactMailAddress@cit.tum.de
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "artemis",
"version": "7.5.5",
"version": "7.5.6",
"description": "Interactive Learning with Individual Feedback",
"private": true,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void setLocalVCBaseUrl(URL localVCBaseUrl) {

// Cache the retrieved repositories for quicker access.
// The resolveRepository method is called multiple times per request.
// Key: repositoryPath --> Value: Repository
private final Map<String, Repository> repositories = new HashMap<>();

public LocalVCServletService(AuthenticationManager authenticationManager, UserRepository userRepository, ProgrammingExerciseRepository programmingExerciseRepository,
Expand Down Expand Up @@ -441,18 +442,23 @@ public void authorizeUser(String repositoryTypeOrUserName, User user, Programmin
catch (AccessForbiddenException e) {
throw new LocalVCForbiddenException(e);
}
// TODO: retrieving the git commit hash should be done ASYNC together with storing the log in the database to avoid long waiting times during permission check
String commitHash = null;
try {
if (repositoryActionType == RepositoryActionType.READ) {
commitHash = getLatestCommitHash(repositories.get(localVCRepositoryUri.getRelativeRepositoryPath().toString()));
String relativeRepositoryPath = localVCRepositoryUri.getRelativeRepositoryPath().toString();
try (Repository repository = resolveRepository(relativeRepositoryPath)) {
commitHash = getLatestCommitHash(repository);
}
}
// Write a access log entry to the database
String finalCommitHash = commitHash;
vcsAccessLogService.ifPresent(service -> service.storeAccessLog(user, participation, repositoryActionType, authenticationMechanism, finalCommitHash, ipAddress));
}
catch (GitAPIException e) {
log.warn("Failed to obtain commit hash for repository {}. Error: {}", localVCRepositoryUri.getRelativeRepositoryPath().toString(), e.getMessage());
// NOTE: we intentionally catch all issues here to avoid that the user is blocked from accessing the repository
catch (Exception e) {
log.warn("Failed to obtain commit hash or store access log for repository {}. Error: {}", localVCRepositoryUri.getRelativeRepositoryPath().toString(), e.getMessage());
}
// Write a access log entry to the database
String finalCommitHash = commitHash;
vcsAccessLogService.ifPresent(service -> service.storeAccessLog(user, participation, repositoryActionType, authenticationMechanism, finalCommitHash, ipAddress));
}

/**
Expand Down Expand Up @@ -520,9 +526,16 @@ public void processNewPush(String commitHash, Repository repository) {
// Process push to any repository other than the test repository.
processNewPushToRepository(participation, commit);

// For push the correct commitHash is only available here, therefore the preliminary null value is overwritten
String finalCommitHash = commitHash;
vcsAccessLogService.ifPresent(service -> service.updateCommitHash(participation, finalCommitHash));
try {
// For push the correct commitHash is only available here, therefore the preliminary null value is overwritten
String finalCommitHash = commitHash;
vcsAccessLogService.ifPresent(service -> service.updateCommitHash(participation, finalCommitHash));
}
// NOTE: we intentionally catch all issues here to avoid that the user is blocked from accessing the repository
catch (Exception e) {
log.warn("Failed to obtain commit hash or store access log for repository {}. Error: {}", localVCRepositoryUri.getRelativeRepositoryPath().toString(),
e.getMessage());
}
}
catch (GitAPIException | IOException e) {
// This catch clause does not catch exceptions that happen during runBuildJob() as that method is called asynchronously.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class VcsAccessLogService {
* @param commitHash The latest commit hash
* @param ipAddress The ip address of the user accessing the repository
*/
// TODO: this should be ASYNC to avoid long waiting times during permission check
public void storeAccessLog(User user, ProgrammingExerciseParticipation participation, RepositoryActionType actionType, AuthenticationMechanism authenticationMechanism,
String commitHash, String ipAddress) {
log.debug("Storing access operation for user {}", user);
Expand All @@ -59,6 +60,7 @@ public void storeAccessLog(User user, ProgrammingExerciseParticipation participa
* @param participation The participation to which the repository belongs to
* @param commitHash The newest commit hash which should get set for the access log entry
*/
// TODO: this should be ASYNC to avoid long waiting times during permission check
public void updateCommitHash(ProgrammingExerciseParticipation participation, String commitHash) {
vcsAccessLogRepository.findNewestByParticipationIdWhereCommitHashIsNull(participation.getId()).ifPresent(entry -> {
entry.setCommitHash(commitHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -27,7 +26,6 @@
import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation;
import de.tum.cit.aet.artemis.exercise.service.ParticipationService;
import de.tum.cit.aet.artemis.quiz.domain.QuizExercise;
import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission;
import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository;
import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository;
import de.tum.cit.aet.artemis.quiz.repository.SubmittedAnswerRepository;
Expand Down Expand Up @@ -92,18 +90,9 @@ public ResponseEntity<MappingJacksonValue> startParticipation(@PathVariable Long

StudentParticipation participation = participationService.startExercise(exercise, user, true);

Optional<Result> optionalResult = resultRepository.findFirstByParticipationIdAndRatedOrderByCompletionDateDesc(participation.getId(), true);
Result result;
if (optionalResult.isPresent()) {
var quizSubmission = (QuizSubmission) optionalResult.get().getSubmission();
var submittedAnswers = submittedAnswerRepository.findBySubmission(quizSubmission);
quizSubmission.setSubmittedAnswers(submittedAnswers);
result = optionalResult.get();
}
else {
result = new Result();
result.setSubmission(quizSubmissionRepository.findWithEagerSubmittedAnswersByParticipationId(participation.getId()).orElseThrow());
}
// NOTE: starting exercise prevents that two participation will exist, but ensures that a submission is created
var result = resultRepository.findFirstByParticipationIdAndRatedOrderByCompletionDateDesc(participation.getId(), true).orElse(new Result());
result.setSubmission(quizSubmissionRepository.findWithEagerSubmittedAnswersByParticipationId(participation.getId()).orElseThrow());

participation.setResults(Set.of(result));
participation.setExercise(exercise);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ artemis:
telemetry:
enabled: false # Disable sending any telemetry information to the telemetry service by setting this to false
sendAdminDetails: false # Include the admins email and name in the telemetry data. Set to false to disable
destination: telemetry.artemis.cit.tum.de
destination: https://telemetry.artemis.cit.tum.de
2 changes: 1 addition & 1 deletion src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ artemis:
telemetry:
enabled: true # Disable sending any telemetry information to the telemetry service by setting this to false
sendAdminDetails: true # Include personal identifiable information of the admin, including email and name in the telemetry data
destination: telemetry.artemis.cit.tum.de
destination: https://telemetry.artemis.cit.tum.de

spring:
devtools:
Expand Down
29 changes: 0 additions & 29 deletions src/main/webapp/app/account/account.module.ts

This file was deleted.

67 changes: 0 additions & 67 deletions src/main/webapp/app/account/account.route.ts

This file was deleted.

19 changes: 10 additions & 9 deletions src/main/webapp/app/account/activate/activate.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { ActivateService } from './activate.service';
import { ProfileService } from 'app/shared/layouts/profiles/profile.service';
import { mergeMap } from 'rxjs/operators';
import { TranslateDirective } from 'app/shared/language/translate.directive';

@Component({
selector: 'jhi-activate',
templateUrl: './activate.component.html',
standalone: true,
imports: [TranslateDirective, RouterLink, ArtemisSharedModule],
})
export class ActivateComponent implements OnInit {
private activateService = inject(ActivateService);
private route = inject(ActivatedRoute);
private profileService = inject(ProfileService);

error = false;
success = false;
isRegistrationEnabled = false;

constructor(
private activateService: ActivateService,
private route: ActivatedRoute,
private profileService: ProfileService,
) {}

/**
* Checks if the user can be activated with ActivateService
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/account/activate/activate.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class ActivateService {
constructor(private http: HttpClient) {}
private http = inject(HttpClient);

/**
* Sends request to the server to activate the user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisSharedModule } from 'app/shared/shared.module';

@Component({
selector: 'jhi-external-user-password-reset-modal',
templateUrl: './external-user-password-reset-modal.component.html',
standalone: true,
imports: [TranslateDirective, ArtemisSharedModule],
})
export class ExternalUserPasswordResetModalComponent {
private activeModal = inject(NgbActiveModal);

externalCredentialProvider: string;
externalPasswordResetLink: string;

constructor(private activeModal: NgbActiveModal) {}

/**
* Closes the dialog, removes the query parameter and shows a helper message
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { PasswordStrengthBarComponent } from 'app/account/password/password-strength-bar.component';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { PasswordResetFinishService } from './password-reset-finish.service';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH } from 'app/app.constants';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';

@Component({
selector: 'jhi-password-reset-finish',
templateUrl: './password-reset-finish.component.html',
standalone: true,
imports: [TranslateDirective, RouterLink, FormsModule, ReactiveFormsModule, PasswordStrengthBarComponent, ArtemisSharedCommonModule, ArtemisSharedModule],
})
export class PasswordResetFinishComponent implements OnInit, AfterViewInit {
private passwordResetFinishService = inject(PasswordResetFinishService);
private route = inject(ActivatedRoute);
private fb = inject(FormBuilder);

@ViewChild('newPassword', { static: false })
newPassword?: ElementRef;

Expand All @@ -24,12 +33,6 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit {

passwordForm: FormGroup;

constructor(
private passwordResetFinishService: PasswordResetFinishService,
private route: ActivatedRoute,
private fb: FormBuilder,
) {}

ngOnInit() {
this.route.queryParams.subscribe((params) => {
if (params['key']) {
Expand Down
Loading

0 comments on commit 44c1207

Please sign in to comment.