-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODCONSKC-21] - Implement sharing of role capabilities (#87)
* [MODCONSKC-21] - Implement sharing of role capabilities * Fix unit test * Fix descriptor for role-capabilities endpoint * Refactored Duplicate unit tests * Remove custom query, rely on spring jpa * Fix method names * Remove duplication * Update diagram for Sharing Role * Minor update * Fix variable name
- Loading branch information
Showing
37 changed files
with
1,331 additions
and
970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+332 KB
...g-feature-sequence-dagram/diagram-image/sharing-role-capability-sets-delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+485 KB
...ng-feature-sequence-dagram/diagram-image/sharing-role-capability-sets-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+300 KB
docs/sharing-feature-sequence-dagram/diagram-image/sharing-role-delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+439 KB
docs/sharing-feature-sequence-dagram/diagram-image/sharing-role-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-159 KB
...haring-feature-sequence-dagram/sharing-role-cabalities-capablity-set-delete.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-227 KB
...sharing-feature-sequence-dagram/sharing-role-cabalities-capablity-set-start.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
docs/sharing-feature-sequence-dagram/sharing-role-delete.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@startuml | ||
|
||
!pragma teoz true | ||
!theme cerulean | ||
|
||
autonumber | ||
|
||
actor "user" as user | ||
|
||
participant "mod-consortia-keycloak" as mck | ||
database "mod-consortia-keycloak DB" as mck_db | ||
participant "mod-consortia-publish-coordinator" as mc_pc | ||
participant "mod-login-keycloak" as ml | ||
participant "mod-roles-keycloak" as mrk | ||
|
||
user -> mck: Initiate deleting role action | ||
note right | ||
DELETE /consortia/<consortiumId>/sharing/roles/<roleId> | ||
{ | ||
"roleId": "<UUID>", | ||
"url": "string" | ||
} | ||
end note | ||
activate mck | ||
|
||
mck -> mck_db: Retrieve tenants associated with the roleId from sharing_role table using roleId | ||
note bottom | ||
| tenant_id | role_id | | ||
| "tenant A" | <UUID1> | | ||
end note | ||
note right | ||
| tenant_id | role_id | | ||
| "tenant A" | <UUID1> | | ||
| "tenant B" | <UUID2> | | ||
end note | ||
|
||
loop tenants where role is exists | ||
mck -> mck: Add tenant to DELETE Role Publish Coordinator tenants list | ||
end | ||
|
||
mck -> mck_db: Remove record with "roleId" and "tenant A" variables | ||
|
||
mck -> ml: Login via consortia-system-user | ||
ml --> mck: Return system user's token | ||
|
||
mck -> mc_pc: Initiate PC request with DELETE HTTP method to delete a role | ||
mc_pc -> mrk: Send HTTP DELETE request to delete role | ||
mrk --> mc_pc: Return response | ||
mc_pc --> mck: Return Publish Coordinator id | ||
|
||
mck --> user: Return response with PC id | ||
note right | ||
Response payload: | ||
{ | ||
"deleteRolePCId": "<UUID>" | ||
} | ||
end note | ||
|
||
user -> mck: Check if DELETE PC completed: /consortia/<UUID>/publications/<UUID> | ||
|
||
@enduml |
82 changes: 82 additions & 0 deletions
82
docs/sharing-feature-sequence-dagram/sharing-role-start.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@startuml | ||
|
||
!pragma teoz true | ||
!theme cerulean | ||
|
||
autonumber | ||
|
||
actor "user" as user | ||
|
||
participant "mod-consortia-keycloak" as mck | ||
database "mod-consortia-keycloak DB" as mck_db | ||
participant "mod-consortia-publish-coordinator" as mc_pc | ||
participant "mod-login-keycloak" as ml | ||
participant "mod-roles-keycloak" as mrk | ||
|
||
user -> mck: Initiate sharing role action | ||
note right | ||
POST /consortia/<consortiumId>/sharing/roles | ||
{ | ||
"roleId": "<UUID>", | ||
"url": "string", | ||
"payload": { | ||
"id": "<UUID>", | ||
"name": "<String>", | ||
"description": "<String>" | ||
} | ||
} | ||
end note | ||
activate mck | ||
|
||
mck -> mck_db: Retrieve tenants associated with the roleId from sharing_role table | ||
note bottom | ||
| tenant_id | role_id | | ||
| "tenant A" | <UUID1> | | ||
end note | ||
note right | ||
| tenant_id | role_id | | ||
| "tenant A" | <UUID1> | | ||
end note | ||
mck -> mck_db: Retrieve all tenants list | ||
|
||
loop tenants size count | ||
alt #E8F3E1 tenant id does not exist in role_capability_sets table | ||
mck -> mck: Add tenant to POST Role Publish Coordinator tenants list | ||
mck -> mck_db: Create new entity | ||
note right | ||
| tenant_id | role_id | | ||
| "tenant B" | <UUID2> | | ||
end note | ||
else #F3E1E2 tenant id exists | ||
mck -> mck: Add tenant to PUT Role Publish Coordinator tenants list | ||
end | ||
end | ||
|
||
mck -> mck: Set source as Consortium for all role (Create and Update) | ||
|
||
mck -> ml: Login via consortia-system-user | ||
ml --> mck: Return system user's token | ||
|
||
mck -> mc_pc: Initiate PC request with POST HTTP method to create role | ||
mc_pc -> mrk: Send HTTP POST request to create role | ||
mrk --> mc_pc: Return response | ||
mc_pc --> mck: Return Publish Coordinator id | ||
|
||
mck -> mc_pc: Initiate PC request with PUT HTTP method to update role | ||
mc_pc -> mrk: Send HTTP POST request to create role | ||
mrk --> mc_pc: Return response | ||
mc_pc --> mck: Return Publish Coordinator id | ||
|
||
mck --> user: Return response with both PC ids | ||
note right | ||
Response payload: | ||
{ | ||
"createRolePCId": "<UUID>", | ||
"updateRolePCId": "<UUID>" | ||
} | ||
end note | ||
|
||
user -> mck: Check if POST PC completed: /consortia/<UUID>/publications/<UUID> | ||
user -> mck: Check if PUT PC completed: /consortia/<UUID>/publications/<UUID> | ||
|
||
@enduml |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/folio/consortia/controller/SharingRoleCapabilityController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.folio.consortia.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilityDeleteResponse; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilityRequest; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilityResponse; | ||
import org.folio.consortia.rest.resource.RoleCapabilitiesApi; | ||
import org.folio.consortia.service.impl.SharingRoleCapabilityService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.springframework.http.HttpStatus.CREATED; | ||
import static org.springframework.http.HttpStatus.OK; | ||
|
||
@RestController | ||
@RequestMapping("/consortia/{consortiumId}/sharing") | ||
@RequiredArgsConstructor | ||
public class SharingRoleCapabilityController implements RoleCapabilitiesApi { | ||
|
||
private final SharingRoleCapabilityService sharingRoleCapabilityService; | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleCapabilityResponse> startSharingRoleCapabilities(UUID consortiumId, | ||
SharingRoleCapabilityRequest request) { | ||
return ResponseEntity | ||
.status(CREATED) | ||
.body(sharingRoleCapabilityService.start(consortiumId, request)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleCapabilityDeleteResponse> deleteSharingRoleCapabilities(UUID consortiumId, | ||
UUID roleId, | ||
SharingRoleCapabilityRequest request) { | ||
return ResponseEntity | ||
.status(OK) | ||
.body(sharingRoleCapabilityService.delete(consortiumId, roleId, request)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.