From 3f10b68566d006d6f88c5c1c3a2b1578a9171274 Mon Sep 17 00:00:00 2001 From: Gaurav Mishra Date: Thu, 17 Oct 2024 20:46:32 +0530 Subject: [PATCH] fix(build): add the missing excludeReleaseVersion Add the missing variable `excludeReleaseVersion` from #2496 Signed-off-by: Gaurav Mishra --- .../report/SW360ReportController.java | 34 +++++++++++-------- .../report/SW360ReportService.java | 6 ++-- .../restdocs/ComponentSpecTest.java | 5 ++- .../restdocs/ProjectSpecTest.java | 13 +++++-- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportController.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportController.java index 076f79515d..2c5af296de 100644 --- a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportController.java +++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportController.java @@ -89,6 +89,8 @@ public void getProjectReport( @RequestParam(value = "projectId", required = false) String projectId, @Parameter(description = "Module name.", schema = @Schema(allowableValues = {PROJECTS, COMPONENTS})) @RequestParam(value = "module", required = true) String module, + @Parameter(description = "Exclude release version from the license info file") + @RequestParam(value = "excludeReleaseVersion", required = false, defaultValue = "false") boolean excludeReleaseVersion, HttpServletRequest request, HttpServletResponse response ) throws TException { @@ -99,17 +101,17 @@ public void getProjectReport( switch (module) { case PROJECTS: getProjectReports(withLinkedReleases, SW360Constants.MAIL_REQUEST_FOR_PROJECT_REPORT, response, - request, sw360User, module, projectId); + request, sw360User, module, projectId, excludeReleaseVersion); break; case COMPONENTS: getComponentsReports(withLinkedReleases, SW360Constants.MAIL_REQUEST_FOR_COMPONENT_REPORT, response, - request, sw360User, module); + request, sw360User, module, excludeReleaseVersion); break; case LICENSES: - getLicensesReports(request, response, sw360User, module); + getLicensesReports(request, response, sw360User, module, excludeReleaseVersion); break; case LICENSE_INFO: - getLicensesInfoReports(request, response, sw360User, module, projectId); + getLicensesInfoReports(request, response, sw360User, module, projectId, excludeReleaseVersion); break; default: break; @@ -123,7 +125,7 @@ public void getProjectReport( } private void getProjectReports(boolean withLinkedReleases, boolean mailRequest, HttpServletResponse response, - HttpServletRequest request, User sw360User, String module, String projectId) throws TException { + HttpServletRequest request, User sw360User, String module, String projectId, boolean excludeReleaseVersion) throws TException { try { if (mailRequest) { sw360ReportService.getUploadedProjectPath(sw360User, withLinkedReleases,getBaseUrl(request), projectId); @@ -131,7 +133,7 @@ private void getProjectReports(boolean withLinkedReleases, boolean mailRequest, responseJson.addProperty("response", "The downloaded report link will be send to the end user."); response.getWriter().write(responseJson.toString()); } else { - downloadExcelReport(withLinkedReleases, request, response, sw360User, module, projectId); + downloadExcelReport(withLinkedReleases, request, response, sw360User, module, projectId, excludeReleaseVersion); } } catch (Exception e) { throw new TException(e.getMessage()); @@ -139,7 +141,7 @@ private void getProjectReports(boolean withLinkedReleases, boolean mailRequest, } private void getComponentsReports(boolean withLinkedReleases, boolean mailRequest, HttpServletResponse response, - HttpServletRequest request, User sw360User, String module) throws TException { + HttpServletRequest request, User sw360User, String module, boolean excludeReleaseVersion) throws TException { try { if (mailRequest) { sw360ReportService.getUploadedComponentPath(sw360User, withLinkedReleases, getBaseUrl(request)); @@ -147,30 +149,34 @@ private void getComponentsReports(boolean withLinkedReleases, boolean mailReques responseJson.addProperty("response", "Component report download link will get send to the end user."); response.getWriter().write(responseJson.toString()); } else { - downloadExcelReport(withLinkedReleases, request, response, sw360User, module, null); + downloadExcelReport(withLinkedReleases, request, response, sw360User, module, null, excludeReleaseVersion); } } catch (Exception e) { throw new TException(e.getMessage()); } } - private void getLicensesReports(HttpServletRequest request, HttpServletResponse response, User sw360User, String module) throws TException { + private void getLicensesReports(HttpServletRequest request, HttpServletResponse response, + User sw360User, String module, boolean excludeReleaseVersion) throws TException { try { - downloadExcelReport(false, request, response, sw360User, module, null); + downloadExcelReport(false, request, response, sw360User, module, null, excludeReleaseVersion); } catch (Exception e) { throw new TException(e.getMessage()); } } - private void getLicensesInfoReports(HttpServletRequest request, HttpServletResponse response, User sw360User, String module, String projectId) throws TException { + private void getLicensesInfoReports(HttpServletRequest request, HttpServletResponse response, User sw360User, + String module, String projectId, boolean excludeReleaseVersion) throws TException { try { - downloadExcelReport(false, request, response, sw360User, module, projectId); + downloadExcelReport(false, request, response, sw360User, module, projectId, excludeReleaseVersion); }catch (Exception e) { throw new TException(e.getMessage()); } } - private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest request , HttpServletResponse response, User user, String module, String projectId) + private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest request, + HttpServletResponse response, User user, String module, + String projectId, boolean excludeReleaseVersion) throws TException { try { ByteBuffer buffer = null; @@ -189,7 +195,7 @@ private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest final String variant = request.getParameter("variant"); final String template = request.getParameter("template"); final String externalIds = request.getParameter("externalIds"); - buffer = sw360ReportService.getLicenseInfoBuffer(user, projectId, generatorClassName, variant, template, externalIds); + buffer = sw360ReportService.getLicenseInfoBuffer(user, projectId, generatorClassName, variant, template, externalIds, excludeReleaseVersion); break; default: break; diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportService.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportService.java index 4e0c650b36..07ed0411f7 100644 --- a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportService.java +++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/report/SW360ReportService.java @@ -180,7 +180,9 @@ public void sendComponentExportSpreadsheetSuccessMail(String emailURL, String em componentclient.sendExportSpreadsheetSuccessMail(emailURL, email); } - public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generatorClassName, String variant, String template, String externalIds) throws TException { + public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generatorClassName, + String variant, String template, String externalIds, + boolean excludeReleaseVersion) throws TException { final Project sw360Project = projectService.getProjectForUserById(id, sw360User); List mappedProjectLinks = projectService.createLinkedProjects(sw360Project, @@ -217,7 +219,7 @@ public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generat } final LicenseInfoFile licenseInfoFile = licenseInfoService.getLicenseInfoFile(sw360Project, sw360User, outputGeneratorClassNameWithVariant, selectedReleaseAndAttachmentIds, excludedLicensesPerAttachments, - externalIds, fileName); + externalIds, fileName, excludeReleaseVersion); return licenseInfoFile.bufferForGeneratedOutput(); } diff --git a/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ComponentSpecTest.java b/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ComponentSpecTest.java index 910e17b216..db9c985125 100644 --- a/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ComponentSpecTest.java +++ b/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ComponentSpecTest.java @@ -1333,13 +1333,16 @@ public void should_document_get_component_report() throws Exception{ .queryParam("withlinkedreleases", "true") .queryParam("mimetype", "xlsx") .queryParam("module", "components") + .queryParam("excludeReleaseVersion", "false") .accept(MediaTypes.HAL_JSON)) .andExpect(status().isOk()) .andDo(this.documentationHandler.document( queryParameters( parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are ``"), parameterWithName("mimetype").description("Projects download format. Possible values are ``"), - parameterWithName("module").description("module represent the project or component. Possible values are ``") + parameterWithName("module").description("module represent the project or component. Possible values are ``"), + parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. " + + "Possible values are ``") ))); } } diff --git a/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ProjectSpecTest.java b/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ProjectSpecTest.java index c670830bf6..151b0ab283 100644 --- a/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ProjectSpecTest.java +++ b/rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ProjectSpecTest.java @@ -2357,13 +2357,17 @@ public void should_document_get_project_report() throws Exception { .queryParam("withlinkedreleases", "true") .queryParam("mimetype", "xlsx") .queryParam("module", "projects") + .queryParam("excludeReleaseVersion", "false") .accept(MediaTypes.HAL_JSON)) .andExpect(status().isOk()) .andDo(this.documentationHandler.document( queryParameters( parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are ``"), parameterWithName("mimetype").description("Projects download format. Possible values are ``"), - parameterWithName("module").description("module represent the project or component. Possible values are ``")) + parameterWithName("module").description("module represent the project or component. Possible values are ``"), + parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. " + + "Possible values are ``") + ) )); } @@ -2375,6 +2379,7 @@ public void should_document_get_project_licenseclearing_spreadsheet() throws Exc .queryParam("mimetype", "xlsx") .queryParam("module", "projects") .queryParam("projectId", project.getId()) + .queryParam("excludeReleaseVersion", "false") .accept(MediaTypes.HAL_JSON)) .andExpect(status().isOk()) .andDo(this.documentationHandler.document( @@ -2382,8 +2387,10 @@ public void should_document_get_project_licenseclearing_spreadsheet() throws Exc parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are ``"), parameterWithName("mimetype").description("Projects download format. Possible values are ``"), parameterWithName("module").description("module represent the project or component. Possible values are ``"), - parameterWithName("projectId").description("Id of a project")) - )); + parameterWithName("projectId").description("Id of a project"), + parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. " + + "Possible values are ``") + ))); } @Test