Skip to content

Commit f978b7b

Browse files
authored
Merge pull request #56 from PublicisSapient/issue-fix
issue fix
2 parents 1620cc0 + bbee861 commit f978b7b

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

rally/src/main/java/com/publicissapient/kpidashboard/rally/config/RallyProcessorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class RallyProcessorConfig {
1717
private String username;
1818
private String password;
1919
private String apiEndpoint;
20-
private int pageSize = 100;
20+
private int pageSize = 200;
2121
private int maxRetries = 3;
2222
private long retryDelay = 5000;
2323
private String[] workspaceIds;

rally/src/main/java/com/publicissapient/kpidashboard/rally/service/RallyCommonService.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.HashMap;
3333
import java.util.List;
3434
import java.util.Map;
35-
import java.util.Objects;
3635
import java.util.Optional;
3736
import java.util.regex.Matcher;
3837
import java.util.regex.Pattern;
@@ -79,10 +78,6 @@
7978
@Component
8079
public class RallyCommonService {
8180

82-
private static final String RALLY_URL = "https://rally1.rallydev.com/slm/webservice/v2.0";
83-
private static final String API_KEY = "_8BogJQcTuGwVjEemJiAjV0z5SgR2UCSsSnBUu55Y5U";
84-
private static final String PROJECT_NAME = "Core Team";
85-
private static final int PAGE_SIZE = 200; // Number of artifacts per page
8681
private static final String ZSESSIONID = "ZSESSIONID";
8782
private static final String RALLY_ISSUE_REVISION_ENDPOINT = "/Revisions";
8883
public static final String HIERARCHICALREQUIREMENT = "hierarchicalrequirement";
@@ -293,13 +288,13 @@ public List<HierarchicalRequirement> fetchIssuesBasedOnJql(ProjectConfFieldMappi
293288
public RallyResponse getRqlIssues(ProjectConfFieldMapping projectConfig, String deltaDate, int pageStart) {
294289
RallyResponse rallyResponse = null;
295290
try {
296-
List<HierarchicalRequirement> allArtifacts = getHierarchicalRequirements(pageStart);
291+
List<HierarchicalRequirement> allArtifacts = getHierarchicalRequirements(pageStart,projectConfig);
297292
// Create a RallyResponse object and populate it with the combined results
298293
QueryResult queryResult = new QueryResult();
299294
queryResult.setResults(allArtifacts);
300295
queryResult.setTotalResultCount(allArtifacts.size());
301296
queryResult.setStartIndex(pageStart);
302-
queryResult.setPageSize(PAGE_SIZE);
297+
queryResult.setPageSize(rallyProcessorConfig.getPageSize());
303298

304299
rallyResponse = new RallyResponse();
305300
rallyResponse.setQueryResult(queryResult);
@@ -404,14 +399,13 @@ public void setRallyIssueHistory(HierarchicalRequirement hierarchicalRequirement
404399
* @param pageStart starting index for pagination
405400
* @return List of HierarchicalRequirement objects including defects
406401
*/
407-
public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart) {
402+
public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart,ProjectConfFieldMapping projectConfig) {
403+
Optional<Connection> connectionOptional = projectConfig.getJira().getConnection();
408404
HttpHeaders headers = new HttpHeaders();
409-
headers.set(ZSESSIONID, API_KEY);
405+
if (connectionOptional.isPresent())
406+
headers.set(ZSESSIONID, connectionOptional.get().getAccessToken());
410407
HttpEntity<String> entity = new HttpEntity<>(headers);
411408

412-
413-
414-
415409
// Fetch fields for each artifact type, including Defects for hierarchical requirements
416410
String fetchFields = "FormattedID,Name,Owner,PlanEstimate,ScheduleState,Iteration,CreationDate,LastUpdateDate,RevisionHistory,ObjectID";
417411
String hierarchicalRequirementFetchFields = fetchFields + ",Defects";
@@ -425,7 +419,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
425419
boolean hasMoreResults = true;
426420
while (hasMoreResults) {
427421
String url = String.format("%s/%s?query=(Project.Name = \"%s\")&fetch=%s&start=%d&pagesize=%d",
428-
RALLY_URL, "defect", PROJECT_NAME, fetchFields + ",Requirement", start, PAGE_SIZE);
422+
connectionOptional.get().getBaseUrl(), "defect", projectConfig.getJira().getProjectKey(), fetchFields + ",Requirement", start, rallyProcessorConfig.getPageSize());
429423
ResponseEntity<RallyResponse> response = restTemplate.exchange(url, HttpMethod.GET, entity,
430424
RallyResponse.class);
431425
if (response.getStatusCode() == HttpStatus.OK) {
@@ -453,7 +447,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
453447
// Also add to allArtifacts as they are part of the result
454448
allArtifacts.add(defect);
455449
}
456-
start += PAGE_SIZE; // Move to the next page
450+
start += rallyProcessorConfig.getPageSize(); // Move to the next page
457451
} else {
458452
hasMoreResults = false;
459453
}
@@ -475,7 +469,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
475469

476470
while (hasMoreResults) {
477471
String url = String.format("%s/%s?query=(Project.Name = \"%s\")&fetch=%s&start=%d&pagesize=%d",
478-
RALLY_URL, artifactType, PROJECT_NAME, currentFetchFields, start, PAGE_SIZE);
472+
connectionOptional.get().getBaseUrl(), artifactType, projectConfig.getJira().getProjectKey(), currentFetchFields, start, rallyProcessorConfig.getPageSize());
479473
ResponseEntity<RallyResponse> response = restTemplate.exchange(url, HttpMethod.GET, entity,
480474
RallyResponse.class);
481475
if (response.getStatusCode() == HttpStatus.OK) {
@@ -509,7 +503,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
509503
processedDefects.add(fullDefect);
510504
} else {
511505
// If not in our map, fetch it directly
512-
fullDefect = fetchDefectDetails(defectRef.getRef(), entity);
506+
fullDefect = fetchDefectDetails(defectRef.getRef(), entity,connectionOptional.get().getBaseUrl());
513507
if (fullDefect != null) {
514508
processedDefects.add(fullDefect);
515509
defectMap.put(fullDefect.getRef(), fullDefect);
@@ -521,7 +515,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
521515

522516
allArtifacts.add(artifact);
523517
}
524-
start += PAGE_SIZE; // Move to the next page
518+
start += rallyProcessorConfig.getPageSize(); // Move to the next page
525519
} else {
526520
hasMoreResults = false;
527521
}
@@ -544,7 +538,7 @@ public List<HierarchicalRequirement> getHierarchicalRequirements(int pageStart)
544538
* @param entity HTTP entity with authentication headers
545539
* @return HierarchicalRequirement object with defect details
546540
*/
547-
private HierarchicalRequirement fetchDefectDetails(String defectRef, HttpEntity<String> entity) {
541+
private HierarchicalRequirement fetchDefectDetails(String defectRef, HttpEntity<String> entity, String baseUrl) {
548542
try {
549543
String fetchFields = "FormattedID,Name,Owner,PlanEstimate,ScheduleState,Iteration,CreationDate,LastUpdateDate,RevisionHistory,Requirement";
550544
// Extract the defect ID from the reference URL if needed
@@ -553,7 +547,7 @@ private HierarchicalRequirement fetchDefectDetails(String defectRef, HttpEntity<
553547
defectId = defectRef.substring(defectRef.lastIndexOf("/") + 1);
554548
}
555549

556-
String url = String.format("%s/defect/%s?fetch=%s", RALLY_URL, defectId, fetchFields);
550+
String url = String.format("%s/defect/%s?fetch=%s", baseUrl, defectId, fetchFields);
557551
ResponseEntity<RallyResponse> response = restTemplate.exchange(url, HttpMethod.GET, entity, RallyResponse.class);
558552

559553
if (response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {

0 commit comments

Comments
 (0)