use of org.hl7.gravity.refimpl.sdohexchange.exception.DuplicateServerNameNotAllowedException in project Gravity-SDOH-Exchange-RI by FHIR.
the class ServerService method createServer.
@Transactional
public ServerDto createServer(NewServerDto newServerDto) throws AuthClientException {
if (serverRepository.findByServerName(newServerDto.getServerName()).isPresent()) {
throw new DuplicateServerNameNotAllowedException(newServerDto.getServerName());
}
Server server = modelMapper.map(newServerDto, Server.class);
// Just a validation of credentials.
authorizationClient.getTokenResponse(URI.create(newServerDto.getAuthServerUrl()), newServerDto.getClientId(), newServerDto.getClientSecret(), SCOPE);
serverRepository.save(server);
return modelMapper.map(server, ServerDto.class);
}
use of org.hl7.gravity.refimpl.sdohexchange.exception.DuplicateServerNameNotAllowedException in project Gravity-SDOH-Exchange-RI by FHIR.
the class ServerService method updateServer.
@Transactional
public ServerDto updateServer(Integer id, NewServerDto newServerDto) throws AuthClientException {
Server server = serverRepository.findById(id).orElseThrow(() -> new ServerNotFoundException(String.format("No Server was found by id '%s'", id)));
if (serverRepository.findByServerName(newServerDto.getServerName()).isPresent() && !server.getServerName().equals(newServerDto.getServerName())) {
throw new DuplicateServerNameNotAllowedException(newServerDto.getServerName());
}
// Just a validation of credentials.
authorizationClient.getTokenResponse(URI.create(newServerDto.getAuthServerUrl()), newServerDto.getClientId(), newServerDto.getClientSecret(), SCOPE);
modelMapper.map(newServerDto, server);
return modelMapper.map(server, ServerDto.class);
}
Aggregations