Skip to content

Commit

Permalink
added improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer committed Sep 22, 2024
1 parent f9a3472 commit fdac5df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
@Profile(PROFILE_CORE)
@RestController
@RequestMapping("api/")
@RequestMapping("api/auxiliary-repository/")
public class AuxiliaryRepositoryResource extends RepositoryResource {

private final AuxiliaryRepositoryRepository auxiliaryRepositoryRepository;
Expand All @@ -72,7 +72,7 @@ public AuxiliaryRepositoryResource(ProfileService profileService, UserRepository
Repository getRepository(Long auxiliaryRepositoryId, RepositoryActionType repositoryActionType, boolean pullOnGet) throws GitAPIException {
final var auxiliaryRepository = auxiliaryRepositoryRepository.findByIdElseThrow(auxiliaryRepositoryId);
User user = userRepository.getUserWithGroupsAndAuthorities();
repositoryAccessService.checkAccessTestOrAuxRepositoryElseThrow(false, auxiliaryRepository.getExercise(), user, "test");
repositoryAccessService.checkAccessTestOrAuxRepositoryElseThrow(false, auxiliaryRepository.getExercise(), user, "auxiliary");
final var repoUri = auxiliaryRepository.getVcsRepositoryUri();
return gitService.getOrCheckoutRepository(repoUri, pullOnGet);
}
Expand Down Expand Up @@ -103,76 +103,76 @@ String getOrRetrieveBranchOfDomainObject(Long auxiliaryRepositoryId) {
}

@Override
@GetMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/files", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "{auxiliaryRepositoryId}/files", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
public ResponseEntity<Map<String, FileType>> getFiles(@PathVariable Long auxiliaryRepositoryId) {
return super.getFiles(auxiliaryRepositoryId);
}

@Override
@GetMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping(value = "{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@EnforceAtLeastTutor
public ResponseEntity<byte[]> getFile(@PathVariable Long auxiliaryRepositoryId, @RequestParam("file") String filename) {
return super.getFile(auxiliaryRepositoryId, filename);
}

@Override
@PostMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> createFile(@PathVariable Long auxiliaryRepositoryId, @RequestParam("file") String filePath, HttpServletRequest request) {
return super.createFile(auxiliaryRepositoryId, filePath, request);
}

@Override
@PostMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/folder", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "{auxiliaryRepositoryId}/folder", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> createFolder(@PathVariable Long auxiliaryRepositoryId, @RequestParam("folder") String folderPath, HttpServletRequest request) {
return super.createFolder(auxiliaryRepositoryId, folderPath, request);
}

@Override
@PostMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/rename-file", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "{auxiliaryRepositoryId}/rename-file", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> renameFile(@PathVariable Long auxiliaryRepositoryId, @RequestBody FileMove fileMove) {
return super.renameFile(auxiliaryRepositoryId, fileMove);
}

@Override
@DeleteMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping(value = "{auxiliaryRepositoryId}/file", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> deleteFile(@PathVariable Long auxiliaryRepositoryId, @RequestParam("file") String filename) {
return super.deleteFile(auxiliaryRepositoryId, filename);
}

@Override
@GetMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/pull", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "{auxiliaryRepositoryId}/pull", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
public ResponseEntity<Void> pullChanges(@PathVariable Long auxiliaryRepositoryId) {
return super.pullChanges(auxiliaryRepositoryId);
}

@Override
@PostMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/commit", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "{auxiliaryRepositoryId}/commit", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> commitChanges(@PathVariable Long auxiliaryRepositoryId) {
return super.commitChanges(auxiliaryRepositoryId);
}

@Override
@PostMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}/reset", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "{auxiliaryRepositoryId}/reset", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Void> resetToLastCommit(@PathVariable Long auxiliaryRepositoryId) {
return super.resetToLastCommit(auxiliaryRepositoryId);
}

@Override
@GetMapping(value = "auxiliary-repository/{auxiliaryRepositoryId}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "{auxiliaryRepositoryId}", produces = MediaType.APPLICATION_JSON_VALUE)
@EnforceAtLeastTutor
public ResponseEntity<RepositoryStatusDTO> getStatus(@PathVariable Long auxiliaryRepositoryId) throws GitAPIException {
return super.getStatus(auxiliaryRepositoryId);
Expand All @@ -187,16 +187,16 @@ public ResponseEntity<RepositoryStatusDTO> getStatus(@PathVariable Long auxiliar
* @param principal used to check if the user can update the files
* @return {Map<String, String>} file submissions or the appropriate http error
*/
@PutMapping("auxiliary-repository/{auxiliaryRepositoryId}/files")
@PutMapping("{auxiliaryRepositoryId}/files")
@EnforceAtLeastTutor
public ResponseEntity<Map<String, String>> updateTestFiles(@PathVariable("auxiliaryRepositoryId") Long auxiliaryRepositoryId, @RequestBody List<FileSubmission> submissions,
@RequestParam Boolean commit, Principal principal) {
public ResponseEntity<Map<String, String>> updateAuxiliaryFiles(@PathVariable("auxiliaryRepositoryId") Long auxiliaryRepositoryId,
@RequestBody List<FileSubmission> submissions, @RequestParam Boolean commit, Principal principal) {

if (versionControlService.isEmpty()) {
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "VCSNotPresent");
}
AuxiliaryRepository auxiliaryRepository = auxiliaryRepositoryRepository.findByIdElseThrow(auxiliaryRepositoryId);
ProgrammingExercise exercise = programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(auxiliaryRepository.getExercise().getId());
ProgrammingExercise exercise = auxiliaryRepository.getExercise();

Repository repository;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ export class ProgrammingExerciseParticipationService implements IProgrammingExer
* @param repositoryType the repositories type
* @param auxiliaryRepositoryId the id of the repository
*/
retrieveCommitHistoryForAuxiliaryRepository(exerciseId: number, repositoryType: string, auxiliaryRepositoryId: number): Observable<CommitInfo[]> {
retrieveCommitHistoryForAuxiliaryRepository(exerciseId: number, auxiliaryRepositoryId: number): Observable<CommitInfo[]> {
const params: { [key: string]: number } = {};
params['repositoryId'] = auxiliaryRepositoryId;
return this.http.get<CommitInfo[]>(`${this.resourceUrl}${exerciseId}/commit-history/${repositoryType}`, { params: params });
return this.http.get<CommitInfo[]>(`${this.resourceUrl}${exerciseId}/commit-history/AUXILIARY`, { params: params });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class CommitHistoryComponent implements OnInit, OnDestroy {
*/
private handleAuxiliaryRepositoryCommits() {
this.commitsInfoSubscription = this.programmingExerciseParticipationService
.retrieveCommitHistoryForAuxiliaryRepository(this.exerciseId, this.repositoryType, this.repositoryId!)
.retrieveCommitHistoryForAuxiliaryRepository(this.exerciseId, this.repositoryId!)
.subscribe((commits) => {
this.commits = this.sortCommitsByTimestampDesc(commits);
});
Expand Down

0 comments on commit fdac5df

Please sign in to comment.