Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rest): Create new Api's to track feedback, reverse svm match and schedule svm sync in schedule tab. #2269

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions rest/resource-server/src/docs/asciidoc/schedule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,102 @@ include::{snippets}/should_document_schedule_cve_search/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_schedule_cve_search/http-response.adoc[]

[[schedule-svmsync]]
==== Schedule svm sync for user.

A `POST` request will schedule svm sync for user.

===== Example request
include::{snippets}/should_document_schedule_svm_sync/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_schedule_svm_sync/http-response.adoc[]

[[unschedule-svmSync]]
==== Cancel schedule svm sync for user.

A `DELETE` request will cancel schedule svm sync for user.

===== Example request
include::{snippets}/should_document_cancel_schedule_svm_sync/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_cancel_schedule_svm_sync/http-response.adoc[]

[[reverse-svmmatch]]
==== Svm reverse match for user.

A `POST` request will reverse svm match.

===== Example request
include::{snippets}/should_document_reverse_svm_match/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_reverse_svm_match/http-response.adoc[]

[[unschedule-reversematch]]
==== Cancel reverse match for user.

A `DELETE` request will cancel the reverse match.

===== Example request
include::{snippets}/should_document_cancel_reverse_match/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_cancel_reverse_match/http-response.adoc[]

[[tracking-feedback]]
==== Tracking feedback for user.

A `POST` request will track the user feedback.

===== Example request
include::{snippets}/should_document_track_feedback/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_track_feedback/http-response.adoc[]

[[monitoring-listUpdate]]
==== Monitoring a svm list Update.

A `POST` request will update svm list.

===== Example request
include::{snippets}/should_document_svm_list_update/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_svm_list_update/http-response.adoc[]

[[cancel-monitoringlist]]
==== Cancel monitoring svm list and update.

A `DELETE` request will cancel the monitoring svm list and update.

===== Example request
include::{snippets}/should_document_cancel_monitoring_svm_list/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_cancel_monitoring_svm_list/http-response.adoc[]

[[src-upload]]
==== Source attachment upload service.

A `POST` request will upload the source attachment.

===== Example request
include::{snippets}/should_document_src_upload/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_src_upload/http-response.adoc[]

[[cancel-srcupload]]
==== Cancel source attachment upload service.

A `DELETE` request will cancel the src upload.

===== Example request
include::{snippets}/should_document_cancel_monitoring_cancel_svm_list/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_cancel_monitoring_cancel_svm_list/http-response.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@

import org.apache.thrift.TException;
import org.eclipse.sw360.datahandler.thrift.RequestStatus;
import org.eclipse.sw360.datahandler.thrift.RequestSummary;
import org.eclipse.sw360.datahandler.thrift.users.User;
import org.eclipse.sw360.rest.resourceserver.core.RestControllerHelper;
import org.eclipse.sw360.datahandler.thrift.RequestSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.BasePathAwareController;
import org.springframework.data.rest.webmvc.RepositoryLinksResource;
import org.springframework.hateoas.server.RepresentationModelProcessor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -50,7 +52,6 @@ public class ScheduleAdminController implements RepresentationModelProcessor<Rep
@NonNull
private Sw360ScheduleService scheduleService;


