-
Notifications
You must be signed in to change notification settings - Fork 7
[NAE-2213] Delete global role #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f9a0f2d
[NAE-2213] Delete global role
renczesstefan 1c1b5c0
[NAE-2213] Delete global role˚
renczesstefan daad4ce
[NAE-2213] Delete global role˚
renczesstefan d331122
[NAE-2213] Delete global role
renczesstefan 7fae893
[NAE-2213] Delete global role
renczesstefan d1c8f95
[NAE-2213] Delete global role
renczesstefan dada5a3
[NAE-2213] Delete global role
renczesstefan ab3677f
[NAE-2213] Delete global role
renczesstefan c57829f
[NAE-2213] Delete global role
renczesstefan 56a0b3a
Update schema URL in petriflow_schema.xsd
renczesstefan 375590e
Add Swagger @Parameter annotation to delete global role endpoint
renczesstefan 279c662
Refactor deleteGlobalRole to return detailed error responses
renczesstefan e771098
Add roles field to PetriNetSearch class
renczesstefan e846526
Add validation for referenced roles during deletion
renczesstefan 1107b7f
Merge remote-tracking branch 'origin/release/7.0.0-rev8' into NAE-2213
machacjozef 894f208
[NAE-2213] Delete global role
tuplle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
...gine/src/main/java/com/netgrif/application/engine/petrinet/web/ProcessRoleController.java
This file contains hidden or 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,74 @@ | ||
| package com.netgrif.application.engine.petrinet.web; | ||
|
|
||
| import com.netgrif.application.engine.adapter.spring.common.web.responsebodies.ResponseMessage; | ||
| import com.netgrif.application.engine.adapter.spring.petrinet.domain.roles.RoleNotFoundException; | ||
| import com.netgrif.application.engine.adapter.spring.petrinet.domain.roles.RoleNotGlobalException; | ||
| import com.netgrif.application.engine.adapter.spring.petrinet.domain.roles.RoleReferencedException; | ||
| import com.netgrif.application.engine.adapter.spring.petrinet.service.ProcessRoleService; | ||
| import com.netgrif.application.engine.objects.auth.domain.LoggedUser; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.prepost.PreAuthorize; | ||
| import org.springframework.security.core.Authentication; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.Map; | ||
|
machacjozef marked this conversation as resolved.
|
||
|
|
||
| @Slf4j | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @Tag(name = "ProcessRoles") | ||
| @RequestMapping("/api/roles") | ||
| public class ProcessRoleController { | ||
|
|
||
| private final ProcessRoleService processRoleService; | ||
|
|
||
| @PreAuthorize("@authorizationService.hasAuthority('ADMIN')") | ||
| @Operation(summary = "Delete global role", | ||
| security = {@SecurityRequirement(name = "X-Auth-Token")}) | ||
| @Parameter(name = "id", description = "Id of the global role to be deleted", required = true, example = "GcdIZcAPUc6jh7i2-68d683f80dc9384aa6791a64") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "Global role was deleted successfully"), | ||
| @ApiResponse(responseCode = "400", description = "Invalid role id"), | ||
| @ApiResponse(responseCode = "403", description = "Caller doesn't fulfill the authorisation requirements"), | ||
| @ApiResponse(responseCode = "404", description = "Role not found"), | ||
| @ApiResponse(responseCode = "409", description = "Role is not global"), | ||
| @ApiResponse(responseCode = "500", description = "Internal server error") | ||
| }) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| @DeleteMapping(value = "/{id}",produces = MediaType.APPLICATION_JSON_VALUE) | ||
| public ResponseEntity<ResponseMessage> deleteGlobalRole(@PathVariable("id") String id, Authentication auth) { | ||
| try { | ||
| LoggedUser user = (LoggedUser) auth.getPrincipal(); | ||
| processRoleService.deleteGlobalRole(id, user); | ||
|
renczesstefan marked this conversation as resolved.
|
||
| } catch (RoleNotFoundException e) { | ||
| String message = "Error when deleting global role [%s]".formatted(id); | ||
| log.error(message, e); | ||
| return ResponseEntity.status(404).body(ResponseMessage.createErrorMessage(e.getMessage())); | ||
| } catch (RoleNotGlobalException e) { | ||
| String message = "Error when deleting global role [%s]".formatted(id); | ||
| log.error(message, e); | ||
| return ResponseEntity.status(409).body(ResponseMessage.createErrorMessage(e.getMessage())); | ||
| } catch (RoleReferencedException e) { | ||
| String message = "Error when deleting global role [%s]".formatted(id); | ||
| log.error(message, e); | ||
| return ResponseEntity.status(400).body(ResponseMessage.createErrorMessage(e.getMessage())); | ||
| } catch (IllegalArgumentException e) { | ||
| String message = "Error when deleting global role [%s]".formatted(id); | ||
| log.error(message, e); | ||
| return ResponseEntity.badRequest().body(ResponseMessage.createErrorMessage(e.getMessage())); | ||
| } | ||
| return ResponseEntity.ok(ResponseMessage.createSuccessMessage("Global role was deleted successfully")); | ||
| } | ||
|
renczesstefan marked this conversation as resolved.
|
||
|
|
||
| } | ||
This file contains hidden or 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 hidden or 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
7 changes: 7 additions & 0 deletions
7
...etgrif/application/engine/adapter/spring/petrinet/domain/roles/RoleNotFoundException.java
This file contains hidden or 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,7 @@ | ||
| package com.netgrif.application.engine.adapter.spring.petrinet.domain.roles; | ||
|
|
||
| public class RoleNotFoundException extends RuntimeException { | ||
| public RoleNotFoundException(String message) { | ||
| super(message); | ||
| } | ||
| } | ||
|
renczesstefan marked this conversation as resolved.
|
||
7 changes: 7 additions & 0 deletions
7
...tgrif/application/engine/adapter/spring/petrinet/domain/roles/RoleNotGlobalException.java
This file contains hidden or 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,7 @@ | ||
| package com.netgrif.application.engine.adapter.spring.petrinet.domain.roles; | ||
|
|
||
| public class RoleNotGlobalException extends RuntimeException { | ||
| public RoleNotGlobalException(String message) { | ||
| super(message); | ||
| } | ||
| } | ||
|
renczesstefan marked this conversation as resolved.
|
||
7 changes: 7 additions & 0 deletions
7
...grif/application/engine/adapter/spring/petrinet/domain/roles/RoleReferencedException.java
This file contains hidden or 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,7 @@ | ||
| package com.netgrif.application.engine.adapter.spring.petrinet.domain.roles; | ||
|
|
||
| public class RoleReferencedException extends RuntimeException { | ||
| public RoleReferencedException(String message) { | ||
| super(message); | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.