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 Apr 5, 2023
1 parent 0768cd6 commit 281d7c6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
19 changes: 18 additions & 1 deletion rest/resource-server/src/docs/asciidoc/projects.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,21 @@ include::{snippets}/should_document_update_project_vulnerabilities/curl-request.
include::{snippets}/should_document_update_project_vulnerabilities/http-response.adoc[]

===== Links
include::{snippets}/should_document_update_project_vulnerabilities/links.adoc[]
include::{snippets}/should_document_update_project_vulnerabilities/links.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 @@ -231,6 +231,33 @@ public ResponseEntity<CollectionModel<EntityModel<Project>>> getProjectsForUser(
mapOfProjects, isSearchByName, sw360Projects);
}

@RequestMapping(value = PROJECTS_URL + "/{id}/summary/administration", 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);
sw360Project.unsetDescription();
sw360Project.unsetBusinessUnit();
sw360Project.unsetReleaseIdToUsage();
sw360Project.unsetLinkedProjects();
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.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 @@ -1268,6 +1268,52 @@ 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()+ "/summary/administration")
.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("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("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:vendors").description("An array of all component vendors with full name and link to their <<resources-vendor-get,Vendor 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 281d7c6

Please sign in to comment.