Skip to content

Commit

Permalink
fix(rest): Added endpoint url for summary and administration page info
Browse files Browse the repository at this point in the history
Signed-off-by: Nikesh kumar <[email protected]>
  • Loading branch information
Nikesh kumar committed May 9, 2023
1 parent 2bcb618 commit 0c7d9de
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
17 changes: 17 additions & 0 deletions rest/resource-server/src/docs/asciidoc/projects.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,20 @@ include::{snippets}/should_document_import_sbom/curl-request.adoc[]

===== Example response
include::{snippets}/should_document_import_sbom/http-response.adoc[]
=======
[[resources-project-get-summary-administraion-project]]
==== Administration and Summary Info
A `GET` request will get summary and administration page of project tab.
===== Response structure
include::{snippets}/should_document_create_summary_administration/response-fields.adoc[]
===== Example request
include::{snippets}/should_document_create_summary_administration/curl-request.adoc[]
===== Example response
include::{snippets}/should_document_create_summary_administration/http-response.adoc[]
===== Links
include::{snippets}/should_document_create_summary_administration/links.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ public void addEmbeddedLeadArchitect(HalResource halResource, String leadArchite
User sw360User = getUserByEmail(leadArchitect);
addEmbeddedUser(halResource, sw360User, "leadArchitect");
}

public void addEmbeddedModifiedBy(HalResource halResource, String modifiedBy) {
User sw360User = getUserByEmail(modifiedBy);
addEmbeddedUser(halResource, sw360User, "modifiedBy");
}
public void addEmbeddedReleases(
HalResource halResource,
Set<String> releases,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,55 @@ public ResponseEntity<CollectionModel<EntityModel<Project>>> getProjectsForUser(
mapOfProjects, isSearchByName, sw360Projects, isNoFilter);
}

@RequestMapping(value = PROJECTS_URL + "/{id}/summaryAdministration", method = RequestMethod.GET)
public ResponseEntity<EntityModel<Project>> getAdministration(
@PathVariable("id") String id) throws TException {
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
Project sw360Project = projectService.getProjectForUserById(id, sw360User);
sw360Project.setId(id);
HalResource<Project> userHalResource = createHalSummaryAdministration(sw360Project, sw360User);
return new ResponseEntity<>(userHalResource, HttpStatus.OK);
}

private HalResource<Project> createHalSummaryAdministration(Project sw360Project, User sw360User) throws TException {
HalResource<Project> halProject = new HalResource<>(sw360Project);
User projectCreator = restControllerHelper.getUserByEmail(sw360Project.getCreatedBy());
restControllerHelper.addEmbeddedUser(halProject, projectCreator, "createdBy");

if (sw360Project.getModerators() != null) {
Set<String> moderators = sw360Project.getModerators();
restControllerHelper.addEmbeddedModerators(halProject, moderators);
}

if (sw360Project.getAttachments() != null) {
restControllerHelper.addEmbeddedAttachments(halProject, sw360Project.getAttachments());
}

if(sw360Project.getLeadArchitect() != null) {
restControllerHelper.addEmbeddedLeadArchitect(halProject, sw360Project.getLeadArchitect());
}

if (sw360Project.getContributors() != null) {
Set<String> contributors = sw360Project.getContributors();
restControllerHelper.addEmbeddedContributors(halProject, contributors);
}
if (sw360Project.getModifiedBy() != null) {
restControllerHelper.addEmbeddedModifiedBy(halProject, sw360Project.getModifiedBy());
}
if (sw360Project.getModifiedOn() != null) {
restControllerHelper.addEmbeddedModifiedBy(halProject, sw360Project.getModifiedOn());
}

if (sw360Project.getVendor() != null) {
Vendor vendor = sw360Project.getVendor();
HalResource<Vendor> vendorHalResource = restControllerHelper.addEmbeddedVendor(vendor.getFullname());
halProject.addEmbeddedResource("sw360:vendors", vendorHalResource);
sw360Project.setVendor(null);
}

return halProject;
}

@NotNull
private ResponseEntity<CollectionModel<EntityModel<Project>>> getProjectResponse(Pageable pageable,
String projectType, String group, String tag, boolean allDetails, boolean luceneSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,58 @@ public void should_document_create_project() throws Exception {
subsectionWithPath("_embedded.createdBy").description("The user who created this project")
)));
}
@Test
public void should_document_create_summary_administration() throws Exception {
String accessToken = TestHelper.getAccessToken(mockMvc, testUserId, testUserPassword);
mockMvc.perform(get("/api/projects/" + project.getId()+ "/summaryAdministration")
.header("Authorization", "Bearer " + accessToken)
.accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk())
.andDo(this.documentationHandler.document(
responseFields(
fieldWithPath("name").description("The name of the project"),
fieldWithPath("version").description("The project version"),
fieldWithPath("createdOn").description("The date the project was created"),
fieldWithPath("projectType").description("The project type, possible values are: " + Arrays.asList(ProjectType.values())),
fieldWithPath("domain").description("The domain, possible values are:" + Sw360ResourceServer.DOMAIN.toString()),
fieldWithPath("visibility").description("The project visibility, possible values are: " + Arrays.asList(Visibility.values())),
subsectionWithPath("externalIds").description("When projects are imported from other tools, the external ids can be stored here. Store as 'Single String' when single value, or 'Array of String' when multi-values"),
subsectionWithPath("additionalData").description("A place to store additional data used by external tools"),
fieldWithPath("ownerAccountingUnit").description("The owner accounting unit of the project"),
fieldWithPath("ownerGroup").description("The owner group of the project"),
fieldWithPath("description").description("The project description"),
fieldWithPath("ownerCountry").description("The owner country of the project"),
fieldWithPath("obligationsText").description("The obligations text of the project"),
fieldWithPath("clearingSummary").description("The clearing summary text of the project"),
fieldWithPath("specialRisksOSS").description("The special risks OSS text of the project"),
fieldWithPath("generalRisks3rdParty").description("The general risks 3rd party text of the project"),
fieldWithPath("specialRisks3rdParty").description("The special risks 3rd party text of the project"),
fieldWithPath("deliveryChannels").description("The sales and delivery channels text of the project"),
fieldWithPath("remarksAdditionalRequirements").description("The remark additional requirements text of the project"),
fieldWithPath("tag").description("The project tag"),
fieldWithPath("businessUnit").description("The business unit this project belongs to"),
fieldWithPath("deliveryStart").description("The project delivery start date"),
fieldWithPath("preevaluationDeadline").description("The project preevaluation deadline"),
fieldWithPath("systemTestStart").description("Date of the project system begin phase"),
fieldWithPath("systemTestEnd").description("Date of the project system end phase"),
fieldWithPath("securityResponsibles").description("An array of users responsible for security of the project."),
fieldWithPath("projectResponsible").description("A user who is responsible for the project."),
fieldWithPath("enableSvm").description("Security vulnerability monitoring flag"),
fieldWithPath("considerReleasesFromExternalList").description("Consider list of releases from existing external list"),
fieldWithPath("enableVulnerabilitiesDisplay").description("Displaying vulnerabilities flag."),
fieldWithPath("state").description("The project active status, possible values are: " + Arrays.asList(ProjectState.values())),
fieldWithPath("phaseOutSince").description("The project phase-out date"),
fieldWithPath("clearingRequestId").description("Clearing Request id associated with project."),
subsectionWithPath("_embedded.createdBy").description("The user who created this project"),
subsectionWithPath("_embedded.sw360:moderators").description("An array of moderators"),
subsectionWithPath("linkedProjects").description("The `linked project id` - metadata of linked projects (`enableSvm` - whether linked projects will be part of SVM, `projectRelationship` - relationship between linked project and the project. Possible values: " + Arrays.asList(ProjectRelationship.values())),
subsectionWithPath("linkedReleases").description("The relationship between linked releases of the project"),
subsectionWithPath("_embedded.sw360:vendors").description("An array of all component vendors with full name and link to their <<resources-vendor-get,Vendor resource>>"),
subsectionWithPath("_embedded.sw360:attachments").description("An array of all project attachments and link to their <<resources-attachment-get,Attachment resource>>"),
subsectionWithPath("_links").description("<<resources-index-links,Links>> to other resources")
)));
}

@Test
public void should_document_create_duplicate_project() throws Exception {
Map<String, Object> projectReqs = new HashMap<>();
Expand Down

0 comments on commit 0c7d9de

Please sign in to comment.