Skip to content

Refuse pasting or importing shared modifications missing the study root network tags - #1136

Merged
flomillot merged 24 commits into
mainfrom
feat/guard-root-network-tags-on-pasted-shared-modifications
Oct 27, 2026
Merged

flomillot merged 24 commits into
mainfrom
feat/guard-root-network-tags-on-pasted-shared-modifications

Conversation

@flomillot

@flomillot flomillot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Requires gridsuite/network-modification-server#937.

Copying modifications, copying a node or a subtree from another study, and importing composites from gridexplore are refused when a shared modification the user cannot write on, brought into the study, is not associated with all its root network tags. Cuts and copies within a study are not checked, its shared modifications being already associated with its tags, except for copied modifications whose origin is unknown. A composite imported as shared is checked itself; a copied one only through its content.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…te on miss

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…t-network-applicabilities

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…rk-tags-on-shared-modifications

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…at/guard-root-network-tags-on-shared-modifications

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…ot network tags

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91d05f1b-f129-4ace-8dfc-d83433be078e
Commits

Reviewing files that changed from the base of the PR and between 355aee1 and b1b6524.

Files selected for processing: 13
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java
  • src/main/java/org/gridsuite/study/server/dto/RootNetworkTagsCheckInfos.java
  • src/main/java/org/gridsuite/study/server/dto/SharedModificationsWriteAccess.java
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java
  • src/test/java/org/gridsuite/study/server/NetworkModificationTest.java
  • src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkApplicabilityTest.java
  • src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
  • src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java
  • src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java
  • src/test/java/org/gridsuite/study/server/utils/TestUtils.java
  • src/test/java/org/gridsuite/study/server/utils/wiremock/WireMockStubs.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change adds user-aware shared-modification write-access results and root-network tag authorization checks. Study operations validate tags during root-network updates, copies, duplication, and composite handling.

Changes: Root-network tag authorization

Layer / File(s) Summary
Authorization contracts and client requests
src/main/java/org/gridsuite/study/server/controller/StudyController.java, src/main/java/org/gridsuite/study/server/dto/*, src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java, src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
The controller returns shared-modification write-access states. The REST client sends user-aware tag-authorization requests and retrieves write-access results.
Root-network tag checks and write-access endpoint
src/main/java/org/gridsuite/study/server/service/StudyService.java, src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkApplicabilityTest.java
Root-network creation and tag updates check tag applicability. The write-access endpoint returns an enum state and passes the user ID to the access lookup.
Copy, duplication, and composite checks
src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java, src/main/java/org/gridsuite/study/server/service/StudyService.java, src/test/java/org/gridsuite/study/server/NetworkModificationTest.java, src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java, src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java, src/test/java/org/gridsuite/study/server/utils/*
Cross-study copies, modification duplication, and composite operations check target-study tag rules. Tests verify authorization requests and same-study copy behavior.

Sequence Diagram(s)

sequenceDiagram
  participant StudyService
  participant NetworkModificationRestService
  participant RootNetworkTagsAuthorizationEndpoint
  StudyService->>NetworkModificationRestService: Submit entity UUIDs, tags, and user ID
  NetworkModificationRestService->>RootNetworkTagsAuthorizationEndpoint: POST tag-authorization request
  RootNetworkTagsAuthorizationEndpoint-->>NetworkModificationRestService: Return authorization result
  NetworkModificationRestService-->>StudyService: Return authorization result
Loading

Suggested reviewers: etiennehomer, slimaneamar

Priority: Normal

Merge Risk: Minimal · up to b1b65

No actionable issue is established from the available evidence; the change is ready for normal validation.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: refusing pastes or imports of shared modifications that lack required study root-network tags.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly matches the changes. It describes root-network tag authorization for copied modifications, cross-study node or subtree copies, and imported composites, including …
Full details: Description check

Explanation

The pull request description directly matches the changes. It describes root-network tag authorization for copied modifications, cross-study node or subtree copies, and imported composites, including the shared and copied composite rules.

Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch feat/guard-root-network-tags-on-pasted-shared-modifications
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…difications

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>

@Meklo Meklo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny test coverage adjustment needed for the CI to pass

Comment on lines +2041 to +2055
// CHECK ON SHARED MODIFICATIONS BEFORE INSERTION
// Only an INSERT of a composite marked as shared puts a reference to it in the study: the study then uses the
// shared composite itself, which is checked, along with its content. Any other composite (COPY, SPLIT, or INSERT
// not marked as shared) is copied: the study only gets its content, whose references to shared modifications are
// checked, the composite being passed as the container of that content.
boolean isInsert = action == StudyConstants.CompositeModificationsActionType.INSERT;
List<UUID> copiedCompositeUuids = compositesInfos.stream()
.filter(composite -> !isInsert || !composite.isShared())
.map(CompositeInfos::id)
.toList();
List<UUID> sharedCompositeUuids = compositesInfos.stream()
.filter(composite -> isInsert && composite.isShared())
.map(CompositeInfos::id)
.toList();
assertCanWriteModificationsInStudy(targetStudyUuid, copiedCompositeUuids, List.of(), sharedCompositeUuids, userId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be extracted in a dedicated function to improve readability imo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I do that and also make it smaller with only one stream

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
…pplicabilities' into HEAD

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/service/StudyService.java
#	src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
…shared-modifications' into feat/guard-root-network-tags-on-pasted-shared-modifications

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/service/StudyService.java
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
…shared-modifications' into feat/guard-root-network-tags-on-pasted-shared-modifications

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/dto/RootNetworkTagsCheckInfos.java
#	src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java
#	src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
@flomillot
flomillot requested a review from Meklo October 22, 2026 10:15
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
…shared-modifications' into feat/guard-root-network-tags-on-pasted-shared-modifications

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
…rk-tags-on-pasted-shared-modifications

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
…rk-tags-on-pasted-shared-modifications

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java
#	src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/service/StudyService.java
#	src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkApplicabilityTest.java
Base automatically changed from feat/guard-root-network-tags-on-shared-modifications to main October 26, 2026 16:13
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/study/server/dto/RootNetworkTagsCheckInfos.java
#	src/main/java/org/gridsuite/study/server/service/StudyService.java
#	src/main/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationRestService.java
#	src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkApplicabilityTest.java
#	src/test/java/org/gridsuite/study/server/service/networkmodification/NetworkModificationServiceTest.java
@sonarqubecloud

Copy link
Copy Markdown

@flomillot
flomillot merged commit 2ea5a17 into main Oct 27, 2026
5 checks passed
@flomillot
flomillot deleted the feat/guard-root-network-tags-on-pasted-shared-modifications branch October 27, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants