Commit ac88ca87 authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Enriko Käsper

See merge request teis/auth-service!21
parents c9fcea68 61f15f05
theGroup=ee.sm.ti.teis
theVersion=1.1.1
commonsVersion=1.2.0
commonApiGatewayVersion=1.2.0
schedulerVersion=1.1.0
theVersion=1.2.0
commonsVersion=1.4.0
commonApiGatewayVersion=1.4.0
schedulerVersion=1.3.0
pluginVersion=1.0.0
mapstructVersion=1.3.0.Final
......@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-5.2.1-all.zip
package ee.sm.ti.teis.authorization.person;
import ee.sm.ti.teis.authorization.AuthServiceAppTestBase;
import ee.sm.ti.teis.authorization.representatives.RepresentativesService;
import ee.sm.ti.teis.authorization.role.RoleService;
import ee.sm.ti.teis.authorization.xroad.XroadArService;
import ee.sm.ti.teis.authorization.xroad.XroadTorService;
import ee.sm.ti.teis.authorization.serviceclient.person.PersonServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.representatives.RepresentativesServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.role.RoleServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.xroad.XroadArServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.xroad.XroadTorServiceClient;
import ee.sm.ti.teis.commongateway.auth.GetMyCompaniesRequest;
import ee.sm.ti.teis.commongateway.auth.GetMyCompaniesResponse;
import ee.sm.ti.teis.domain.ClassifierItemLight;
......@@ -18,7 +19,6 @@ import ee.sm.ti.teis.domain.tor.TorEmployers;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.PersonType;
import ee.sm.ti.teis.types.enums.RoleType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
......@@ -65,13 +66,13 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
RoleDefinition roleDefinition3 = composeRoleDefinition("EMPLOYEE", RoleType.EH, ROLE_ID3, "Töötaja");
Employer employer = composeEmployer(legalPerson2, roleDefinition2);
RepresentativesService.RepresentativeListDomainResponse representativeResponse = new RepresentativesService.RepresentativeListDomainResponse();
RepresentativesServiceClient.RepresentativeListDomainResponse representativeResponse = new RepresentativesServiceClient.RepresentativeListDomainResponse();
representativeResponse.setPayload(List.of(representative), new RequestMetaDTO());
doReturn(representativeResponse)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.Representative.requestList"), any(Object.class), any());
PersonMsService.LegalPersonsResponseMessage personResponse = new PersonMsService.LegalPersonsResponseMessage();
PersonServiceClient.LegalPersonsResponseMessage personResponse = new PersonServiceClient.LegalPersonsResponseMessage();
personResponse.setPayload(List.of(Person.builder().legalPerson(legalPerson).build()), new RequestMetaDTO());
doReturn(personResponse)
.when(msRabbitTemplate)
......@@ -80,7 +81,7 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
TorEmployers torEmployers = TorEmployers.builder()
.employers(List.of(employer))
.build();
XroadTorService.TorEmployersResponse torEmployersResponse = new XroadTorService.TorEmployersResponse();
XroadTorServiceClient.TorEmployersResponse torEmployersResponse = new XroadTorServiceClient.TorEmployersResponse();
torEmployersResponse.setPayload(torEmployers, new RequestMetaDTO());
doReturn(torEmployersResponse)
.when(msRabbitTemplate)
......@@ -90,19 +91,19 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
.representations(List.of(employer))
.id(UUID.fromString(EMPLOYER_ID))
.build();
XroadArService.ArRepresentationsResponse arRepresentationsResponse = new XroadArService.ArRepresentationsResponse();
XroadArServiceClient.ArRepresentationsResponse arRepresentationsResponse = new XroadArServiceClient.ArRepresentationsResponse();
arRepresentationsResponse.setPayload(arRepresentations, new RequestMetaDTO());
doReturn(arRepresentationsResponse)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.ArRepresentations.request"), any(Object.class), any());
RoleService.RoleResponseMessage roleResponseMessage = new RoleService.RoleResponseMessage();
RoleServiceClient.RoleResponseMessage roleResponseMessage = new RoleServiceClient.RoleResponseMessage();
roleResponseMessage.setPayload(roleDefinition, new RequestMetaDTO());
doReturn(roleResponseMessage)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.RoleDefinition.request"), any(Object.class), any());
RoleService.RoleListDomainResponse roleListDomainResponse = new RoleService.RoleListDomainResponse();
RoleServiceClient.RoleListDomainResponse roleListDomainResponse = new RoleServiceClient.RoleListDomainResponse();
roleListDomainResponse.setPayload(List.of(roleDefinition2, roleDefinition3), new RequestMetaDTO());
doReturn(roleListDomainResponse)
.when(msRabbitTemplate)
......@@ -118,7 +119,7 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
parameters.setId(PERSON_ID);
request.setPayload(parameters, new RequestMetaDTO());
GetMyCompaniesResponse myCompanies = personGwListener.getMyCompanies(request);
Assertions.assertTrue(myCompanies.getPayload().size() == 1);
assertEquals(1, myCompanies.getPayload().size());
clearRedisCache();
}
......@@ -130,14 +131,14 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
LegalPerson legalPerson = composeLegalPerson(country, EMPLOYER_ID, REGCODE1, "Subaru Auto OÜ");
LegalPerson legalPerson2 = composeLegalPerson(country, EMPLOYER_ID2, "1219774634", "Kommipood");
RepresentativesService.RepresentativeListDomainResponse representativeResponse = new RepresentativesService.RepresentativeListDomainResponse();
RepresentativesServiceClient.RepresentativeListDomainResponse representativeResponse = new RepresentativesServiceClient.RepresentativeListDomainResponse();
representativeResponse.setPayload(List.of(representative, representative2), new RequestMetaDTO());
doReturn(representativeResponse)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.Representative.requestList"), any(Object.class), any());
PersonMsService.LegalPersonsResponseMessage personResponse = new PersonMsService.LegalPersonsResponseMessage();
PersonServiceClient.LegalPersonsResponseMessage personResponse = new PersonServiceClient.LegalPersonsResponseMessage();
personResponse.setPayload(List.of(Person.builder().legalPerson(legalPerson).build(), Person.builder().legalPerson(legalPerson2).build()), new RequestMetaDTO());
doReturn(personResponse)
.when(msRabbitTemplate)
......@@ -148,7 +149,7 @@ public class PersonGwListenerTest extends AuthServiceAppTestBase {
parameters.setId(PERSON_ID);
request.setPayload(parameters, new RequestMetaDTO());
GetMyCompaniesResponse myCompanies = personGwListener.getMyCompanies(request);
Assertions.assertTrue(myCompanies.getPayload().size() == 2);
assertEquals(2, myCompanies.getPayload().size());
clearRedisCache();
}
......
package ee.sm.ti.teis.authorization.userinfo;
import ee.sm.ti.teis.authorization.AuthServiceAppTestBase;
import ee.sm.ti.teis.authorization.person.IndividualPersonService;
import ee.sm.ti.teis.authorization.person.IndividualPersonService.IndividualPersonResponseMessage;
import ee.sm.ti.teis.authorization.person.IndividualPersonService.IndividualPersonsResponseMessage;
import ee.sm.ti.teis.authorization.serviceclient.person.IndividualPersonServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.person.IndividualPersonServiceClient.IndividualPersonResponseMessage;
import ee.sm.ti.teis.authorization.serviceclient.person.IndividualPersonServiceClient.IndividualPersonsResponseMessage;
import ee.sm.ti.teis.domain.person.IndividualPerson;
import ee.sm.ti.teis.domain.person.Person;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -34,6 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ExtendWith(SpringExtension.class)
@SuppressWarnings({"squid:S00100", "squid:S1192"})
public class UserInfoControllerTest extends AuthServiceAppTestBase {
@Autowired
RabbitTemplate msRabbitTemplate;
@Autowired
......@@ -62,11 +63,9 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.andExpect(MockMvcResultMatchers.jsonPath("$.personId").value("99aaa6bb-acad-4a66-a012-6da981fdf647"))
.andExpect(MockMvcResultMatchers.jsonPath("$.personalCode").value("12345678901"))
.andExpect(MockMvcResultMatchers.jsonPath("$.fullName").value("Juhan Jurakas"))
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isEmpty())
;
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isEmpty());
}
@Test
@WithMockUser
// FIXME
......@@ -81,8 +80,7 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.andExpect(MockMvcResultMatchers.jsonPath("$.personId").value("99aaa6bb-acad-4a66-a012-6da981fdf647"))
.andExpect(MockMvcResultMatchers.jsonPath("$.personalCode").value("12345678901"))
.andExpect(MockMvcResultMatchers.jsonPath("$.fullName").value("Juhan Jurakas"))
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isNotEmpty())
;
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isNotEmpty());
}
@Test
......@@ -102,8 +100,7 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.andExpect(MockMvcResultMatchers.jsonPath("$.personId").value("8ebacd29-8872-4095-87cc-b646165980a0"))
.andExpect(MockMvcResultMatchers.jsonPath("$.personalCode").value("12345678901"))
.andExpect(MockMvcResultMatchers.jsonPath("$.fullName").value("<unidentified> <unidentified>"))
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isEmpty())
;
.andExpect(MockMvcResultMatchers.jsonPath("$.roles").isEmpty());
}
@Test
......@@ -113,8 +110,7 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.get("/internal/user-info")
.param("personalCode", "ee123432432432")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest())
;
.andExpect(status().isBadRequest());
}
@Test
......@@ -123,8 +119,7 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.get("/internal/user-info")
.param("personalCode", "ee12345678901")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isUnauthorized())
;
.andExpect(status().isUnauthorized());
}
@Test
......@@ -146,8 +141,7 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
.param("personalCode", "ee12345678901")
.param("applicationType", "PORTAL")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
;
.andExpect(status().isOk());
}
private List<Person> getPersons() {
......@@ -164,13 +158,12 @@ public class UserInfoControllerTest extends AuthServiceAppTestBase {
}
private IndividualPerson getNewPerson() {
IndividualPerson individualPerson = IndividualPerson.builder()
return IndividualPerson.builder()
.id(UUID.fromString("8ebacd29-8872-4095-87cc-b646165980a0"))
.personType(I)
.firstName(IndividualPersonService.NEW_PERSON_NAME)
.lastName(IndividualPersonService.NEW_PERSON_NAME)
.firstName(IndividualPersonServiceClient.NEW_PERSON_NAME)
.lastName(IndividualPersonServiceClient.NEW_PERSON_NAME)
.idCode("12345678901")
.build();
return individualPerson;
}
}
package ee.sm.ti.teis.authorization.officials;
import ee.sm.ti.teis.authorization.keycloak.KeycloakOfficialsService;
import ee.sm.ti.teis.authorization.serviceclient.official.OfficialUsersServiceClient;
import ee.sm.ti.teis.domain.officials.OfficialUser;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import lombok.extern.slf4j.Slf4j;
......@@ -19,14 +20,14 @@ import static java.text.MessageFormat.format;
@Slf4j
public class OfficialUsersSyncService {
private final OfficialUsersService officialUsersService;
private final OfficialUsersServiceClient officialUsersServiceClient;
private final KeycloakOfficialsService keycloakService;
private boolean isTestProfile = true;
public OfficialUsersSyncService(OfficialUsersService officialUsersService, KeycloakOfficialsService keycloakService,
public OfficialUsersSyncService(OfficialUsersServiceClient officialUsersServiceClient, KeycloakOfficialsService keycloakService,
Environment env) {
this.officialUsersService = officialUsersService;
this.officialUsersServiceClient = officialUsersServiceClient;
this.keycloakService = keycloakService;
if (env != null) {
this.isTestProfile = isTestProfile(env);
......@@ -40,7 +41,7 @@ public class OfficialUsersSyncService {
int deletedUsers = 0;
Set<UserRepresentation> keycloakUsers = keycloakService.getKeycloakTeisGroupUsers();
List<OfficialUser> currentOfficialUsers = officialUsersService.getCurrentOfficialUsers(requestMetaDTO);
List<OfficialUser> currentOfficialUsers = officialUsersServiceClient.getCurrentOfficialUsers(requestMetaDTO);
log.info("Found {} AD users from Keycloak and {} CURRENT TeIS official users.",
keycloakUsers.size(), currentOfficialUsers.size());
......@@ -59,12 +60,12 @@ public class OfficialUsersSyncService {
// update existing user name
currentOfficialUser.setFirstName(keycloakUser.getFirstName().trim());
currentOfficialUser.setLastName(keycloakUser.getLastName().trim());
officialUsersService.updateOfficialUser(currentOfficialUser, requestMetaDTO);
officialUsersServiceClient.updateOfficialUser(currentOfficialUser, requestMetaDTO);
updatedUsers++;
}
} else {
// add new users
officialUsersService.createOfficialUser(mapOfficialUser(keycloakUser), requestMetaDTO);
officialUsersServiceClient.createOfficialUser(mapOfficialUser(keycloakUser), requestMetaDTO);
createdUsers++;
}
}
......@@ -74,7 +75,7 @@ public class OfficialUsersSyncService {
if (keycloakUsers.stream().noneMatch(keycloakUser ->
keycloakUser.getUsername().equals(officialUser.getIdCode()))
&& !isTestUser(officialUser)) {
officialUsersService.deleteOfficialUser(officialUser, requestMetaDTO);
officialUsersServiceClient.deleteOfficialUser(officialUser, requestMetaDTO);
deletedUsers++;
}
}
......
......@@ -2,10 +2,11 @@ package ee.sm.ti.teis.authorization.person;
import ee.sm.ti.teis.authorization.classifier.ClassifierMapper;
import ee.sm.ti.teis.authorization.representatives.RepresentativesService;
import ee.sm.ti.teis.authorization.role.RoleService;
import ee.sm.ti.teis.authorization.xroad.XroadArService;
import ee.sm.ti.teis.authorization.xroad.XroadTorService;
import ee.sm.ti.teis.authorization.serviceclient.person.PersonServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.representatives.RepresentativesServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.role.RoleServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.xroad.XroadArServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.xroad.XroadTorServiceClient;
import ee.sm.ti.teis.commongateway.auth.GetMyCompaniesRequest;
import ee.sm.ti.teis.commongateway.auth.UserCompanyDto;
import ee.sm.ti.teis.commongateway.person.LegalPersonDto;
......@@ -26,47 +27,41 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import static java.util.Collections.singletonList;
@Service
@Transactional
@Slf4j
public class PersonCompaniesService {
private final RepresentativesService representativesService;
private final PersonMsService personMsService;
private final XroadTorService xroadTorService;
private final XroadArService xroadArService;
private final ClassifierMapper classifierMapper;
private final RoleService roleService;
@Value("${teis.xroad.timeout:30}")
private int xroadTimeout = 30;
private static final int xroadTimeout = 30;
private final RepresentativesServiceClient representativesServiceClient;
private final PersonServiceClient personServiceClient;
private final XroadTorServiceClient xroadTorServiceClient;
private final ClassifierMapper classifierMapper;
private final XroadArServiceClient xroadArServiceClient;
private final RoleServiceClient roleServiceClient;
public PersonCompaniesService(RepresentativesService representativesService,
PersonMsService personMsService,
XroadTorService xroadTorService,
XroadArService xroadArService,
public PersonCompaniesService(RepresentativesServiceClient representativesServiceClient,
PersonServiceClient personServiceClient,
XroadTorServiceClient xroadTorServiceClient,
XroadArServiceClient xroadArServiceClient,
ClassifierMapper classifierMapper,
RoleService roleService) {
this.representativesService = representativesService;
this.personMsService = personMsService;
this.xroadTorService = xroadTorService;
this.xroadArService = xroadArService;
RoleServiceClient roleServiceClient) {
this.representativesServiceClient = representativesServiceClient;
this.personServiceClient = personServiceClient;
this.xroadTorServiceClient = xroadTorServiceClient;
this.xroadArServiceClient = xroadArServiceClient;
this.classifierMapper = classifierMapper;
this.roleService = roleService;
this.roleServiceClient = roleServiceClient;
}
@Cacheable(value = "userCompanies", key = "#request.payload.id", cacheResolver = "prefixedCacheResolver", unless = "#result == null or #result.isEmpty()")
......@@ -145,20 +140,20 @@ public class PersonCompaniesService {
}
List<Representative> getRepresentatives(GetMyCompaniesRequest request) {
return representativesService.getMyCompanies(request);
return representativesServiceClient.getMyCompanies(request);
}
TorEmployers getTorEmployers(GetMyCompaniesRequest request) {
return xroadTorService.getMyCompanies(request);
return xroadTorServiceClient.getMyCompanies(request);
}
ArRepresentations getArRepresentations(GetMyCompaniesRequest request) {
return xroadArService.getMyCompanies(request);
return xroadArServiceClient.getMyCompanies(request);
}
List<LegalPerson> getLegalPersons(GetMyCompaniesRequest request, List<Representative> representatives) {
Set<UUID> legalPersonIds = extractLegalPersons(representatives);
return personMsService.getLegalPersonsByIds(new ArrayList<>(legalPersonIds), request.getRequestMetaDTO());
return personServiceClient.getLegalPersonsByIds(new ArrayList<>(legalPersonIds), request.getRequestMetaDTO());
}
List<UserCompanyDto> composeCompanyListFromLegalPerson(GetMyCompaniesRequest request) {
......@@ -180,7 +175,7 @@ public class PersonCompaniesService {
.id(legalPerson.getId())
.legalPerson(
makeLegalPersonDto(legalPerson))
.roles(new HashSet(Arrays.asList(role))).build();
.roles(new HashSet(singletonList(role))).build();
userCompanyDtos.add(userCompany);
}
}
......@@ -198,7 +193,7 @@ public class PersonCompaniesService {
.filter(legalPerson -> legalPerson.getId().equals(representative.getEmployerId()))
.findFirst();
if (legalPersonsOptional.isPresent()) {
return roleService.getRole(representative.getRoleId(), requestMetaDTO);
return roleServiceClient.getRole(representative.getRoleId(), requestMetaDTO);
} else {
return null;
}
......@@ -213,10 +208,10 @@ public class PersonCompaniesService {
}
void composeCompanyFromEmployer(List<Employer> employers, List<UserCompanyDto> userCompanyDtos, RequestMetaDTO requestMetaDTO) {
List<RoleDefinitionLightDto> roleByType = roleService.getRoleByType(RoleType.EH, requestMetaDTO);
List<RoleDefinitionLightDto> roleByType = roleServiceClient.getRoleByType(RoleType.EH, requestMetaDTO);
for (Employer employer : employers) {
Optional<UserCompanyDto> company = findCompanyIfPresent(userCompanyDtos, employer.getLegalPerson());
RoleDefinitionLightDto role = roleService.findRoleByCode(roleByType, employer);
RoleDefinitionLightDto role = roleServiceClient.findRoleByCode(roleByType, employer);
if (company.isPresent()) {
company.get().getLegalPerson().setName(employer.getLegalPerson().getName());
addRoleIfNotPresent(role, company.get());
......@@ -224,13 +219,12 @@ public class PersonCompaniesService {
UserCompanyDto userCompany = UserCompanyDto.builder()
.id(null)
.legalPerson(makeLegalPersonDto(employer.getLegalPerson()))
.roles(new HashSet(Arrays.asList(role))).build();
.roles(new HashSet(singletonList(role))).build();
userCompanyDtos.add(userCompany);
}
}
}
LegalPersonDto makeLegalPersonDto(LegalPerson legalPerson) {
return LegalPersonDto.builder()
.name(legalPerson.getName())
......@@ -238,5 +232,4 @@ public class PersonCompaniesService {
.country(classifierMapper.toGwLightDto(legalPerson.getCountry())).build();
}
}
package ee.sm.ti.teis.authorization.person;
import ee.sm.ti.teis.authorization.role.RolePrivilegeService;
import ee.sm.ti.teis.authorization.serviceclient.person.LegalPersonServiceClient;
import ee.sm.ti.teis.authorization.serviceclient.role.RolePrivilegeServiceClient;
import ee.sm.ti.teis.commongateway.auth.GetMyCompaniesRequest;
import ee.sm.ti.teis.commongateway.auth.UserCompanyDto;
import ee.sm.ti.teis.commongateway.person.LegalPersonDto;
......@@ -23,17 +24,17 @@ import java.util.stream.Collectors;
public class SelectedCompanyService {
private final PersonCompaniesService personCompaniesService;
private final PersonMapper personMapper;
private final RolePrivilegeService rolePrivilegeService;
private final LegalPersonService legalPersonService;
private final RolePrivilegeServiceClient rolePrivilegeServiceClient;
private final LegalPersonServiceClient legalPersonServiceClient;
SelectedCompanyService(PersonMapper personMapper,
RolePrivilegeService rolePrivilegeService,
RolePrivilegeServiceClient rolePrivilegeServiceClient,
PersonCompaniesService personCompaniesService,
LegalPersonService legalPersonService) {
LegalPersonServiceClient legalPersonServiceClient) {
this.personCompaniesService = personCompaniesService;
this.personMapper = personMapper;
this.rolePrivilegeService = rolePrivilegeService;
this.legalPersonService = legalPersonService;
this.rolePrivilegeServiceClient = rolePrivilegeServiceClient;
this.legalPersonServiceClient = legalPersonServiceClient;
}
......@@ -63,7 +64,7 @@ public class SelectedCompanyService {
.regCode(userCompanyDto.getLegalPerson().getRegCode())
.name(userCompanyDto.getLegalPerson().getName())
.build());
LegalPerson legalPerson = legalPersonService.getLegalPerson(requestedPerson, requestMetaDTO);
LegalPerson legalPerson = legalPersonServiceClient.getLegalPerson(requestedPerson, requestMetaDTO);
userCompanyDto.setLegalPerson(personMapper.toGwLegalPerson(legalPerson));
userCompanyDto.setId(legalPerson.getId());
userCompanyDto.setPrivileges(getPrivileges(requestMetaDTO, userCompanyDto));
......@@ -85,7 +86,7 @@ public class SelectedCompanyService {
private List<String> getPrivileges(RequestMetaDTO requestMetaDTO, UserCompanyDto company) {
List<UUID> roleIds = company.getRoles().stream().map(RoleDefinitionLightDto::getId).collect(Collectors.toList());
List<RolePrivilege> privileges = rolePrivilegeService.getPrivileges(roleIds, requestMetaDTO);
List<RolePrivilege> privileges = rolePrivilegeServiceClient.getPrivileges(roleIds, requestMetaDTO);
return privileges.stream().distinct().map(privilege -> privilege.getPrivilege().name()).collect(Collectors.toList());
}
......
package ee.sm.ti.teis.authorization.userinfo;
package ee.sm.ti.teis.authorization.serviceclient;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.domain.officials.OfficialUser;
......@@ -16,9 +16,9 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserInfoMsService extends TeisRabbitClient<OfficialUser> {
public class UserInfoServiceClient extends TeisRabbitClient<OfficialUser> {
public UserInfoMsService(RabbitTemplate msRabbitTemplate) {
public UserInfoServiceClient(RabbitTemplate msRabbitTemplate) {
super(msRabbitTemplate);
}
......
package ee.sm.ti.teis.authorization.officials;
package ee.sm.ti.teis.authorization.serviceclient.official;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.domain.officials.OfficialUser;
......@@ -18,23 +18,23 @@ import java.util.List;
import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
@Service
public class OfficialUsersService extends TeisRabbitClient<OfficialUser> {
public class OfficialUsersServiceClient extends TeisRabbitClient<OfficialUser> {
public OfficialUsersService(RabbitTemplate msRabbitTemplate) {
public OfficialUsersServiceClient(RabbitTemplate msRabbitTemplate) {
super(msRabbitTemplate);
}
List<OfficialUser> getCurrentOfficialUsers(RequestMetaDTO requestMetaDTO) {
public List<OfficialUser> getCurrentOfficialUsers(RequestMetaDTO requestMetaDTO) {
OfficialUser item = new OfficialUser();
item.setObjectStatus(CURRENT);
return getItems(item, OfficialUsersQueryResponse.class, requestMetaDTO);
}
OfficialUser deleteOfficialUser(OfficialUser officialUser, RequestMetaDTO requestMetaDTO) {
public OfficialUser deleteOfficialUser(OfficialUser officialUser, RequestMetaDTO requestMetaDTO) {
return deleteItem(officialUser, OfficialUserDomainResponse.class, requestMetaDTO);
}
OfficialUser createOfficialUser(OfficialUser officialUser, RequestMetaDTO requestMetaDTO) {
public OfficialUser createOfficialUser(OfficialUser officialUser, RequestMetaDTO requestMetaDTO) {
return createItem(officialUser, OfficialUserDomainResponse.class, requestMetaDTO);
}
......
package ee.sm.ti.teis.authorization.person;
package ee.sm.ti.teis.authorization.serviceclient.person;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.authorization.exception.TeisSystemException;
......@@ -20,18 +20,16 @@ import static ee.sm.ti.teis.types.enums.PersonType.I;
import static ee.sm.ti.teis.types.enums.classifier.ClassifierDefinitionCode.COUNTRY;
@Service
public class IndividualPersonService {
public class IndividualPersonServiceClient {