Skip to content

Commit

Permalink
feat(rest) : Adding or Modifying fields to project summaryadminastrat…
Browse files Browse the repository at this point in the history
…ion page

Signed-off-by: Keerthi B L <[email protected]>
  • Loading branch information
keerthi-bl committed Oct 25, 2023
1 parent 4666d87 commit bb5d31a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1311,4 +1311,28 @@ public void addEmbeddedCotsDetails(HalResource halResource, Release release) {
addEmbeddedFields("sw360:cotsDetail", cotsDetailsHalResource, halResource);
}
}

public void addEmbeddedProjectResponsible(HalResource halResource, String projectResponsible) {
User sw360User = getUserByEmail(projectResponsible);
if(sw360User!=null)
addEmbeddedUser(halResource, sw360User, "projectResponsible");
}

public void addEmbeddedSecurityResponsibles (HalResource halResource, Set<String> securityResponsibles) {
for (String securityResponsible : securityResponsibles) {
User sw360User = getUserByEmail(securityResponsible);
if(sw360User!=null)
addEmbeddedUser(halResource, sw360User, "securityResponsibles");
}
}

public void addEmbeddedClearingTeam(HalResource<Project> userHalResource, String clearingTeam, String resource) {
User sw360User = getUserByEmail(clearingTeam);
if(sw360User!=null)
addEmbeddedUser(userHalResource, sw360User, resource);
}

public void addEmbeddedLicenseInfoHeaderText(HalResource<Project> halResource, String licenseInfoHeaderText, String relation) {
halResource.addEmbeddedResource(relation, licenseInfoHeaderText);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1870,12 +1870,49 @@ public ResponseEntity<EntityModel<Project>> getAdministration(
sw360Project.setReleaseIdToUsage(null);
sw360Project.setLinkedProjects(null);
HalResource<Project> userHalResource = createHalProject(sw360Project, sw360User);
setAdditionalFieldsToHalResource(sw360Project,userHalResource);
sw360Project.unsetLinkedProjects();
sw360Project.unsetReleaseIdToUsage();
sw360Project.unsetModifiedBy();
sw360Project.unsetProjectOwner();

return new ResponseEntity<>(userHalResource, HttpStatus.OK);
}

private void setAdditionalFieldsToHalResource(Project sw360Project, HalResource<Project> userHalResource) throws TException {
try {
String licenseInfoHeaderText = sw360Project.getLicenseInfoHeaderText();
if(licenseInfoHeaderText == null) {
licenseInfoHeaderText="";
}
restControllerHelper.addEmbeddedLicenseInfoHeaderText(userHalResource, licenseInfoHeaderText, "licenseInfoHeaderText");

User projectModifier = restControllerHelper.getUserByEmail(sw360Project.getModifiedBy());
if(projectModifier != null) {
restControllerHelper.addEmbeddedUser(userHalResource, projectModifier, "modifiedBy");
}
User projectOwner = restControllerHelper.getUserByEmail(sw360Project.getProjectOwner());
if(projectOwner != null) {
restControllerHelper.addEmbeddedUser(userHalResource, projectOwner, "projectOwner");
}
if (sw360Project.getSecurityResponsibles() != null || sw360Project.getSecurityResponsibles().isEmpty()) {
sw360Project.setSecurityResponsibles(new HashSet<String>(){{add("");}});
}
Set<String> securityResponsibles = sw360Project.getSecurityResponsibles();
restControllerHelper.addEmbeddedSecurityResponsibles(userHalResource, securityResponsibles);

String clearingTeam = sw360Project.getClearingTeam();
if(clearingTeam != null) {
restControllerHelper.addEmbeddedClearingTeam(userHalResource, clearingTeam, "clearingTeam");
}
if (sw360Project.getProjectResponsible() != null) {
restControllerHelper.addEmbeddedProjectResponsible(userHalResource,sw360Project.getProjectResponsible());
}
}catch (Exception e) {
throw new TException(e.getMessage());
}
}

private HalResource<ProjectDTO> createHalProjectDTO(Project sw360Project, User sw360User) throws TException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1959,15 +1959,16 @@ public void should_document_create_summary_administration() throws Exception {
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."),
fieldWithPath("licenseInfoHeaderText").description("Display licenseInfoHeaderText info"),
fieldWithPath("securityResponsibles").description("The securityResponsibles display"),
fieldWithPath("projectResponsible").description("The projectResponsible display"),
subsectionWithPath("_embedded.licenseInfoHeaderText").description("Display licenseInfoHeaderText info"),
subsectionWithPath("externalUrls").description("A place to store additional data used by external URLs"),
subsectionWithPath("_embedded.createdBy").description("The user who created this project"),
subsectionWithPath("_embedded.sw360:moderators").description("An array of moderators"),
Expand Down

0 comments on commit bb5d31a

Please sign in to comment.