Skip to content

Commit

Permalink
feat(rest): API to get vulnerability tracking status
Browse files Browse the repository at this point in the history
Signed-off-by: Keerthi B L <[email protected]>
  • Loading branch information
keerthi-bl committed Aug 23, 2023
1 parent 16dae1a commit 546e622
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ include::{snippets}/should_document_delete_release_vulnerability_relation/http-r
[[resources-vulnerabilitie-get-status]]
==== Get a vulnerability tracking status

A `GET` request will get vulnerability tracking status.
A `GET` request will get vulnerability tracking status for project.

===== Example request
include::{snippets}/should_document_get_vulnerabilities_tracking_status/curl-request.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public enum VulnerabilityOperation {
CREATE, UPDATE, DELETE;
}

public List<ReleaseClearingStatusData> getReleaseClearingStatusesWithAccessibility(User user, String projectId)
public List<ReleaseClearingStatusData> getReleasesClearingStatusWithAccessibility(User user, String projectId)
throws TException {
ProjectService.Iface sw360ProjectClient = new ThriftClients().makeProjectClient();
return sw360ProjectClient.getReleaseClearingStatusesWithAccessibility(projectId, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,25 +366,25 @@ private Set<Release> getReleaseRelationsInfo(Vulnerability vulnerability, User u
return releaseList;
}

@GetMapping(value = VULNERABILITIES_URL + "/trackingstatus" + "/{projectid}")
public void getVulnerabilitiesTrackingStatus(@PathVariable("projectid") String projectId,
@GetMapping(value = VULNERABILITIES_URL + "/trackingStatus" + "/{projectId}")
public void getVulnerabilitiesTrackingStatus(@PathVariable("projectId") String projectId,
HttpServletResponse response) throws TException, IOException {
List<JsonObject> resultJson = new ArrayList<>();
try {
User user = restControllerHelper.getSw360UserFromAuthentication();
List<ReleaseClearingStatusData> releaseClearingStatusList = vulnerabilityService
.getReleaseClearingStatusesWithAccessibility(user, projectId);
.getReleasesClearingStatusWithAccessibility(user, projectId);
releaseClearingStatusList.forEach(rel -> {
if (rel.getRelease() != null) {
JsonObject jobj = new JsonObject();
jobj.addProperty("releaseid", rel.getRelease().getId());
jobj.addProperty("releaseId", rel.getRelease().getId());
jobj.addProperty("name", rel.getRelease().getName());
jobj.addProperty("projectorigin", rel.getProjectNames());
jobj.addProperty("svmtrackingstatus",
jobj.addProperty("projectOrigin", rel.getProjectNames());
jobj.addProperty("svmTrackingStatus",
null != rel.getRelease().getExternalIds() && !rel.getRelease().getExternalIds().equals("")
? rel.getRelease().getExternalIds().get("svmComponentId")
: "");
jobj.addProperty("shortstatus",
jobj.addProperty("shortStatus",
null != rel.getRelease().getAdditionalData()
&& !rel.getRelease().getAdditionalData().equals("")
? rel.getRelease().getAdditionalData().get("svmShortStatus")
Expand All @@ -396,6 +396,8 @@ public void getVulnerabilitiesTrackingStatus(@PathVariable("projectid") String p
response.getWriter().write(resultJson.toString());
} catch (SW360Exception e) {
throw new TException(e.why);
}catch(Exception ex) {
throw new TException(ex.getMessage());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public void should_document_create_release_vulnerability_relation() throws Excep
@Test
public void should_document_get_vulnerabilities_tracking_status() throws Exception {
String accessToken = TestHelper.getAccessToken(mockMvc, testUserId, testUserPassword);
mockMvc.perform(get("/api/vulnerabilities/trackingstatus/" + project.getId())
mockMvc.perform(get("/api/vulnerabilities/trackingStatus/" + project.getId())
.header("Authorization", "Bearer " + accessToken).accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk()).andDo(this.documentationHandler.document());
}
Expand Down

0 comments on commit 546e622

Please sign in to comment.