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
private Mono<UserDto> validateUpdate(Long partyId, UserDto request) { | |
return partyClient.getIndividual(partyId) | |
.flatMap(r -> securityClient.getByUserName(request.getUsername())) | |
.switchIfEmpty(Mono.just(UserModel.builder().withId(partyId).build())) //dummy to have something to compare with and kee the reactive flow "flowing" | |
.flatMap(r -> { | |
if (!r.getId().equals(partyId)) { | |
throw new UserAlreadyExistsException("Username already taken"); | |
} | |
return Mono.just(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
curl -X PUT \ | |
http://127.0.0.1:8500/v1/catalog/register \ | |
-H 'cache-control: no-cache' \ | |
-H 'content-type: application/json' \ | |
-H 'postman-token: 9aa3163f-31b9-8c8f-f9cd-6feaca81d4ce' \ | |
-d '{ | |
"Datacenter": "dc1", | |
"Node": "externalServices", | |
"Address": "172.30.50.59", | |
"Service": { |
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
private Mono<UserDto> validateUserNameAvailable(UserDto user) { | |
Mono<Boolean> result = securityClient.getByUserName(user.getUserName()).hasElement(); | |
return result.flatMap(value -> { | |
if (value) { | |
throw new UserAlreadyExistsException( | |
String.format("User {} already exists", user.getUserName())); | |
} | |
return Mono.just(user); | |
}); | |
} |