Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#50 from catenax-ng/concurrency-bu…
Browse files Browse the repository at this point in the history
…g-fix

Concurrency bug fix
  • Loading branch information
SebastianBezold committed May 12, 2023
2 parents c0d61a3 + 244eb6b commit a8668af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
NA

### Changed
- make DapsManager methods synchronized

## [2.0.6] - 2023-05-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class DapsManager implements DapsApiDelegate {
@SneakyThrows
@Override
@PreAuthorize("hasAuthority(@securityRoles.createRole)")
public ResponseEntity<Map<String, Object>> createClientPost(String clientName,
public synchronized ResponseEntity<Map<String, Object>> createClientPost(String clientName,
URI referringConnector,
MultipartFile file,
String securityProfile) {
Expand All @@ -80,15 +80,15 @@ public ResponseEntity<Map<String, Object>> createClientPost(String clientName,

@Override
@PreAuthorize("hasAuthority(@securityRoles.retrieveRole)")
public ResponseEntity<Map<String, Object>> getClientGet(String clientId) {
public synchronized ResponseEntity<Map<String, Object>> getClientGet(String clientId) {
var jsonNode = dapsClient.getClient(clientId);
Map<String, Object> result = mapper.convertValue(jsonNode, new TypeReference<>() {});
return new ResponseEntity<>(result, HttpStatus.OK);
}

@Override
@PreAuthorize("hasAuthority(@securityRoles.updateRole)")
public ResponseEntity<Void> updateClientPut(String clientId, Map<String, String> newAttr) {
public synchronized ResponseEntity<Void> updateClientPut(String clientId, Map<String, String> newAttr) {
var clientAttr = dapsClient.getClient(clientId).get("attributes");
var keys = new HashSet<>();
var attr = Stream.concat(
Expand All @@ -106,7 +106,7 @@ public ResponseEntity<Void> updateClientPut(String clientId, Map<String, String>

@Override
@PreAuthorize("hasAuthority(@securityRoles.deleteRole)")
public ResponseEntity<Void> deleteClientDelete(String clientId) {
public synchronized ResponseEntity<Void> deleteClientDelete(String clientId) {
dapsClient.deleteCert(clientId);
dapsClient.deleteClient(clientId);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
Expand Down

0 comments on commit a8668af

Please sign in to comment.