Skip to content

Commit

Permalink
Development: Add check for REST endpoints to be in kebab case (#9210)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Oct 3, 2024
1 parent 93138e3 commit ad160ff
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,14 @@ else if (courseUpdate.getCourseIcon() == null && existingCourse.getCourseIcon()
}

/**
* PUT courses/:courseId/onlineCourseConfiguration : Updates the onlineCourseConfiguration for the given course.
* PUT courses/:courseId/online-course-configuration : Updates the onlineCourseConfiguration for the given course.
*
* @param courseId the id of the course to update
* @param onlineCourseConfiguration the online course configuration to update
* @return the ResponseEntity with status 200 (OK) and with body the updated online course configuration
*/
// TODO: move into LTIResource
@PutMapping("courses/{courseId}/onlineCourseConfiguration")
@PutMapping("courses/{courseId}/online-course-configuration")
@EnforceAtLeastInstructor
@Profile(PROFILE_LTI)
public ResponseEntity<OnlineCourseConfiguration> updateOnlineCourseConfiguration(@PathVariable Long courseId,
Expand Down Expand Up @@ -821,12 +821,12 @@ public ResponseEntity<Course> getCourseWithOrganizations(@PathVariable Long cour
}

/**
* GET /courses/:courseId/lockedSubmissions Get locked submissions for course for user
* GET /courses/:courseId/locked-submissions Get locked submissions for course for user
*
* @param courseId the id of the course
* @return the ResponseEntity with status 200 (OK) and with body the course, or with status 404 (Not Found)
*/
@GetMapping("courses/{courseId}/lockedSubmissions")
@GetMapping("courses/{courseId}/locked-submissions")
@EnforceAtLeastTutor
public ResponseEntity<List<Submission>> getLockedSubmissionsForCourse(@PathVariable Long courseId) {
log.debug("REST request to get all locked submissions for course : {}", courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,13 +1170,13 @@ public ResponseEntity<ExamInformationDTO> getLatestIndividualEndDateOfExam(@Path
}

/**
* GET /courses/:courseId/exams/:examId/lockedSubmissions Get locked submissions for exam for user
* GET /courses/:courseId/exams/:examId/locked-submissions Get locked submissions for exam for user
*
* @param courseId - the id of the course
* @param examId - the id of the exam
* @return the ResponseEntity with status 200 (OK) and with body the course, or with status 404 (Not Found)
*/
@GetMapping("courses/{courseId}/exams/{examId}/lockedSubmissions")
@GetMapping("courses/{courseId}/exams/{examId}/locked-submissions")
@EnforceAtLeastInstructor
public ResponseEntity<List<Submission>> getLockedSubmissionsForExam(@PathVariable Long courseId, @PathVariable Long examId) {
log.debug("REST request to get all locked submissions for course : {}", courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public ExerciseGroupResource(ExerciseGroupRepository exerciseGroupRepository, Ex
}

/**
* POST /courses/{courseId}/exams/{examId}/exerciseGroups : Create a new exercise group.
* POST /courses/{courseId}/exams/{examId}/exercise-groups : Create a new exercise group.
*
* @param courseId the course to which the exercise group belongs to
* @param examId the exam to which the exercise group belongs to
Expand All @@ -92,7 +92,7 @@ public ExerciseGroupResource(ExerciseGroupRepository exerciseGroupRepository, Ex
* or with status 400 (Bad Request) if the exerciseGroup has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("courses/{courseId}/exams/{examId}/exerciseGroups")
@PostMapping("courses/{courseId}/exams/{examId}/exercise-groups")
@EnforceAtLeastEditor
public ResponseEntity<ExerciseGroup> createExerciseGroup(@PathVariable Long courseId, @PathVariable Long examId, @RequestBody ExerciseGroup exerciseGroup)
throws URISyntaxException {
Expand All @@ -117,19 +117,19 @@ public ResponseEntity<ExerciseGroup> createExerciseGroup(@PathVariable Long cour
Exam savedExam = examRepository.save(examFromDB);
ExerciseGroup savedExerciseGroup = savedExam.getExerciseGroups().getLast();

return ResponseEntity.created(new URI("/api/courses/" + courseId + "/exams/" + examId + "/exerciseGroups/" + savedExerciseGroup.getId())).body(savedExerciseGroup);
return ResponseEntity.created(new URI("/api/courses/" + courseId + "/exams/" + examId + "/exercise-groups/" + savedExerciseGroup.getId())).body(savedExerciseGroup);
}

/**
* PUT /courses/{courseId}/exams/{examId}/exerciseGroups : Update an existing exercise group.
* PUT /courses/{courseId}/exams/{examId}/exercise-groups : Update an existing exercise group.
*
* @param courseId the course to which the exercise group belongs to
* @param examId the exam to which the exercise group belongs to
* @param updatedExerciseGroup the exercise group to update
* @return the ResponseEntity with status 200 (OK) and with the body of the updated exercise group
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("courses/{courseId}/exams/{examId}/exerciseGroups")
@PutMapping("courses/{courseId}/exams/{examId}/exercise-groups")
@EnforceAtLeastEditor
public ResponseEntity<ExerciseGroup> updateExerciseGroup(@PathVariable Long courseId, @PathVariable Long examId, @RequestBody ExerciseGroup updatedExerciseGroup)
throws URISyntaxException {
Expand Down Expand Up @@ -170,14 +170,14 @@ public ResponseEntity<List<ExerciseGroup>> importExerciseGroup(@PathVariable Lon
}

/**
* GET /courses/{courseId}/exams/{examId}/exerciseGroups/{exerciseGroupId} : Find an exercise group by id.
* GET /courses/{courseId}/exams/{examId}/exercise-groups/{exerciseGroupId} : Find an exercise group by id.
*
* @param courseId the course to which the exercise group belongs to
* @param examId the exam to which the exercise group belongs to
* @param exerciseGroupId the id of the exercise group to find
* @return the ResponseEntity with status 200 (OK) and with the found exercise group as body
*/
@GetMapping("courses/{courseId}/exams/{examId}/exerciseGroups/{exerciseGroupId}")
@GetMapping("courses/{courseId}/exams/{examId}/exercise-groups/{exerciseGroupId}")
@EnforceAtLeastEditor
public ResponseEntity<ExerciseGroup> getExerciseGroup(@PathVariable Long courseId, @PathVariable Long examId, @PathVariable Long exerciseGroupId) {
log.debug("REST request to get exercise group : {}", exerciseGroupId);
Expand All @@ -189,13 +189,13 @@ public ResponseEntity<ExerciseGroup> getExerciseGroup(@PathVariable Long courseI
}

/**
* GET courses/{courseId}/exams/{examId}/exerciseGroups : Get all exercise groups of the given exam
* GET courses/{courseId}/exams/{examId}/exercise-groups : Get all exercise groups of the given exam
*
* @param courseId the course to which the exercise groups belong to
* @param examId the exam to which the exercise groups belong to
* @return the ResponseEntity with status 200 (OK) and a list of exercise groups. The list can be empty
*/
@GetMapping("courses/{courseId}/exams/{examId}/exerciseGroups")
@GetMapping("courses/{courseId}/exams/{examId}/exercise-groups")
@EnforceAtLeastEditor
public ResponseEntity<List<ExerciseGroup>> getExerciseGroupsForExam(@PathVariable Long courseId, @PathVariable Long examId) {
log.debug("REST request to get all exercise groups for exam : {}", examId);
Expand All @@ -207,7 +207,7 @@ public ResponseEntity<List<ExerciseGroup>> getExerciseGroupsForExam(@PathVariabl
}

/**
* DELETE /courses/{courseId}/exams/{examId}/exerciseGroups/{exerciseGroupId} : Delete the exercise group with the given id.
* DELETE /courses/{courseId}/exams/{examId}/exercise-groups/{exerciseGroupId} : Delete the exercise group with the given id.
*
* @param courseId the course to which the exercise group belongs to
* @param examId the exam to which the exercise group belongs to
Expand All @@ -218,7 +218,7 @@ public ResponseEntity<List<ExerciseGroup>> getExerciseGroupsForExam(@PathVariabl
* LocalCI, it does not make sense to keep these artifacts
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("courses/{courseId}/exams/{examId}/exerciseGroups/{exerciseGroupId}")
@DeleteMapping("courses/{courseId}/exams/{examId}/exercise-groups/{exerciseGroupId}")
@EnforceAtLeastInstructor
public ResponseEntity<Void> deleteExerciseGroup(@PathVariable Long courseId, @PathVariable Long examId, @PathVariable Long exerciseGroupId,
@RequestParam(defaultValue = "true") boolean deleteStudentReposBuildPlans, @RequestParam(defaultValue = "true") boolean deleteBaseReposBuildPlans) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public ResponseEntity<List<StudentParticipation>> getAllParticipationsForCourse(
* @param participationId the participationId of the participation to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the participation, or with status 404 (Not Found)
*/
@GetMapping("participations/{participationId}/withLatestResult")
@GetMapping("participations/{participationId}/with-latest-result")
@EnforceAtLeastStudent
public ResponseEntity<StudentParticipation> getParticipationWithLatestResult(@PathVariable Long participationId) {
log.debug("REST request to get Participation : {}", participationId);
Expand Down Expand Up @@ -756,7 +756,7 @@ public ResponseEntity<StudentParticipation> getParticipationForCurrentUser(@Path
* @param participationId The participationId of the participation
* @return The latest build artifact (JAR/WAR) for the participation
*/
@GetMapping("participations/{participationId}/buildArtifact")
@GetMapping("participations/{participationId}/build-artifact")
@EnforceAtLeastStudent
public ResponseEntity<byte[]> getParticipationBuildArtifact(@PathVariable Long participationId) {
log.debug("REST request to get Participation build artifact: {}", participationId);
Expand Down Expand Up @@ -931,14 +931,14 @@ private ResponseEntity<Void> deleteParticipation(StudentParticipation participat
}

/**
* DELETE /participations/:participationId : remove the build plan of the ProgrammingExerciseStudentParticipation of the "participationId".
* DELETE /participations/:participationId/cleanup-build-plan : remove the build plan of the ProgrammingExerciseStudentParticipation of the "participationId".
* This only works for programming exercises.
*
* @param participationId the participationId of the ProgrammingExerciseStudentParticipation for which the build plan should be removed
* @param principal The identity of the user accessing this resource
* @return the ResponseEntity with status 200 (OK)
*/
@PutMapping("participations/{participationId}/cleanupBuildPlan")
@PutMapping("participations/{participationId}/cleanup-build-plan")
@EnforceAtLeastInstructor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<Participation> cleanupBuildPlan(@PathVariable Long participationId, Principal principal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public ResponseEntity<String> getAeolusTemplate(@PathVariable ProgrammingLanguag
}

/**
* GET /api/aeolus/templates/:language/:projectType : Get the aeolus template file with the given filename<br/>
* GET /api/aeolus/templates/:language : Get the aeolus template file with the given filename
* GET /api/aeolus/template-scripts/:language/:projectType : Get the aeolus template file with the given filename<br/>
* GET /api/aeolus/template-scripts/:language : Get the aeolus template file with the given filename
* <p>
* The windfile contains the default build plan configuration for new programming exercises.
*
Expand All @@ -91,7 +91,7 @@ public ResponseEntity<String> getAeolusTemplate(@PathVariable ProgrammingLanguag
* @param testCoverage Whether the test coverage template should be used
* @return The requested file, or 404 if the file doesn't exist
*/
@GetMapping({ "templateScripts/{language}/{projectType}", "templateScripts/{language}" })
@GetMapping({ "template-scripts/{language}/{projectType}", "template-scripts/{language}" })
@EnforceAtLeastEditor
public ResponseEntity<String> getAeolusTemplateScript(@PathVariable ProgrammingLanguage language, @PathVariable Optional<ProjectType> projectType,
@RequestParam(value = "staticAnalysis", defaultValue = "false") boolean staticAnalysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CourseManagementService {
* @param onlineCourseConfiguration - the updates to the online course configuration
*/
updateOnlineCourseConfiguration(courseId: number, onlineCourseConfiguration: OnlineCourseConfiguration): Observable<EntityResponseType> {
return this.http.put<OnlineCourseConfiguration>(`${this.resourceUrl}/${courseId}/onlineCourseConfiguration`, onlineCourseConfiguration, { observe: 'response' });
return this.http.put<OnlineCourseConfiguration>(`${this.resourceUrl}/${courseId}/online-course-configuration`, onlineCourseConfiguration, { observe: 'response' });
}

findAllOnlineCoursesWithRegistrationId(clientId: string): Observable<OnlineCourseDtoModel[]> {
Expand Down Expand Up @@ -442,7 +442,7 @@ export class CourseManagementService {
* @param {number} courseId - The id of the course to be searched for
*/
findAllLockedSubmissionsOfCourse(courseId: number): Observable<HttpResponse<Submission[]>> {
return this.http.get<Submission[]>(`${this.resourceUrl}/${courseId}/lockedSubmissions`, { observe: 'response' }).pipe(
return this.http.get<Submission[]>(`${this.resourceUrl}/${courseId}/locked-submissions`, { observe: 'response' }).pipe(
filter((res) => !!res.body),
tap((res) => reconnectSubmissions(res.body!)),
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/exam/manage/exam-management.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export class ExamManagementService {
}

findAllLockedSubmissionsOfExam(courseId: number, examId: number) {
return this.http.get<Submission[]>(`${this.resourceUrl}/${courseId}/exams/${examId}/lockedSubmissions`, { observe: 'response' }).pipe(
return this.http.get<Submission[]>(`${this.resourceUrl}/${courseId}/exams/${examId}/locked-submissions`, { observe: 'response' }).pipe(
filter((res) => !!res.body),
tap((res) => reconnectSubmissions(res.body!)),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ExerciseGroupService {
* @param exerciseGroup The exercise group to create.
*/
create(courseId: number, examId: number, exerciseGroup: ExerciseGroup): Observable<EntityResponseType> {
return this.http.post<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exerciseGroups`, exerciseGroup, { observe: 'response' });
return this.http.post<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exercise-groups`, exerciseGroup, { observe: 'response' });
}

/**
Expand All @@ -33,7 +33,7 @@ export class ExerciseGroupService {
* @param exerciseGroup The exercise group to update.
*/
update(courseId: number, examId: number, exerciseGroup: ExerciseGroup): Observable<EntityResponseType> {
return this.http.put<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exerciseGroups`, exerciseGroup, { observe: 'response' });
return this.http.put<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exercise-groups`, exerciseGroup, { observe: 'response' });
}

/**
Expand All @@ -43,7 +43,7 @@ export class ExerciseGroupService {
* @param exerciseGroupId The id of the exercise group to get.
*/
find(courseId: number, examId: number, exerciseGroupId: number): Observable<EntityResponseType> {
return this.http.get<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exerciseGroups/${exerciseGroupId}`, { observe: 'response' });
return this.http.get<ExerciseGroup>(`${this.resourceUrl}/${courseId}/exams/${examId}/exercise-groups/${exerciseGroupId}`, { observe: 'response' });
}

/**
Expand All @@ -60,7 +60,7 @@ export class ExerciseGroupService {
params = params.set('deleteStudentReposBuildPlans', deleteStudentReposBuildPlans.toString());
params = params.set('deleteBaseReposBuildPlans', deleteBaseReposBuildPlans.toString());
}
return this.http.delete<void>(`${this.resourceUrl}/${courseId}/exams/${examId}/exerciseGroups/${exerciseGroupId}`, { params, observe: 'response' });
return this.http.delete<void>(`${this.resourceUrl}/${courseId}/exams/${examId}/exercise-groups/${exerciseGroupId}`, { params, observe: 'response' });
}

/**
Expand All @@ -69,6 +69,6 @@ export class ExerciseGroupService {
* @param examId The exam id.
*/
findAllForExam(courseId: number, examId: number): Observable<EntityArrayResponseType> {
return this.http.get<ExerciseGroup[]>(`${this.resourceUrl}/${courseId}/exams/${examId}/exerciseGroups`, { observe: 'response' });
return this.http.get<ExerciseGroup[]>(`${this.resourceUrl}/${courseId}/exams/${examId}/exercise-groups`, { observe: 'response' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AeolusService {
*/
getAeolusTemplateScript(language: ProgrammingLanguage, projectType?: ProjectType, staticAnalysis?: boolean, sequentialRuns?: boolean, coverage?: boolean): Observable<string> {
const uriWithParams = this.buildURIWithParams(language, projectType, staticAnalysis, sequentialRuns, coverage);
return this.http.get<string>(`${this.resourceUrl}/templateScripts/` + uriWithParams.uri, {
return this.http.get<string>(`${this.resourceUrl}/template-scripts/` + uriWithParams.uri, {
responseType: 'text' as 'json',
params: uriWithParams.params,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ export class ParticipationService {
cleanupBuildPlan(participation: StudentParticipation): Observable<EntityResponseType> {
const copy = this.convertParticipationDatesFromClient(participation);
return this.http
.put<StudentParticipation>(`${this.resourceUrl}/${participation.id}/cleanupBuildPlan`, copy, { observe: 'response' })
.put<StudentParticipation>(`${this.resourceUrl}/${participation.id}/cleanup-build-plan`, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertParticipationResponseDatesFromServer(res)));
}

downloadArtifact(participationId: number): Observable<BuildArtifact> {
return this.http.get(`${this.resourceUrl}/${participationId}/buildArtifact`, { observe: 'response', responseType: 'blob' }).pipe(
return this.http.get(`${this.resourceUrl}/${participationId}/build-artifact`, { observe: 'response', responseType: 'blob' }).pipe(
map((res: EntityBlobResponseType) => {
const fileNameCandidate = (res.headers.get('content-disposition') || '').split('filename=')[1];
const fileName = fileNameCandidate ? fileNameCandidate.replace(/"/g, '') : 'artifact';
Expand Down
Loading

0 comments on commit ad160ff

Please sign in to comment.