@Override
public RepositoryLinksResource process(RepositoryLinksResource resource) {
resource.add(linkTo(ScheduleAdminController.class).slash("api/schedule").withRel("schedule"));
Expand Down Expand Up @@ -88,12 +89,20 @@ public ResponseEntity<?> unscheduleAllServices()throws TException {
example = "SUCCESS")))
})
@PostMapping(SCHEDULE_URL + "/cveService")
public ResponseEntity<?> scheduleCve()throws TException {
public ResponseEntity<?> scheduleCve() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.scheduleCveSearch(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@RequestMapping(value = SCHEDULE_URL + "/scheduleSvmSync", method = RequestMethod.POST)
public ResponseEntity<?> scheduleSvmSync()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.svmSync(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@Operation(
summary = "Unschedule the CVE service.",
Expand All @@ -107,12 +116,19 @@ public ResponseEntity<?> scheduleCve()throws TException {
example = "SUCCESS")))
})
@PostMapping(SCHEDULE_URL + "/unscheduleCve")
public ResponseEntity<?> unscheduleCveSearch()throws TException {
public ResponseEntity<?> unscheduleCveSearch() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.cancelCveSearch(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}
@RequestMapping(value = SCHEDULE_URL + "/unscheduleSvmSync", method = RequestMethod.DELETE)
public ResponseEntity<?> unscheduleSvmSync() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.cancelSvmSync(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}

@Operation(
summary = "Schedule the attachment deletion service.",
Expand All @@ -126,13 +142,21 @@ public ResponseEntity<?> unscheduleCveSearch()throws TException {
example = "SUCCESS")))
})
@PostMapping(SCHEDULE_URL + "/deleteAttachment")
public ResponseEntity<?> scheduleDeleteAttachment()throws TException {
public ResponseEntity<?> scheduleDeleteAttachment() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.deleteAttachmentService(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@RequestMapping(value = SCHEDULE_URL + "/svmReverseMatch", method = RequestMethod.POST)
public ResponseEntity<?> svmReverseMatch() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.scheduleSvmReverseMatch(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@Operation(
summary = "Unschedule the attachment deletion service.",
description = "Unschedule the service for attachment deletion from local FS.",
Expand All @@ -144,6 +168,7 @@ public ResponseEntity<?> scheduleDeleteAttachment()throws TException {
schema = @Schema(implementation = String.class,
example = "SUCCESS")))
})

@PostMapping(SCHEDULE_URL + "/unScheduleDeleteAttachment")
public ResponseEntity<?> unscheduleDeleteAttachment()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
Expand All @@ -152,6 +177,14 @@ public ResponseEntity<?> unscheduleDeleteAttachment()throws TException {
return new ResponseEntity<>(requestStatus, status);
}

@RequestMapping(value = SCHEDULE_URL + "/unscheduleSvmReverseMatch", method = RequestMethod.DELETE)
public ResponseEntity<?> unscheduleSvmReverseMatch()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.cancelSvmReverseMatch(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}

@Operation(
summary = "Cancel the attachment deletion service.",
description = "Cancel service for attachment deletion from local FS.",
Expand All @@ -164,13 +197,37 @@ public ResponseEntity<?> unscheduleDeleteAttachment()throws TException {
example = "SUCCESS")))
})
@PostMapping(SCHEDULE_URL + "/cancelAttachmentDeletion")
public ResponseEntity<?> attachmentDeleteLocalFS()throws TException {
public ResponseEntity<?> attachmentDeleteLocalFS() throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.cancelAttachmentDeletionLocalFS(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}

@RequestMapping(value = SCHEDULE_URL + "/trackingFeedback", method = RequestMethod.POST)
public ResponseEntity<?> svmTrackingFeedback()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.svmReleaseTrackingFeedback(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@RequestMapping(value = SCHEDULE_URL + "/monitoringListUpdate", method = RequestMethod.POST)
public ResponseEntity<?> monitoringListUpdate()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.svmMonitoringListUpdate(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@RequestMapping(value = SCHEDULE_URL + "/cancelMonitoringListUpdate", method = RequestMethod.DELETE)
public ResponseEntity<?> cancelMonitoringListUpdate()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.cancelSvmMonitoringListUpdate(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}

@Operation(
summary = "Schedule the CVE search.",
description = "Schedule the CVE search.",
Expand All @@ -189,4 +246,20 @@ public ResponseEntity<?> cveSearch()throws TException {
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}

@RequestMapping(value = SCHEDULE_URL + "/srcUpload", method = RequestMethod.POST)
public ResponseEntity<?> srcUpload()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestSummary requestSummary = scheduleService.triggeSrcUpload(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestSummary, status);
}

@RequestMapping(value = SCHEDULE_URL + "/cancelSrcUpload", method = RequestMethod.DELETE)
public ResponseEntity<?> cancelsrcUpload()throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
RequestStatus requestStatus = scheduleService.unscheduleSrcUpload(sw360User);
HttpStatus status = HttpStatus.ACCEPTED;
return new ResponseEntity<>(requestStatus, status);
}
}
Loading