export network#1001
Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughReplaces node-scoped network-modifications export with a study-scoped export API. Adds DTOs for export/import, a batch network-modification export method, StudyService orchestration to assemble StudyExportInfos, a GET endpoint returning StudyExportInfos, and corresponding tests. ChangesFull Study Export
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.3)src/main/java/org/gridsuite/study/server/controller/StudyController.javasrc/main/java/org/gridsuite/study/server/service/StudyService.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java`:
- Around line 95-107: The method getModificationsInfosToExport currently returns
whatever restTemplate.exchange(...).getBody() returns, which can be null if the
remote service responds without a body; change the return path to defensively
handle null by returning Map.of() when getBody() is null. Update
getModificationsInfosToExport (and the other batch-export helper that invokes
restTemplate.exchange(...).getBody() for a Map<UUID,Object>) to capture the
response body into a local variable and return body != null ? body : Map.of(),
ensuring callers always receive a non-null Map.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dc2e1299-9776-461c-b48d-455fd6f4964c
📒 Files selected for processing (8)
src/main/java/org/gridsuite/study/server/controller/StudyController.javasrc/main/java/org/gridsuite/study/server/dto/RootNetworkExportInfos.javasrc/main/java/org/gridsuite/study/server/dto/StudyExportInfos.javasrc/main/java/org/gridsuite/study/server/dto/StudyImportInfos.javasrc/main/java/org/gridsuite/study/server/dto/StudyTreeNodeExportInfos.javasrc/main/java/org/gridsuite/study/server/service/NetworkModificationService.javasrc/main/java/org/gridsuite/study/server/service/RootNetworkService.javasrc/main/java/org/gridsuite/study/server/service/StudyService.java
| public Map<UUID, Object> getModificationsInfosToExport(List<UUID> groupUuids) { | ||
| Objects.requireNonNull(groupUuids); | ||
| if (groupUuids.isEmpty()) { | ||
| return Map.of(); | ||
| } | ||
| var path = UriComponentsBuilder.fromPath("groups" + DELIMITER + "modifications" + DELIMITER + "export") | ||
| .queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false) | ||
| .toUriString(); | ||
|
|
||
| return restTemplate.exchange(getNetworkModificationServerURI(false) + path, HttpMethod.GET, null, String.class).getBody(); | ||
| HttpEntity<List<UUID>> httpEntity = new HttpEntity<>(groupUuids); | ||
| return restTemplate.exchange(getNetworkModificationServerURI(false) + path, HttpMethod.POST, httpEntity, | ||
| new ParameterizedTypeReference<Map<UUID, Object>>() { }).getBody(); | ||
| } |
There was a problem hiding this comment.
Handle null HTTP bodies for batch export responses.
Line 106 and Line 477 can return null when the remote service responds without a body, which can break callers expecting a map. Return Map.of() instead.
💡 Proposed fix
public Map<UUID, Object> getModificationsInfosToExport(List<UUID> groupUuids) {
Objects.requireNonNull(groupUuids);
if (groupUuids.isEmpty()) {
return Map.of();
@@
- return restTemplate.exchange(getNetworkModificationServerURI(false) + path, HttpMethod.POST, httpEntity,
- new ParameterizedTypeReference<Map<UUID, Object>>() { }).getBody();
+ Map<UUID, Object> body = restTemplate.exchange(
+ getNetworkModificationServerURI(false) + path,
+ HttpMethod.POST,
+ httpEntity,
+ new ParameterizedTypeReference<Map<UUID, Object>>() { }
+ ).getBody();
+ return body != null ? body : Map.of();
}
@@
public Map<UUID, JsonNode> getModificationsToExportByGroups(List<UUID> groupUuids) {
Objects.requireNonNull(groupUuids);
if (groupUuids.isEmpty()) {
return Map.of();
@@
- return restTemplate.exchange(
+ Map<UUID, JsonNode> body = restTemplate.exchange(
getNetworkModificationServerURI(false) + path,
HttpMethod.POST,
entity,
new ParameterizedTypeReference<Map<UUID, JsonNode>>() { }
- ).getBody();
+ ).getBody();
+ return body != null ? body : Map.of();
}Also applies to: 457-478
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java`
around lines 95 - 107, The method getModificationsInfosToExport currently
returns whatever restTemplate.exchange(...).getBody() returns, which can be null
if the remote service responds without a body; change the return path to
defensively handle null by returning Map.of() when getBody() is null. Update
getModificationsInfosToExport (and the other batch-export helper that invokes
restTemplate.exchange(...).getBody() for a Map<UUID,Object>) to capture the
response body into a local variable and return body != null ? body : Map.of(),
ensuring callers always receive a non-null Map.
|



PR Summary