Skip to content

Commit

Permalink
fix eclipse-tractusx#47 race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
dvasunin committed May 12, 2023
1 parent 78a7203 commit cf4017c
Showing 1 changed file with 4 additions and 4 deletions.
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 cf4017c

Please sign in to comment.