From 48639dd7161ffd3d1b4dbcb44d93f9da7fe12d4b Mon Sep 17 00:00:00 2001 From: Anna Karyakina Date: Mon, 6 Dec 2021 16:16:23 -0800 Subject: [PATCH] D495028 | Jenkins: limit number of application versions returned - replacing dropdown with search following PM discussion --- .../fortifyclient/ApiClientWrapper.java | 41 ++++--------------- .../plugin/jenkins/FortifyPlugin/config.jelly | 16 ++++---- .../jenkins/steps/CloudScanMbs/config.jelly | 4 +- .../jenkins/steps/CloudScanStart/config.jelly | 4 +- .../jenkins/steps/FortifyUpload/config.jelly | 4 +- 5 files changed, 21 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/fortify/plugin/jenkins/fortifyclient/ApiClientWrapper.java b/src/main/java/com/fortify/plugin/jenkins/fortifyclient/ApiClientWrapper.java index dfa1636..ef9b09c 100644 --- a/src/main/java/com/fortify/plugin/jenkins/fortifyclient/ApiClientWrapper.java +++ b/src/main/java/com/fortify/plugin/jenkins/fortifyclient/ApiClientWrapper.java @@ -105,24 +105,10 @@ public List getApplications(String query, int limit) throws ApiExceptio List appList = new ArrayList(); ProjectControllerApi projectControllerApi = new ProjectControllerApi(apiClient); - ApiResultListProject apiResultListProject = projectControllerApi.listProject("name,id", Integer.valueOf(0), Integer.valueOf(limit), null, false, "name"); - boolean hasQuery = !StringUtils.isEmpty(query); - boolean found = false; + String partialQuery = StringUtils.isEmpty(query) ? null : "name:\"*" + query + "*\""; + ApiResultListProject apiResultListProject = projectControllerApi.listProject("name,id", Integer.valueOf(0), Integer.valueOf(limit), partialQuery, false, "name"); for (Project app : apiResultListProject.getData()) { appList.add(app); - if (hasQuery) { - if (query.equals(app.getName())) { - found = true; - } - } - } - if (hasQuery && !found) { - appList.clear(); - String partialQuery = "name:\"*" + query + "*\""; - apiResultListProject = projectControllerApi.listProject("name,id", Integer.valueOf(0), Integer.valueOf(limit), partialQuery, false, "name"); - for (Project app : apiResultListProject.getData()) { - appList.add(app); - } } return appList; } @@ -138,26 +124,11 @@ public List getAllApplicationVersions(String query, int limit) t List appVersionList = new ArrayList(); ProjectVersionControllerApi projectVersionControllerApi = new ProjectVersionControllerApi(apiClient); + String partialQuery = StringUtils.isEmpty(query) ? null : "name:\"*" + query + "*\""; ApiResultListProjectVersion apiResultListProjectVersion = projectVersionControllerApi.listProjectVersion("name,id,project", - Integer.valueOf(0), Integer.valueOf(limit), null, false, "name", false, false, false); - boolean hasQuery = !StringUtils.isEmpty(query); - boolean found = false; + Integer.valueOf(0), Integer.valueOf(limit), partialQuery, false, "name", false, false, false); for (ProjectVersion appVersion : apiResultListProjectVersion.getData()) { appVersionList.add(appVersion); - if (hasQuery) { - if (query.equals(appVersion.getName())) { - found = true; - } - } - } - if (hasQuery && !found) { - appVersionList.clear(); - String partialQuery = "name:\"*" + query + "*\""; - apiResultListProjectVersion = projectVersionControllerApi.listProjectVersion("name,id,project", - Integer.valueOf(0), Integer.valueOf(limit), partialQuery, false, "name", false, false, false); - for (ProjectVersion appVersion : apiResultListProjectVersion.getData()) { - appVersionList.add(appVersion); - } } return appVersionList; } @@ -171,8 +142,10 @@ public List getAllApplicationVersions(String query, int limit) t public List getApplicationVersionsFor(long applicationId, String query, int limit) throws ApiException { List appVersionList = new ArrayList(); ProjectVersionOfProjectControllerApi appVerApi = new ProjectVersionOfProjectControllerApi(apiClient); + + String partialQuery = StringUtils.isEmpty(query) ? null : "name:\"*" + query + "*\""; ApiResultListProjectVersion apiResultListProjectVersion = appVerApi.listProjectVersionOfProject(applicationId, - "name,id", Integer.valueOf(0), Integer.valueOf(limit), null, false, "name", false, false); + "name,id", Integer.valueOf(0), Integer.valueOf(limit), partialQuery, false, "name", false, false); for (ProjectVersion appVersion : apiResultListProjectVersion.getData()) { appVersionList.add(appVersion); } diff --git a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly index e151922..5e8afae 100644 --- a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly +++ b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly @@ -90,7 +90,7 @@
- +
- +
- +
- +
@@ -294,7 +294,7 @@
- +
- +
@@ -343,7 +343,7 @@
- +
${progress} @@ -355,7 +355,7 @@
- +
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly index 45a461c..b7d9adc 100644 --- a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly +++ b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly @@ -73,7 +73,7 @@ clazz="setting-input project-name read-only" items="${descriptor.appNameItems}"/>
-
-
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly index eb0ebb3..9490236 100644 --- a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly +++ b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly @@ -67,7 +67,7 @@ clazz="setting-input project-name read-only" items="${descriptor.appNameItems}"/>
-
-
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly index e5ca81b..a38d1ee 100644 --- a/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly +++ b/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly @@ -22,7 +22,7 @@
- +
- +